Drawing Custom Geometry
From C4 Engine Wiki
You may want to draw custom geometry, such as for visualization or effects. The way to do this is by subclassing C4::Effect, adding your geometry to that, and adding it to the scene graph.
class MyGeometry : public Effect { public: MyGeometry(EffectType type) : Effect(type, kRenderLines, kRenderDepthTest) { SetVertexCount(n); SetFaceCount(m); SetAttributeArray(kArrayVertex, vs); // some pointer to vertex data SetFaceArray(fs); // some pointer to an index array SetNodeFlags(GetNodeFlags() | kNodeNonpersistent); } bool CalculateBoundingSphere(BoundingSphere *sphere) const { sphere->SetCenter(0.0F, 0.0F, 0.0F); sphere->SetRadius(10.0F); return (true); } } MyGeometry *geometry = new MyGeometry('1234'); geometry->SetNodePosition(Point3D(1.0F, 2.0F, 3.0F)); TheWorldMgr->GetWorld()->GetRootZone()->AddNewSubnode(geometry);
Note that if the custom geometry wants to span more than one zone, it should reside in some zone that contains all those zones -- typically, the global infinite zone. Additionally, the zone that the effect resides in must be connected to the zone that the camera is viewing using some sequence of portals -- as if the effect could see the camera using a crooked view path -- and the bounds of the effect need to intersect the view frustum. Typically, you'll create a portal FROM the infinite zone TO some zone within your zone hierarchy, and that means that any effect in the infinite zone will be rendered if it intersects a zone that is actually being rendered.
