Nuke binary plugins 15.0.5
 
Loading...
Searching...
No Matches
DD::Image::rTriangle Class Reference

#include <rTriangle.h>

Inheritance diagram for DD::Image::rTriangle:
DD::Image::rPrimitive DD::Image::Box3

Public Types

enum  EdgeMask { eMaskEdge01 , eMaskEdge12 , eMaskEdge20 , eMaskEdgeAll }
 
- Public Types inherited from DD::Image::rPrimitive
enum  rPrimitiveType { eUnknownRPrimitive , eRTriangle , eRPoint }
 

Public Member Functions

const char * Class () override
 
 rTriangle (const GeoInfo *info, const Primitive *p)
 
 rTriangle (const rTriangle &)
 
rPrimitiveduplicate () const override
 
bool add_to_render (Scene *, PrimitiveContext *) override
 
bool add_to_displacement_render (Scene *, PrimitiveContext *) override
 
bool intersect (float x, float y) const override
 
bool intersect (float x, float y, float *dist) const override
 
bool intersect_dist_squared (float x, float y, float *dist_squared) const override
 
bool intersect_scanline (float y, int &X, int &R, VArray &out, VArray &du, VArray &dv) const override
 
float trace (Scene *) override
 
float distance (float x, float y) const override
 
float distance_squared (float x, float y) const override
 
void subdivide (std::vector< rPrimitive * > &primitives, SubdivisionContext *stx) override
 
rPrimitiveType getPrimitiveType () const override
 
float polygonEdgeDistance (const Vector4 &P, const float mindist) const
 
- Public Member Functions inherited from DD::Image::rPrimitive
virtual const char * Class ()
 
 rPrimitive (const GeoInfo *info, const Primitive *p)
 
 rPrimitive (const rPrimitive &)
 
virtual ~rPrimitive ()
 
virtual rPrimitiveduplicate () const
 
const GeoInfogeoinfo () const
 
const Primitiveparent () const
 
bool cast_shadows () const
 
bool receive_shadows () const
 
virtual bool add_to_render (Scene *, PrimitiveContext *)=0
 
virtual bool add_to_displacement_render (Scene *, PrimitiveContext *)
 
virtual bool intersect (float x, float y) const =0
 
virtual bool intersect (float x, float y, float *dist) const =0
 
virtual bool intersect_dist_squared (float x, float y, float *dist_squared) const =0
 
virtual bool intersect_scanline (float y, int &X, int &R, VArray &v0, VArray &du, VArray &dv) const =0
 
virtual float trace (Scene *)=0
 
virtual float distance (float x, float y) const =0
 
virtual float distance_squared (float x, float y) const =0
 
virtual void subdivide (std::vector< rPrimitive * > &primitives, SubdivisionContext *stx)
 
virtual rPrimitiveType getPrimitiveType () const
 
void * operator new (size_t size)
 
void operator delete (void *mem)
 
void * operator new[] (size_t size)
 
void operator delete[] (void *mem)
 
- Public Member Functions inherited from DD::Image::Box3
 Box3 (float x, float y, float z)
 
 Box3 (const Vector3 p)
 
 Box3 (const Vector3 p1, const Vector3 p2)
 
const Vector3min () const
 
const Vector3max () const
 
float x () const
 
float y () const
 
float n () const
 near, min z
 
float r () const
 right, max x
 
float t () const
 top, max y
 
float f () const
 far, max z
 
float w () const
 width
 
float h () const
 height
 
float d () const
 depth
 
Vector3 center () const
 
float radius () const
 
void set (float x, float y, float z, float r, float t, float f)
 
void set (Vector3 p1, Vector3 p2)
 
void set (const Box3 &v)
 
void set_min (float x, float y, float z)
 
void set_max (float x, float y, float z)
 
bool empty () const
 
void clear ()
 
bool inside (const Vector3 &p) const
 
void expand (const Box3 &v)
 
void expand (const Vector3 &p)
 
void intersect (const Box3 &v)
 
void transform (const Matrix4 &m)
 
void project (const Matrix4 &m, Box &bbox) const
 
void append (Hash &h) const
 
void print_info (const char *title=nullptr) const
 

Public Attributes

VArray v [3]
 in SCREEN coordiantes, w_normalized!!!
 
float Ax
 
float Ay
 
float Bx
 
float By
 
float Nz
 For figuring out derivatives.
 
uint8_t edgesmask
 triangle edge mask
 
rTrianglepolygon
 cirular list of all triangles that define the original polygon
 

Additional Inherited Members

- Protected Attributes inherited from DD::Image::rPrimitive
const GeoInfogeoinfo_
 Parent object.
 
const Primitiveparent_
 What primitive generated us.
 

Detailed Description

Renderable triangle class, created once a projection into screen space is known. The Triangle primitive class creates one of these, and add_to_render() may then change this to 0,1, or 2 renderable triangles (depending on clipping). Other primitives such as grid will create quite a few more of these.

Constructor & Destructor Documentation

◆ rTriangle() [1/2]

rTriangle::rTriangle ( const GeoInfo info,
const Primitive p 
)

Constructor.

References edgesmask, and polygon.

◆ rTriangle() [2/2]

