Horde3D http://horde3d.org/forums/ |
|
Triangle Indices? http://horde3d.org/forums/viewtopic.php?f=2&t=987 |
Page 1 of 1 |
Author: | karstux [ 22.10.2009, 08:49 ] |
Post subject: | Triangle Indices? |
Hello, first of all, let me state that I'm new to the Horde3D engine, and so far very impressed by its lean and elegant design, flexibility and neat code style! This is a great piece of open-source software. Now, I'm currently trying to procedurally generate geometry data, and I'm having a little difficulty with the process. I looked at the geo format documentation, and it seems rather straightforward - but I don't understand the triangle index stream. Is it supposed to be a set of 3-tuples, where every element denotes a vertex defined earlier in the vertex stream? If so, is the index 0-based or 1-based? To learn the process, I'm trying to make a simple example - a procedurally generated cube. Conceptually, I'm not quite sure what the proper steps are. I suppose I first have to add a Geometry resource for my cube, then create a memory buffer into which I write the geometry data as if it were loaded from disk, then load that buffer into the resource with h3dLoadResource. Is it correct that I can then simply attach the geometry resource to the scene graph root node to display it? (Plus light, camera and pipeline nodes, I guess.) Sorry for the newbie-ish questions. I hope it's not too annoying. |
Author: | Volker [ 22.10.2009, 11:39 ] |
Post subject: | Re: Triangle Indices? |
Internally the geometry is rendered using glDrawRangeElements with GL_TRIANGLES as primitive mode. So you have to make sure, that your data and indices fit to that kind of rendering. The indices are zero based array accessors to the vertex data. An example (unfortunately not a very simple one) of creating dynamic geometry resource is in the terrain.cpp of the Terrain extension. In TerrainNode::createGeometryResource a dump of the loaded terrain can be created. |
Author: | marciano [ 25.10.2009, 09:57 ] |
Post subject: | Re: Triangle Indices? |
karstux wrote: To learn the process, I'm trying to make a simple example - a procedurally generated cube. Conceptually, I'm not quite sure what the proper steps are. I suppose I first have to add a Geometry resource for my cube, then create a memory buffer into which I write the geometry data as if it were loaded from disk, then load that buffer into the resource with h3dLoadResource. This is the current way to do it. However, we will add some more functions for the next version with which you can create resources using the API (like h3dCreateTexture) and don't have to create an in-memory file yourself. karstux wrote: Is it correct that I can then simply attach the geometry resource to the scene graph root node to display it? (Plus light, camera and pipeline nodes, I guess.) You can create a model node which references the geometry (h3dAddModelNode) and a mesh node as child (h3dAddMeshNode). Take a look at a simple scene file for reference (like sphere.scene.xml). |
Author: | wakko [ 26.10.2009, 13:11 ] |
Post subject: | Re: Triangle Indices? |
I have almost finished my "Procedurally generated geometry" tutorial: http://www.horde3d.org/wiki/index.php5?title=Procedurally_generated_geometry_tutorial (Horde3D beta3 only...) Lots of code, though. I hope that it's not too confusing.... But it could give you a hint on how to generate the triangle indices. |
Author: | DarkAngel [ 02.11.2009, 00:32 ] |
Post subject: | Re: Triangle Indices? |
Wow that's great wakko! |
Page 1 of 1 | All times are UTC + 1 hour |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |