Public Member Functions | Public Attributes

RenderInstance Class Reference

Search for all occurrences

Detailed Description

This class is available in release 2.0 and later only.



This class provides information about a single node being rendered. This includes information such as the mesh of the object, its material, unique node ID, object space bounding extents, number of lights affecting it, material requirements, and normals and vertex coordinates in various spaces (object and camera).

Data Members:
ULONG flags;

The flags that describe the properties of this instance. See Render Instance Flags .

Mtl *mtl;

This is the material from the node.

float wireSize;

The wireframe size.

Mesh *mesh;

The mesh to be rendered. This is the result of GeomObject::GetRenderMesh().

float vis;

Object visibility (between 0.0 and 1.0). This is the value the visibility track evaluates to at a particular time.

int nodeID;

A unique ID associated with the node. It's unique within the scene during a render.

int objMotBlurFrame;

This will be equal to NO_MOTBLUR for all non-blurred objects. For blurred objects, it takes on the values (0..nBlurFrames-1) for the successive blur-instances.

int objBlurID;

The purpose of this is to differentiate blur-instances generated from different nodes. All the blur-instances for an object-motion-blurred object will have the same objBlurID. This is as distinct from nodeID, which is different for every instance. This makes it possible to easily avoid intersecting a ray with all blur-instances for an object. If RenderGlobalContext::IntersectWorld() is being used, then passing in the objBlurID for the parameter skipID will have this effect.

The basic technique is this: When reflecting or refracting rays, and object motion blur is enabled, choose sub-frame times randomly for the different rays (effectively giving a coarse stochastic sampling of time).

Matrix3 objToWorld;

This matrix can be used to transform object coordinates to world coordinates.

Matrix3 objToCam;

This matrix can be used to transform object coordinates to camera coordinates.

Matrix3 normalObjToCam;

This matrix can be used for transforming surface normals from object space to camera space.

Matrix3 camToObj;

This matrix can be used to transform camera coordinates to object coordinates.

Box3 obBox;

The object space extents of the object being rendered.

Point3 center;

The object bounding sphere center (in camera coordinates)

float radsq;

The square of the bounding sphere's radius.
See also:
Class Mtl, Class LightDesc, Class INode, Class Object, Class Mesh, Class Matrix3, Class Box3, Class Point3, Class Interval.

#include <render.h>

Inheritance diagram for RenderInstance:
Inheritance graph
[legend]

List of all members.

Public Member Functions

virtual  ~RenderInstance ()
  Destructor.
void  SetFlag (ULONG f, BOOL b)
  Sets the specified flag(s) to the state passed.
void  SetFlag (ULONG f)
  Sets the specified flag(s) to on.
void  ClearFlag (ULONG f)
  Clears the specified flag(s).
BOOL  TestFlag (ULONG f)
  Returns TRUE if the specified flag(s) are set; otherwise FALSE.
BOOL  Hidden ()
BOOL  IsClip ()
virtual RenderInstance Next ()=0
  Returns a pointer to the next in RenderInstance in the list.
virtual Interval  MeshValidity ()=0
  Returns the validity interval of the mesh of this render instance.
virtual int  NumLights ()=0
  Returns the number of lights affecting the node.
virtual LightDesc Light (int n)=0
  Returns a pointer to the LightDesc for the 'i-th' light affecting the node.
virtual BOOL  CastsShadowsFrom (const ObjLightDesc &lt)=0
virtual INode GetINode ()=0
  Returns the INode pointer for the instance.
virtual Object GetEvalObject ()=0
  Returns a pointer to the evaluated object for the instance.
virtual ULONG  MtlRequirements (int mtlNum, int faceNum)=0
  Returns the material requirements of the material assigned to the node.
virtual Point3  GetFaceNormal (int faceNum)=0
  Returns the geometric normal of the specified face in object space.
virtual Point3  GetFaceVertNormal (int faceNum, int vertNum)=0
  Returns the vertex normal of the specified face in camera coordinates.
virtual void  GetFaceVertNormals (int faceNum, Point3 n[3])=0
  Returns the three vertex normals of the specified face in camera coordinates.
virtual Point3  GetCamVert (int vertnum)=0
  Returns the coordinate for the specified vertex in camera coordinates.
virtual void  GetObjVerts (int fnum, Point3 obp[3])=0
  Returns the vertices of the specified face in object coordinates.
virtual void  GetCamVerts (int fnum, Point3 cp[3])=0
  Returns the vertices of the specified face in camera (view) coordinates.
virtual INT_PTR  Execute (int cmd, ULONG_PTR arg1=0, ULONG_PTR arg2=0, ULONG_PTR arg3=0)
virtual Mtl GetMtl (int faceNum)=0

Public Attributes

ULONG  flags
Mtl mtl
float  wireSize
Mesh mesh
float  vis
int  nodeID
int  objMotBlurFrame
int  objBlurID
Matrix3  objToWorld
Matrix3  objToCam
Matrix3  normalObjToCam
Matrix3  camToObj
Box3  obBox
Point3  center
float  radsq

Constructor & Destructor Documentation

virtual ~RenderInstance ( ) [inline, virtual]

Destructor.

{}

Member Function Documentation

void SetFlag ( ULONG  f,
BOOL  b 
) [inline]

Sets the specified flag(s) to the state passed.

Parameters:
ULONG f

The flags to set. See Render Instance Flags .

BOOL b

The state to set; TRUE for on; FALSE for off.
{ if (b) flags |= f; else flags &= ~f; }
void SetFlag ( ULONG  f ) [inline]

Sets the specified flag(s) to on.

Parameters:
ULONG f

The flags to set. See Render Instance Flags .
{  flags |= f; }
void ClearFlag ( ULONG  f ) [inline]

