Horde3D

Next-Generation Graphics Engine
It is currently 29.11.2024, 05:42

All times are UTC + 1 hour




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Triangle Indices?
PostPosted: 22.10.2009, 08:49 
Offline

Joined: 21.10.2009, 16:25
Posts: 7
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.


Top
 Profile  
Reply with quote  
 Post subject: Re: Triangle Indices?
PostPosted: 22.10.2009, 11:39 
Offline
Tool Developer

Joined: 13.11.2007, 11:07
Posts: 1150
Location: Germany
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.


Top
 Profile  
Reply with quote  
 Post subject: Re: Triangle Indices?
PostPosted: 25.10.2009, 09:57 
Offline
Engine Developer

Joined: 10.09.2006, 15:52
Posts: 1217
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).


Top
 Profile  
Reply with quote  
 Post subject: Re: Triangle Indices?
PostPosted: 26.10.2009, 13:11 
Offline

Joined: 21.12.2008, 23:46
Posts: 23
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.


Top
 Profile  
Reply with quote  
 Post subject: Re: Triangle Indices?
PostPosted: 02.11.2009, 00:32 
Offline

Joined: 08.11.2006, 03:10
Posts: 384
Location: Australia
Wow that's great wakko!


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 6 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group