API independent mesh class

Started by
10 comments, last by Basiror 18 years, 8 months ago
Quote:Original post by Promit
Quote:Original post by Opwiz
Anyway, I can't seperate transform and texture (and other render-state changes) from the mesh.


Of course you can. There is a critical point here.

A mesh is not an object that exists in the world of your game.

A mesh is a geometrical description of the visual representation of an object. A mesh is exactly the same as a transform, a material (textures, shaders, et al), or anything else. It's an attribute of a parent object. Not only that, a mesh shouldn't even have a render method. (Some kind of visitor double-dispatch render function maybe, but it shouldn't actually be drawing itself.) It merely needs to make the rendering data available to whoever is responsible for actually drawing it.

I see.

Quote:If I understand correctly, what's happening in your specific case is that the scene graph is a bit mangled and object relationships aren't quite clear. First of all, you need to construct some kind of entity class. These entities are the real things that are part of your game world, and have a material and mesh (but not transform) associated with them. Put these entities in a transform hierarchy, where transforms are internal nodes and entities are leaf nodes. Construct a seperate hierarchy that deals with rendering states. Attempting to merge these two trees will turn out badly, trust me.

Actually this is (sort of) what I do (sorry if I was'nt clear in my previous post), the object relationships are very clear. I have a base class "Spatial" (entity) that defines transform and bound. The scene is a generic collection of spatials (usually organized spatially to optimize spatial operations such as frustum culling). So the only kind of relation I have between scene objects (spatials/entities) is a spatial relationship. I have a seperate transform hierarchy where I can put the spatials transform.

www.marklightforunity.com | MarkLight: Markup Extension Framework for Unity

Advertisement
how do you store your vertices and uv coordinates then?

each in a seperate buffer or as a interleaved array which is actually suggested to improve performance


but are there interleaved versions for multitexturing
otherwise you had to store everything in its own array

http://www.8ung.at/basiror/theironcross.html

This topic is closed to new replies.

Advertisement