Horde3D http://www.horde3d.org/forums/ |
|
Get Vertex Location http://www.horde3d.org/forums/viewtopic.php?f=2&t=1607 |
Page 1 of 1 |
Author: | Elnof [ 12.12.2011, 04:24 ] |
Post subject: | Get Vertex Location |
I'm hoping to use collision meshes for a game engine that I'm working on and I was curious if Horde3D has some method for retrieving vertex locations. I'm guessing that I'd use h3dFineNode(Mesh), though I don't know if I can get specific vertices from that. Thank you in advance! On a side not, if anyone could point me to a good tutorial on content creation for Horde, I'd appreciate it. |
Author: | Irdis [ 12.12.2011, 09:00 ] |
Post subject: | Re: Get Vertex Location |
Hi, Elnof. If you wish to get vertex data from mesh, you can find the code here. I should warn you that the code is untested. You can find more detailed code in Horde Bullet Physics Integration. |
Author: | Elnof [ 12.12.2011, 21:50 ] |
Post subject: | Re: Get Vertex Location |
Sweet. Thank you. I'll look this over as soon as I have time. I glanced at it and noticed that the code assumed that there would only be one mesh per model. Getting the handle for various meshes is just a matter of changing the index in h3dGetNodeChild(model, index), right? |
Author: | Irdis [ 13.12.2011, 08:31 ] |
Post subject: | Re: Get Vertex Location |
Yes. You can do something like that: Code: h3dFindNodes(H3DRootNode, "model_name", H3DNodeTypes::Mesh); // find your mesh
H3DNode mesh = h3dGetNodeFindResult(0); int i = 0; H3DNode childMesh = 0; while( ( childMesh = h3dGetNodeChild( mesh, i++ ) ) != 0 ) { // your code here } |
Author: | Elnof [ 15.01.2012, 09:04 ] |
Post subject: | Re: Get Vertex Location |
I have that code mostly working now (just some simple problems I should be able to figure out). Thank you for linking it to me. |
Author: | Elnof [ 15.01.2012, 23:29 ] |
Post subject: | Re: Get Vertex Location |
Quick question: Code: unsigned int numVertices = h3dGetNodeParamI(mesh, H3DMesh::VertREndI) - h3dGetNodeParamI(mesh, H3DMesh::VertRStartI) + 1; In my model with 40 verticies, numVertices is equal to 120. I assume that's because the vertex index is only a single dimension so numVertices = vertices * 3? However, when I loop through to put nodes a the vertices, I have to multiply numVertices by three again or I don't get them all.Code: for(int i = 0; i < numVertices * 3; i += 3) { H3DNode newbox = h3dAddNodes(holder, boxres); h3dSetNodeTransform(newbox, sx * vertexBase[i], sy * vertexBase[i + 1], sz * vertexBase[i + 2], 0, 0, 0, .1, .1, .1); } Why is that? All the vertices are correct, so I'm not sure whether I'm using the vertex index incorrectly or whether the geometry resource has duplicates. |
Author: | Irdis [ 16.01.2012, 10:10 ] |
Post subject: | Re: Get Vertex Location |
In the Bullet Physics module getting vertices from mesh was handled like this: Code: // Create new mesh in physics engine m_btTriangleMesh = new btTriangleMesh(); int offset = 3; //if (triangleMode == 5) // Triangle Strip // offset = 1; // copy mesh from graphics to physics bool index16 = false; if (TriangleBase16) index16 = true; for (unsigned int i = 0; i < numTriangleIndices - 2; i+=offset) { unsigned int index1 = index16 ? (TriangleBase16[i] - vertRStart) * 3 : (TriangleBase32[i] - vertRStart) * 3; unsigned int index2 = index16 ? (TriangleBase16[i+1] - vertRStart) * 3 : (TriangleBase32[i+1] - vertRStart) * 3; unsigned int index3 = index16 ? (TriangleBase16[i+2] - vertRStart) * 3 : (TriangleBase32[i+2] - vertRStart) * 3; m_btTriangleMesh->addTriangle( btVector3(vertexBase[index1], vertexBase[index1+1], vertexBase[index1+2] ), btVector3(vertexBase[index2], vertexBase[index2+1], vertexBase[index2+2] ), btVector3(vertexBase[index3], vertexBase[index3+1], vertexBase[index3+2] ) ); } So basically your first step is to get triangle indices and only then you can get the vertex. |
Author: | Elnof [ 19.01.2012, 01:52 ] |
Post subject: | Re: Get Vertex Location |
I'm getting the correct number of faces now, and I suppose that's what really matters. Thank you. |
Author: | Elnof [ 24.01.2012, 23:51 ] |
Post subject: | Re: Get Vertex Location |
The geometry resource will not change based on animations, correct? Edit: The geometry does have duplicate vertices. Is there a reason for this? Code: Vertex Location @ Index:
(1, 1, -1) @ 0 (-1, 1, 1) @ 3 (0.999999, 1, 1) @ 6 --- (1, 1, -1) @ 0 (-1, 1, -1) @ 9 (-1, 1, 1) @ 3 --- (1, -1, 1) @ 12 (0.999999, 1, 1) @ 15 (-1, 1, 1) @ 18 --- (1, -1, 1) @ 12 (-1, 1, 1) @ 18 (-1, -1, 1) @ 21 --- (1, -1, -1) @ 24 (1, -1, 1) @ 27 (-1, -1, 1) @ 30 --- (1, -1, -1) @ 24 (-1, -1, 1) @ 30 (-1, -1, -1) @ 33 --- (1, -1, -1) @ 36 (0.999999, 1, 1) @ 39 (1, -1, 1) @ 42 --- (1, -1, -1) @ 36 (1, 1, -1) @ 45 (0.999999, 1, 1) @ 39 --- (-1, -1, 1) @ 48 (-1, 1, 1) @ 51 (-1, 1, -1) @ 54 --- (-1, -1, 1) @ 48 (-1, 1, -1) @ 54 (-1, -1, -1) @ 57 --- (1, 1, -1) @ 60 (-1, -1, -1) @ 63 (-1, 1, -1) @ 66 --- (1, 1, -1) @ 60 (1, -1, -1) @ 69 (-1, -1, -1) @ 63 --- |
Page 1 of 1 | All times are UTC + 1 hour |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |