I am a collada newbie. and now i try to implement my own collada loader and viewer in C++/DirectX.
I have read the spec. but I don’t realize the semantics of input mean for accessor…
for example : if the input use POSITION, does it mean it’s source should provide “X”, “Y”, “Z” data and the accessors should indicate how to access “X”, “Y”, “Z”,
so NORMAL should have similar struct with POSITION.
COLOR’s source should provide “R”, “G”, “B”, “A”
TEXCOORD’s source should provide “S”, “T”, “P”, “Q”
However, when I use the 3ds max exportor, the COLOR/TEXCOORD use the “S”, “T”, “R” as accessors name…
This make me confused .
Sorry for my poor English and Thanks for your help:)
but how about this (use different param name instead of “X”, “Y”, “Z”)
<accessor source="#someArray" …>
<param name=“S” type=“float” flow=“OUT”/>
<param name=“T” type=“float” flow=“OUT”/>
<param name=“R” type=“float” flow=“OUT”/>
The information in the accessor nodes define how to use the source’s array’s data. In both cases you mention, the <input> node is valid. Its up to the application to read the input’s semantic and the accessor’s parameter and figure out how it should interpret the data. In the ColladaMaya importer, we don’t read in the parameter names, we simply read in the accessor’s stride and assume from there. I suggest you do the same.
If the input semantic is “VERTEX”, it should always point to a <vertices> node, although I don’t think that’s enforced anywhere. What you should do, in your importer, when you read in the <mesh> node:
Read in the <vertices> node. There should always be one. Parse its inputs.
2.0 For each of the <polygons>/<triangles>/etc nodes
2.1 Read in the inner <input> nodes.
2.2 If some of the <input> nodes semantics are “VERTEX”, replace them with the <input> nodes from the <vertices> node.
2.3 Read in the tessellation
Read in the sources
Merge all this information into vertex/index buffers…
Param elements under the <accessor> are optional. If they are present they provide additional information to bind the data source to the consumer.
Gauillaume you can’t completely ignore the parameters though, because they can indicate data flow and ordering constraints. For instance the data in the array might be stored in ZYX order and the <accessor> <param> elements will tell you this. If you ignore it then you will consume it as XYZ data. Another example is if the <accessor> takes only XZ data from a XYZ array. In this case, the stride will still be 3 and there will be an unbound <param name=""/> to skip the Y value in the middle of each access.
yes. I use the latest 3ds max exportor and it export something like that…
Because there is no detail rules about the naming of semanic and accessor’s param in the COLLADA specification document, I just guess what it would look like.
so when I find a input’s semantic is POSITION, then I will assume it’s source would give me the assessor of “X”, “Y”, “Z”,
and if COLOR, then the it’s source would give me the accessor of “R”, “G”, “B”( now I know there will be no accessor of “A” because of COLLADA color model). but it just my guess…
When I test some data that use “S”, “T”, "R"as the accessor name of COLOR source, I feel confused…