DD::Image::Triangle Class Reference

Inherits DD::Image::PolygonPrimitive.

Public Member Functions

const char * Class () const
 
 Triangle (int p0=0, int p1=1, int p2=2)
 
 Triangle (const Triangle &)
 
Triangleoperator= (const Triangle &b)
 
Primitiveduplicate () const
 
Vector3 average_center (const PointList *) const
 Returns the xyz center average of the triangle. More...
 
bool IntersectsRay (const Ray &ray, int n, const PointList *pointList, CollisionResult *result) const
 Test for the intersection of this primitive with a given ray. More...
 
void validate (PrimitiveContext *)
 
unsigned faces () const
 
void draw_wireframe (ViewerContext *, PrimitiveContext *, Primitive *prev_prim=nullptr) const
 
void draw_solid (ViewerContext *, PrimitiveContext *, Primitive *prev_prim=nullptr) const
 
void draw_solid_face (int n, ViewerContext *, PrimitiveContext *) const
 
void draw_primitive_num (ViewerContext *, PrimitiveContext *) const
 
void draw_primitive_normal (ViewerContext *, PrimitiveContext *) const
 
void print_info () const
 
PrimitiveType getPrimitiveType () const
 
- Public Member Functions inherited from DD::Image::PolygonPrimitive
 PolygonPrimitive (unsigned vertices=0)
 
virtual void tessellate (Scene *, PrimitiveContext *) const
 
virtual void tessellateFace (int faceIndex, Scene *scene, PrimitiveContext *ptx, VertexContext *vtx) const
 
- Public Member Functions inherited from DD::Image::Primitive
virtual void vertex_shader (int v, Scene *, PrimitiveContext *, VArray &out, const Vector3 *normal=nullptr) const
 
virtual void vertex_shader (int v, Scene *, PrimitiveContext *, VertexContext &, VArray &out, const Vector3 *normal=nullptr) const
 
 Primitive (unsigned vertices=0)
 
 Primitive (const Primitive &)
 
virtual ~Primitive ()
 
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_and_bounds (int f, const PointList *points, Vector3 &min, Vector3 &max) const
 
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 faceUsesVertex (unsigned int faceIdx, unsigned int vertIdx) const
 
Iopmaterial () const
 
IoprenderingShader (const GeoInfo *info) const
 
const Vector3normal () const
 
virtual Vector3 vertex_normal (unsigned v, const PointList *) 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
 
void * operator new (size_t size)
 
void operator delete (void *mem)
 
void * operator new[] (size_t size)
 
void operator delete[] (void *mem)
 

Protected Member Functions

void copy (const Triangle *)
 
- Protected Member Functions inherited from DD::Image::Primitive
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
 

Additional Inherited Members

- Static Public Member Functions inherited from DD::Image::Primitive
static void draw_normal (const Vector3 &p, const Vector3 &n, ViewerContext *, PrimitiveContext *)
 
- Protected Attributes inherited from DD::Image::Primitive
std::vector< unsigned, STL3DAllocator< unsigned > > vertex_
 Point indices.
 
unsigned vertex_offset_
 Vertex attribute starting index.
 
Vector3 normal_
 Normal determined from vertex positions.
 
Iopmaterial_
 Material assignment.
 

Detailed Description

Simple triangle primitive.

Constructor & Destructor Documentation

Triangle::Triangle ( int  p0 = 0,
int  p1 = 1,
int  p2 = 2 
)

Constructor accepting 3 points.

References DD::Image::Primitive::vertex_.

Referenced by duplicate().

Triangle::Triangle ( const Triangle b)

Copy constuctor.

References copy().

Member Function Documentation

void Triangle::copy ( const Triangle b)
protected

Destructive copy.

References DD::Image::Primitive::copy().

Referenced by Triangle().

Primitive * Triangle::duplicate ( ) const
virtual

Copy this Triangle into a new one, and return a pointer to it. Vertex data is duplicated, point indices are unchanged.

Implements DD::Image::Primitive.

References Triangle().

Vector3 Triangle::average_center ( const PointList *  points) const
virtual

Returns the xyz center average of the triangle.

Return the primitive's xyz local-space center.

Reimplemented from DD::Image::Primitive.

bool DD::Image::Triangle::IntersectsRay ( const Ray ray,
int  n,
const PointList *  pointList,
CollisionResult *  result 
) const
inlinevirtual

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 Triangle::validate ( PrimitiveContext ptx)
virtual

Calculate the surface normal - points out with a ccw winding.

Reimplemented from DD::Image::Primitive.

References DD::Image::Primitive::normal_, DD::Image::Vector3::normalize(), and DD::Image::Primitive::validate().

void Triangle::draw_solid_face ( int  n,
ViewerContext ctx,
PrimitiveContext ptx 
) const
virtual

Draw the single face as a filled triangle.

Reimplemented from DD::Image::Primitive.

References DD::Image::Vector3::array(), and DD::Image::Primitive::vertex_.



©2024 The Foundry Visionmongers, Ltd. All Rights Reserved.
www.thefoundry.co.uk