[idx3d::Docu3]
Working with 3d objects
Instances of idx3d_Object represent mesh objects. An idx3d_Object contains vertices
and triangles. Each triangle is linked to three vertices, and each vertex has references
to the triangles which use it as an anchor in 3d space.
idx3d_Object contains dynamic data structures and temporary static data structures. To manually
update the static structures, call rebuild().
If you assign an idx3d_Material to an object, it can be rendered.
idx3d_Object also contains a member Object userData, where you can attach additional
information.
1.
|
Data structures
|
Vertices [idx3d_Vertex]
- Add: void addVertex(idx3d_vertex newVertex)
- Remove: void removeVertex(idx3d_Vertex v) or void removeVertexAt(int pos)
- Retrieve: idx3d_Vertex vertex(int pos)
If you need very quick access to a vertex (for example if you want to iterate through the
vertex list), you can access it over the temporary static data structures by its index.
Rebuild the static data structures with rebuild()
and access an instance with idx3d_Vertex vertex[index]. The total number of vertices
is stored in member int vertices.
Triangle [idx3d_Triangle]
- Add: void addTriangle(idx3d_triangle newTriangle) or void addTriangle(int vertexId1, int vertexId2, int vertexId3)
- Remove: void removeTriangle(idx3d_Triangle v) or void removeTriangleAt(int pos)
- Retrieve: idx3d_Triangle triangle(int pos)
If you need very quick access to a triangle (for example if you want to iterate through the
triangle list), you can access it over the temporary static data structures by its index.
Rebuild the static data structures with rebuild()
and access an instance with idx3d_Triangle triangle[index]. The total number of vertices
is stored in member int vertices.
| |
2.
|
Assigning materials to 3d objects
|
You assign an instance of idx3d_Material to an idx3d_Object with:
setMaterial(idx3d_Material material).
The idx3d_Rasterizer then knows how to render it correctly.
| |
3.
|
Importing objects from 3ds (3d Studio Max) mesh files
|
You can import entire scenes form 3ds files using the idx3d_3ds_Importer.
Create a new instance of idx3d_3ds_Importer and use one of the following methods:
importFromURL(URL urlOf3dsFile, idx3d_Scene scene)
to import from an URL into a scene
importFromStream(InputStream in, idx3d_Scene scene)
to import from an InputStream, for example with new FileInputStream(new File(filename))
from an application.
| |
4.
|
3d Manipulations [inherited from idx3d_CoreObject]
|
public final void transform(idx3d_Matrix m)
Transforms this objects my the matrix m
public final void shift(float dx, float dy, float dz)
Shifts the object
public final void shift(idx3d_Vector v)
Shifts the object
public final void scale(float d)
Scales the object relative to the world (scene)
public final void scale(float dx, float dy, float dz)
Scales the object relative to the world (scene)
public final void scaleSelf(float dx, float dy, float dz)
Scales the object relative to its own
public final void rotate(float dx, float dy, float dz)
Rotates the object relative to the world (scene)
public final void rotateSelf(float dx, float dy, float dz)
Rotates the object relative to its own
public final void setPos(float x, float y, float z)
Sets the position of the object
public final void setPos(idx3d_Vector v)
Sets the position of the object
public final idx3d_Vector getPos()
Gets the position of the object
| |
5.
|
Other methods / members
|
public idx3d_Vector center()
Returns the center of this object
public idx3d_Vector dimension()
Returns the dimension of this object (width,height,depth)
public void detach()
Centers the object in its own coordinate system and applies the correction to its matrix.
public void matrixMeltdown()
Applies the transformations of the object matrix to its vertices and resets the matrix.
public idx3d_Object getClone()
Returns a deep copy of this object (recursive cloning)
public idx3d_Object removeDuplicateVertices()
Removes duplicate vertices and reconnects the triangles
public idx3d_Object removeDegeneratedTriangles()
Removes degenerated triangles (triangles with less than 3 different vertices)
public idx3d_Object meshSmooth()
Applies mesh smoothing to this object. Each triangle will be split into 4 parts.
| |
|
|