3ds Max C++ API Reference
LightDesc Class Reference

#include <imtl.h>

+ Inheritance diagram for LightDesc:

Public Member Functions

 LightDesc ()
 
virtual BOOL Illuminate (ShadeContext &sc, Point3 &normal, Color &color, Point3 &dir, float &dot_nl, float &diffuseCoef)
 
virtual Point3 LightPosition ()
 
virtual CoreExport void DeleteThis ()
 
- Public Member Functions inherited from RenderData
virtual INT_PTR Execute (int cmd, ULONG_PTR arg1=0, ULONG_PTR arg2=0, ULONG_PTR arg3=0)
 
- Public Member Functions inherited from InterfaceServer
virtual UtilExport ~InterfaceServer ()
 Destructor. More...
 
virtual UtilExport BaseInterfaceGetInterface (Interface_ID id)
 
template<class InterfaceType >
InterfaceType * GetTypedInterface ()
 

Public Attributes

BOOL affectDiffuse
 
BOOL affectSpecular
 
BOOL ambientOnly
 
DWORD extra
 

Additional Inherited Members

- Static Public Member Functions inherited from MaxHeapOperators
static UtilExport voidoperator new (size_t size)
 Standard new operator used to allocate objects If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, const std::nothrow_t &e)
 Standard new operator used to allocate objects if there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new (size_t size, const char *filename, int line)
 New operator used to allocate objects that takes the filename and line number where the new was called If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, int block_type, const char *filename, int line)
 New operator used to allocate objects that takes the type of memory, filename and line number where the new was called If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, const std::nothrow_t &e, const char *filename, int line)
 New operator used to allocate objects that takes the filename and line number where the new was called If there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new (size_t size, unsigned long flags)
 New operator used to allocate objects that takes extra flags to specify special operations If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, const std::nothrow_t &e, unsigned long flags)
 New operator used to allocate objects that takes extra flags to specify special operations If there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new[] (size_t size)
 New operator used to allocate arrays of objects If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new[] (size_t size, const std::nothrow_t &e)
 New operator used to allocate arrays of objects If there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new[] (size_t size, const char *filename, int line)
 New operator used to allocate arrays of objects If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new[] (size_t size, int block_type, const char *filename, int line)
 New operator used to allocate arrays of objects. More...
 
static UtilExport voidoperator new[] (size_t size, const std::nothrow_t &e, const char *filename, int line)
 New operator used to allocate arrays of objects If there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new[] (size_t size, unsigned long flags)
 New operator used to allocate arrays of objects If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new[] (size_t size, const std::nothrow_t &e, unsigned long flags)
 New operator used to allocate arrays of objects If there is insufficient memory, NULL will be returned. More...
 
static UtilExport void operator delete (void *ptr)
 Standard delete operator used to deallocate an object If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete (void *ptr, const std::nothrow_t &e)
 Standard delete operator used to deallocate an object If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete (void *ptr, const char *filename, int line)
 Delete operator used to deallocate an object that takes the filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete (void *ptr, int block_type, const char *filename, int line)
 Delete operator used to deallocate an object that takes the type of memory, filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete (void *ptr, const std::nothrow_t &e, const char *filename, int line)
 Delete operator used to deallocate an object that takes the filename and line number where the delete was called If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete (void *ptr, unsigned long flags)
 Delete operator used to deallocate an object that takes extra flags to specify special operations If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete (void *ptr, const std::nothrow_t &e, unsigned long flags)
 Delete operator used to deallocate an object that takes extra flags to specify special operations If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete[] (void *ptr)
 Standard delete operator used to deallocate an array of objects If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete[] (void *ptr, const std::nothrow_t &e)
 Standard delete operator used to deallocate an array of objects If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete[] (void *ptr, const char *filename, int line)
 Delete operator used to deallocate an array of objects that takes the filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete[] (void *ptr, int block_type, const char *filename, int line)
 Delete operator used to deallocate an array of objects that takes the type of memory, filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete[] (void *ptr, const std::nothrow_t &e, const char *filename, int line)
 Delete operator used to deallocate an array of objects that takes the filename and line number where the delete was called If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete[] (void *ptr, unsigned long flags)
 Delete operator used to deallocate an array of objects that takes extra flags to specify special operations If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete[] (void *ptr, const std::nothrow_t &e, unsigned long flags)
 Delete operator used to deallocate an array of objects that takes extra flags to specify special operations If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, void *placement_ptr)
 Placement new operator. More...
 
