World Triangle mesh - model or world coords

Started by
5 comments, last by Havana Smurf 23 years, 10 months ago
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
''Once a smurf, always a smurf''
Advertisement
jeez sory the diagrams i drew came out nothing like i drew em at all
''Once a smurf, always a smurf''
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
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.
_______________________________
"To understand the horse you'll find that you're going to be working on yourself. The horse will give you the answers and he will question you to see if you are sure or not."
- Ray Hunt, in Think Harmony With Horses
ALU - SHRDLU - WORDNET - CYC - SWALE - AM - CD - J.M. - K.S. | CAA - BCHA - AQHA - APHA - R.H. - T.D. | 395 - SPS - GORDIE - SCMA - R.M. - G.R. - V.C. - C.F.
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
_______________________________
"To understand the horse you'll find that you're going to be working on yourself. The horse will give you the answers and he will question you to see if you are sure or not."
- Ray Hunt, in Think Harmony With Horses
ALU - SHRDLU - WORDNET - CYC - SWALE - AM - CD - J.M. - K.S. | CAA - BCHA - AQHA - APHA - R.H. - T.D. | 395 - SPS - GORDIE - SCMA - R.M. - G.R. - V.C. - C.F.
bishop_pass, please check that again

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


Regards,
Laarz
Regards,Laarz
I stand corrected.

I guess my eyes made me see 5,2,4 instead of 5,4,2.
Sorry.

My tri stripping formula still applies though.
_______________________________
"To understand the horse you'll find that you're going to be working on yourself. The horse will give you the answers and he will question you to see if you are sure or not."
- Ray Hunt, in Think Harmony With Horses
ALU - SHRDLU - WORDNET - CYC - SWALE - AM - CD - J.M. - K.S. | CAA - BCHA - AQHA - APHA - R.H. - T.D. | 395 - SPS - GORDIE - SCMA - R.M. - G.R. - V.C. - C.F.

This topic is closed to new replies.

Advertisement