Engine Nine ships with the following types of built-in primitives inside Nine.Graphics.Primitives namespace:

Screenshot 0000 Screenshot 0001 Screenshot 0002
Box Sphere Cone
Screenshot 0003 Screenshot 0006 Screenshot 0007
Cylinder Torus Cross
Screenshot 0008 Screenshot 0009 Screenshot 0012
Plane Teapot Dome

The Material property can be used to adjust the appearance of the primitive. The MaterialLevels property can be used to adjust the material of the primitive based on the distance to the camera. The InvertWindingOrder property can be used to invert the triangle winding order of the given primitive.

When shadows are enabled, a primitive will cast shadows by default. To make the primitive receive shadows, assign a material that shows shadows.

To create you own primitive, derive from the Primitive class and override the OnBuild method. The vertex buffer and index buffer of primitives are shared to improve performance, override the CanShareBufferWith method to specify how primitive buffers are shared.


Dynamic Primitive

Sometimes it is desirable to create and change primitive dynamically while the game is running. DynamicPrimitive class can be used to represent these types of primitives. There are a lot of built-in shapes that is shipped with dynamic primitive through extension methods. To create customized dynamic primitives, use the BeginPrimitive, EndPrimitive, AddVertex and AddIndex methods.

Primitives drawn using the dynamic primitive are batched to improve performance.

Last edited Sep 25, 2012 at 9:53 AM by yufeih, version 8


No comments yet.