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 FCDEffect.h
|
---|
14 | This file contains the FCDEffect class.
|
---|
15 | */
|
---|
16 |
|
---|
17 | #ifndef _FCD_EFFECT_H_
|
---|
18 | #define _FCD_EFFECT_H_
|
---|
19 |
|
---|
20 | #include "FUtils/FUDaeEnum.h"
|
---|
21 | #include "FCDocument/FCDEntity.h"
|
---|
22 |
|
---|
23 | class FCDocument;
|
---|
24 | class FCDEffectStandard;
|
---|
25 | class FCDEffectParameter;
|
---|
26 | class FCDEffectProfile;
|
---|
27 | class FCDEffectParameterList;
|
---|
28 |
|
---|
29 | /**
|
---|
30 | @defgroup FCDEffect COLLADA Effect Classes [ColladaFX]
|
---|
31 | */
|
---|
32 |
|
---|
33 | class FCDEffectProfile;
|
---|
34 | class FCDEffectParameterList;
|
---|
35 | class FCDImage;
|
---|
36 |
|
---|
37 | /** A dynamically-sized array of effect profiles. */
|
---|
38 | typedef vector<FCDEffectProfile*> FCDEffectProfileList;
|
---|
39 | typedef vector<FCDImage*> FCDEffectImageList;
|
---|
40 |
|
---|
41 | /**
|
---|
42 | A COLLADA effect.
|
---|
43 |
|
---|
44 | A COLLADA effect is one of many abstraction level that defines how
|
---|
45 | to render mesh polygon sets. It contains one or more rendering profile
|
---|
46 | that the application can choose to support. In theory, all the rendering
|
---|
47 | profiles should reach the same render output, using different
|
---|
48 | rendering technologies.
|
---|
49 |
|
---|
50 | An effect may also declare new general purpose parameters that are common
|
---|
51 | to all the profiles.
|
---|
52 |
|
---|
53 | @ingroup FCDEffect
|
---|
54 | */
|
---|
55 | class FCOLLADA_EXPORT FCDEffect : public FCDEntity
|
---|
56 | {
|
---|
57 | private:
|
---|
58 | DeclareObjectType;
|
---|
59 | FCDEffectProfileList profiles;
|
---|
60 | FCDEffectParameterList* parameters;
|
---|
61 | FCDEffectImageList images;
|
---|
62 |
|
---|
63 | public:
|
---|
64 | /** Constructor: do not use directly.
|
---|
65 | Instead use the FCDMaterialLibrary::AddEffect function.
|
---|
66 | @param document The COLLADA document that owns this effect. */
|
---|
67 | FCDEffect(FCDocument* document);
|
---|
68 |
|
---|
69 | /** Destructor: do not use directly.
|
---|
70 | Instead use the FCDMaterialLibrary::ReleaseEffect function. */
|
---|
71 | virtual ~FCDEffect();
|
---|
72 |
|
---|
73 | /** Retrieves the type for this entity class.
|
---|
74 | This function is a part of the FCDEntity interface.
|
---|
75 | @return The entity type: EFFECT. */
|
---|
76 | virtual Type GetType() const { return FCDEntity::EFFECT; }
|
---|
77 |
|
---|
78 | /** Retrieves the number of profiles contained within the effect.
|
---|
79 | @return The number of profiles within the effect. */
|
---|
80 | size_t GetProfileCount() const { return profiles.size(); }
|
---|
81 |
|
---|
82 | /** Retrieves a profile contained within the effect.
|
---|
83 | @param index The index of the profile.
|
---|
84 | @return The profile. This pointer will be NULL, if the given index is out-of-bounds. */
|
---|
85 | FCDEffectProfile* GetProfile(size_t index) { FUAssert(index < GetProfileCount(), return NULL); return profiles.at(index); }
|
---|
86 | const FCDEffectProfile* GetProfile(size_t index) const { FUAssert(index < GetProfileCount(), return NULL); return profiles.at(index); } /**< See above. */
|
---|
87 |
|
---|
88 | /** Retrieves the list of the profiles contained within the effect.
|
---|
89 | @return The list of effect profiles. */
|
---|
90 | FCDEffectProfileList& GetProfiles() { return profiles; }
|
---|
91 | const FCDEffectProfileList& GetProfiles() const { return profiles; } /**< See above. */
|
---|
92 |
|
---|
93 | /** Retrieves the profile for a specific profile type.
|
---|
94 | There should only be one profile of each type within an effect. This
|
---|
95 | function allows you to retrieve the profile for a given type.
|
---|
96 | @param type The profile type.
|
---|
97 | @return The profile of this type. This pointer will be NULL if the effect
|
---|
98 | does not have any profile of this type. */
|
---|
99 | FCDEffectProfile* FindProfile(FUDaeProfileType::Type type);
|
---|
100 | const FCDEffectProfile* FindProfile(FUDaeProfileType::Type type) const; /**< See above. */
|
---|
101 |
|
---|
102 | /** Retrieves the profile for a specific profile type and platform.
|
---|
103 | There should only be one profile of each type within an effect. This
|
---|
104 | function allows you to retrieve the profile for a given type.
|
---|
105 | @param type The profile type and platform.
|
---|
106 | @return The profile of this type. This pointer will be NULL if the effect
|
---|
107 | does not have any profile of this type. */
|
---|
108 | FCDEffectProfile* FindProfileByTypeAndPlatform(FUDaeProfileType::Type type, string platform);
|
---|
109 | const FCDEffectProfile* FindProfileByTypeAndPlatform(FUDaeProfileType::Type type, string platform) const; /**< See above. */
|
---|
110 |
|
---|
111 | /** Retrieves whether the effect contains a profile of the given type.
|
---|
112 | @param type The profile type.
|
---|
113 | @return Whether the effect has a profile of this type. */
|
---|
114 | inline bool HasProfile(FUDaeProfileType::Type type) const { return FindProfile(type) != NULL; }
|
---|
115 |
|
---|
116 | /** Creates a profile of the given type.
|
---|
117 | If a profile of this type already exists, it will be released, as
|
---|
118 | a COLLADA effect should only contain one profile of each type.
|
---|
119 | @param type The profile type.
|
---|
120 | @return The new effect profile. */
|
---|
121 | FCDEffectProfile* AddProfile(FUDaeProfileType::Type type);
|
---|
122 |
|
---|
123 | /** Releases the given effect profile.
|
---|
124 | @param profile The effect profile. */
|
---|
125 | void ReleaseProfile(FCDEffectProfile* profile);
|
---|
126 |
|
---|
127 | /** Retrieves the list of common effect parameters declared at the effect level.
|
---|
128 | According to the COLLADA 1.4 schema, you should expect only parameter generators
|
---|
129 | at this abstraction level.
|
---|
130 | @return The list of effect parameters. */
|
---|
131 | FCDEffectParameterList* GetParameters() { return parameters; }
|
---|
132 | const FCDEffectParameterList* GetParameters() const { return parameters; } /**< See above. */
|
---|
133 |
|
---|
134 | /** [INTERNAL] Inserts an existing parameter into the list of common effect parameters
|
---|
135 | at this abstraction level. This function is used during the flattening of a material.
|
---|
136 | @param parameter The effect parameter to insert. */
|
---|
137 | void AddParameter(FCDEffectParameter* parameter);
|
---|
138 |
|
---|
139 | /** Retrieves a common effect parameter. Looks for the common effect parameter with the correct
|
---|
140 | semantic, in order to bind or override its value.
|
---|
141 | This function searches through the effect and the level of abstractions below.
|
---|
142 | @param semantic The effect parameter semantic to match.
|
---|
143 | @return The first effect parameter that matches the semantic.
|
---|
144 | This pointer will be NULL if no effect parameter matches the given semantic. */
|
---|
145 | FCDEffectParameter* FindParameterBySemantic(const string& semantic);
|
---|
146 |
|
---|
147 | /** Retrieves a subset of the common effect parameter list.
|
---|
148 | Look for the effect parameter generators with the correct semantic.
|
---|
149 | This function searches through the effect and the level of abstractions below.
|
---|
150 | @param semantic The effect parameter semantic to match.
|
---|
151 | @param parameters The list of parameters to fill in. This list is not cleared. */
|
---|
152 | void FindParametersBySemantic(const string& semantic, FCDEffectParameterList& parameters);
|
---|
153 |
|
---|
154 | /** Retrieves a subset of the common effect parameter list.
|
---|
155 | Look for the effect parameter generators with the correct reference.
|
---|
156 | This function searches through the effect and the level of abstractions below.
|
---|
157 | @param reference The effect parameter reference to match. In the case of effect
|
---|
158 | parameter generators, the reference is replaced by the sub-id.
|
---|
159 | @param parameters The list of parameters to fill in. This list is not cleared. */
|
---|
160 | void FindParametersByReference(const string& reference, FCDEffectParameterList& parameters);
|
---|
161 |
|
---|
162 | /** Clones the effect object. Everything is cloned, including the effect parameter
|
---|
163 | and their animations. You will need release the cloned effect directly, by deleting the pointer.
|
---|
164 | @return The cloned effect object. You will must delete this pointer. */
|
---|
165 | FCDEffect* Clone();
|
---|
166 |
|
---|
167 | /** [INTERNAL] Flattens the effect, pushing all the common effect parameters
|
---|
168 | into to the effect technique level of abstraction. To correctly flatten a
|
---|
169 | material, use the FCDMaterialInstance::FlattenMaterial function. */
|
---|
170 | void Flatten();
|
---|
171 |
|
---|
172 | /** [INTERNAL] Reads in the \<effect\> element from a given COLLADA XML tree node.
|
---|
173 | @param effectNode The COLLADA XML tree node.
|
---|
174 | @return The status of the import. If the status is not successful,
|
---|
175 | it may be dangerous to extract information from the effect.*/
|
---|
176 | virtual FUStatus LoadFromXML(xmlNode* effectNode);
|
---|
177 |
|
---|
178 | /** [INTERNAL] Writes out the \<effect\> element to the given COLLADA XML tree node.
|
---|
179 | @param parentNode The COLLADA XML parent node in which to insert the effect.
|
---|
180 | @return The created element XML tree node. */
|
---|
181 | virtual xmlNode* WriteToXML(xmlNode* parentNode) const;
|
---|
182 |
|
---|
183 | /** Retrieves the list of the images contained within the effect.
|
---|
184 | @return The list of effect images. */
|
---|
185 | FCDEffectImageList& GetImages() { return images; }
|
---|
186 | const FCDEffectImageList& GetImages() const { return images; } /**< See above. */
|
---|
187 | };
|
---|
188 |
|
---|
189 | #endif // _FCD_MATERIAL_H_
|
---|