Clears the specified flag(s).

Parameters:
ULONG f

The flags to set to zero. See Render Instance Flags .
{  flags &= ~f; }
BOOL TestFlag ( ULONG  f ) [inline]

Returns TRUE if the specified flag(s) are set; otherwise FALSE.

Parameters:
ULONG f

The flags to set to zero. See Render Instance Flags
{ return flags&f?1:0; }
BOOL Hidden ( ) [inline]
BOOL IsClip ( ) [inline]
virtual RenderInstance* Next ( ) [pure virtual]

Returns a pointer to the next in RenderInstance in the list.

A pointer to the first element in the list may to retrieved from RenderGlobalContext::InstanceList().

virtual Interval MeshValidity ( ) [pure virtual]

Returns the validity interval of the mesh of this render instance.

virtual int NumLights ( ) [pure virtual]

Returns the number of lights affecting the node.

virtual LightDesc* Light ( int  n ) [pure virtual]

Returns a pointer to the LightDesc for the 'i-th' light affecting the node.

Parameters:
int n

Specifies which light.
virtual BOOL CastsShadowsFrom ( const ObjLightDesc lt ) [pure virtual]
Remarks:
Returns TRUE if this particular instance will cast shadows from the particular light based on the light's Exclusion/Inclusion list; FALSE if it won't cast shadows.
Parameters:
const ObjLightDesc& lt

Describes the light. See Class ObjLightDesc.
virtual INode* GetINode ( ) [pure virtual]

Returns the INode pointer for the instance.

virtual Object* GetEvalObject ( ) [pure virtual]

Returns a pointer to the evaluated object for the instance.

You can use this to get more information about the type of object being rendered. For instance you could look at the Class_ID and recognize it as a sphere, a box, a torus, etc.

virtual ULONG MtlRequirements ( int  mtlNum,
int  faceNum 
) [pure virtual]

Returns the material requirements of the material assigned to the node.

See Material Requirements Flags.

Parameters:
int mtlNum

Specifies the number of the sub-material whose requirements should be returned. A value of -1 may be passed to return a value generated by looping over all the sub-materials and ORing together the requirements.

int faceNum

This parameter is available in release 4.0 and later only.

This is the integer face number for objects which support material per face (if flag INST_MTL_BYFACE is set). See Class IChkMtlAPI.
virtual Point3 GetFaceNormal ( int  faceNum ) [pure virtual]

Returns the geometric normal of the specified face in object space.

Parameters:
int faceNum

Zero based index of the face whose normal is returned.
virtual Point3 GetFaceVertNormal ( int  faceNum,
int  vertNum 
) [pure virtual]

Returns the vertex normal of the specified face in camera coordinates.

Parameters:
int faceNum

Zero based index of the face in the mesh.

int vertNum

Zero based index of the vertex in the face.
virtual void GetFaceVertNormals ( int  faceNum,
Point3  n[3] 
) [pure virtual]

Returns the three vertex normals of the specified face in camera coordinates.

Parameters:
int faceNum

Zero based index of the face in the mesh.

Point3 n[3]

The normals are returned here.
virtual Point3 GetCamVert ( int  vertnum ) [pure virtual]

Returns the coordinate for the specified vertex in camera coordinates.

Parameters:
int vertnum

The zero based index of the vertex in the mesh.
virtual void GetObjVerts ( int  fnum,
Point3  obp[3] 
) [pure virtual]

Returns the vertices of the specified face in object coordinates.

Parameters:
int fnum

Zero based index of the face in the mesh.

Point3 obp[3]

The three vertices of the face in object coordinates.
virtual void GetCamVerts ( int  fnum,
Point3  cp[3] 
) [pure virtual]

Returns the vertices of the specified face in camera (view) coordinates.

Parameters:
int fnum

Zero based index of the face in the mesh.

Point3 cp[3]

The three vertices of the face in camera coordinates.
virtual INT_PTR Execute ( int  cmd,
ULONG_PTR  arg1 = 0,
ULONG_PTR  arg2 = 0,
ULONG_PTR  arg3 = 0 
) [inline, virtual]
Remarks:
This is a general purpose function that allows the API to be extended in the future. The 3ds Max development team can assign new cmd numbers and continue to add functionality to this class without having to 'break' the API.
Parameters:
int cmd

The index of the command to execute.

ULONG_PTR arg1=0

Optional argument 1. See the documentation where the cmd option is discussed for more details on these parameters.

ULONG_PTR arg2=0

Optional argument 2.

ULONG_PTR arg3=0

Optional argument 3.
Returns:
An integer return value. See the documentation where the cmd option is discussed for more details on the meaning of this value.
Default Implementation:
{ return 0; }
{ return 0; } 
virtual Mtl* GetMtl ( int  faceNum ) [pure virtual]
Remarks:
Objects can provide a material as a function of face number via the interface provided by Class IChkMtlAPI. This method will return RenderInstance::mtl if flag INST_MTL_BYFACE is not set. If INST_MTL_BYFACE is set it will return the proper by-face material. See Render Instance Flags .
Parameters:
int faceNum

The zero based index of the face in the mesh.

Objects can provide a material as a function of face number via the IChkMtlAPI interface (chkmtlapi.h).

Member Data Documentation

ULONG flags
Mtl* mtl
float wireSize
float vis
int nodeID
int objBlurID
float radsq

RenderInstance RenderInstance RenderInstance RenderInstance RenderInstance RenderInstance RenderInstance RenderInstance RenderInstance RenderInstance
RenderInstance RenderInstance RenderInstance RenderInstance RenderInstance RenderInstance RenderInstance RenderInstance RenderInstance RenderInstance