Difference between revisions of "Procedurally generated geometry tutorial"
Line 1: | Line 1: | ||
+ | |||
+ | == Due to the current changes in the Horde API this tutorial will be delayed == | ||
+ | |||
+ | |||
'''Work in progress''' | '''Work in progress''' | ||
Line 18: | Line 22: | ||
=StreamGenerator= | =StreamGenerator= | ||
+ | {{CppSourceCode| | ||
+ | description= StreamGenerator.h| | ||
+ | code= | ||
+ | <source lang="cpp" line="1"> | ||
+ | #pragma once | ||
+ | |||
+ | |||
+ | |||
+ | #include <sstream> | ||
+ | |||
+ | #include <string> | ||
+ | |||
+ | #include <iostream> | ||
+ | |||
+ | |||
+ | |||
+ | class StreamGenerator | ||
+ | |||
+ | { | ||
+ | |||
+ | |||
+ | |||
+ | public: | ||
+ | |||
+ | StreamGenerator(); | ||
+ | |||
+ | virtual ~StreamGenerator(); | ||
+ | |||
+ | virtual const char* getStream() = 0; | ||
+ | |||
+ | virtual const int getStreamSize() = 0; | ||
+ | |||
+ | }; | ||
+ | </source> | ||
+ | }} | ||
=CustomGeometry base class= | =CustomGeometry base class= |
Revision as of 11:32, 26 October 2009
Contents
Due to the current changes in the Horde API this tutorial will be delayed
Work in progress
Important notes
- The code used here has been tested with Horde3D 1.0.0 beta2 and beta3 and will NOT work with the latest release (beta4)
Overview
Basic approach
To create and display a procedurally generated mesh that, instead of being loaded from a Horde3D Scene node and a geoemtry file(*.scene.xml, *.geo), will be created in-memory by some algorithm, you have to create a mesh first and then "fake" the .geo-file and the scene node itself and pass it to the engine.
To do that you have to create your procedural geometry first. This is easy for simple shapes like single triangles, squares or triangle-strips, but will become way more difficult when we try to generate complex meshes, e.g. when we have a cloud of points in 3D space and have to describe which points make triangles, and which don't (calculating the triangle indices, texture coordinates and normals).
When we have calculated the geometry itself we need to create a char-stream to make Horde believe the geometry has been read from a file and pass it to Horde as a geometry Resource. The final step is to create a Horde3D Scene Node from our procedurally generated mesh and render it into our scene. [ This is how it could look like]
StreamGenerator
StreamGenerator.h |
#pragma once
#include <sstream>
#include <string>
#include <iostream>
class StreamGenerator
{
public:
StreamGenerator();
virtual ~StreamGenerator();
virtual const char* getStream() = 0;
virtual const int getStreamSize() = 0;
}; |