input's semantic & accessor

hi,

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:)

it seems like no one understand my question.
I would like to give some example to explain my question…

There is an input like this
<input semantic=“NORMAL” source="#someSource" idx=“0”/>

Does it mean it’s source should be something ike the following code.

<source id=“someSource”>
<technique profile=“COMMON”>
<accessor source="#someArray" …>
<param name=“X” type=“float” flow=“OUT”/>
<param name=“Y” type=“float” flow=“OUT”/>
<param name=“Z” type=“float” flow=“OUT”/>
</accessor>
</technique>
</source>

but how about this (use different param name instead of “X”, “Y”, “Z”)
<source id=“someSource”>
<technique profile=“COMMON”>
<accessor source="#someArray" …>
<param name=“S” type=“float” flow=“OUT”/>
<param name=“T” type=“float” flow=“OUT”/>
<param name=“R” type=“float” flow=“OUT”/>
</accessor>
</technique>
</source>

or this

<source id=“someSource”>
<technique profile=“COMMON”>
<accessor source="#someArray" …>
<param name=“A” type=“float” flow=“OUT”/>
<param name="" type=“float” flow=“OUT”/>
<param name=“C” type=“float” flow=“OUT”/>
</accessor>
</technique>
</source>

does it make sense?

one more question, if the input’s semantic is VERTEX, does it mean it’s source must indicate a <vertices> , it CANNOT just indicate a <source>
can it?

Thanks for your help


Gino

Hey there,

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:

  1. 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
  2. Read in the sources
  3. Merge all this information into vertex/index buffers…

At least, that’s the way I see it.

Guillaume Laforte
Feeling Software Inc.
http://www.feelingsoftware.com

Yes for 3D data.

Yes.

Yes, except that the COLLADA color model is RGB.

Yes.

Do you mean as param name’s?

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.

[quote=“marcus”]

Yes.

Do you mean as param name’s?[/quote]

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…

so is there any detail rules about this?

Thanks

Gino:)