Jump to content
  • Advertisement
Sign in to follow this  

Unity (yet another) Collada DOM help request. @Enrico

This topic is 3178 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello all, Like many others, I cannot find an updated/relevant documentation on Collada DOM's wiki so I am trying my luck here. I saw this post: http://www.gamedev.net/community/forums/topic.asp?topic_id=507896 and Enrico's comment Qoute Enrico -- "I still don't see your problem(s) :-( The Collada DOM API maps 1:1 to the file format specification. Take the file format specification and think of it as the DOM API documentation. That's it... I know this is confusing at the beginning and I had my problems with it, too. However, after a few days it just "worked" :-)" So I opened up monkey.dae (the one from Blender) and did a one to one comparison and miraculously, I got up to this point:
domCOLLADA* root = dae.open(file);
domLibrary_geometries_Array geomLib = root->getLibrary_geometries_array();
domGeometry_Array geoms = geomLib[0]->getGeometry_array();
domGeometryRef geom = geoms[0];
domMeshRef mesh = geom->getMesh();
domVerticesRef vertices = mesh->getVertices();
domTriangles_Array triangles = mesh->getTriangles_array();
domTrianglesRef triangle = triangles[0];
triangle->?? // stuck here.
A snipped version of this part of the monkey.dae is at http://jakesee.com/gamedev/monkey.xml Now, how do I proceed? 1. I understand how to decipher "offset", "sematic" and "source" attributes of the <input>, but is there a quick way than brute force implementation? 2. furthermore, what is the function that returns value in <tag>value</tag> in Collada DOM?

Share this post

Link to post
Share on other sites
I did this sometime back and it took me some effort to figure out the indexing, but in a nutshell, what you need to do is extract vertex information based on <input> and

information. Using that information, you will have your pairs of 3 vertices in place and can make triangles from that.

Here is a snippet from my code:

domTriangles* triangles = domTr_Array;

//domTriangles* triangles = a_domMesh->getTriangles_array()[0];
domInputLocalOffset_Array inputArray = triangles->getInput_array();

int width = 0; //gives an idea of the number of attributes stored per vertex
for(unsigned int i = 0; i < inputArray.getCount(); i++)
domInputLocalOffset* inp = inputArray;
list_Input.push_back(new Input(inp) );

if (inp->getOffset() > width)
width = inp->getOffset();
width ++;

domP* p_elem = triangles->getP();
if( !p_elem )
std::cout << std::endl << "No <p> primitive elements found in <Triangles>" << std::endl;

domListOfUInts indArray = p_elem->getValue();

std::vector<int> pArray(indArray.getCount());
for(unsigned int i =0; i < indArray.getCount(); i++)
pArray = indArray;

std::list<Input*>::iterator it_In;

for(unsigned int i = 0; i < pArray.size(); i+= width)
Vertex* v1 = new Vertex();
Vertex& v = *v1;
for(it_In = list_Input.begin(); it_In != list_Input.end(); it_In++)
Input* input = *it_In;
Source* src = m_SourceLookup[input->SourceString()]; // extracted from input source
v[input->Type()] = (*src)[ pArray[ i + input->Index_Offset() ] ];

This should give you some idea. I'd also recommend looking up the documentation and their wiki as it explains this scenario very well.

I hope that helps

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!