static UtilExport void operator delete (void *ptr, void *placement_ptr)
 Placement delete operator. More...
 
static UtilExport voidaligned_malloc (size_t size, size_t alignment)
 Allocates memory on a specified alignment boundary. More...
 
static UtilExport voidaligned_realloc (void *ptr, size_t size, size_t alignment)
 Reallocates memory on a specified alignment boundary. More...
 
static UtilExport void aligned_free (void *ptr)
 Frees a block of memory that was allocated with aligned_malloc/aligned_realloc. More...
 

Detailed Description

See also
Class RenderData, Class LightRayTraversal, Class ObjLightDesc, Class ShadeContext, Class Color, Class Point3.

Description:
This class has a method Illuminate() used to determine the color and direction of the light striking the point sc.P() and a method to get the position of the light. It also has two public data members that determine if the diffuse and specular colors of objects are affected.
Data Members:
BOOL affectDiffuse;

This data member is available in release 2.0 and later only.

If TRUE the light affects the diffuse color; otherwise it does not.

BOOL affectSpecular;

This data member is available in release 2.0 and later only.

If TRUE the light affects the specular color; otherwise it does not.

BOOL ambientOnly;

This data member is available in release 3.0 and later only.

If TRUE the light affects the ambient color only; otherwise it does not.

DWORD extra;

This data member is available in release 3.0 and later only.

This is not currently used and is available for use in the future.

Constructor & Destructor Documentation

◆ LightDesc()

LightDesc ( )
inline
Remarks
Constructor. The affectDiffuse and affectSpecular data members are set to TRUE.
131 { affectDiffuse = affectSpecular = TRUE; ambientOnly = FALSE; }
BOOL affectDiffuse
Definition: imtl.h:125
BOOL ambientOnly
Definition: imtl.h:127
BOOL affectSpecular
Definition: imtl.h:126

Member Function Documentation

◆ Illuminate()

virtual BOOL Illuminate ( ShadeContext sc,
Point3 normal,
Color color,
Point3 dir,
float &  dot_nl,
float &  diffuseCoef 
)
inlinevirtual
Remarks
This method is called to determine the color and direction of illumination from the light that is hitting the point (sc.P()).
Parameters:
ShadeContext& sc

Describes the properties of the point to shade. The point itself is sc.P().

Point3& normal

The normal to the surface in camera space.

Color& color

The color that is returned. This is the brightness of light striking the point (sc.P())

Point3 &dir

The direction that the light is coming from.

float &dot_nl

This provides a bit of optimization as most lights will have to calculate this quantity. This is the dot product between the light vector and the normal to the surface.

float &diffuseCoef

This parameter should be set by the Illuminate function. The default value is the same as dot_nl. It will be used by shading functions instead of dot_nl to compute the diffuse illumination of the surface. The built-in lights use the new "Contrast" parameter (which has a range of [0..100]) to compute the diffuseCoef from the dot_nl by the Contrast function:
// precomputed:
float a = contrast/200.0f + 0.5f; // so "a" varies from .5 to 1.0
kA = (2.0f-1.0f/a);
kB = 1.0f-kA;
// called by Illuminate() to compute diffuseCoef from dot_nl.
float ContrastFunc(float nl)
{
// the "Bias" function described in Graphics Gems IV, pp. 401ff
return (contrast==0.0f)? nl : nl/(kA*nl+kB);
}
Returns
Returns FALSE if the hitpoint is outside the effective range of the light or if the normal of the surface faces away from the light. This is a hint to the material that the light did not calculate its illumination because it is assumed it wasn't going to be used. If TRUE the point is being illuminated.
Default Implementation:
{ return 0;}
178 { return 0;}

◆ LightPosition()

virtual Point3 LightPosition ( )
inlinevirtual
Remarks
Returns the position of the light.
Default Implementation:
{ return Point3(0,0,0); }

Reimplemented in ObjLightDesc.

183 { return Point3(0,0,0); }
Definition: point3.h:54

◆ DeleteThis()

virtual CoreExport void DeleteThis ( )
virtual
Remarks
This method is used to delete an instance of the class.
Default Implementation:
{delete this; }

Implements RenderData.

Member Data Documentation

◆ affectDiffuse

BOOL affectDiffuse

◆ affectSpecular

BOOL affectSpecular

◆ ambientOnly

BOOL ambientOnly

◆ extra

DWORD extra