rTriangle::rTriangle ( const rTriangle b)

Copy constructor.

Member Function Documentation

◆ Class()

const char * DD::Image::rTriangle::Class ( )
inlineoverridevirtual

Reimplemented from DD::Image::rPrimitive.

◆ duplicate()

rPrimitive * rTriangle::duplicate ( ) const
overridevirtual

Reimplemented from DD::Image::rPrimitive.

◆ add_to_render()

bool rTriangle::add_to_render ( Scene scene,
PrimitiveContext ptx 
)
overridevirtual

Transform this triangle into homogeneous clipping space. Add any sub-triangles to the rendering scene. There's no need to further break a triangle down unless it intersects one of the frustum planes. Lastly we apply the homogeneous division by W which applies perspective to the points and places them into NDC space(Normalized Device Coordinates). This must be done AFTER clipping to guarantee that W is always > 0.

Clip the triangle against the frustum(W) near plane. There's two possibilities: a) One vertex is outside the plane. The triangle needs one additional edge defining the plane intersection line. To keep it a triangle we interpolate both vertices to the plane, and create one additional triangle primitive:

| 1 | 1 | /\ | /\ |/ \ 0 |/ \ | \ | A \ /| \ —> 1 |\ \ /X| \ | \ \ /XX| \ | \ \ /XXX| \ | B \ \ 0 -—|------— 2 0 |------— 2 | |

 b) Two vertices are outside the plane, so the outside edge
   is simply interpolated to the plane:

             1  |                        |
            /\  |                        |
           /XX\ |                        |
          /XXXX\|                        |
         /XXXXXX|      --->              |
        /XXXXXXX|\                     1 |\
       /XXXXXXXX| \                      | \
      /XXXXXXXXX|  \                     |  \
    0 ----------|--- 2                 0 |--- 2

| |

Implements DD::Image::rPrimitive.

References DD::Image::Scene::camera, edgesmask, DD::Image::eVelocityMotionVector, DD::Image::Scene::lens_func, DD::Image::Box3::t(), v, and DD::Image::Box3::w().

◆ add_to_displacement_render()

bool rTriangle::add_to_displacement_render ( Scene scene,
PrimitiveContext ptx 
)
overridevirtual

Transform this triangle into homogeneous clipping space.
And add to the displacement map list in scene

Reimplemented from DD::Image::rPrimitive.

References DD::Image::Iop::displacement_bound(), DD::Image::Scene::lens_func, and DD::Image::GeoInfo::material.

◆ intersect() [1/2]

bool rTriangle::intersect ( float  x,
float  y 
) const
overridevirtual

Intersect the screen-space projected triangle with an XY point, returning true if successful.

Implements DD::Image::rPrimitive.

References v.

Referenced by distance().

◆ intersect() [2/2]

bool rTriangle::intersect ( float  x,
float  y,
float *  dist 
) const
overridevirtual

Intersect the screen-space projected triangle with an XY point. Return true it was successful, and assigns the distance to the nearest edge.

Implements DD::Image::rPrimitive.

References DD::Image::Box3::inside(), and intersect_dist_squared().

◆ intersect_dist_squared()

bool rTriangle::intersect_dist_squared ( float  x,
float  y,
float *  dist_squared 
) const
overridevirtual

Intersect the screen-space projected triangle with an XY point. Return true it was successful, and assigns the square of the distance to the nearest edge.

Implements DD::Image::rPrimitive.

References DD::Image::Box3::inside(), MIN(), and v.

Referenced by distance_squared(), and intersect().

◆ intersect_scanline()

bool rTriangle::intersect_scanline ( float  y,
int &  X,
int &  R,
VArray out,
VArray du,
VArray dv 
) const
overridevirtual

Intersect the triangle with a scanline. Return whether it was successful, and set X and R to the left and rightmost pixels affected, and set out to the value at 0,y (ie pixel 0 of the scanline, even if outside the triangle), and set du/dv to the screen-space derivatives, such that out+x*du is the value at any pixel in the scanline.

Implements DD::Image::rPrimitive.

References fast_floor(), Nz, and v.

◆ trace()

float rTriangle::trace ( Scene scene)
overridevirtual

Not implemented yet.

Implements DD::Image::rPrimitive.

◆ distance()

float rTriangle::distance ( float  x,
float  y 
) const
overridevirtual

Distance to the nearest edge the object in screen-space. Returns 0 or negative if inside the object.

Implements DD::Image::rPrimitive.

References DD::Image::Box3::d(), and intersect().

◆ distance_squared()

float rTriangle::distance_squared ( float  x,
float  y 
) const
overridevirtual

Square of the distance to the nearest edge the object in screen-space. Returns 0 or negative if inside the object.

Implements DD::Image::rPrimitive.

References DD::Image::Box3::d(), and intersect_dist_squared().

◆ subdivide()

void rTriangle::subdivide ( std::vector< rPrimitive * > &  primitives,
SubdivisionContext *  stx 
)
overridevirtual

Reimplemented from DD::Image::rPrimitive.

◆ getPrimitiveType()

rPrimitiveType DD::Image::rTriangle::getPrimitiveType ( ) const
inlineoverridevirtual

Reimplemented from DD::Image::rPrimitive.



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