Inherits DD::Image::PolygonPrimitive.
Public Member Functions | |
const char * | Class () const |
Mesh (int columns, int rows, bool wrapU=false, bool wrapV=false, MeshSubdivisionMethod subd=QUADS) | |
Mesh (const Mesh &) | |
Primitive * | duplicate () const |
int | columns () const |
int | rows () const |
bool | wrapU () const |
bool | wrapV () const |
MeshSubdivisionMethod | subd_method () const |
void | subd_method (MeshSubdivisionMethod v) |
int | vertex_index (int x, int y) const |
unsigned | point_index (int x, int y) const |
int | add_points (PointList *, int plane=PLANE_ZX) |
void | remap_points (PointList *, int plane=PLANE_ZX, float sx=1.0f, float sy=1.0f) const |
void | create_point_uvs (Attribute *, float scaleU=1.0f, float scaleV=1.0f) const |
void | create_point_uvs (Attribute *attrib, float minU, float minV, float maxU, float maxV) const |
void | create_point_normals (Attribute *, const Vector3 &N) const |
bool | IntersectsRay (const Ray &ray, int n, const PointList *pointList, CollisionResult *result) const |
Test for the intersection of this primitive with a given ray. | |
void | validate (PrimitiveContext *) |
Vector3 | vertex_normal (unsigned v, const PointList *) const |
Vector3 | get_face_normal (int n, const PointList *points) const |
void | tessellateFace (int faceIndex, Scene *scene, PrimitiveContext *ptx, VertexContext *vtx) const |
void | tessellate (Scene *scene, PrimitiveContext *ptx) const |
unsigned | faces () const |
Vector3 | face_average_center (int n, const PointList *) const |
unsigned | face_vertices (int n) const |
void | get_face_vertices (int n, unsigned *array) const |
void | draw_wireframe (ViewerContext *, PrimitiveContext *, Primitive *prev_prim=0) const |
void | draw_solid (ViewerContext *, PrimitiveContext *, Primitive *prev_prim=0) const |
void | draw_solid_face (int n, ViewerContext *, PrimitiveContext *) const |
void | draw_primitive_normal (ViewerContext *, PrimitiveContext *) const |
Draw poly's normal. | |
void | print_info () const |
PrimitiveType | getPrimitiveType () const |
Static Public Member Functions | |
static int | mesh_index (int x, int y, int w) |
Protected Member Functions | |
void | copy (const Mesh *) |
Protected Attributes | |
int | columns_ |
int | rows_ |
Number of rows and columns. | |
bool | wrapU_ |
bool | wrapV_ |
Whether mesh wraps around - only one can be true. | |
MeshSubdivisionMethod | subd_method_ |
What method to subdivide the mesh. |
A 2-dimensional mesh of m*n vertices.
void Mesh::copy | ( | const Mesh * | b | ) | [protected] |
Destructive copy.
References rows_, subd_method_, and wrapV_.
Primitive * Mesh::duplicate | ( | ) | const [virtual] |
Copy this Mesh into a new one, and return a pointer to it. Vertex data is duplicated, point indices are unchanged.
Implements DD::Image::Primitive.
int Mesh::add_points | ( | PointList * | points, |
int | plane = PLANE_ZX |
||
) |
Add the points for the mesh to the GeoInfo's PointList. This is a convenience function.
References rows_, and DD::Image::Primitive::vertex_.
void Mesh::create_point_uvs | ( | Attribute * | attrib, |
float | scaleU = 1.0f , |
||
float | scaleV = 1.0f |
||
) | const |
Add uvs to the points. U/V will map 0->1. This is a convenience function.
References DD::Image::Attribute::resize(), rows_, DD::Image::Vector4::set(), and DD::Image::VECTOR4_ATTRIB.
void Mesh::create_point_uvs | ( | Attribute * | attrib, |
float | minU, | ||
float | minV, | ||
float | maxU, | ||
float | maxV | ||
) | const |
Add uvs to the points. U/V will map (minU, minV) -> (maxU, maxV). This is a convenience function.
References DD::Image::Attribute::resize(), rows_, DD::Image::Vector4::set(), and DD::Image::VECTOR4_ATTRIB.
Add normal N to each point. This is a convenience function.
References DD::Image::NORMAL_ATTRIB, DD::Image::Attribute::resize(), and rows_.
bool DD::Image::Mesh::IntersectsRay | ( | const Ray & | ray, |
int | n, | ||
const PointList * | pointList, | ||
CollisionResult * | result | ||
) | const [inline, virtual] |
Test for the intersection of this primitive with a given ray.
If a collision is detected, information is returned in the collision result
Reimplemented from DD::Image::Primitive.
References DD::Image::Primitive::PolyIntersectsRay().
void Mesh::validate | ( | PrimitiveContext * | ptx | ) | [virtual] |
If Normal attribute doesn't exist, create it from the constituent faces.
Reimplemented from DD::Image::Primitive.
References DD::Image::Vector3::fast_normalize(), DD::Image::Primitive::normal_, rows_, DD::Image::Vector3::set(), and subd_method_.
Vector3 Mesh::vertex_normal | ( | unsigned | v, |
const PointList * | points | ||
) | const [virtual] |
Return a normal that best represents the normal at point's location on the mesh surface.
Reimplemented from DD::Image::Primitive.
References DD::Image::Vector3::normalize(), rows_, and subd_method_.
Vector3 Mesh::get_face_normal | ( | int | n, |
const PointList * | points | ||
) | const [virtual] |
Returns the normal for face.
Reimplemented from DD::Image::Primitive.
References get_face_vertices(), and DD::Image::Vector3::normalize().
void Mesh::tessellateFace | ( | int | faceIndex, |
Scene * | scene, | ||
PrimitiveContext * | ptx, | ||
VertexContext * | vtx | ||
) | const [virtual] |
Subdivide a single face of the mesh into triangles and add them to the rendering pipeline.
Reimplemented from DD::Image::PolygonPrimitive.
References DD::Image::Scene::add_render_primitive(), DD::Image::PrimitiveContext::face_vertices_, get_face_vertices(), and DD::Image::Primitive::vertex_shader().
Vector3 Mesh::face_average_center | ( | int | n, |
const PointList * | points | ||
) | const [virtual] |
Return the subface's average local-space center.
Reimplemented from DD::Image::Primitive.
References get_face_vertices().
void Mesh::get_face_vertices | ( | int | n, |
unsigned * | array | ||
) | const [virtual] |
Fill the pre-allocated array with vertices constituting the sub face.
Reimplemented from DD::Image::Primitive.
Referenced by face_average_center(), get_face_normal(), and tessellateFace().
void Mesh::draw_solid_face | ( | int | n, |
ViewerContext * | ctx, | ||
PrimitiveContext * | ptx | ||
) | const [virtual] |
Draw the specified face as a filled quad.
Reimplemented from DD::Image::Primitive.