I miss something here .
I have the following polygon:
v0, v1, v2, v3 ( you can see it as line loop here and counter clock wice)
now if i want to convert this polygon to traingle (in a simple way and using EPT_TRIANGLES) it will be
T1: v0,v1,v2
T2: v0,v2, v3
but when i want to use EPT_TRIANGLE_STRIP i should build the vertex for the buffer like
v0,v1,v2,v3,v0
so it will create following traingles
T1: v0,v1,v2
T2: v1,v2,v3
T3: v2,v3,v0
which means to draw a polygon as a traingle i need 3 Traingles with 5 vertex when using EPT_TRIANGLE_STRIP and I need 2 Traingles with 6 vertex when using EPT_TRIANGLES.
I see the different only on memory usage for the vertex buffers. but what about the speed in the opengl engine?
The whole thing it depend on how i put the vertex in the buffer. in the above buffer if i want to draw the polygon with two Traingle and 4 vertex i should declare the vertex like
v2,v0,v1,v3
this will generate t
T1: v2,v0,v1,
T2: v0,v1,v3
is my assumption here are correct?
Understanding EPT_TRIANGLE_STRIP
-
- Admin
- Posts: 14143
- Joined: Wed Apr 19, 2006 9:20 pm
- Location: Oldenburg(Oldb), Germany
- Contact:
Re: Understanding EPT_TRIANGLE_STRIP
No, you don't need more vertices or indices. Simply use 1,2,3,0 as indices, which will render also two triangles as a quad. The thing is that for tri_strip, the last line is always repeated in reverse order as start, and then the next index is used as third point. You have to check if this fits your purposes.
Re: Understanding EPT_TRIANGLE_STRIP
can you describe how to call drawVertexPrimitiveList to draw the quad as you describe the indices?
Actually i don't want to draw only a quad. my user may create a polygon with more than 4 edges and can be convergence or not, thus i will use an algorithm which then generate a traingles from the polygon.
then i will draw them with drawVertexPrimitiveList.
my issue will be on how got from the generated traingles the correct vertex order
Actually i don't want to draw only a quad. my user may create a polygon with more than 4 edges and can be convergence or not, thus i will use an algorithm which then generate a traingles from the polygon.
then i will draw them with drawVertexPrimitiveList.
my issue will be on how got from the generated traingles the correct vertex order
-
- Admin
- Posts: 14143
- Joined: Wed Apr 19, 2006 9:20 pm
- Location: Oldenburg(Oldb), Germany
- Contact:
Re: Understanding EPT_TRIANGLE_STRIP
You can probably save a lot more render cycles by using standard layout hardware vertex buffers. Though we have a patch already for support of hardware buffers for generic render lists, it's much simpler and still quite efficient to do so with simple triangles.
Anyway, the call is drawVertexPrimitiveList(vertices, 4, indices, 2, EPT_TRIANGLE_STRIP) with vertices an array of S3DVertex as above (0,1,2,3) and indices an array with just integers [1,2,3, 0]. Indices can also be [0,1,2,3] as I just found out, not sure why I first thought that you have to use a different order. It's just a different edge to continue with, and the diagonal intersection is differently oriented.
Anyway, the call is drawVertexPrimitiveList(vertices, 4, indices, 2, EPT_TRIANGLE_STRIP) with vertices an array of S3DVertex as above (0,1,2,3) and indices an array with just integers [1,2,3, 0]. Indices can also be [0,1,2,3] as I just found out, not sure why I first thought that you have to use a different order. It's just a different edge to continue with, and the diagonal intersection is differently oriented.
Re: Understanding EPT_TRIANGLE_STRIP
I will try it today late.
but i can remember i done like you said but i got such a surface
|.................|
|...|..........|.|
|......|....|....|
|.........|......|
|____________|
intepretate "...." as empty spaces.
As you say it didnt draw the quad correctly.
but i can remember i done like you said but i got such a surface
|.................|
|...|..........|.|
|......|....|....|
|.........|......|
|____________|
intepretate "...." as empty spaces.
As you say it didnt draw the quad correctly.
-
- Admin
- Posts: 14143
- Joined: Wed Apr 19, 2006 9:20 pm
- Location: Oldenburg(Oldb), Germany
- Contact:
Re: Understanding EPT_TRIANGLE_STRIP
Well, this text figure is not really conclusive, but here's what it should look like for the first case
and the second
Code: Select all
1 2
--------
|\ |
| \ |
| \ |
| \ |
| \|
--------
0 3
Code: Select all
1 2
--------
| /|
| / |
| / |
|/ |
--------
0 3
Re: Understanding EPT_TRIANGLE_STRIP
here is my code i am using to initialize the buffer
the out put is
sorry i can't get the text figure correctly but you see there is a part from the quad is not build.
Code: Select all
m_buffer = new irr::scene::CDynamicMeshBuffer(irr::video::EVT_STANDARD, irr::video::EIT_16BIT);
m_buffer->getMaterial().Wireframe = false;
m_buffer->getMaterial().Lighting = false;
m_buffer->getMaterial().Thickness = 1;
m_buffer->getMaterial().FogEnable = false;
m_buffer->getMaterial().ZWriteEnable = false;
m_buffer->getMaterial().BackfaceCulling = false;
m_buffer->getMaterial().AntiAliasing = true;
// Set the default culling state to Frustum Box
AutomaticCullingState = scene::EAC_FRUSTUM_BOX;
u32 indexIndex = 0;
m_buffer->getVertexBuffer().push_back(video::S3DVertex(vec[0], core::vector3df(0,1,0), m_backlgcolor, core::vector2df(0.0f, 0.0f)));
m_buffer->getIndexBuffer().push_back(indexIndex++);
m_buffer->getVertexBuffer().push_back(video::S3DVertex(vec[1], core::vector3df(0,1,0), m_backlgcolor, core::vector2df(0.0f, 0.0f)));
m_buffer->getIndexBuffer().push_back(indexIndex++);
m_buffer->getVertexBuffer().push_back(video::S3DVertex(vec[2], core::vector3df(0,1,0), m_backlgcolor, core::vector2df(0.0f, 0.0f)));
m_buffer->getIndexBuffer().push_back(indexIndex++);
m_buffer->getVertexBuffer().push_back(video::S3DVertex(vec[3], core::vector3df(0,1,0), m_backlgcolor, core::vector2df(0.0f, 0.0f)));
m_buffer->getIndexBuffer().push_back(indexIndex++);
....
driver->setMaterial(m_buffer->getMaterial());
driver->setTransform(video::ETS_WORLD, AbsoluteTransformation);
driver->drawVertexPrimitiveList(m_buffer->getVertexBuffer().getData(), // const void* vertices
m_buffer->getVertexBuffer().size(), //u32 vertexCount
m_buffer->getIndexBuffer().getData(), // const void* indexList
m_buffer->getVertexBuffer().size()-2, // u32 primCount
m_buffer->getVertexType(), // E_VERTEX_TYPE vType
scene::EPT_TRIANGLE_STRIP, // scene::E_PRIMITIVE_TYPE pType
m_buffer->getIndexType() ); // E_INDEX_TYPE iType
Code: Select all
1 2
------------
| |
| |
| /\ |
| / \ |
|/ \ |
0 3
Re: Understanding EPT_TRIANGLE_STRIP
Clearly indices for vertices 1, 2 are the ones "repeated" while it should be the 1, 3 or 0, 2.
Your indices are 0,1,2,3 as far as I can tell from that code. They should probably go like 0, 1, 3, 2
Your indices are 0,1,2,3 as far as I can tell from that code. They should probably go like 0, 1, 3, 2
Working on game: Marrbles (Currently stopped).
Re: Understanding EPT_TRIANGLE_STRIP
yes it work with your suggestion.
What i am try to figure is when i generate traingles from a polygon i don't know how to generate the indices. thus i will use the triangles type which i need to define each traingle in the vertex buffer, this is will need more memory but i don't have alot of traingles. for each node it will be max 100 traingles and i will have per max 100s of nodes per frame.
What i am try to figure is when i generate traingles from a polygon i don't know how to generate the indices. thus i will use the triangles type which i need to define each traingle in the vertex buffer, this is will need more memory but i don't have alot of traingles. for each node it will be max 100 traingles and i will have per max 100s of nodes per frame.