From Horde3D Wiki
The HOWTO contains quick answers for smaller problems.
How to enable anti-aliasing (MSAA)
Anti-aliasing can only be enabled for render targets. The RenderTarget element used in Pipeline resources has an attribute maxSamples which defines the maximum number of samples used for MSAA. The actual number of samples is controlled by the engine option SampleCount. This makes it possible to control the anti-aliasing quality from the application. If SampleCount is set to zero, MSAA is disabled. Note that the hardware needs to support the EXT_framebuffer_multisample extension in order for the MSAA to work.
How to get the size of a loaded texture
The following code queries the dimensions of the base mipmap of a loaded texture:
If you want to get the dimensions of mipmap level n, change the elemIdx parameter which is 0 above to n.
How to procedurally generate a texture
To generate a texture and bind it to a shader, you need to perform three steps:
First, create the texture handle, map data stream and write to it. Note that you need to perform this step before loading resources from disk (using
Second, to bind the texture to a shader, you need to include it in the material XML file like this:
<Material> <Shader source="shaders/myshader.shader" /> <Sampler name="myTexture" map="myTexRes" /> </Material>
Finally, to reference the sampler in the shader, you need to declare it like this:
Information taken from this thread on the forums.
How to procedurally generate a geometry resource
To generate a geometry resource from given data call h3dutCreateGeometryRes:
the following example will create a simple 2D plane.
How to modify vertex data
Vertex data is stored as streams in geometry resources. A pointer to the vertex data can be obtained by mapping a stream. The following code modifies the y coordinates of all vertex positions stored in the specified geometry resource.
How to exchange a texture of a mesh
Consider you want to exchange the diffuse texture (sampler named albedoMap) of a given mesh (with node handle myMesh) by a texture resource with resource handle myNewTex. You can do that with the following code:
First you need to retrieve the material used by the mesh. After that, you can find the desired sampler in the material. Finally, once you have the sampler index, you can access the sampler data and override its texture resource.
Note: The code above changes directly the material resource. If several meshes are using the same material, all of them will have the new texture. If that is not desired, you can create a private copy of the material by cloning it.
How to display text in the scene
Usually, text is displayed as part of a GUI or HUD on top of the scene. However, sometimes it can be useful to display text inside the scene at the location of a specific node. The following snippet displays the names of all models at the nodes' origins. For obtaining the right screen position, the node positions are projected and converted to overlay coordinates.
How to tell the camera to look at a point
Only pseudo code here, how the math behind this works can be found by searching for gluLookAt.
This example will fail when either forward is a zero vector or forward is parallel to the choosen up vector.
How to orbit / rotate the camera around a point
When following another scene node use that node instead of h3dRootNode as a parent in the h3dAddGroupNode call.