Nuke binary plugins 15.0.5
 
Loading...
Searching...
No Matches
DD::Image::Primitive Class Referenceabstract

#include <Primitive.h>

Inheritance diagram for DD::Image::Primitive:
DD::Image::Particles DD::Image::ParticlesSprite DD::Image::Point DD::Image::PolygonPrimitive DD::Image::Mesh DD::Image::PolyMesh DD::Image::Polygon DD::Image::Triangle

Public Member Functions

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 ()
 
virtual const char * Class () const =0
 
virtual Primitiveduplicate () 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
 
Iopmaterial () const
 
IoprenderingShader (const GeoInfo *info) const
 
const Vector3normal () 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=nullptr) const =0
 
virtual void draw_solid (ViewerContext *, PrimitiveContext *, Primitive *prev_prim=nullptr) 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.
 
Iopmaterial_
 Material assignment.
 

Friends

class GeoInfo
 
class GeometryList
 
class Scene
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ Primitive()

Primitive::Primitive ( const Primitive b)

Copy constructor.

References copy().

◆ ~Primitive()

Primitive::~Primitive ( )
virtual

Base destructor.

Member Function Documentation

◆ draw_wireframe_vertex()

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_.

◆ draw_solid_vertex()

◆ copy()

◆ PolyIntersectsRay()

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().

◆ vertex_shader()

void Primitive::vertex_shader ( int  v,
Scene scene,
PrimitiveContext ptx,
VArray out,
const Vector3 normal = nullptr 
) 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...

References normal(), and vertex_shader().

Referenced by DD::Image::Point::tessellate(), DD::Image::Mesh::tessellateFace(), DD::Image::Scene::validate(), and vertex_shader().

◆ duplicate()

virtual Primitive * DD::Image::Primitive::duplicate ( ) const
pure virtual

◆ getDataArray()

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::UV, DD::Image::GeoInfo::UV_ref, vertex_, and vertex_offset_.

◆ offset_point_indices()

void Primitive::offset_point_indices ( int  offset)

Offset point list indices for all vertices.

References vertex_.

◆ add_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_.

◆ add_vertices()

unsigned Primitive::add_vertices ( unsigned  num)

Add 'num' of vertices to primitive. Returns the starting index in the vertex list.

References vertex_.

◆ average_center()

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::Triangle, and DD::Image::Point.

Referenced by draw_primitive_normal(), draw_primitive_num(), draw_vertex_num(), and draw_vertex_uvs().

◆ average_center_and_bounds()

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().

◆ faces()

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().

◆ face_average_center()

virtual Vector3 DD::Image::Primitive::face_average_center ( int  n,
const PointList points 
) const
inlinevirtual

Returns the xyz center average of the sub face. Base class returns the primitive center.

Reimplemented in DD::Image::Mesh.

◆ face_vertices()

virtual unsigned DD::Image::Primitive::face_vertices ( int  n) const
inlinevirtual

◆ get_face_vertices()

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().

◆ get_bbox()

Box3 Primitive::get_bbox ( const GeoInfo info) const
virtual

Returns the primitive bounding box

References DD::Image::Box3::expand().

◆ get_face_normal()

virtual Vector3 DD::Image::Primitive::get_face_normal ( int  n,
const PointList points 
) const
inlinevirtual

Returns the normal for face.

Reimplemented in DD::Image::Mesh.

◆ get_geometric_normal()

virtual Vector3 DD::Image::Primitive::get_geometric_normal ( int  v,
const PointList points 
) const
inlinevirtual

Return the geometric normal for vertex.

◆ get_vertex_faces()

virtual int DD::Image::Primitive::get_vertex_faces ( int  v,
std::vector< int > &  faces 
) const
inlinevirtual

Return the number of faces that vertex connects to and fills in the list of face indices.

◆ IntersectsRay()

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

Test for the intersection of this primitive face with a given ray .

Reimplemented in DD::Image::Mesh, DD::Image::Polygon, and DD::Image::Triangle.

◆ validate()

virtual void DD::Image::Primitive::validate ( PrimitiveContext )
inlinevirtual

Initialize any variables prior to display or rendering.

Reimplemented in DD::Image::Mesh, and DD::Image::Triangle.

Referenced by DD::Image::Mesh::validate(), and DD::Image::Triangle::validate().

◆ faceUsesVertex()

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().

◆ normal()

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.

Referenced by vertex_shader().

◆ vertex_normal()

Vector3 DD::Image::Primitive::vertex_normal ( unsigned  v,
const PointList  
) const
inlinevirtual

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.

◆ tessellate()

virtual void DD::Image::Primitive::tessellate ( Scene ,
PrimitiveContext  
) const
pure virtual

◆ draw_solid_face()

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_.

◆ draw_primitive_normal()

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_.

Referenced by DD::Image::Mesh::draw_primitive_normal().

◆ draw_primitive_num()

void Primitive::draw_primitive_num ( ViewerContext ctx,
PrimitiveContext ptx 
) const
virtual

Draw primitive's index number.

References average_center(), DD::Image::gl_text(), and snprintf().

◆ draw_vertex_num()

void Primitive::draw_vertex_num ( ViewerContext ctx,
PrimitiveContext ptx 
) const
virtual

Draw vertex number.

References average_center(), DD::Image::gl_text(), snprintf(), and vertex_.

◆ draw_vertex_normals()

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_.

◆ draw_vertex_uvs()

void Primitive::draw_vertex_uvs ( ViewerContext ctx,
PrimitiveContext ptx 
) const
virtual

◆ draw_normal()

void Primitive::draw_normal ( const Vector3 p,
const Vector3 n,
ViewerContext ctx,
PrimitiveContext ptx 
)
static

◆ getPrimitiveType()

virtual PrimitiveType DD::Image::Primitive::getPrimitiveType ( ) const
inlinevirtual

Only for internal Nuke use, it will be deprecated

Reimplemented in DD::Image::ParticlesSprite.



©2024 The Foundry Visionmongers, Ltd. All Rights Reserved.
www.foundry.com