[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 FCDEffectPass.h
|
---|
| 8 | This file contains the FCDEffectPass class.
|
---|
| 9 | */
|
---|
| 10 |
|
---|
| 11 | #ifndef _FCD_EFFECT_PASS_H_
|
---|
| 12 | #define _FCD_EFFECT_PASS_H_
|
---|
| 13 |
|
---|
| 14 | #include "FCDocument/FCDObject.h"
|
---|
| 15 |
|
---|
| 16 | class FCDEffectTechnique;
|
---|
| 17 | class FCDEffectParameter;
|
---|
| 18 | class FCDEffectParameterList;
|
---|
| 19 | class FCDEffectPassShader;
|
---|
| 20 |
|
---|
| 21 | typedef vector<FCDEffectPassShader*> FCDEffectPassShaderList; /**< A dynamically-sized array of shaders. */
|
---|
| 22 | typedef vector<string> MeshDataList; /**< @deprecated A dynamically-sized array of mesh bindings. These should be bound using the \<bind\> element, at the instantiation level! */
|
---|
| 23 |
|
---|
| 24 | /**
|
---|
| 25 | A COLLADA effect pass.
|
---|
| 26 |
|
---|
| 27 | The effect pass contains a list of effect shaders. While they
|
---|
| 28 | may be missing, it does not make sense for the effect pass to
|
---|
| 29 | contain more than two shaders: a vertex shader and a fragment/pixel shader.
|
---|
| 30 |
|
---|
| 31 | For this reason, we provide the GetVertexShader and the GetFragmentShader
|
---|
| 32 | which we expect will be used for most applications, rather than looking
|
---|
| 33 | through the list of shader objects.
|
---|
| 34 |
|
---|
| 35 | @ingroup FCDEffect
|
---|
| 36 | */
|
---|
| 37 | class FCOLLADA_EXPORT FCDEffectPass : public FCDObject
|
---|
| 38 | {
|
---|
| 39 | private:
|
---|
| 40 | DeclareObjectType;
|
---|
| 41 | fstring name;
|
---|
| 42 | FCDEffectTechnique* parent;
|
---|
| 43 | FCDEffectPassShaderList shaders;
|
---|
| 44 | MeshDataList meshdata;
|
---|
| 45 |
|
---|
| 46 | public:
|
---|
| 47 | /** Constructor: do not use directly.
|
---|
| 48 | Instead, use the FCDEffectTechnique::AddPass function.
|
---|
| 49 | @param document The COLLADA document that owns this effect pass.
|
---|
| 50 | @param _parent The effect technique that contains this effect pass. */
|
---|
| 51 | FCDEffectPass(FCDocument* document, FCDEffectTechnique *_parent);
|
---|
| 52 |
|
---|
| 53 | /** Destructor: do not use directly.
|
---|
| 54 | Instead, use the FCDEffectTechnique::ReleasePass function. */
|
---|
| 55 | virtual ~FCDEffectPass();
|
---|
| 56 |
|
---|
| 57 | /** Retrieves the effect techniques which contains this effect pass.
|
---|
| 58 | @return The parent technique. */
|
---|
| 59 | FCDEffectTechnique* GetParent() { return parent; }
|
---|
| 60 | const FCDEffectTechnique* GetParent() const { return parent; } /**< See above. */
|
---|
| 61 |
|
---|
| 62 | /** Retrieves the COLLADA id of the parent effect.
|
---|
| 63 | This function is mostly useful as a shortcut for debugging and reporting.
|
---|
| 64 | @return The COLLADA id of the parent effect. */
|
---|
| 65 | const string& GetDaeId() const;
|
---|
| 66 |
|
---|
| 67 | /** Retrieves the sub-id of the effect pass.
|
---|
| 68 | This sub-id is optional.
|
---|
| 69 | @return The sub-id. */
|
---|
| 70 | const fstring& GetPassName() const { return name; }
|
---|
| 71 |
|
---|
| 72 | /** Sets the optional sub-id for the effect pass.
|
---|
| 73 | This sub-id is optional.
|
---|
| 74 | @param _name The sub-id. */
|
---|
| 75 | void SetPassName(const fstring& _name) { name = _name; }
|
---|
| 76 |
|
---|
| 77 | /** @deprecated Retrieves the list of mesh data bindings.
|
---|
| 78 | This patches bad export data in ColladaMaya and will be removed soon.
|
---|
| 79 | @return The list of mesh data bindings. */
|
---|
| 80 | const MeshDataList& GetMeshData() const { return meshdata; }
|
---|
| 81 |
|
---|
| 82 | /** Retrieves the number of shaders contained within the effect pass.
|
---|
| 83 | @return The number of shaders. */
|
---|
| 84 | size_t GetShaderCount() const { return shaders.size(); }
|
---|
| 85 |
|
---|
| 86 | /** Retrieves a specific shader.
|
---|
| 87 | @param index The index of the shader.
|
---|
| 88 | @return The shader. This pointer will be NULL if the index is out-of-bounds. */
|
---|
| 89 | FCDEffectPassShader* GetShader(size_t index) { FUAssert(index < GetShaderCount(), return NULL); return shaders.at(index); }
|
---|
| 90 | const FCDEffectPassShader* GetShader(size_t index) const { FUAssert(index < GetShaderCount(), return NULL); return shaders.at(index); } /**< See above. */
|
---|
| 91 |
|
---|
| 92 | /** Adds a new shader to the pass.
|
---|
| 93 | @return The new shader. */
|
---|
| 94 | FCDEffectPassShader* AddShader();
|
---|
| 95 |
|
---|
| 96 | /** Releases a shader contained within the pass.
|
---|
| 97 | @param shader The shader to release. */
|
---|
| 98 | void ReleaseShader(FCDEffectPassShader* shader);
|
---|
| 99 |
|
---|
| 100 | /** Retrieves the vertex shader for this effect pass.
|
---|
| 101 | @return The vertex shader. This pointer will be NULL if no
|
---|
| 102 | shader within the pass affects vertices. */
|
---|
| 103 | FCDEffectPassShader* GetVertexShader();
|
---|
| 104 | const FCDEffectPassShader* GetVertexShader() const; /**< See above. */
|
---|
| 105 |
|
---|
| 106 | /** Retrieves the fragment shader for this effect pass.
|
---|
| 107 | @return The fragment shader. This pointer will be NULL if no
|
---|
| 108 | shader within the pass affects pixels/fragments. */
|
---|
| 109 | FCDEffectPassShader* GetFragmentShader();
|
---|
| 110 | const FCDEffectPassShader* GetFragmentShader() const; /**< See above. */
|
---|
| 111 |
|
---|
| 112 | /** Adds a new vertex shader to the pass.
|
---|
| 113 | If a vertex shader already exists within the pass, it will be released.
|
---|
| 114 | @return The new vertex shader. */
|
---|
| 115 | FCDEffectPassShader* AddVertexShader();
|
---|
| 116 |
|
---|
| 117 | /** Adds a new fragment shader to the pass.
|
---|
| 118 | If a fragment shader already exists within the pass, it will be released.
|
---|
| 119 | @return The new fragment shader. */
|
---|
| 120 | FCDEffectPassShader* AddFragmentShader();
|
---|
| 121 |
|
---|
| 122 | /** [INTERNAL] Clones the full effect pass.
|
---|
| 123 | @param newParent The effect technique that will contain the cloned profile.
|
---|
| 124 | @return The cloned pass. This pointer will never be NULL. */
|
---|
| 125 | FCDEffectPass* Clone(FCDEffectTechnique* newParent) const;
|
---|
| 126 |
|
---|
| 127 | /** [INTERNAL] Reads in the effect pass from a given COLLADA XML tree node.
|
---|
| 128 | @param passNode The COLLADA XML tree node.
|
---|
| 129 | @param techniqueNode X @deprecated bad interface : this dependency must be taken out[3]
|
---|
| 130 | @param profileNode X @deprecated bad interface : this dependency must be taken out[2]
|
---|
| 131 | @return The status of the import. If the status is not successful,
|
---|
| 132 | it may be dangerous to extract information from the effect pass.*/
|
---|
| 133 | FUStatus LoadFromXML(xmlNode* passNode, xmlNode* techniqueNode, xmlNode* profileNode);
|
---|
| 134 |
|
---|
| 135 | /** [INTERNAL] Writes out the effect pass to the given COLLADA XML tree node.
|
---|
| 136 | @param parentNode The COLLADA XML parent node in which to insert the effect pass.
|
---|
| 137 | @return The created element XML tree node. */
|
---|
| 138 | xmlNode* WriteToXML(xmlNode* parentNode) const;
|
---|
| 139 | };
|
---|
| 140 |
|
---|
| 141 | #endif
|
---|