Technology Demo

Procedural Meshes Demo

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Spot for images


This demo will show you how to create a procedural mesh.

Creating Shapes

To create a procedural mesh, you need to create a new SimpleDisplayObject3D.

self.shape = luster.display.SimpleDisplayObject3D()

This creates a new procedural mesh so that you can start setting up vertices for it. All that is needed is a list of vertices that will be used to create the shape.

To start building the mesh, we need to use the start method, called as shown below.

self.shape:start(luster.resources.Material("Default"), luster.display.RenderOperation.TRIANGLE_LIST)

The start method takes in the material to be used on the mesh and the render operation for it. Here, we give it the default material and a triangle list.

Next, we need to list the vertices that will be used to create the shapes. Each vertex can be reused to make other sections of the shape.


Each shape has a list of vertices that are defined as below. Every time the "self.shape:position(luster.Vector3(x,y,z))" method is called, a new vertex is created. A normal is then made for it.

self.shape:position(luster.Vector3(-1, -1, -1))
self.shape:normal(luster.Vector3(0, 1, 0))

When all the vertices have been listed, there are different ways to make planes to compose a shape. You can use triangle or quad - for this demo, we'll use quad.

As you create each vertex, it is given an index to make it easier to call later when used to make a plane. The first vertex listed will have an index of 0, and proceed from there. If you're going to have a lot of vertices, you might want to make a comment above each to remind you of the index of that vertex.

The order in which the vertices are called in a quad or triangle is important. Because of hardware culling, if the vertices are called in clockwise order, they won't display on the screen. They need to be called in counter-clockwise order.

For this demo, the following vertices were used:

self.shape:position(luster.Vector3(-1, -1, -1))
self.shape:normal(luster.Vector3(0, 1, 0))
self.shape:position(luster.Vector3(1, -1, -1))
self.shape:normal(luster.Vector3(0, 1, 0))
self.shape:position(luster.Vector3(1, -1, 1))
self.shape:normal(luster.Vector3(0, 1, 0))
self.shape:position(luster.Vector3(-1, -1, 1))
self.shape:normal(luster.Vector3(0, 1, 0))

To create a plane, it's as simple as giving it the indices of the vertices you want.

self.shape:quad(3, 2, 1, 0)

For this demo, the camera's z position was set to 10, so that the shape could be visible. To finish the mesh, call the "stop" method.


When you run it, you should see your shape.