• Advertisement
Sign in to follow this  

Edges of .x??

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

I need to get the edges of the mesh .x
but I have no idea how to do this
I googled about it but found nothing :(

float           ptr_vertices[];
unsigned short ptr_triangles[];
unsigned short ptr_edges[];

int i_num_vertices; //num of vertces * 3 (x,y,z)
int i_num_triangles; // num of triangles * 3 (index vertex1, index vertex2, index vertex3)
int i_num_edges; //num of edges * 4 (index triangle1, index triangle2, index edge1, index edge2)

loadMeshFromYourFile(ptr_vertices, i_num_vertices, ptr_triangles, i_num_triangles, ptr_edges, i_num_edges);

for (int i=0; i<i_num_vertices; i++)
navigation_mesh.addVertex( AI_Vector3(ptr_vertices, ptr_vertices[i+1], ptr_vertices[i+2]) );

for (int i=0; i<i_num_triangles; i+3)
navigation_mesh.addTriangle( ptr_triangles, ptr_triangles[i+1], ptr_triangles[i+2]) );

for (int i=0; i<i_num_edges; i+3)
navigation_mesh.addEdge( ptr_edges, ptr_edges[i+1], ptr_edges[i+2], ptr_edges[i+3] );



Look the function of Edges
Quote:
ai_index AI_NavigationMesh::addEdge ( ai_index i_t1,
ai_index i_t2,
ai_index i_v1,
ai_index i_v2
)
Add edge into navigation mesh.

Parameters:
i_t1 Index of the first adjacent triangle of winged edge.
i_t2 Index of the second adjacent triangle of winged edge.
i_v1 Index of the first vertex of the edge.
i_v2 Index of the second vertex of the edge.


Thanks

Share this post


Link to post
Share on other sites
Advertisement
If you want to convert from vertices and triangles to vertices and edges, go thru all triangles and create edges A-B, B-C and C-A with the face normal in each new edge. If an edge already exist, ignore the creation and add another face normal. Remember that A-B is the same edge as B-A. Each edge will have 1 or 2 face normals telling if the edge is convex, flat, concave or a one sided end. A stored normal will need a position or similar to tell what side it came from.

Share this post


Link to post
Share on other sites
Sorry friend

I was a little confused :(
you know any example or drawing to help me understand?

thanks again

Share this post


Link to post
Share on other sites
Thanks friend, but I don't need to draw the edges, just need the number and positions of each edge

Share this post


Link to post
Share on other sites
Vertices:
Index 1 to 4 at some positions

Triangles:
1-2-3
3-4-1

This is how you do if you don't need the convex/concave data.

2-3
|/|
1-4

A-B-C = 1-2-3
1-2 Created
2-3 Created
3-1 Created
A-B-C = 3-4-1
3-4 Created
4-1 Created
1-3 Equivalent to 3-1


Share this post


Link to post
Share on other sites
In the function:
 navigation_mesh.addEdge( ptr_edges, ptr_edges[i+1], ptr_edges[i+2], ptr_edges[i+3] )

Quote:
ai_index AI_NavigationMesh::addEdge ( ai_index i_t1,
ai_index i_t2,
ai_index i_v1,
ai_index i_v2
)
Add edge into navigation mesh.

Parameters:
i_t1 Index of the first adjacent triangle of winged edge.
i_t2 Index of the second adjacent triangle of winged edge.
i_v1 Index of the first vertex of the edge.
i_v2 Index of the second vertex of the edge.


I must enter values 1,2,3,4??

2-3
|/|
1-4

And how can these values? (Code)

Sorry my ignorance friend

[Edited by - VitaliBR on October 19, 2010 6:32:13 AM]

Share this post


Link to post
Share on other sites
To get the vertices, I did as follows:
	std::ofstream m_stream;
m_Mesh = m_Geometry.getMesh();
m_stream.open("log_level.txt");

// Clone the original mesh in a more simple only for readability (though not necessary)
ID3DXMesh *pClone = NULL;
m_Mesh->CloneMeshFVF(D3DXMESH_SYSTEMMEM, D3DFVF_XYZ, m_pDevice, &pClone);

// get some data ...
const int nFaces = pClone->GetNumFaces(); // número de polígonos
const int nVBVertices = pClone->GetNumVertices(); // número de vértices no vertex buffer
const int nVertices = nFaces*3; // número de vértices totais (se não formos utilizar o index buffer)

// Dimensiona o array de triângulos
//m_pTriangulos = new Triangulo [nFaces];

// Pointers that will point to the vertex and index buffer
WORD *pIndices = NULL;
D3DXVECTOR3 *pVertices = NULL;

// lock the index buffer and vertex of the mesh cloned
pClone->LockIndexBuffer(D3DLOCK_READONLY, (LPVOID*)&pIndices);
pClone->LockVertexBuffer(D3DLOCK_READONLY, (LPVOID*)&pVertices);

// Goes through all the polygons of the mesh
for (int t=0; t < nFaces; t++)
{
m_stream << "Vertice " << t*3+0 << ": " << pVertices[pIndices[t*3+0]].x << " " <<
pVertices[pIndices[t*3+0]].y << " " <<
pVertices[pIndices[t*3+0]].z << std::endl;
m_stream << "Vertice " << t*3+1 << ": " << pVertices[pIndices[t*3+1]].x << " " <<
pVertices[pIndices[t*3+1]].y << " " <<
pVertices[pIndices[t*3+1]].z << std::endl;
m_stream << "Vertice " << t*3+2 << ": " << pVertices[pIndices[t*3+2]].x << " " <<
pVertices[pIndices[t*3+2]].y << " " <<
pVertices[pIndices[t*3+2]].z << std::endl;
}

// Unlocks the buffers
pClone->UnlockVertexBuffer();
pClone->UnlockIndexBuffer();

// Release the clone
pClone->Release();

m_stream.close();



in txt file, is as follows:
Quote:
Vertice 0: -30.855 -0.398274 -6.67006
Vertice 1: -9.30708 -0.398274 -6.67006
Vertice 2: -30.855 -0.398274 -17.2169
Vertice 3: -9.30708 -0.398274 -17.2169
Vertice 4: -30.855 -0.398274 -17.2169
Vertice 5: -9.30708 -0.398274 -6.67006
Vertice 6: -9.30708 -0.398274 -6.67006
Vertice 7: 12.2409 -0.398274 -6.67006
Vertice 8: -9.30708 -0.398274 -17.2169
.
.
.
Vertice 79836: 113.356 -0.301825 8.44534
Vertice 79837: 111.019 -0.301825 8.44534
Vertice 79838: 113.356 -0.301825 6.10806
Vertice 79839: 111.019 -0.301825 6.10806
Vertice 79840: 113.356 -0.301825 6.10806
Vertice 79841: 111.019 -0.301825 8.44534


right?

and with triangles and edges? would look like?

thanks

[Edited by - VitaliBR on October 19, 2010 10:40:14 AM]

Share this post


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

  • Advertisement