To do or not to do... Implementing a few classes.

Started by
2 comments, last by ANSI2000 22 years, 3 months ago
I started implementing a few classes to represent meshes (objects)... I have a Vector class contains things suchs ass x, y, z, color info etc... I have a Triangle Class, the triangle class has a few methods to set the vertices of teh triangle and to get the vertices of the triangle. The setMethods receive 3 vetor references. Bassically like using the indexing to the vectors... Now in my mesh class a I have such a function called draw... This function goes through each triangle and gets the 3 vertice values and puts them into an array, once that array is full I then use glDrawElelements to draw the mesh on screen... The code is nice and modular. But I would assume that going through x amount of tris and getting the vertice values to create my vertex buffer is killer??? So it would be safer to just automatically from load time store each x,y,z value in the array directly??
Advertisement
One minor thing: I would call it a Vertex and not a Vector. A 3D vector has x,y,z nothing more, nothing less. A vertex might need more data like color, texture coordinates, etc.

Now on your design, if you are interested in high performance you should definately put your vertices into an array at load time. Unless this is impossible, for example with a highly dynamic mesh. But even then, you should create the vertex buffer at load time and update the vertices in it when needed.
Dirk =[Scarab]= Gerrits
Crap I forgot to post my reply doh!!!! i will repost it again

Edited by - ANSI2000 on January 11, 2002 1:03:35 AM
Well the fisrt time I posted abot a vertex class all pppl got weird and freaky on me about the name... That is why I said vector instead so no one goes all wako and shit!

Anywhooo.....

I think we an array you can still have a highly dynamic mesh... You just acees teh array with an index at every 3 position since the array will store the values as [x, y, z, x, y, z ....] and you modify the values as you wish... And for LOD, unless it is compute mathematically. you can have a dynamix array taht resizes... But LOD I thinks is implement 1 array per LOD level..... No?

This topic is closed to new replies.

Advertisement