#### Archived

This topic is now archived and is closed to further replies.

# World Triangle mesh - model or world coords

This topic is 6723 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Try this one on for size guys - been thinking about this one for a while now heres an example of a heightfield of my world. / 1 / 2 / 3 / / 4 / 5 / 6 / / 7 / 8 / 9 / so my heightmap is 3*3. so my first triangle would be 1,2,4. my second triangle 5,4,2 (thats way i would do it anyway). for each of my vertices for each triangle should i specify them in world coords or local coords. Currently i am thinking in local coords and then having a D3DVECTOR describing its position in world space. something like this struct Triangle{ D3DLVERTEX vertices[2]; D3DVECTOR worldpos; } for example the triangle 1,2,4 in local coords would look like this ____ / / / / // crappy diagram yes but the bottom corner is at the origin of the local coords (0,height at point 4 on heightmap, 0); top left is (0, height at point 1 on heightmap, 1) and top rite is (1,height at point 2 on heightmap,1). sory should say that the triangle is lying on the xz axis pointing into the page. when it comes to rendering i transform the worldposition vector into world coords and send it to the renderer - is this correct ? should i be specifying the vertices in world coords in the beginnging ? some hints would be greatly appreciated

##### Share on other sites
jeez sory the diagrams i drew came out nothing like i drew em at all

##### Share on other sites
Mr Smurf,

If I understand what you''re saying, you should be specifying your ground vertices as WORLD coordinates. If you try and specify one corner of each triangle as (0,0,0) local coords, you will need a transformation matrix for each triangle (OUCH!).

If the ground isn''t going to move around, and you don''t need to render the same section of ground in other places, use world coords.

It''s working well for me.

Cheers

Matt

Check out my project at:www.btinternet.com/~Matthew.Bennett

##### Share on other sites
You absolutely should specify them in object space!

Here is why:
There is no performance penalty; I''ll explain later.
It makes life easier. This is because if by chance you have a regular height field where each triangle vertice is evenly spaced in a lateral direction, then we only need to store altitude at each vertice, saving space. Say z is altitude, then x and y are latitude and longitude. x and y are implicit and derived from their index position in the array. A simple transformation into world space can scale x or y and shift x or y and we don''t have to store this info for each vertex.

You may find later that you modify your code and it is very convenient maintain height field data independent of how it may exist in the world.

Here is why there is no performance penalty; In general, all vertices will undergo a transformation into world space at the same time they are transformed into eye space anyway with one transformation multiply. This is called your ModelView matrix in Opengl. All 3d APIs function similarly.

Your total cost per frame to transform your entire height field into world space is one matrix multiply which is nothing.

##### Share on other sites
quote:
Original post by Havana Smurf

Try this one on for size guys - been thinking about this one for a while now

heres an example of a heightfield of my world.

/ 1 / 2 / 3 /
/ 4 / 5 / 6 /
/ 7 / 8 / 9 /

so my heightmap is 3*3. so my first triangle would be 1,2,4. my second triangle 5,4,2 (thats way i would do it anyway).

Better yet, strip them like this: They will all be counterclockwise when defined as a strip this way.
1,4,2 then 5, then 3, then 6.
This renders the whole top row with only 6 transforms and 6 vertices sent down the bus.

Edited by - bishop_pass on June 22, 2000 3:58:47 PM

##### Share on other sites

1, 2, 4 and 5, 4, 2 defines two clockwise triangles

Regards,
Laarz

##### Share on other sites
I stand corrected.

Sorry.

My tri stripping formula still applies though.

1. 1
Rutin
40
2. 2
3. 3
4. 4
5. 5

• 9
• 19
• 20
• 14
• 14
• ### Forum Statistics

• Total Topics
633382
• Total Posts
3011580
• ### Who's Online (See full list)

There are no registered users currently online

×