DOM guide: Resolving SIDs: Difference between revisions
m fix catg |
2.4 notes |
||
(9 intermediate revisions by 4 users not shown) | |||
Line 1: | Line 1: | ||
In [[COLLADA]], some elements are identified with | In [[COLLADA]], some elements are identified with a ''sid'' (scoped identifier). In the [[COLLADA DOM]], <code>daeSIDResolver</code> is a helper class to resolve these COLLADA address syntax targets. It can also be used to do “sidRef”-type lookups (used often in [[COLLADA FX]] and [[COLLADA Physics]]). | ||
==Resolving normal SIDs== | |||
To resolve a normal/absolute COLLADA ''sid'' target (for example, in <animation>/<channel> elements), pass it: | To resolve a normal/absolute COLLADA ''sid'' target (for example, in <animation>/<channel> elements), pass it: | ||
* The containing element (same concept as in <code>daeURI</code>) | * The containing element (same concept as in <code>daeURI</code>.) | ||
* The target string | * The target string | ||
* Optionally, the profile to look into ( | * <s>Optionally, the profile to look into (by default, it uses the COMMON profile.)</s> | ||
* Optionally, the profile to look into (as of 2.4, by default, it looks in any and all profiles; potentially mixing them. Selecting the technique_common profile is impossible--this will change in 2.5.) | |||
To “hack it” to do ''sid'' lookups used in COLLADA FX, you can pass in a relative target string. This must be done programmatically because the documents specify “sid refs” by ''sid'' alone and not in relative COLLADA addressing syntax. For example, <code>SomeSID</code> would become <code>./SomeSID</code>. Then the container would be where to start the | ==Resolving SIDs in COLLADA FX== | ||
To “hack it” to do ''sid'' lookups used in COLLADA FX, you can pass in a relative target string. This must be done programmatically because the documents specify “sid refs” by ''sid'' alone and not in relative COLLADA addressing syntax. For example, <code>SomeSID</code> would become <code>./SomeSID</code>. Then the container would be where to start looking. | |||
==Example== | |||
This example uses the <code>daeSIDResolver</code> class to find the "pelvis" joint of a skeleton. | |||
void sidResolve() { | |||
DAE dae; | |||
char* docUri = "file:///home/sthomas/models/skinnedModel.dae"; | |||
if (dae.load(docUri) != DAE_OK) | |||
return; | |||
// Get the first <skeleton> in the model | |||
daeElement* element = 0; | |||
dae.getDatabase()->getElement(&element, 0, 0, "skeleton"); | |||
domInstance_controller::domSkeleton* skeleton = | |||
daeSafeCast<domInstance_controller::domSkeleton>(element); | |||
if (!skeleton) | |||
return; | |||
// Get the root node of the <skeleton> | |||
daeElement* skeletonRootNode = skeleton->getValue().getElement(); | |||
// Find the joint named "pelvis". The "./" part is necessary. | |||
daeSIDResolver resolver(skeletonRootNode, "./pelvis"); | |||
domNode* pelvis = daeSafeCast<domNode>(resolver.getElement()); | |||
if (!pelvis) | |||
return; | |||
cout << pelvis->getId() << endl; | |||
} | |||
{{DOM navigation}} | {{DOM navigation}} | ||
[[Category:DOM | [[Category:COLLADA DOM|Resolving SIDs]] |
Latest revision as of 00:19, 16 May 2016
In COLLADA, some elements are identified with a sid (scoped identifier). In the COLLADA DOM, daeSIDResolver
is a helper class to resolve these COLLADA address syntax targets. It can also be used to do “sidRef”-type lookups (used often in COLLADA FX and COLLADA Physics).
Resolving normal SIDs
To resolve a normal/absolute COLLADA sid target (for example, in <animation>/<channel> elements), pass it:
- The containing element (same concept as in
daeURI
.) - The target string
Optionally, the profile to look into (by default, it uses the COMMON profile.)- Optionally, the profile to look into (as of 2.4, by default, it looks in any and all profiles; potentially mixing them. Selecting the technique_common profile is impossible--this will change in 2.5.)
Resolving SIDs in COLLADA FX
To “hack it” to do sid lookups used in COLLADA FX, you can pass in a relative target string. This must be done programmatically because the documents specify “sid refs” by sid alone and not in relative COLLADA addressing syntax. For example, SomeSID
would become ./SomeSID
. Then the container would be where to start looking.
Example
This example uses the daeSIDResolver
class to find the "pelvis" joint of a skeleton.
void sidResolve() { DAE dae; char* docUri = "file:///home/sthomas/models/skinnedModel.dae"; if (dae.load(docUri) != DAE_OK) return; // Get the first <skeleton> in the model daeElement* element = 0; dae.getDatabase()->getElement(&element, 0, 0, "skeleton"); domInstance_controller::domSkeleton* skeleton = daeSafeCast<domInstance_controller::domSkeleton>(element); if (!skeleton) return; // Get the root node of the <skeleton> daeElement* skeletonRootNode = skeleton->getValue().getElement(); // Find the joint named "pelvis". The "./" part is necessary. daeSIDResolver resolver(skeletonRootNode, "./pelvis"); domNode* pelvis = daeSafeCast<domNode>(resolver.getElement()); if (!pelvis) return; cout << pelvis->getId() << endl; }
COLLADA DOM - Version 2.4 Historical Reference |
---|
List of main articles under the DOM portal. |
User Guide chapters: • Intro • Architecture • Setting up • Working with documents • Creating docs • Importing docs • Representing elements • Working with elements • Resolving URIs • Resolving SIDs • Using custom COLLADA data • Integration templates • Error handling Systems: • URI resolver • Meta • Load/save flow • Runtime database • Memory • StringRef • Code generator |