getting edges position (x,y,z)

Problems building or running the engine, queries about how to use features etc.
Post Reply
_lkoikm
Halfling
Posts: 57
Joined: Fri Feb 11, 2005 7:52 am
Location: Here.

getting edges position (x,y,z)

Post by _lkoikm »

My question is how to get current coordinates of some edge (x,y,z) in mesh/submesh , or maybe coordinates of weight center of mesh
is this possible ?
i got something like BoundingBox but it is not changing while i move node to whom mesh is attached.
_lkoikm
Halfling
Posts: 57
Joined: Fri Feb 11, 2005 7:52 am
Location: Here.

Post by _lkoikm »

so nobody knows how to do it??
come on if this is an animation engine and nobody knows where is current entity in world???
User avatar
monster
OGRE Community Helper
OGRE Community Helper
Posts: 1098
Joined: Mon Sep 22, 2003 2:40 am
Location: Melbourne, Australia
Contact:

Post by monster »

come on if this is an animation engine and nobody knows where is current entity in world???
What a great way to encourage people to spend their time helping you out!

Use the code posted in the Wiki to read the triangle "edge" data from the mesh attached to your entity.
http://ogrewiki.digitalsentience.com/in ... VertexData
You'll need to multiply that by the world transform of the node to which it is attached, the code from the Wiki will do that for you if you pass the position, orient and scale parameters as entity->getParentSceneNode()->_getDerivedPosition(), entity->getParentSceneNode()->_getDerivedOrientation(), and entity->getParentSceneNode()->_getDerivedScale() respectively.

If you want the actual positions of animated meshes at certain point in their animation then you'll need to make the changes I detailed in this thread;
http://www.ogre3d.org/phpBB2/viewtopic.php?t=7824
To use the cached blended vertex data from the entity and subentities. There's an updated version of the Wiki vertex reading code that does this in the new version of OgreOde which will hopefully be out around the release of Ogre 1.0.0

Weight center (I assume you mean center of gravity) in entirely dependent on your implementation. OgreOde's ragdolls, for example, build oriented capsules and boxes to encompass the vertices and the center of gravity is placed at the centroid of that body. Given the vertex data you could use more sophisticated methods to obtain the volume of the mesh and calculate it's center of gravity, but that's entirely up to you.

And remember; no-one owes you any answers.
_lkoikm
Halfling
Posts: 57
Joined: Fri Feb 11, 2005 7:52 am
Location: Here.

Post by _lkoikm »

checking this out , either way i got the answer. To redeem myself i'll post some ready method code which cover this. Thanks. (for the code wait a while :arrow: )
vimes
Gnoblar
Posts: 15
Joined: Fri May 19, 2006 5:00 am

Post by vimes »

I have a question related to this topic : are the indices in the wiki-code the indices of the vertex of a triangle in the mesh?
I'm trying to retrieve the pairs of vertices that define edges in a mesh but with EdgeData in hand, I'm not sure what to do next.
Should I do something of the like :

Code: Select all

std::vector<Vector3> vertices;
//got filled like in the wiki
[...]
Ogre::IndexData* index_data = submesh->indexData;
[...]
        for(size_t k = 0; k < numTris; ++k)
        {
            size_t offset = (submesh->useSharedVertices)?shared_offset:current_offset;

            unsigned int vindex1 = use32bitindexes? *pInt++ : *pShort++;
            unsigned int vindex2 = use32bitindexes? *pInt++ : *pShort++;
            unsigned int vindex3 = use32bitindexes? *pInt++ : *pShort++;
            Vector3 vertex1 = vertice[vindex1+ offset];
            Vector3 vertex2 = vertice[vindex2+ offset];             
            Vector3 vertex3 = vertice[vindex3+ offset];

           MyEdgeClass Edge1(vertex1,vertex2)
           MyEdgeClass Edge2(vertex2,vertex3)
           MyEdgeClass Edge3(vertex3,vertex1)
            //then add the edge to a container
 
            index_offset += 3;
        }
Post Reply