Inherited by DD::Image::Particles, DD::Image::ParticlesSprite, DD::Image::Point, and DD::Image::PolygonPrimitive.
Public Member Functions | |
virtual void | vertex_shader (int v, Scene *, PrimitiveContext *, VArray &out, const Vector3 *normal=NULL) const |
virtual void | vertex_shader (int v, Scene *, PrimitiveContext *, VertexContext &, VArray &out, const Vector3 *normal=NULL) const |
Primitive (unsigned vertices=0) | |
Primitive (const Primitive &) | |
virtual | ~Primitive () |
virtual const char * | Class () const =0 |
virtual Primitive * | duplicate () const =0 |
void | getDataArray (int n, ViewerContext *ctx, PrimitiveContext *ptx, std::vector< Vector3 > &pntArray, std::vector< Vector3 > &normalArray, std::vector< Vector4 > &uvOrColArray, bool &validUV) const |
const unsigned & | vertex (unsigned v) const |
unsigned & | vertex (unsigned v) |
unsigned | vertices () const |
void | offset_point_indices (int offset) |
unsigned | vertex_offset () const |
void | build_index_array (unsigned *indices, unsigned primitive, unsigned vertex) const |
unsigned | add_vertex (unsigned point_index) |
unsigned | add_vertices (unsigned num) |
virtual Vector3 | average_center (const PointList *) const |
Returns the xyz center average of the primitive. | |
virtual Vector3 | average_center_and_bounds (int f, const PointList *points, Vector3 &min, Vector3 &max) const |
virtual unsigned | faces () const =0 |
virtual Vector3 | face_average_center (int n, const PointList *points) const |
virtual unsigned | face_vertices (int n) const |
virtual void | get_face_vertices (int n, unsigned *array) const |
virtual Box3 | get_bbox (const GeoInfo *info) const |
virtual Vector3 | get_face_normal (int n, const PointList *points) const |
virtual Vector3 | get_geometric_normal (int v, const PointList *points) const |
virtual int | get_vertex_faces (int v, std::vector< int > &faces) const |
virtual bool | IntersectsRay (const Ray &ray, int n, const PointList *pointList, CollisionResult *result) const |
virtual void | validate (PrimitiveContext *) |
virtual bool | faceUsesVertex (unsigned int faceIdx, unsigned int vertIdx) const |
Iop * | material () const |
Iop * | renderingShader (const GeoInfo *info) const |
const Vector3 & | normal () const |
virtual Vector3 | vertex_normal (unsigned v, const PointList *) const |
virtual void | tessellate (Scene *, PrimitiveContext *) const =0 |
virtual void | draw_wireframe (ViewerContext *, PrimitiveContext *, Primitive *prev_prim=0) const =0 |
virtual void | draw_solid (ViewerContext *, PrimitiveContext *, Primitive *prev_prim=0) const =0 |
virtual void | draw_solid_face (int n, ViewerContext *, PrimitiveContext *) const |
virtual void | draw_primitive_normal (ViewerContext *, PrimitiveContext *) const |
virtual void | draw_primitive_num (ViewerContext *, PrimitiveContext *) const |
virtual void | draw_vertex_num (ViewerContext *, PrimitiveContext *) const |
virtual void | draw_vertex_normals (ViewerContext *, PrimitiveContext *) const |
virtual void | draw_vertex_uvs (ViewerContext *, PrimitiveContext *) const |
virtual void | print_info () const |
virtual PrimitiveType | getPrimitiveType () const |
void * | operator new (size_t size) |
void | operator delete (void *mem) |
void * | operator new[] (size_t size) |
void | operator delete[] (void *mem) |
Static Public Member Functions | |
static void | draw_normal (const Vector3 &p, const Vector3 &n, ViewerContext *, PrimitiveContext *) |
Protected Member Functions | |
void | draw_wireframe_vertex (int v, ViewerContext *, PrimitiveContext *) const |
void | draw_solid_vertex (int v, ViewerContext *, PrimitiveContext *) const |
void | copy (const Primitive *) |
bool | PolyIntersectsRay (const Ray &ray, int n, const PointList *pointList, CollisionResult *result) const |
Protected Attributes | |
std::vector< unsigned, STL3DAllocator< unsigned > > | vertex_ |
Point indices. | |
unsigned | vertex_offset_ |
Vertex attribute starting index. | |
Vector3 | normal_ |
Normal determined from vertex positions. | |
Iop * | material_ |
Material assignment. | |
Friends | |
class | GeoInfo |
class | GeometryList |
class | Scene |
This is the base class of anything renderable!
We use this class to handle renderable objects that can have simple geometry such as triangles, spheres, etc.
Primitives are contained within GeoInfo structures which are responsible for their maintenance.
Primitive::~Primitive | ( | ) | [virtual] |
Base destructor.
void Primitive::draw_wireframe_vertex | ( | int | v, |
ViewerContext * | ctx, | ||
PrimitiveContext * | ptx | ||
) | const [protected] |
Draw just the xyz position of a vertex in OpenGL
References DD::Image::Vector3::array(), and vertex_.
void Primitive::draw_solid_vertex | ( | int | v, |
ViewerContext * | ctx, | ||
PrimitiveContext * | ptx | ||
) | const [protected] |
Draw the vertex with normals and point color.
References DD::Image::Vector3::array(), DD::Image::GeoInfo::Cf_ref, DD::Image::GeoInfo::display3d, DD::Image::ViewerContext::display3d(), DD::Image::GeoInfo::N_ref, normal_, DD::Image::GeoInfo::UV_ref, vertex_, and vertex_offset_.
void Primitive::copy | ( | const Primitive * | b | ) | [protected] |
Destructive copy.
References material_, normal_, vertex_, and vertex_offset_.
Referenced by Primitive().
bool Primitive::PolyIntersectsRay | ( | const Ray & | ray, |
int | n, | ||
const PointList * | pointList, | ||
CollisionResult * | result | ||
) | const [protected] |
Polygon face test for the intersection of this primitive face with a given ray .
References face_vertices(), faces(), and get_face_vertices().
Referenced by DD::Image::Triangle::IntersectsRay(), DD::Image::Polygon::IntersectsRay(), and DD::Image::Mesh::IntersectsRay().
void Primitive::vertex_shader | ( | int | v, |
Scene * | scene, | ||
PrimitiveContext * | ptx, | ||
VArray & | out, | ||
const Vector3 * | normal = NULL |
||
) | const [virtual] |
Fill in the VArray with the correct values for this vertex. The values in this array as set by each vertex in the primitive are linerly interpolated by the renderer and passed to the fragment_shader.
Before being passed to the fragment_shader, everything is divided by w and w is replaced with 1/w. This is to produce a linearly-interpolated value. Probably this function should do the division, not the caller!
I guess subclasses could move the points around, but that probably could be done by the shaders instead...
Referenced by DD::Image::Point::tessellate(), DD::Image::Mesh::tessellateFace(), and DD::Image::Scene::validate().
void Primitive::getDataArray | ( | int | n, |
ViewerContext * | ctx, | ||
PrimitiveContext * | ptx, | ||
std::vector< Vector3 > & | pntArray, | ||
std::vector< Vector3 > & | normalArray, | ||
std::vector< Vector4 > & | uvOrColArray, | ||
bool & | validUV | ||
) | const |
Return the data in three arrays pntArray, normalArray, and uvOrColArray. If the validUV is set to true than the uv/color array contains the uv values or else color values. This method is based on the draw_solid_vertex().
References DD::Image::GeoInfo::Cf_ref, DD::Image::GeoInfo::display3d, DD::Image::ViewerContext::display3d(), DD::Image::GeoInfo::N_ref, DD::Image::GeoInfo::UV_ref, vertex_, and vertex_offset_.
void Primitive::offset_point_indices | ( | int | offset | ) |
Offset point list indices for all vertices.
References vertex_.
unsigned Primitive::add_vertex | ( | unsigned | point_index | ) |
Append a vertex to a primitive and assign it a point index. Returns the starting index in the vertex list.
References vertex_.
unsigned Primitive::add_vertices | ( | unsigned | num | ) |
Add 'num' of vertices to primitive. Returns the starting index in the vertex list.
References vertex_.
Vector3 Primitive::average_center | ( | const PointList * | points | ) | const [virtual] |
Returns the xyz center average of the primitive.
Return the primitive's xyz local-space center.
Reimplemented in DD::Image::Point, and DD::Image::Triangle.
Referenced by draw_primitive_normal(), draw_primitive_num(), draw_vertex_num(), and draw_vertex_uvs().
Vector3 Primitive::average_center_and_bounds | ( | int | f, |
const PointList * | points, | ||
Vector3 & | min, | ||
Vector3 & | max | ||
) | const [virtual] |
Returns the xyz center average of the primitive, plus local space bounds.
Reimplemented in DD::Image::Point.
References face_vertices(), and get_face_vertices().
virtual unsigned DD::Image::Primitive::faces | ( | ) | const [pure virtual] |
Returns the number of sub faces this primitive generates. Pure virtual.
Referenced by DD::Image::GeometryList::add_primitive(), DD::Image::ViewFrustum::getVisibility(), PolyIntersectsRay(), and DD::Image::Scene::validate().
virtual Vector3 DD::Image::Primitive::face_average_center | ( | int | n, |
const PointList * | points | ||
) | const [inline, virtual] |
Returns the xyz center average of the sub face. Base class returns the primitive center.
Reimplemented in DD::Image::Mesh.
virtual unsigned DD::Image::Primitive::face_vertices | ( | int | n | ) | const [inline, virtual] |
Returns the number of vertices for the sub face.
Referenced by DD::Image::GeometryList::add_primitive(), average_center_and_bounds(), faceUsesVertex(), get_face_vertices(), DD::Image::ViewFrustum::getVisibility(), PolyIntersectsRay(), and DD::Image::Scene::validate().
void Primitive::get_face_vertices | ( | int | n, |
unsigned * | array | ||
) | const [virtual] |
Fill the pre-allocated array with vertices constituting the sub face.
Reimplemented in DD::Image::Mesh.
References face_vertices().
Referenced by average_center_and_bounds(), faceUsesVertex(), DD::Image::ViewFrustum::getVisibility(), PolyIntersectsRay(), and DD::Image::Scene::validate().
Returns the primitive bounding box
References DD::Image::Box3::expand().
virtual Vector3 DD::Image::Primitive::get_face_normal | ( | int | n, |
const PointList * | points | ||
) | const [inline, virtual] |
Returns the normal for face.
Reimplemented in DD::Image::Mesh.
virtual Vector3 DD::Image::Primitive::get_geometric_normal | ( | int | v, |
const PointList * | points | ||
) | const [inline, virtual] |
Return the geometric normal for vertex.
virtual int DD::Image::Primitive::get_vertex_faces | ( | int | v, |
std::vector< int > & | faces | ||
) | const [inline, virtual] |
Return the number of faces that vertex connects to and fills in the list of face indices.
virtual bool DD::Image::Primitive::IntersectsRay | ( | const Ray & | ray, |
int | n, | ||
const PointList * | pointList, | ||
CollisionResult * | result | ||
) | const [inline, virtual] |
Test for the intersection of this primitive face with a given ray .
Reimplemented in DD::Image::Mesh, DD::Image::Polygon, and DD::Image::Triangle.
virtual void DD::Image::Primitive::validate | ( | PrimitiveContext * | ) | [inline, virtual] |
Initialize any variables prior to display or rendering.
Reimplemented in DD::Image::Mesh, and DD::Image::Triangle.
bool Primitive::faceUsesVertex | ( | unsigned int | faceIdx, |
unsigned int | vertIdx | ||
) | const [virtual] |
Does this face in this primitive reference this vertex?
References face_vertices(), and get_face_vertices().
const Vector3 & DD::Image::Primitive::normal | ( | ) | const [inline] |
Returns a normal vector for the whole primitive. The subclass initializes this (by setting the normal_ member) to a vector that points out of "front" surface of the polygon. This normal is used if there is no normal attribute or zero-length normal for the points. It is also used to flip normals that appear to be backwards when rendering in OpenGL.
Vector3 DD::Image::Primitive::vertex_normal | ( | unsigned | v, |
const PointList * | |||
) | const [inline, virtual] |
Returns a normal that best represents the normal at point's location on the primitive. Base class ignores the vertex argument and returns the primitive's base normal.
Reimplemented in DD::Image::Mesh.
void Primitive::draw_solid_face | ( | int | n, |
ViewerContext * | ctx, | ||
PrimitiveContext * | ptx | ||
) | const [virtual] |
Draw a sub-face as a filled polygon.
Reimplemented in DD::Image::Mesh, DD::Image::Polygon, and DD::Image::Triangle.
References DD::Image::Vector3::array(), and vertex_.
void Primitive::draw_primitive_normal | ( | ViewerContext * | ctx, |
PrimitiveContext * | ptx | ||
) | const [virtual] |
Draw primitive's normal as a short line coming from it's center.
Reimplemented in DD::Image::Mesh.
References average_center(), draw_normal(), and normal_.
void Primitive::draw_primitive_num | ( | ViewerContext * | ctx, |
PrimitiveContext * | ptx | ||
) | const [virtual] |
Draw primitive's index number.
References average_center(), and DD::Image::gl_text().
void Primitive::draw_vertex_num | ( | ViewerContext * | ctx, |
PrimitiveContext * | ptx | ||
) | const [virtual] |
Draw vertex number.
References average_center(), DD::Image::gl_text(), and vertex_.
void Primitive::draw_vertex_normals | ( | ViewerContext * | ctx, |
PrimitiveContext * | ptx | ||
) | const [virtual] |
Draw vertex normals as short lines coming from vertex's position.
References draw_normal(), DD::Image::AttribContext::group, DD::Image::GeoInfo::N_ref, vertex_, and vertex_offset_.
void Primitive::draw_vertex_uvs | ( | ViewerContext * | ctx, |
PrimitiveContext * | ptx | ||
) | const [virtual] |
Print the vertex UV value at the vertex's position.
References average_center(), DD::Image::gl_text(), DD::Image::GeoInfo::UV_ref, vertex_, and vertex_offset_.
void Primitive::draw_normal | ( | const Vector3 & | p, |
const Vector3 & | n, | ||
ViewerContext * | ctx, | ||
PrimitiveContext * | ptx | ||
) | [static] |
OpenGL helper function to draw a single normal expressed in geometry local coordinate
References DD::Image::Vector3::array(), DD::Image::Vector3::fast_normalize(), DD::Image::ViewerContext::icon_size(), DD::Image::Matrix4::ntransform(), and DD::Image::Matrix4::transform().
Referenced by draw_primitive_normal(), and draw_vertex_normals().
virtual PrimitiveType DD::Image::Primitive::getPrimitiveType | ( | ) | const [inline, virtual] |
Only for internal Nuke use, it will be deprecated
Reimplemented in DD::Image::ParticlesSprite.