source: NonGTP/FCollada/FCDocument/FCDEffectTechnique.h @ 964

Revision 964, 8.7 KB checked in by igarcia, 18 years ago (diff)
RevLine 
[964]1/*
2        Copyright (C) 2005-2006 Feeling Software Inc.
3        MIT License: http://www.opensource.org/licenses/mit-license.php
4*/
5
6/**
7        @file FCDEffectTechnique.h
8        This file declares the FCDEffectTechnique class.
9*/
10
11#ifndef _FCD_EFFECT_TECHNIQUE_H_
12#define _FCD_EFFECT_TECHNIQUE_H_
13
14#include "FCDocument/FCDObject.h"
15
16class FCDEffectCode;
17class FCDEffectPass;
18class FCDEffectParameter;
19class FCDEffectParameterList;
20class FCDEffectProfileFX;
21
22typedef vector<FCDEffectPass*> FCDEffectPassList; /**< A dynamically-sized array of effect passes. */
23typedef vector<FCDEffectCode*> FCDEffectCodeList; /**< A dynamically-sized array of effect code inclusions. */
24
25/**
26        A COLLADA effect technique.
27
28        The COLLADA effect technique contains the passes to be used in the rendering of
29        polygon sets.
30       
31        It also contains a list of effect parameters: both generators and overrides
32        and it is the lowest level of abstraction in which you can access effect parameters. For
33        flattened materials, this means that all the effect parameters will be accessible at this level.
34
35        It also contains a list of effect code inclusions.
36
37        @ingroup FCDEffect
38*/
39class FCOLLADA_EXPORT FCDEffectTechnique : public FCDObject
40{
41private:
42        DeclareObjectType;
43        FCDEffectProfileFX* parent;
44
45        fstring name;
46        FCDEffectCodeList codes;
47        FCDEffectPassList passes;
48        FCDEffectParameterList* parameters;
49
50public:
51        /** Constructor: do not use directly.
52                Instead, use the FCDEffectProfileFX::AddTechnique function.
53                @param document The COLLADA document which owns this technique.
54                @param _parent The effect profile which contains the technique. */
55        FCDEffectTechnique(FCDocument* document, FCDEffectProfileFX *_parent);
56
57        /** Destructor: do not use directly.
58                Instead, use the FCDEffectProfileFX::ReleaseTechnique function. */
59        virtual ~FCDEffectTechnique();
60
61        /** Retrieves the effect profile that contains this technique.
62                @return The parent effect profile. */
63        FCDEffectProfileFX* GetParent() { return parent; }
64        const FCDEffectProfileFX* GetParent() const { return parent; } /**< See above. */
65
66        /** Retrieves the COLLADA id of the parent effect.
67                This function is mostly useful as a shortcut for debugging and reporting.
68                @return The COLLADA id of the parent effect. */
69        const string& GetDaeId() const;
70
71        /** Retrieves the sub-id of the technique.
72                @return The sub-id of the technique. */
73        const fstring& GetName() const { return name; }
74
75        /** Sets the sub-id of the technique.
76                The effect technique must have a valid sub-id that is unique
77                within its scope. Otherwise, one will be provided on XML export.
78                @param _name A valid sub-id. */
79        void SetName(const fstring& _name) { name = _name; }
80
81        /** Retrieves the list of passes.
82                @return The list of passes. */
83        FCDEffectPassList& GetPassList() { return passes; }
84        const FCDEffectPassList& GetPassList() const { return passes; } /**< See above. */
85
86        /** Retrieves the number of passes contained within this effect technique.
87                @return The number of passes. */
88        size_t GetPassCount() const { return passes.size(); }
89
90        /** Retrieves a specific pass contained within this effect technique.
91                @param index The index of the pass.
92                @return The pass. This pointer will be NULL if the index is out-of-bounds. */
93        FCDEffectPass* GetPass(size_t index) { FUAssert(index < GetPassCount(), return NULL); return passes.at(index); }
94        const FCDEffectPass* GetPass(size_t index) const { FUAssert(index < GetPassCount(), return NULL); return passes.at(index); } /**< See above. */
95
96        /** Adds a new pass to this effect technique.
97                @return The new pass. */
98        FCDEffectPass* AddPass();
99
100        /** Releases a pass contaied within this effect technique.
101                @param pass The pass to release. */
102        void ReleasePass(FCDEffectPass* pass);
103
104        /** Retrieves the list of code inclusions.
105                @return The list of code inclusions. */         
106        FCDEffectCodeList& GetCodeList() { return codes; }
107        const FCDEffectCodeList& GetCodeList() const { return codes; } /**< See above. */
108
109        /** Retrieves the number of code inclusions contained within the effect profile.
110                @return The number of code inclusions. */
111        size_t GetCodeCount() const { return codes.size(); }
112
113        /** Retrieves a code inclusion contained within the effect profile.
114                @param index The index of the code inclusion.
115                @return The code inclusion. This pointer will be NULL if the index is out-of-bounds. */
116        FCDEffectCode* GetCode(size_t index) { FUAssert(index < GetCodeCount(), return NULL); return codes.at(index); }
117        const FCDEffectCode* GetCode(size_t index) const { FUAssert(index < GetCodeCount(), return NULL); return codes.at(index); } /**< See above. */
118
119        /** Retrieves the code inclusion with the given sub-id.
120                @param sid A COLLADA sub-id.
121                @return The code inclusion with the given sub-id. This pointer will be NULL,
122                        if there are no code inclusions that match the given sub-id. */
123        FCDEffectCode* FindCode(const string& sid);
124        const FCDEffectCode* FindCode(const string& sid) const; /**< See above. */
125
126        /** Adds a new code inclusion to this effect profile.
127                @return The new code inclusion. */
128        FCDEffectCode* AddCode();
129
130        /** Releases a code inclusion contained within this effect profile.
131                @param code The code inclusion to release. */
132        void ReleaseCode(FCDEffectCode* code);
133
134        /** Retrieves the list of effect parameters contained within the effect profile.
135                This is the lowest level of abstraction and may contain either effect parameter
136                generators or effect parameter overrides.
137                @return The list of effect parameters. */
138        FCDEffectParameterList* GetParameterList() { return parameters; }
139        const FCDEffectParameterList* GetParameterList() const { return parameters; } /**< See above. */
140
141        /** [INTERNAL] Inserts an existing parameter into the list of effect parameters
142                at this abstraction level. This function is used during the flattening of a material.
143                @param parameter The effect parameter to insert. */
144        void AddParameter(FCDEffectParameter* parameter);
145
146        /** Retrieves an effect parameter.
147                Looks for the effect parameter with the correct reference, in order to bind or override its value.
148                @param reference The reference to match. In the case of effect parameter generators,
149                        the sub-id is used to match.
150                @return The first effect parameter that matches the reference.
151                        This pointer will be NULL if no effect parameter matches the given semantic. */
152        const FCDEffectParameter* FindParameter(const char* reference) const;
153
154        /** Retrieves an effect parameter.
155                Looks for the effect parameter with the correct semantic, in order to bind or override its value.
156                @param semantic The effect parameter semantic to match.
157                @return The first effect parameter that matches the semantic.
158                        This pointer will be NULL if no effect parameter matches the given semantic. */
159        virtual FCDEffectParameter* FindParameterBySemantic(const string& semantic);
160
161        /** Retrieves a subset of the effect parameter list.
162                Look for the effect parameter generators with the correct semantic.
163                @param semantic The effect parameter semantic to match.
164                @param parameters The list of parameters to fill in. This list is not cleared. */
165        virtual void FindParametersBySemantic(const string& semantic, FCDEffectParameterList& parameters);
166
167        /** Retrieves a subset of the effect parameter list.
168                Look for the effect parameter generators with the correct reference.
169                @param reference The effect parameter reference to match. In the case of effect
170                        parameter generators, the reference is replaced by the sub-id.
171                @param parameters The list of parameters to fill in. This list is not cleared. */
172        virtual void FindParametersByReference(const string& reference, FCDEffectParameterList& parameters);
173
174        /** [INTERNAL] Clones the full effect technique.
175                @param newParent The effect profile that will contain the cloned technique.
176                @return The cloned technique. This pointer will never be NULL. */
177        FCDEffectTechnique* Clone(FCDEffectProfileFX* newParent);
178
179        /** [INTERNAL] Flattens this effect technique.
180                Merges the parameter overrides into the parameter generators. */
181        void Flatten();
182
183        /** [INTERNAL] Reads in the effect technique from a given COLLADA XML tree node.
184                @param techniqueNode The COLLADA XML tree node.
185                @param profileNode X @deprecated bad interface : this dependency must be taken out.
186                @return The status of the import. If the status is not successful,
187                        it may be dangerous to extract information from the effect technique.*/
188        FUStatus LoadFromXML(xmlNode* techniqueNode, xmlNode* profileNode);
189
190        /** [INTERNAL] Writes out the effect technique to the given COLLADA XML tree node.
191                @param parentNode The COLLADA XML parent node in which to insert the effect technique.
192                @return The created element XML tree node. */
193        xmlNode* WriteToXML(xmlNode* parentNode) const;
194};
195
196#endif
Note: See TracBrowser for help on using the repository browser.