Create 3D Mesh and Scene
Create a 3D Cube Mesh
A Mesh
is defined by a set of control points and the many n-sided polygons as needed. This article explains how to define a Mesh.
In order to create a Mesh surface, we need to define control points and polygons as follows:
Here’s an example to attach a Phong material to the cube node:
Define the Control Points
A mesh is composed by a set of control points in space, and polygons to describe the mesh surface, to create a mesh, we need to define the control points:
Vector4
instead of Vector3
in the example code.
Example:
Create Polygons
The control points are not renderable, to make the cube visible, we need to define polygons in each side:
Create Polygons with PolygonBuilder Class
We can also define polygon by vertices with PolygonBuilder
class:
Now it’s finished, to make the mesh visible, we need to prepare a node for it.
How to Triangulate a Mesh
Triangulate mesh is useful for game industry because the triangular is the only supported primitive that GPU hardware supports (non-triangular data are triangulated in driver-level, which is inefficient in real-time rendering)
In this example, we triangulate a Mesh by importing FBX file and saved it in FBX format.
Create a 3D Cube Scene
This topic demonstrates how to add Mesh geometry to the 3D scene. The example code places a cube and save 3D scene in the supported file formats.
Create a Cube Node
A node is invisible, but the geometry attached to the node can be rendered.
Mesh
class object as narrated there.
Example