[964] | 1 | /*
|
---|
| 2 | Copyright (C) 2005-2006 Feeling Software Inc.
|
---|
| 3 | MIT License: http://www.opensource.org/licenses/mit-license.php
|
---|
| 4 | */
|
---|
| 5 | /*
|
---|
| 6 | Based on the FS Import classes:
|
---|
| 7 | Copyright (C) 2005-2006 Feeling Software Inc
|
---|
| 8 | Copyright (C) 2005-2006 Autodesk Media Entertainment
|
---|
| 9 | MIT License: http://www.opensource.org/licenses/mit-license.php
|
---|
| 10 | */
|
---|
| 11 |
|
---|
| 12 | /**
|
---|
| 13 | @file FCDEffectProfileFX.h
|
---|
| 14 | This file declares the FCDEffectProfileFX class.
|
---|
| 15 | */
|
---|
| 16 |
|
---|
| 17 | #ifndef _FCD_EFFECT_PROFILE_FX_H_
|
---|
| 18 | #define _FCD_EFFECT_PROFILE_FX_H_
|
---|
| 19 |
|
---|
| 20 | #include "FUtils/FUDaeEnum.h"
|
---|
| 21 | #include "FCDocument/FCDEffectProfile.h"
|
---|
| 22 |
|
---|
| 23 | class FCDocument;
|
---|
| 24 | class FCDEffect;
|
---|
| 25 | class FCDEffectCode;
|
---|
| 26 | class FCDEffectParameter;
|
---|
| 27 | class FCDEffectParameterSurface;
|
---|
| 28 | class FCDEffectTechnique;
|
---|
| 29 | class FCDEffectParameterList;
|
---|
| 30 |
|
---|
| 31 | typedef vector<FCDEffectTechnique*> FCDEffectTechniqueList; /**< A dynamically-sized array of effect techniques. */
|
---|
| 32 | typedef vector<FCDEffectCode*> FCDEffectCodeList; /**< A dynamically-sized array of effect code inclusion. */
|
---|
| 33 |
|
---|
| 34 | /**
|
---|
| 35 | A general effect profile description.
|
---|
| 36 |
|
---|
| 37 | The general effect profile contains all the information necessary
|
---|
| 38 | to implement the advanced effect profiles, such as CG, HLSL, GLSL and GLES.
|
---|
| 39 | Since these effect profiles contains extremely similar information, they
|
---|
| 40 | use the same description structure. For the COMMON profile,
|
---|
| 41 | see the FCDEffectStandard class.
|
---|
| 42 |
|
---|
| 43 | You should use the GetType function to figure out which profile this structure
|
---|
| 44 | addresses. You can then retrieve one or many of the FCDEffectTechnique objects
|
---|
| 45 | that describe how to render for this profile. You may want to check the
|
---|
| 46 | FCDEffectMaterialTechniqueHint objects at the FCDMaterial level, in order to
|
---|
| 47 | determine which technique(s) to use for your platform. At the profile
|
---|
| 48 | level of abstraction, parameters may be generated within the FCDEffectParamterList.
|
---|
| 49 |
|
---|
| 50 | @ingroup FCDEffect
|
---|
| 51 | */
|
---|
| 52 | class FCOLLADA_EXPORT FCDEffectProfileFX : public FCDEffectProfile
|
---|
| 53 | {
|
---|
| 54 | private:
|
---|
| 55 | DeclareObjectType;
|
---|
| 56 | FUDaeProfileType::Type type;
|
---|
| 57 | string includeFilename;
|
---|
| 58 | fstring platform;
|
---|
| 59 |
|
---|
| 60 | FCDEffectCodeList codes;
|
---|
| 61 | FCDEffectTechniqueList techniques;
|
---|
| 62 | FCDEffectParameterList* parameters;
|
---|
| 63 |
|
---|
| 64 | public:
|
---|
| 65 | /** Constructor: do not use directly. Instead, use the FCDEffect::AddProfile function.
|
---|
| 66 | @param document The COLLADA document which owns the effect profile.
|
---|
| 67 | @param parent The effect which contains this profile.
|
---|
| 68 | @param type The type of profile. */
|
---|
| 69 | FCDEffectProfileFX(FCDocument* document, FCDEffect* parent, FUDaeProfileType::Type type);
|
---|
| 70 |
|
---|
| 71 | /** Destructor: do not use directly. Instead, use the FCDEffect:RemoveProfile function. */
|
---|
| 72 | virtual ~FCDEffectProfileFX();
|
---|
| 73 |
|
---|
| 74 | /** Retrieves the profile type for this effect.
|
---|
| 75 | This function is a part of the FCDEffectProfile interface and allows you
|
---|
| 76 | to up-cast an effect profile pointer safely to this class.
|
---|
| 77 | @return The profile type. This should never be the value: 'COMMON',
|
---|
| 78 | but all other profiles currently derive from this class. */
|
---|
| 79 | virtual FUDaeProfileType::Type GetType() const { return type; }
|
---|
| 80 |
|
---|
| 81 | /** @deprecated Retrieves the filename of the file that contains the code for this effect profile.
|
---|
| 82 | Instead, look through the FCDEffectCode object, using the GetCodeList function and retrieve
|
---|
| 83 | the correct object and its filename string.
|
---|
| 84 | @return The filename of the file to import. */
|
---|
| 85 | const string& GetIncludeFilename() const { return includeFilename; }
|
---|
| 86 |
|
---|
| 87 | /** Retrieves the name of the platform in which to use the effect profile.
|
---|
| 88 | This parameter is very optional.
|
---|
| 89 | @return The platform name. */
|
---|
| 90 | const fstring& GetPlatform() const { return platform; }
|
---|
| 91 |
|
---|
| 92 | /** Sets the name of the platform in which to use the effect profile.
|
---|
| 93 | This parameter is very optional.
|
---|
| 94 | @param _platform The platform name. */
|
---|
| 95 | void SetPlatform(fstring& _platform) { platform = _platform; }
|
---|
| 96 |
|
---|
| 97 | /** Retrieves the list of techniques contained within this effect profile.
|
---|
| 98 | You may want to check the FCDEffectMaterialTechniqueHint objects at the FCDMaterial level,
|
---|
| 99 | in order to determine which technique(s) to use for your platform.
|
---|
| 100 | @return The list of inner techniques. */
|
---|
| 101 | FCDEffectTechniqueList& GetTechniqueList() { return techniques; }
|
---|
| 102 | const FCDEffectTechniqueList& GetTechniqueList() const { return techniques; } /**< See above. */
|
---|
| 103 |
|
---|
| 104 | /** Retrieves the number of techniques contained within this effect profile.
|
---|
| 105 | @return The number of inner techniques. */
|
---|
| 106 | size_t GetTechniqueCount() const { return techniques.size(); }
|
---|
| 107 |
|
---|
| 108 | /** Retrieves a technique contained within this effect profile.
|
---|
| 109 | You may want to check the FCDEffectMaterialTechniqueHint objects at the FCDMaterial level,
|
---|
| 110 | in order to determine which technique(s) to use for your platform.
|
---|
| 111 | @param index The index of the technique.
|
---|
| 112 | @return The inner technique. This pointer will be NULL if the index is out-of-bounds. */
|
---|
| 113 | FCDEffectTechnique* GetTechnique(size_t index) { FUAssert(index < GetTechniqueCount(), return NULL); return techniques.at(index); }
|
---|
| 114 | const FCDEffectTechnique* GetTechnique(size_t index) const { FUAssert(index < GetTechniqueCount(), return NULL); return techniques.at(index); } /**< See above. */
|
---|
| 115 |
|
---|
| 116 | /** Adds a new technique to this effect profile.
|
---|
| 117 | @return The new technique object. */
|
---|
| 118 | FCDEffectTechnique* AddTechnique();
|
---|
| 119 |
|
---|
| 120 | /** Releases a technique contained within this effect profile.
|
---|
| 121 | @param technique The technique to release. */
|
---|
| 122 | void ReleaseTechnique(FCDEffectTechnique* technique);
|
---|
| 123 |
|
---|
| 124 | /** Retrieves the list of code inclusions.
|
---|
| 125 | @return The list of code inclusions. */
|
---|
| 126 | FCDEffectCodeList& GetCodeList() { return codes; }
|
---|
| 127 | const FCDEffectCodeList& GetCodeList() const { return codes; } /**< See above. */
|
---|
| 128 |
|
---|
| 129 | /** Retrieves the number of code inclusions contained within the effect profile.
|
---|
| 130 | @return The number of code inclusions. */
|
---|
| 131 | size_t GetCodeCount() const { return codes.size(); }
|
---|
| 132 |
|
---|
| 133 | /** Retrieves a code inclusion contained within the effect profile.
|
---|
| 134 | @param index The index of the code inclusion.
|
---|
| 135 | @return The code inclusion. This pointer will be NULL if the index is out-of-bounds. */
|
---|
| 136 | FCDEffectCode* GetCode(size_t index) { FUAssert(index < GetCodeCount(), return NULL); return codes.at(index); }
|
---|
| 137 | const FCDEffectCode* GetCode(size_t index) const { FUAssert(index < GetCodeCount(), return NULL); return codes.at(index); } /**< See above. */
|
---|
| 138 |
|
---|
| 139 | /** Retrieves the code inclusion with the given sub-id.
|
---|
| 140 | @param sid A COLLADA sub-id.
|
---|
| 141 | @return The code inclusion with the given sub-id. This pointer will be NULL,
|
---|
| 142 | if there are no code inclusions that match the given sub-id. */
|
---|
| 143 | FCDEffectCode* FindCode(const string& sid);
|
---|
| 144 | const FCDEffectCode* FindCode(const string& sid) const; /**< See above. */
|
---|
| 145 |
|
---|
| 146 | /** Adds a new code inclusion to this effect profile.
|
---|
| 147 | @return The new code inclusion. */
|
---|
| 148 | FCDEffectCode* AddCode();
|
---|
| 149 |
|
---|
| 150 | /** Releases a code inclusion contained within this effect profile.
|
---|
| 151 | @param code The code inclusion to release. */
|
---|
| 152 | void ReleaseCode(FCDEffectCode* code);
|
---|
| 153 |
|
---|
| 154 | /** Retrieves the list of effect parameters contained within the effect profile.
|
---|
| 155 | At this level of abstraction, there should be only effect parameter generators.
|
---|
| 156 | @return The list of effect parameters. */
|
---|
| 157 | FCDEffectParameterList* GetParameters() { return parameters; }
|
---|
| 158 | const FCDEffectParameterList* GetParameters() const { return parameters; } /**< See above. */
|
---|
| 159 |
|
---|
| 160 | /** [INTERNAL] Inserts an existing parameter into the list of effect parameters
|
---|
| 161 | at this abstraction level. This function is used during the flattening of a material.
|
---|
| 162 | @param parameter The effect parameter to insert. */
|
---|
| 163 | void AddParameter(FCDEffectParameter* parameter);
|
---|
| 164 |
|
---|
| 165 | /** Retrieves an effect parameter.
|
---|
| 166 | Looks for the effect parameter with the correct reference, in order to bind or override its value.
|
---|
| 167 | This function searches through the effect profile and the level of abstractions below.
|
---|
| 168 | @param reference The reference to match. In the case of effect parameter generators,
|
---|
| 169 | the sub-id is used to match.
|
---|
| 170 | @return The first effect parameter that matches the reference.
|
---|
| 171 | This pointer will be NULL if no effect parameter matches the given semantic. */
|
---|
| 172 | const FCDEffectParameter* FindParameter(const char* reference) const;
|
---|
| 173 |
|
---|
| 174 | /** Retrieves an effect parameter.
|
---|
| 175 | Looks for the effect parameter with the correct semantic, in order to bind or override its value.
|
---|
| 176 | This function searches through the effect profile and the level of abstractions below.
|
---|
| 177 | @param semantic The effect parameter semantic to match.
|
---|
| 178 | @return The first effect parameter that matches the semantic.
|
---|
| 179 | This pointer will be NULL if no effect parameter matches the given semantic. */
|
---|
| 180 | virtual FCDEffectParameter* FindParameterBySemantic(const string& semantic);
|
---|
| 181 |
|
---|
| 182 | /** Retrieves a subset of the effect parameter list.
|
---|
| 183 | Look for the effect parameter generators with the correct semantic.
|
---|
| 184 | This function searches through the effect profile and the level of abstractions below.
|
---|
| 185 | @param semantic The effect parameter semantic to match.
|
---|
| 186 | @param parameters The list of parameters to fill in. This list is not cleared. */
|
---|
| 187 | virtual void FindParametersBySemantic(const string& semantic, FCDEffectParameterList& parameters);
|
---|
| 188 |
|
---|
| 189 | /** Retrieves a subset of the effect parameter list.
|
---|
| 190 | Look for the effect parameter generators with the correct reference.
|
---|
| 191 | This function searches through the effect profile and the level of abstractions below.
|
---|
| 192 | @param reference The effect parameter reference to match. In the case of effect
|
---|
| 193 | parameter generators, the reference is replaced by the sub-id.
|
---|
| 194 | @param parameters The list of parameters to fill in. This list is not cleared. */
|
---|
| 195 | virtual void FindParametersByReference(const string& reference, FCDEffectParameterList& parameters);
|
---|
| 196 |
|
---|
| 197 | /** [INTERNAL] Clones the full effect profile.
|
---|
| 198 | @param newParent The effect that will contain the cloned profile.
|
---|
| 199 | @return The cloned profile. This pointer will never be NULL. */
|
---|
| 200 | virtual FCDEffectProfile* Clone(FCDEffect* newParent);
|
---|
| 201 |
|
---|
| 202 | /** [INTERNAL] Flattens this effect profile. Pushes all the effect parameter overrides
|
---|
| 203 | into the effect parameter generators and moves all the parameters to the
|
---|
| 204 | effect technique level of abstraction. To flatten the material, use the
|
---|
| 205 | FCDMaterialInstance::FlattenMaterial function. */
|
---|
| 206 | virtual void Flatten();
|
---|
| 207 |
|
---|
| 208 | /** [INTERNAL] Reads in the effect profile from a given COLLADA XML tree node.
|
---|
| 209 | @param profileNode The COLLADA XML tree node.
|
---|
| 210 | @return The status of the import. If the status is not successful,
|
---|
| 211 | it may be dangerous to extract information from the effect profile.*/
|
---|
| 212 | virtual FUStatus LoadFromXML(xmlNode* profileNode);
|
---|
| 213 |
|
---|
| 214 | /** [INTERNAL] Writes out the effect profile to the given COLLADA XML tree node.
|
---|
| 215 | @param parentNode The COLLADA XML parent node in which to insert the material declaration.
|
---|
| 216 | @return The created element XML tree node. */
|
---|
| 217 | virtual xmlNode* WriteToXML(xmlNode* parentNode) const;
|
---|
| 218 | };
|
---|
| 219 |
|
---|
| 220 | #endif // _FCD_EFFECT_PROFILE_H_
|
---|