Jump to content
  • Advertisement
Sign in to follow this  
AmidaBucu

stucked with collada dom

This topic is 2900 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

Hi! I want to load some dae file with collada dom, but i have stucked with it.


unsigned int nGeometry = dae.getDatabase()->getElementCount(NULL, COLLADA_TYPE_GEOMETRY, NULL);
for(unsigned int cGeometry = 0; cGeometry < 1; cGeometry++)
{

myMesh.nVertices = 0;

//minden mesh-hez külön-külön :F
map<string, helper> myFloats; // csak ideiglenes

domGeometry* geometry;
dae.getDatabase()->getElement((daeElement**)&geometry, cGeometry, NULL, COLLADA_TYPE_GEOMETRY, NULL);

domMesh* mesh = geometry->getMesh();

//első feladatunk kigyüjteni a float-tömböket
domSource_Array sourceArray = mesh->getSource_array();
unsigned int nSource = sourceArray.getCount();
for(unsigned int cSource = 0; cSource < nSource; cSource++)
{
domSource* source = sourceArray[cSource];
domAccessor* accessor = source->getTechnique_common()->getAccessor();

domListOfFloats floatArray = source->getFloat_array()->getValue();
unsigned int nFloat = floatArray.getCount();


pair<map<string, helper>::const_iterator, bool> cit =
myFloats.insert(pair<string, helper>(source->getID(), helper(new float[nFloat], nFloat)));
for(unsigned int cFloat = 0; cFloat < nFloat; cFloat+=3)
{
cit.first->second.array[cFloat] = floatArray[cFloat];
}

}

domTriangles_Array triangleArray = mesh->getTriangles_array();
unsigned int nTriangle = triangleArray.getCount();
for(unsigned int cTriangle = 0; cTriangle < nTriangle; cTriangle++)
{
bool vertex = false;
bool normal = false;
bool texcoord = false;

domTriangles* triangle = triangleArray[cTriangle];
domInputLocalOffset_Array inputArray = triangle->getInput_array();
unsigned int nInput = inputArray.getCount();
for(unsigned int cInput = 0; cInput < nInput; cInput++)
{
if((string)inputArray[cInput]->getSemantic() == "VERTEX") vertex = true;
else if((string)inputArray[cInput]->getSemantic() == "NORMAL") normal = true;
else if((string)inputArray[cInput]->getSemantic() == "TEXCOORD") texcoord = true;
}

myMesh.nVertices += (triangle->getP()->getValue().getCount()/(vertex+normal+texcoord));
}

myMesh.vertices = new float[myMesh.nVertices*3];
myMesh.normals = new float[myMesh.nVertices*3];
myMesh.texcoords = new float[myMesh.nVertices*2];

memset(myMesh.vertices,0,myMesh.nVertices*3*sizeof(float));
memset(myMesh.normals,0,myMesh.nVertices*3*sizeof(float));
memset(myMesh.texcoords,0,myMesh.nVertices*2*sizeof(float));


unsigned int startOffset = 0;
for(unsigned int cTriangle = 0; cTriangle < nTriangle; cTriangle++)
{
bool vertex = false; unsigned int verO; float* verF;
bool normal = false; unsigned int norO;
bool texcoord = false; unsigned int texO;

domTriangles* triangle = triangleArray[cTriangle];
domInputLocalOffset_Array inputArray = triangle->getInput_array();
unsigned int nInput = inputArray.getCount();
for(unsigned int cInput = 0; cInput < nInput; cInput++)
{
if((string)inputArray[cInput]->getSemantic() == "VERTEX")
{
vertex = true;
verO = inputArray[cInput]->getOffset();
domVertices* vertices = (domVertices*) (domElement*) inputArray[cInput]->getSource().getElement();
verF = myFloats.find(vertices->getInput_array()[0]->getSource().getElement()->getID())->second.array;
}
else if((string)inputArray[cInput]->getSemantic() == "NORMAL")
{
normal = true;
norO = inputArray[cInput]->getOffset();
}
else if((string)inputArray[cInput]->getSemantic() == "TEXCOORD")
{
texcoord = true;
texO = inputArray[cInput]->getOffset();
}
}

unsigned int step = vertex+normal+texcoord;

domListOfUInts uints = triangle->getP()->getValue();
unsigned int nUint = uints.getCount();
for(unsigned int cUint = 0; cUint < nUint-step+1; cUint+=step)
{
if(vertex)
{
myMesh.vertices[startOffset+cUint+0] = verF[(uints[cUint]*3)+0];
myMesh.vertices[startOffset+cUint+1] = verF[(uints[cUint]*3)+1];
myMesh.vertices[startOffset+cUint+2] = verF[(uints[cUint]*3)+2];
}
}
startOffset += (nUint/step)*3;
}
}


[Edited by - AmidaBucu on July 7, 2010 7:07:25 AM]

Share this post


Link to post
Share on other sites
Advertisement
And I got an "undrawable" triangle list. I have a lot of vertex like (0,0,0).
Any Idea?

[Edited by - AmidaBucu on July 7, 2010 7:17:26 AM]

Share this post


Link to post
Share on other sites
No idea? And I could not found out what the return type of the domPolylist_Array.operator[] is. (tried domPolygons*, but that is not I am looking after) Or does Anyone have a docs generated by doxygen?

[Edited by - AmidaBucu on July 11, 2010 5:03:08 PM]

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!