Shaping wrote:
I have read through most of the doc, but am still wanting general guidelines on scene construction strategies--things always to do, things never to do, invariants concerning scene construction, and similar. I need to choreograph the movements of primitives and cameras programmatically.
I created a C++ class called Node which is the base class for several other classes: GroupNode, ModelNode, MeshNode, JointNode, EmitterNode, LightNode, CameraNode and TerrainNode.
The constructors of these classes call Horde3D functions like: addGroupNode, addNodes, addModelNode, etc. in order to create the actual node within the Horde scene-graph. These classes have only one member variable, which contains an integer handle to Horde's node.
The constructors place constraints on how nodes can be created.
E.g. A terrain node can be constructed with a GroupNode to act as the parent in the scene, and a SceneGraph-resource to load the actual TerrainNode from (
this resource must contain a Terrain node at it's root, or construction will fail).
A Joint node must use a Model node as the parent, and a name and index must be supplied.
A Camera node can only attach to a group node, and requires a name and a Pipeline resource.
Code:
TerrainNode( const GroupNode& pParent, const SceneGraph& );
JointNode( const ModelNode& pParent, const std::string& name, uint index );
CameraNode( const GroupNode& pParent, const std::string& name, const Pipeline& res );
These classes provide member functions which use their handle to call Horde3D functions like setNodeParamf.
Shaping wrote:
Needed geometric resources, for the time being, are the sphere, cube, and parallelipiped. Instances of the first two will be simply colored; the last will be textured. ... Can anyone suggest the simplest way to make a cube and a sphere on the fly, programmatically, without using a DCC like Maya?
The user manual describes the binary layout of the horde geometry files and the XML layout of model/scene files. With a bit of study is should be possible to programmatically generate these files within the language of your choice. Horde's resource loading model is abstracted, so if data buffers are present in memory (as opposed to a file on the disc) it is very simple to load the data into the Horde engine.
Shaping wrote:
Does anyone have a working 2D GUI that I can overlay on a 3D scene? I need the usual buttons, lists, sliders, etc.
There's a topic about integrating Horde3D with AntTweakbar, which is a very utilitarian GUI. Most GUI libraries that contain an OpenGL renderer should be able to be integrated though..
Shaping wrote:
Apart from how text would be displayed in a flat GUI, does anyone have experience using TT fonts with Horde3D to place text in overlays on a 3D scene, whilst translating/scaling the text? The dynamic text must look very smooth in all respects. I'll be using the best antialiasing settings.
I haven't done this with Horde3D, but on Gamebryo I implemented smooth/scalable fonts using a series of quads with a grey-scale texture map and a fragment shader.
The paper at
http://www.valvesoftware.com/publications/2007/SIGGRAPH2007_AlphaTestedMagnification.pdf describes both a pre-processing step and the rendering (shader) technique.
To create the texture files:
1.1) I used a Win32 program to render each glyph/character to a
high resolution 1 bit-per-pixel bitmap (e.g. 8196x8196)
1.2) Record the corner positions of each glyph for use as texture coordinates later.
2) Calculate a high resolution (floating-point) distance field from the bitmap.
3) Scale the field down to a lower resolution (e.g. 256x256) using a decent filter (e.g. box/liner, not point/NN!)
4) Encode the field in a 8 bit-per-pixel bitmap (
(clamp(f/range, -1, 1)+1)/2.0 * 255 )
To render the text:
1) Use the glyph texture coordinates to create 1 quad per character, using the distance field texture.
2) Write a fragment shader that samples the texture, and "discards" the fragment if the sample is less than 0.5 (0.5 represents the edge of the shape).
3) As well as being used to detect the edge, you can even use this texture-sample to programmatically generate efficient soft-shadows, outlines, color-gradients, etc for your text.