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

Revision 964, 33.7 KB checked in by igarcia, 18 years ago (diff)
Line 
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 FCDEffectParameter.h
8        This file contains the FCDEffectParameter interface and most of its derivate classes:
9        FCDEffectParameterSampler, FCDEffectParameterFloat, FCDEffectParameterVector...
10*/
11
12#ifndef _FCD_EFFECT_PARAMETER_H_
13#define _FCD_EFFECT_PARAMETER_H_
14
15#include "FCDocument/FCDObject.h"
16
17class FCDEffectPass;
18class FCDocument;
19class FCDEffectParameterSurface;
20
21/**
22        A COLLADA effect parameter.
23
24        This interface class is used to define all the valid
25        ColladaFX parameter types. There are many types of
26        parameters: integers, booleans, floating-point
27        values, 2D, 3D and 4D vectors of floating-point values,
28        matrices, strings, surfaces and their samplers.
29
30        A COLLADA effect parameter may generate a new
31        effect parameter, in which case it will declare a semantic
32        and a reference: to represent it within the COLLADA document.
33
34        @ingroup FCDEffect
35*/
36class FCOLLADA_EXPORT FCDEffectParameter : public FCDObject
37{
38public:
39        /** The type of the effect parameter class. */
40        enum Type
41        {
42                SAMPLER, /**< A sampler effect parameter. Points towards a surface parameter and adds extra texturing parameters. */
43                INTEGER, /**< A single integer effect parameter. */
44                BOOLEAN, /**< A single boolean effect parameter. */
45                FLOAT, /**< A single floating-pointer value effect parameter. */
46                FLOAT2, /**< A 2D vector of floating-pointer values. */
47                FLOAT3, /**< A 3D vector of floating-pointer values. */
48                VECTOR, /**< A 4D vector of floating-pointer values. */
49                MATRIX, /**< A 4x4 matrix. */
50                STRING, /**< A string effect parameter. */
51                SURFACE /**< A surface effect parameter. Contains a COLLADA image pointer. */
52        };
53
54private:
55        DeclareObjectType;
56        bool isGenerator; // whether this effect parameter structure generates a new value or modifies an existing value (is <newparam>?)
57        string reference;
58        string semantic; // this is a Collada Semantic, not a Cg semantic
59       
60        // [glaforte] These two members should be somewhere else
61        string bindSymbol; // this can be used in Cg to bind to the correct variable
62        bool isFragment; // parameter bound to the fragment program or the vertex one
63
64public:
65        /** Constructor: do not use directly.
66                Instead, use the FCDEffectParameterList::AddParameter function.
67                @param document The COLLADA document that owns the effect parameter. */
68        FCDEffectParameter(FCDocument* document);
69
70        /** Destructor: do not use directly.
71                Instead, use the FCDEffectParameterList::ReleaseParameter function.
72                When released, the effect parameter list will also release all
73                its parameters, if it owns them. */
74        virtual ~FCDEffectParameter();
75
76        /** Retrieves the type of effect parameter class.
77                @return The type of the effect parameter class.*/
78        virtual Type GetType() const = 0;
79
80        /** Retrieves the reference for this effect parameter.
81                In the case of generators, the reference string contains the sub-id.
82                @return The reference. */
83        const string& GetReference() const { return reference; }
84
85        /** Retrieves the semantic for this effect parameter.
86                @return The semantic. */
87        const string& GetSemantic() const { return semantic; }
88
89        /** Sets the semantic for this effect parameter.
90                @param _semantic The semantic. */
91        void SetSemantic(const string& _semantic) { semantic = _semantic; }
92
93        /** Retrieves whether this effect parameter is a parameter generator.
94                A ColladaFX parameter must be generated to be modified or bound at
95                higher abstraction levels.
96                @return Whether this is a generator. */
97        bool IsGenerator() const { return isGenerator; }
98
99        /** Retrieves whether this effect parameter is a parameter modifier.
100                A ColladaFX parameter must be generated to be modified or bound at
101                higher abstraction levels.
102                @return Whether this is a modifier. */
103        bool IsModifier() const { return !isGenerator; }
104
105        /** @deprecated Retrieves the program bind symbol for
106                this parameter. This information should be available
107                per-shader, in the FCDEffectPassShader class.
108                @return The program bind symbol. */
109        const string& GetBindSymbol() const { return bindSymbol; }
110
111        /** @deprecated Sets the program bind symbol for this parameter.
112                This information is available per-shader, in the FCDEffectPassShader class.
113                @param _bindSymbol The program bind symbol. */
114        void SetBindSymbol(const string& _bindSymbol) { bindSymbol = _bindSymbol; }
115
116        /** @deprecated Retrieves whether the program bind symbol attached
117                to this parameter belongs to a fragment/pixel shader.
118                This information is available per-shader, in the FCDEffectPassShader class.
119                @return Whether it belongs to a fragment/pixel shader. */
120        bool IsFragment() const { return isFragment; }
121
122        /** @deprecated Sets whether the program bind symbol attached to this
123                parameter belongs to a fragment/pixel shader.
124                This information is available per-shader, in the FCDEffectPassShader class.
125                @param _isFragment Whether it belongs to a fragment/pixel shader. */
126        void SetFragment(bool _isFragment) { isFragment = _isFragment;}
127
128        /** Creates a full copy of the effect parameter.
129                @return The cloned effect parameter. You will need to delete this pointer. */
130        virtual FCDEffectParameter* Clone() = 0;
131
132        /** [INTERNAL] Overwrites the target parameter with this parameter.
133                This function is used during the flattening of materials.
134                @param target The target parameter to overwrite. */
135        virtual void Overwrite(FCDEffectParameter* target);
136
137        /** [INTERNAL] Reads in the effect parameter from a given COLLADA XML tree node.
138                @param parameterNode The COLLADA XML tree node.
139                @return The status of the import. If the status is not successful,
140                        it may be dangerous to extract information from the parameter.*/
141        virtual FUStatus LoadFromXML(xmlNode* parameterNode);
142
143        /** [INTERNAL] Writes out the effect parameter to the given COLLADA XML tree node.
144                @param parentNode The COLLADA XML parent node in which to insert the parameter.
145                @return The created element XML tree node. */
146        virtual xmlNode* WriteToXML(xmlNode* parentNode) const;
147
148protected:
149        /** [INTERNAL] Copies into the given effect parameters, the variables
150                held by the FCDEffectParameter interface. This function is used by the classes
151                based on this interface during the cloning process.
152                @param clone The parameter to clone. */
153        void Clone(FCDEffectParameter* clone);
154};
155
156/**
157        A COLLADA sampler effect parameter.
158        A sampler parameter provides the extra texturing information necessary
159        to correctly sample a surface parameter.
160        There are four types of samplers supported: 1D, 2D, 3D and cube.
161
162        @ingroup FCDEffect
163*/
164class FCOLLADA_EXPORT FCDEffectParameterSampler : public FCDEffectParameter
165{
166public:
167        /** The type of sampling to execute. */
168        enum SamplerType
169        {
170                SAMPLER1D, /** 1D sampling. */
171                SAMPLER2D, /** 2D sampling. */
172                SAMPLER3D, /** 3D sampling. */
173                SAMPLERCUBE /** Cube-map sampling. */
174        };
175
176private:
177        SamplerType samplerType;
178        string surfaceSid;
179
180public:
181        /** Constructor: do not use directly.
182                Instead, use the FCDEffectParameterList::AddParameter function.
183                @param document The COLLADA document that owns the effect parameter. */
184        FCDEffectParameterSampler(FCDocument* document);
185
186        /** Destructor: do not use directly.
187                Instead, use the FCDEffectParameterList::ReleaseParameter function.
188                When released, the effect parameter list will also release all
189                its parameters, if it owns them. */
190        virtual ~FCDEffectParameterSampler();
191
192        /** Retrieves the type of effect parameter class.
193                @return The parameter class type: SAMPLER. */
194        virtual Type GetType() const { return SAMPLER; }
195
196        /** Retrieves the sub-id of the surface parameter.
197                You will want to search for that sub-id within the parameters to find the
198                FCDEffectParameterSurface object.
199                @return The sub-id. */
200        const char* GetSurfaceSid() const { return surfaceSid.c_str(); }
201
202        /** Sets the sub-id of the surface parameter to sample.
203                @param sid The surface parameter sub-id. */
204        void SetSurfaceSid(const char* sid) { surfaceSid = sid; }
205
206        /** Retrieves the type of sampling to do.
207                @return The sampling type. */
208        SamplerType GetSamplerType() const { return samplerType; }
209
210        /** Sets the type of sampling to do.
211                @param type The sampling type. */
212        void SetSamplerType(SamplerType type) { samplerType = type; }
213
214        /** Creates a full copy of the effect parameter.
215                @return The cloned effect parameter. You will need to delete this pointer. */
216        virtual FCDEffectParameter* Clone();
217
218        /** [INTERNAL] Overwrites the target parameter with this parameter.
219                This function is used during the flattening of materials.
220                @param target The target parameter to overwrite. */
221        virtual void Overwrite(FCDEffectParameter* target);
222
223        /** [INTERNAL] Reads in the effect parameter from a given COLLADA XML tree node.
224                @param parameterNode The COLLADA XML tree node.
225                @return The status of the import. If the status is not successful,
226                        it may be dangerous to extract information from the parameter.*/
227        virtual FUStatus LoadFromXML(xmlNode* parameterNode);
228
229        /** [INTERNAL] Writes out the effect parameter to the given COLLADA XML tree node.
230                @param parentNode The COLLADA XML parent node in which to insert the parameter.
231                @return The created element XML tree node. */
232        virtual xmlNode* WriteToXML(xmlNode* parentNode) const;
233};
234
235/**
236        A COLLADA integer effect parameter.
237        Contains a single, unanimated integer.
238*/
239class FCOLLADA_EXPORT FCDEffectParameterInt : public FCDEffectParameter
240{
241private:
242        int value;
243
244public:
245        /** Constructor: do not use directly.
246                Instead, use the FCDEffectParameterList::AddParameter function.
247                @param document The COLLADA document that owns the effect parameter. */
248        FCDEffectParameterInt(FCDocument* document);
249
250        /** Destructor: do not use directly.
251                Instead, use the FCDEffectParameterList::ReleaseParameter function.
252                When released, the effect parameter list will also release all
253                its parameters, if it owns them. */
254        virtual ~FCDEffectParameterInt();
255
256        /** Retrieves the type of effect parameter class.
257                @return The parameter class type: INTEGER. */
258        virtual Type GetType() const { return INTEGER; }
259
260        /** Retrieves the value of the effect parameter.
261                @return The integer value. */
262        int GetValue() const { return value; }
263
264        /** Sets the integer value of the effect parameter.
265                @param _value The integer value. */
266        void SetValue(int _value) { value = _value; }
267
268        /** Creates a full copy of the effect parameter.
269                @return The cloned effect parameter. You will need to delete this pointer. */
270        virtual FCDEffectParameter* Clone();
271
272        /** [INTERNAL] Overwrites the target parameter with this parameter.
273                This function is used during the flattening of materials.
274                @param target The target parameter to overwrite. */
275        virtual void Overwrite(FCDEffectParameter* target);
276
277        /** [INTERNAL] Reads in the effect parameter from a given COLLADA XML tree node.
278                @param parameterNode The COLLADA XML tree node.
279                @return The status of the import. If the status is not successful,
280                        it may be dangerous to extract information from the parameter.*/
281        virtual FUStatus LoadFromXML(xmlNode* parameterNode);
282
283        /** [INTERNAL] Writes out the effect parameter to the given COLLADA XML tree node.
284                @param parentNode The COLLADA XML parent node in which to insert the parameter.
285                @return The created element XML tree node. */
286        virtual xmlNode* WriteToXML(xmlNode* parentNode) const;
287};
288
289/**
290        A COLLADA boolean effect parameter.
291        Contains a single, unanimated boolean.
292*/
293class FCOLLADA_EXPORT FCDEffectParameterBool : public FCDEffectParameter
294{
295private:
296        bool value;
297
298public:
299        /** Constructor: do not use directly.
300                Instead, use the FCDEffectParameterList::AddParameter function.
301                @param document The COLLADA document that owns the effect parameter. */
302        FCDEffectParameterBool(FCDocument* document);
303
304        /** Destructor: do not use directly.
305                Instead, use the FCDEffectParameterList::ReleaseParameter function.
306                When released, the effect parameter list will also release all
307                its parameters, if it owns them. */
308        virtual ~FCDEffectParameterBool();
309
310        /** Retrieves the type of effect parameter class.
311                @return The parameter class type: BOOLEAN. */
312        virtual Type GetType() const { return BOOLEAN; }
313
314        /** Retrieves the boolean value of the effect parameter.
315                @return The boolean value. */
316        bool GetValue() const { return value; }
317
318        /** Sets the boolean value of the effect parameter.
319                @param _value The boolean value. */
320        void SetValue(bool _value) { value = _value; }
321
322        /** Creates a full copy of the effect parameter.
323                @return The cloned effect parameter. You will need to delete this pointer. */
324        virtual FCDEffectParameter* Clone();
325
326        /** [INTERNAL] Overwrites the target parameter with this parameter.
327                This function is used during the flattening of materials.
328                @param target The target parameter to overwrite. */
329        virtual void Overwrite(FCDEffectParameter* target);
330
331        /** [INTERNAL] Reads in the effect parameter from a given COLLADA XML tree node.
332                @param parameterNode The COLLADA XML tree node.
333                @return The status of the import. If the status is not successful,
334                        it may be dangerous to extract information from the parameter.*/
335        virtual FUStatus LoadFromXML(xmlNode* parameterNode);
336
337        /** [INTERNAL] Writes out the effect parameter to the given COLLADA XML tree node.
338                @param parentNode The COLLADA XML parent node in which to insert the parameter.
339                @return The created element XML tree node. */
340        virtual xmlNode* WriteToXML(xmlNode* parentNode) const;
341};
342
343/**
344        A COLLADA string effect parameter.
345        Contains a single, unanimated string.
346*/
347class FCOLLADA_EXPORT FCDEffectParameterString : public FCDEffectParameter
348{
349private:
350        string value;
351
352public:
353        /** Constructor: do not use directly.
354                Instead, use the FCDEffectParameterList::AddParameter function.
355                @param document The COLLADA document that owns the effect parameter. */
356        FCDEffectParameterString(FCDocument* document);
357
358        /** Destructor: do not use directly.
359                Instead, use the FCDEffectParameterList::ReleaseParameter function.
360                When released, the effect parameter list will also release all
361                its parameters, if it owns them. */
362        virtual ~FCDEffectParameterString();
363
364        /** Retrieves the type of effect parameter class.
365                @return The parameter class type: STRING. */
366        virtual Type GetType() const { return STRING; }
367
368        /** Retrieves the string contained in the effect parameter.
369                @return The string. */
370        const string& GetValue() const { return value; }
371
372        /** Sets the string contained in the effect parameter.
373                @param _value The string. */
374        void SetValue(const string& _value) { value = _value; }
375
376        /** Creates a full copy of the effect parameter.
377                @return The cloned effect parameter. You will need to delete this pointer. */
378        virtual FCDEffectParameter* Clone();
379
380        /** [INTERNAL] Overwrites the target parameter with this parameter.
381                This function is used during the flattening of materials.
382                @param target The target parameter to overwrite. */
383        virtual void Overwrite(FCDEffectParameter* target);
384
385        /** [INTERNAL] Reads in the effect parameter from a given COLLADA XML tree node.
386                @param parameterNode The COLLADA XML tree node.
387                @return The status of the import. If the status is not successful,
388                        it may be dangerous to extract information from the parameter.*/
389        virtual FUStatus LoadFromXML(xmlNode* parameterNode);
390
391        /** [INTERNAL] Writes out the effect parameter to the given COLLADA XML tree node.
392                @param parentNode The COLLADA XML parent node in which to insert the parameter.
393                @return The created element XML tree node. */
394        virtual xmlNode* WriteToXML(xmlNode* parentNode) const;
395};
396
397/**
398        A COLLADA float effect parameter.
399        Contains a single, possibly animated, floating-point value.
400        The type of the floating-point value may be HALF or FLOAT.
401*/
402class FCOLLADA_EXPORT FCDEffectParameterFloat : public FCDEffectParameter
403{
404public:
405        /** The supported types of float-point values. */
406        enum FloatType
407        {
408                FLOAT, /** A full-fledged floating-point value. This is the default. */
409                HALF /** Probably implies a 16-bit floating-point value. */
410        };
411
412private:
413        FloatType floatType;
414        float value;
415        float min;
416        float max;
417
418public:
419        /** Constructor: do not use directly.
420                Instead, use the FCDEffectParameterList::AddParameter function.
421                @param document The COLLADA document that owns the effect parameter. */
422        FCDEffectParameterFloat(FCDocument* document);
423
424        /** Destructor: do not use directly.
425                Instead, use the FCDEffectParameterList::ReleaseParameter function.
426                When released, the effect parameter list will also release all
427                its parameters, if it owns them. */
428        virtual ~FCDEffectParameterFloat();
429
430        /** Retrieves the type of effect parameter class.
431                @return The parameter class type: FLOAT. */
432        virtual FCDEffectParameter::Type GetType() const { return FCDEffectParameter::FLOAT; }
433
434        /** Retrieves the type of floating-point value held by this effect parameter.
435                @return The type of floating-point value. */
436        FloatType GetFloatType() const { return floatType; }
437
438        /** Sets the type of floating-point value held by this effect parameter.
439                @param type The type of floating-point value. */
440        void SetFloatType(FloatType type) { floatType = type; }
441
442        /** Retrieves the floating-point value of the effect parameter.
443                @return The floating-point value. */
444        float& GetValue() { return value; }
445        const float& GetValue() const { return value; } /**< See above. */
446
447        /** Sets the floating-point value of the effect parameter.
448                @param _value The floating-point value. */
449        void SetValue(float _value) { value = _value; }
450
451        /** Retrieves the minimum value for the UI widget created for this effect parameter.
452                This value is for UI purposes only and has no real impact on the value.
453                @return The minimum value. */
454        float GetMin() const { return min; }
455
456        /** Sets the minimum value for the UI widget created for this effect parameter.
457                This value is for UI purposes only and has no real impact on the value.
458                @param _min The minimum value. */
459        void SetMin(float _min) { min = _min; }
460
461        /** Retrieves the maximum value for the UI widget created for this effect parameter.
462                This value is for UI purposes only and has no real impact on the value.
463                @return The maximum value. */
464        float GetMax() const { return max; }
465
466        /** Sets the maximum value for the UI widget created for this effect parameter.
467                This value is for UI purposes only and has no real impact on the value.
468                @param _max The maximum value. */
469        void SetMax(float _max) { max = _max; }
470
471        /** Creates a full copy of the effect parameter.
472                @return The cloned effect parameter. You will need to delete this pointer. */
473        virtual FCDEffectParameter* Clone();
474
475        /** [INTERNAL] Overwrites the target parameter with this parameter.
476                This function is used during the flattening of materials.
477                @param target The target parameter to overwrite. */
478        virtual void Overwrite(FCDEffectParameter* target);
479
480        /** [INTERNAL] Reads in the effect parameter from a given COLLADA XML tree node.
481                @param parameterNode The COLLADA XML tree node.
482                @return The status of the import. If the status is not successful,
483                        it may be dangerous to extract information from the parameter.*/
484        virtual FUStatus LoadFromXML(xmlNode* parameterNode);
485
486        /** [INTERNAL] Writes out the effect parameter to the given COLLADA XML tree node.
487                @param parentNode The COLLADA XML parent node in which to insert the parameter.
488                @return The created element XML tree node. */
489        virtual xmlNode* WriteToXML(xmlNode* parentNode) const;
490};
491
492/**
493        A COLLADA 2D vector of floats.
494        Contains two, possibly animated, floating-point values.
495        The type of the floating-point values may be HALF or FLOAT.
496*/
497class FCOLLADA_EXPORT FCDEffectParameterFloat2 : public FCDEffectParameter
498{
499public:
500        /** The supported types of float-point values. */
501        enum FloatType
502        {
503                FLOAT, /** A full-fledged floating-point value. This is the default. */
504                HALF /** Probably implies a 16-bit floating-point value. */
505        };
506
507private:
508        FloatType floatType;
509        float value_x;
510        float value_y;
511
512public:
513        /** Constructor: do not use directly.
514                Instead, use the FCDEffectParameterList::AddParameter function.
515                @param document The COLLADA document that owns the effect parameter. */
516        FCDEffectParameterFloat2(FCDocument* document);
517
518        /** Destructor: do not use directly.
519                Instead, use the FCDEffectParameterList::ReleaseParameter function.
520                When released, the effect parameter list will also release all
521                its parameters, if it owns them. */
522        virtual ~FCDEffectParameterFloat2();
523
524        /** Retrieves the type of effect parameter class.
525                @return The parameter class type: FLOAT2. */
526        virtual Type GetType() const { return FLOAT2; }
527
528        /** Retrieves the type of floating-point value held by this effect parameter.
529                @return The type of floating-point value. */
530        FloatType GetFloatType() const { return floatType; }
531
532        /** Sets the type of floating-point value held by this effect parameter.
533                @param type The type of floating-point value. */
534        void SetFloatType(FloatType type) { floatType = type; }
535
536        /** Retrieves the first floating-point value of the effect parameter.
537                @return The first floating-point value. */
538        float& GetValueX() { return value_x; }
539        const float& GetValueX() const { return value_x; } /**< See above. */
540
541        /** Sets the first floating-point value of the effect parameter.
542                @param value The first floating-point value. */
543        void SetValueX(float value) { value_x = value; }
544
545        /** Retrieves the second floating-point value of the effect parameter.
546                @return The second floating-point value. */
547        float& GetValueY() { return value_y; }
548        const float& GetValueY() const { return value_y; } /**< See above. */
549
550        /** Sets the second floating-point value of the effect parameter.
551                @param value The second floating-point value. */
552        void SetValueY(float value) { value_y = value; }
553
554        /** Creates a full copy of the effect parameter.
555                @return The cloned effect parameter. You will need to delete this pointer. */
556        virtual FCDEffectParameter* Clone();
557
558        /** [INTERNAL] Overwrites the target parameter with this parameter.
559                This function is used during the flattening of materials.
560                @param target The target parameter to overwrite. */
561        virtual void Overwrite(FCDEffectParameter* target);
562
563        /** [INTERNAL] Reads in the effect parameter from a given COLLADA XML tree node.
564                @param parameterNode The COLLADA XML tree node.
565                @return The status of the import. If the status is not successful,
566                        it may be dangerous to extract information from the parameter.*/
567        virtual FUStatus LoadFromXML(xmlNode* parameterNode);
568
569        /** [INTERNAL] Writes out the effect parameter to the given COLLADA XML tree node.
570                @param parentNode The COLLADA XML parent node in which to insert the parameter.
571                @return The created element XML tree node. */
572        virtual xmlNode* WriteToXML(xmlNode* parentNode) const;
573};
574
575/**
576        A COLLADA 3D vector of floats.
577        Contains three, possibly animated, floating-point values.
578        The type of the floating-point values may be HALF or FLOAT.
579*/
580class FCOLLADA_EXPORT FCDEffectParameterFloat3 : public FCDEffectParameter
581{
582public:
583        /** The supported types of float-point values. */
584        enum FloatType
585        {
586                FLOAT, /** A full-fledged floating-point value. This is the default. */
587                HALF /** Probably implies a 16-bit floating-point value. */
588        };
589
590private:
591        FloatType floatType;
592        FMVector3 value;
593
594public:
595        /** Constructor: do not use directly.
596                Instead, use the FCDEffectParameterList::AddParameter function.
597                @param document The COLLADA document that owns the effect parameter. */
598        FCDEffectParameterFloat3(FCDocument* document);
599
600        /** Destructor: do not use directly.
601                Instead, use the FCDEffectParameterList::ReleaseParameter function.
602                When released, the effect parameter list will also release all
603                its parameters, if it owns them. */
604        virtual ~FCDEffectParameterFloat3();
605
606        /** Retrieves the type of effect parameter class.
607                @return The parameter class type: FLOAT3. */
608        virtual Type GetType() const { return FLOAT3; }
609
610        /** Retrieves the type of floating-point value held by this effect parameter.
611                @return The type of floating-point value. */
612        FloatType GetFloatType() const { return floatType; }
613
614        /** Sets the type of floating-point value held by this effect parameter.
615                @param type The type of floating-point value. */
616        void SetFloatType(FloatType type) { floatType = type; }
617
618        /** Retrieves the first floating-point value of the effect parameter.
619                @return The first floating-point value. */
620        float& GetValueX() { return value.x; }
621        const float& GetValueX() const { return value.x; } /**< See above. */
622
623        /** Sets the first floating-point value of the effect parameter.
624                @param _value The first floating-point value. */
625        void SetValueX(float _value) { value.x = _value; }
626
627        /** Retrieves the second floating-point value of the effect parameter.
628                @return The second floating-point value. */
629        float& GetValueY() { return value.y; }
630        const float& GetValueY() const { return value.y; } /**< See above. */
631
632        /** Sets the second floating-point value of the effect parameter.
633                @param _value The second floating-point value. */
634        void SetValueY(float _value) { value.y = _value; }
635
636        /** Retrieves the third floating-point value of the effect parameter.
637                @return The third floating-point value. */
638        float& GetValueZ() { return value.z; }
639        const float& GetValueZ() const { return value.z; } /**< See above. */
640
641        /** Sets the third floating-point value of the effect parameter.
642                @param _value The third floating-point value. */
643        void SetValueZ(float _value) { value.z = _value; }
644
645        /** Creates a full copy of the effect parameter.
646                @return The cloned effect parameter. You will need to delete this pointer. */
647        virtual FCDEffectParameter* Clone();
648
649        /** [INTERNAL] Overwrites the target parameter with this parameter.
650                This function is used during the flattening of materials.
651                @param target The target parameter to overwrite. */
652        virtual void Overwrite(FCDEffectParameter* target);
653
654        /** [INTERNAL] Reads in the effect parameter from a given COLLADA XML tree node.
655                @param parameterNode The COLLADA XML tree node.
656                @return The status of the import. If the status is not successful,
657                        it may be dangerous to extract information from the parameter.*/
658        virtual FUStatus LoadFromXML(xmlNode* parameterNode);
659
660        /** [INTERNAL] Writes out the effect parameter to the given COLLADA XML tree node.
661                @param parentNode The COLLADA XML parent node in which to insert the parameter.
662                @return The created element XML tree node. */
663        virtual xmlNode* WriteToXML(xmlNode* parentNode) const;
664};
665
666/**
667        A COLLADA 4D vector of floats.
668        Contains four, possibly animated, floating-point values.
669        The type of the floating-point values may be HALF or FLOAT.
670*/
671class FCOLLADA_EXPORT FCDEffectParameterVector : public FCDEffectParameter
672{
673public:
674        /** The supported types of float-point values. */
675        enum FloatType
676        {
677                FLOAT, /** A full-fledged floating-point value. This is the default. */
678                HALF /** Probably implies a 16-bit floating-point value. */
679        };
680
681private:
682        FloatType floatType;
683        float vector[4];
684
685public:
686        /** Constructor: do not use directly.
687                Instead, use the FCDEffectParameterList::AddParameter function.
688                @param document The COLLADA document that owns the effect parameter. */
689        FCDEffectParameterVector(FCDocument* document);
690
691        /** Destructor: do not use directly.
692                Instead, use the FCDEffectParameterList::ReleaseParameter function.
693                When released, the effect parameter list will also release all
694                its parameters, if it owns them. */
695        virtual ~FCDEffectParameterVector();
696
697        /** Retrieves the type of effect parameter class.
698                @return The parameter class type: VECTOR. */
699        virtual Type GetType() const { return VECTOR; }
700
701        /** Retrieves the type of floating-point value held by this effect parameter.
702                @return The type of floating-point value. */
703        FloatType GetFloatType() const { return floatType; }
704
705        /** Sets the type of floating-point value held by this effect parameter.
706                @param type The type of floating-point value. */
707        void SetFloatType(FloatType type) { floatType = type; }
708
709        /** Sets the vector value of the effect parameter.
710                @return The vector value. */
711        float* GetVector() { return vector; }
712        const float* GetVector() const { return vector; } /**< See above. */
713
714        /** Retrieves the first floating-point value of the effect parameter.
715                @return The first floating-point value. */
716        float& GetValueX() { return vector[0]; }
717        const float& GetValueX() const { return vector[0]; } /**< See above. */
718
719        /** Sets the first floating-point value of the effect parameter.
720                @param _value The first floating-point value. */
721        void SetValueX(float _value) { vector[0] = _value; }
722
723        /** Retrieves the second floating-point value of the effect parameter.
724                @return The second floating-point value. */
725        float& GetValueY() { return vector[1]; }
726        const float& GetValueY() const { return vector[1]; } /**< See above. */
727
728        /** Sets the second floating-point value of the effect parameter.
729                @param _value The second floating-point value. */
730        void SetValueY(float _value) { vector[1] = _value; }
731
732        /** Retrieves the third floating-point value of the effect parameter.
733                @return The third floating-point value. */
734        float& GetValueZ() { return vector[2]; }
735        const float& GetValueZ() const { return vector[2]; } /**< See above. */
736
737        /** Sets the third floating-point value of the effect parameter.
738                @param _value The third floating-point value. */
739        void SetValueZ(float _value) { vector[2] = _value; }
740
741        /** Retrieves the fourth floating-point value of the effect parameter.
742                @return The fourth floating-point value. */
743        float& GetValueW() { return vector[3]; }
744        const float& GetValueW() const { return vector[3]; } /**< See above. */
745
746        /** Sets the fourth floating-point value of the effect parameter.
747                @param _value The fourth floating-point value. */
748        void SetValueW(float _value) { vector[3] = _value; }
749
750        /** Creates a full copy of the effect parameter.
751                @return The cloned effect parameter. You will need to delete this pointer. */
752        virtual FCDEffectParameter* Clone();
753
754        /** [INTERNAL] Overwrites the target parameter with this parameter.
755                This function is used during the flattening of materials.
756                @param target The target parameter to overwrite. */
757        virtual void Overwrite(FCDEffectParameter* target);
758
759        /** [INTERNAL] Reads in the effect parameter from a given COLLADA XML tree node.
760                @param parameterNode The COLLADA XML tree node.
761                @return The status of the import. If the status is not successful,
762                        it may be dangerous to extract information from the parameter.*/
763        virtual FUStatus LoadFromXML(xmlNode* parameterNode);
764
765        /** [INTERNAL] Writes out the effect parameter to the given COLLADA XML tree node.
766                @param parentNode The COLLADA XML parent node in which to insert the parameter.
767                @return The created element XML tree node. */
768        virtual xmlNode* WriteToXML(xmlNode* parentNode) const;
769};
770
771/**
772        A COLLADA 4x4 matrix.
773        Contains 16 floating-point values that represent a COLLADA column-major 4x4 matrix.
774        The type of the floating-point values may be HALF or FLOAT.
775*/
776class FCOLLADA_EXPORT FCDEffectParameterMatrix : public FCDEffectParameter
777{
778public:
779        /** The supported types of float-point values. */
780        enum FloatType
781        {
782                FLOAT, /** A full-fledged floating-point value. This is the default. */
783                HALF /** Probably implies a 16-bit floating-point value. */
784        };
785
786private:
787        FloatType floatType;
788        FMMatrix44 matrix;
789
790public:
791        /** Constructor: do not use directly.
792                Instead, use the FCDEffectParameterList::AddParameter function.
793                @param document The COLLADA document that owns the effect parameter. */
794        FCDEffectParameterMatrix(FCDocument* document);
795
796        /** Destructor: do not use directly.
797                Instead, use the FCDEffectParameterList::ReleaseParameter function.
798                When released, the effect parameter list will also release all
799                its parameters, if it owns them. */
800        virtual ~FCDEffectParameterMatrix();
801
802        /** Retrieves the type of effect parameter class.
803                @return The parameter class type: MATRIX. */
804        virtual Type GetType() const { return MATRIX; }
805
806        /** Retrieves the type of floating-point value held by this effect parameter.
807                @return The type of floating-point value. */
808        FloatType GetFloatType() const { return floatType; }
809
810        /** Sets the type of floating-point value held by this effect parameter.
811                @param type The type of floating-point value. */
812        void SetFloatType(FloatType type) { floatType = type; }
813
814        /** Retrieves the matrix contained within this effect parameter.
815                @return The matrix. */
816        FMMatrix44& GetMatrix() { return matrix; }
817        const FMMatrix44& GetMatrix() const { return matrix; } /**< See above. */
818
819        /** Sets the matrix contained within this effect parameter.
820                @param mx The matrix. */
821        void SetMatrix(const FMMatrix44& mx) { matrix = mx; }
822
823        /** Creates a full copy of the effect parameter.
824                @return The cloned effect parameter. You will need to delete this pointer. */
825        virtual FCDEffectParameter* Clone();
826
827        /** [INTERNAL] Overwrites the target parameter with this parameter.
828                This function is used during the flattening of materials.
829                @param target The target parameter to overwrite. */
830        virtual void Overwrite(FCDEffectParameter* target);
831
832        /** [INTERNAL] Reads in the effect parameter from a given COLLADA XML tree node.
833                @param parameterNode The COLLADA XML tree node.
834                @return The status of the import. If the status is not successful,
835                        it may be dangerous to extract information from the parameter.*/
836        virtual FUStatus LoadFromXML(xmlNode* parameterNode);
837
838        /** [INTERNAL] Writes out the effect parameter to the given COLLADA XML tree node.
839                @param parentNode The COLLADA XML parent node in which to insert the parameter.
840                @return The created element XML tree node. */
841        virtual xmlNode* WriteToXML(xmlNode* parentNode) const;
842};
843
844#endif // _FCD_EFFECT_PARAMETER_H_
845
Note: See TracBrowser for help on using the repository browser.