ExposureMaterialControl Class Reference

#include <expmtlControl.h>

Class Description

This is the inteface class to implement in order to support exposure controls.

See also
Class ExposureMaterialControlImp
Description:
This class is an extension to allow maxscript to determine whether a material's shaded output is to be processed by a tone operator and whether the self-illumination, reflection or refraction channels are to be inverted by the tone operator so the actual rgb values will appear in the display.

This class is added to materials that want to expose control over the results of the exposure control on the shaded output of the material. This is useful when a material knows the specific RGB value to appear in the rendered image, and does not want this color to be adjusted. For example, a material might already perform its own physically-based lighting calculations with handling for image exposure. Or, in the case of specialty "non-physical" materials, it might be inappropriate to perform exposure adjustments on the color.

You determine whether a material allows this control by asking for the interface. If the interface is present, then you can set values. This is how you ask for the interface: A material can support this interface by deriving from this class and handling the GetInterface() method as follows:
return Mtl::GetInterface(id); //If the interface ID is not recognized, call the superclass method
}
There are four properties in the interface, each with a get and a set method. Use the get method to get the current value and set to set a new value for the property.

The properties are:
  • NoExposure
  • InvertSelfIllum
  • InvertReflect
  • InvertRefract

Also, if you want your material's ExposureMaterialControl methods to be exposed to MAXScript, you can derive from ExposureMaterialControlImp.

+ Inheritance diagram for ExposureMaterialControl:

Public Types

enum  {
  kGetNoExposureControl = 0, kSetNoExposureControl = 1, kGetInvertSelfIllum = 2, kSetInvertSelfIllum = 3,
  kGetInvertReflect = 4, kSetInvertReflect = 5, kGetInvertRefract = 6, kSetInvertRefract = 7
}
 
- Public Types inherited from BaseInterface
enum  LifetimeType { noRelease, immediateRelease, wantsRelease, serverControlled }
 

Public Member Functions

 ExposureMaterialControl ()
 
 PROP_FNS (kGetNoExposureControl, GetNoExposure, kSetNoExposureControl, SetNoExposure, TYPE_BOOL)
 
 PROP_FNS (kGetInvertSelfIllum, GetInvertSelfIllum, kSetInvertSelfIllum, SetInvertSelfIllum, TYPE_BOOL)
 
 PROP_FNS (kGetInvertReflect, GetInvertReflect, kSetInvertReflect, SetInvertReflect, TYPE_BOOL)
 
 PROP_FNS (kGetInvertRefract, GetInvertRefract, kSetInvertRefract, SetInvertRefract, TYPE_BOOL)
 
BOOL GetNoExposure () const
 
virtual void SetNoExposure (BOOL on)
 
BOOL GetInvertSelfIllum () const
 
virtual void SetInvertSelfIllum (BOOL on)
 
BOOL GetInvertReflect () const
 
virtual void SetInvertReflect (BOOL on)
 
BOOL GetInvertRefract () const
 
virtual void SetInvertRefract (BOOL on)
 
ULONG isNoExposure () const
 
bool isInvertSelfIllum () const
 
bool isInvertReflect () const
 
bool isInvertRefract () const
 
IOResult Save (ISave *isave)
 
IOResult Load (ILoad *iload)
 
- Public Member Functions inherited from FPMixinInterface
 FPMixinInterface ()
 
virtual LifetimeType LifetimeControl ()
 
virtual CoreExport bool RegisterNotifyCallback (InterfaceNotifyCallback *incb)
 
virtual void UnRegisterNotifyCallback (InterfaceNotifyCallback *incb)
 
CoreExport ~FPMixinInterface ()
 
virtual BaseInterfaceGetInterface (Interface_ID id)
 
virtual FPInterfaceDescGetDescByID (Interface_ID id)
 
virtual Interface_ID GetID ()
 
- Public Member Functions inherited from FPInterface
virtual FPInterfaceDescGetDesc ()=0
 
virtual CoreExport FPStatus Invoke (FunctionID fid, TimeValue t=0, FPParams *params=NULL)
 
virtual FPStatus Invoke (FunctionID fid, FPParams *params)
 
virtual CoreExport FPStatus Invoke (FunctionID fid, TimeValue t, FPValue &result, FPParams *params=NULL)
 
virtual FPStatus Invoke (FunctionID fid, FPValue &result, FPParams *params=NULL)
 
virtual CoreExport FunctionID FindFn (const MCHAR *name)
 
virtual CoreExport BOOL IsEnabled (FunctionID actionID)
 
virtual CoreExport BOOL IsChecked (FunctionID actionID)
 
virtual CoreExport BOOL IsVisible (FunctionID actionID)
 
virtual CoreExport FunctionID GetIsEnabled (FunctionID actionID)
 
virtual CoreExport FunctionID GetIsChecked (FunctionID actionID)
 
virtual CoreExport FunctionID GetIsVisible (FunctionID actionID)
 
virtual ActionTableGetActionTable ()
 
virtual void EnableActions (BOOL onOff)
 
- Public Member Functions inherited from BaseInterface
virtual UtilExport ~BaseInterface ()
 Destructor. More...
 
virtual BaseInterfaceAcquireInterface ()
 
virtual void ReleaseInterface ()
 
virtual void DeleteInterface ()
 
virtual BaseInterfaceCloneInterface (void *remapDir=NULL)
 
- Public Member Functions inherited from InterfaceServer
virtual UtilExport ~InterfaceServer ()
 Destructor. More...
 

Protected Types

enum  { DATA_CHUNK = 0x322 }
 

Protected Member Functions

IOResult write (ISave *isave, bool &b)
 
IOResult read (ILoad *iload, bool &b)
 
- Protected Member Functions inherited from FPMixinInterface
 FPMixinInterface (const FPMixinInterface &rhs)
 
FPMixinInterfaceoperator= (const FPMixinInterface &rhs)
 
- Protected Member Functions inherited from FPInterface
virtual FPStatus _dispatch_fn (FunctionID fid, TimeValue t, FPValue &result, FPParams *p)
 

Protected Attributes

bool mNoExposure
 
bool mInvertSelfIllum
 
bool mInvertReflect
 
bool mInvertRefract
 
- Protected Attributes inherited from FPMixinInterface
Tab< InterfaceNotifyCallback * > * interfaceNotifyCBs
 

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...
 
- Static Public Attributes inherited from FPInterface
static CoreExport FPInterfaceDesc nullInterface
 

Member Enumeration Documentation

anonymous enum
Enumerator
kGetNoExposureControl 
kSetNoExposureControl 
kGetInvertSelfIllum 
kSetInvertSelfIllum 
kGetInvertReflect 
kSetInvertReflect 
kGetInvertRefract 
kSetInvertRefract 
185  {
190  kGetInvertReflect = 4,
191  kSetInvertReflect = 5,
192  kGetInvertRefract = 6,
194  };
Definition: expmtlControl.h:188
Definition: expmtlControl.h:189
Definition: expmtlControl.h:190
Definition: expmtlControl.h:187
Definition: expmtlControl.h:193
Definition: expmtlControl.h:191
Definition: expmtlControl.h:186
Definition: expmtlControl.h:192
anonymous enum
protected
Enumerator
DATA_CHUNK 
339  {
340  DATA_CHUNK = 0x322
341  };
Definition: expmtlControl.h:340

Constructor & Destructor Documentation

196  :
197  mNoExposure(false),
198  mInvertSelfIllum(false),
199  mInvertReflect(false),
200  mInvertRefract(false) {}
bool mInvertSelfIllum
Definition: expmtlControl.h:347
bool mInvertRefract
Definition: expmtlControl.h:349
bool mInvertReflect
Definition: expmtlControl.h:348
bool mNoExposure
Definition: expmtlControl.h:346

Member Function Documentation

BOOL GetNoExposure ( ) const
inline
Remarks
Returns the NoExposure property. If this returns true, the shaded output of the material is NOT processed by the exposure control. When the property is false the shaded output is processed by the exposure control. This is useful for materials that aren't interacting with lighting that want specific RGB values to end up in the rendered image.
Returns
true if the material should NOT be processed by the exposure control.
220 { return mNoExposure; }
bool mNoExposure
Definition: expmtlControl.h:346
virtual void SetNoExposure ( BOOL  on)
inlinevirtual
Remarks
Sets the NoExposure property. If this is set to true, the shaded output of the material is NOT processed by the exposure control. When the property is false the shaded output is processed by the exposure control. This is useful for materials that aren't interacting with lighting that want specific RGB values to end up in the rendered image.
Parameters
on- if true the material should have no exposure
229 { mNoExposure = on != 0; }
bool mNoExposure
Definition: expmtlControl.h:346
BOOL GetInvertSelfIllum ( ) const
inline
Remarks
Gets the InvertSelfIllum property: When this property is true, the self-illumination portion of the shaded output is converted from RGB to a physical value, so that the physical value gives the original RGB value when processed by the exposure control. When the property is false the self-illumination value is converted by multiplying by the physical scale. This is useful if the self-illumination value is a RGB value that you want preserved, but you also want lighting to interact with the material.
Returns
the value of Invert Self Illumination property
240 { return mInvertSelfIllum; }
bool mInvertSelfIllum
Definition: expmtlControl.h:347
virtual void SetInvertSelfIllum ( BOOL  on)
inlinevirtual
Remarks
Sets the InvertSelfIllum property: When this property is true, the self-illumination portion of the shaded output is converted from RGB to a physical value, so that the physical value gives the original RGB value when processed by the exposure control. When the property is false the self-illumination value is converted by multiplying by the physical scale. This is useful if the self-illumination value is a RGB value that you want preserved, but you also want lighting to interact with the material.
Parameters
on- the new value of Invert Self Illumination property
251 { mInvertSelfIllum = on != 0; }
bool mInvertSelfIllum
Definition: expmtlControl.h:347
BOOL GetInvertReflect ( ) const
inline
Remarks
Gets the InvertReflect property: When this property is true, the reflection map portion of the shaded output is converted from RGB to a physical value so that the physical value gives the original RGB value when processed by the exposure control. When the property is false the reflection map value is converted by multiplying by the physical scale. This is useful if the reflection value is not being calculated by the renderer from the scene.
Returns
the state of the InvertReflect property
261 { return mInvertReflect; }
bool mInvertReflect
Definition: expmtlControl.h:348
virtual void SetInvertReflect ( BOOL  on)
inlinevirtual
Remarks
Sets the InvertReflect property: When this property is true, the reflection map portion of the shaded output is converted from RGB to a physical value so that the physical value gives the original RGB value when processed by the exposure control. When the property is false the reflection map value is converted by multiplying by the physical scale. This is useful if the reflection value is not being calculated by the renderer from the scene.
Parameters
on- the new state of the InvertReflect property
271 { mInvertReflect = on != 0; }
bool mInvertReflect
Definition: expmtlControl.h:348
BOOL GetInvertRefract ( ) const
inline
Remarks
Gets the InvertRefract property: When this property is true, the refraction map portion of the shaded output is converted from RGB to a physical value so that the physical value gives the original RGB value when processed by the exposure control. When the property is false the refraction map value is converted by multiplying by the physical scale. This is useful if the reflection value is not being calculated by the renderer from the scene.
Returns
the state of the InvertRefract property
281 { return mInvertRefract; }
bool mInvertRefract
Definition: expmtlControl.h:349
virtual void SetInvertRefract ( BOOL  on)
inlinevirtual
Remarks
Sets the InvertRefract property: When this property is true, the refraction map portion of the shaded output is converted from RGB to a physical value so that the physical value gives the original RGB value when processed by the exposure control. When the property is false the refraction map value is converted by multiplying by the physical scale. This is useful if the reflection value is not being calculated by the renderer from the scene.
Parameters
on- the new state of the InvertReflect property
291 { mInvertRefract = on != 0; }
bool mInvertRefract
Definition: expmtlControl.h:349
ULONG isNoExposure ( ) const
inline
293 { return mNoExposure ? MTLREQ_NOEXPOSURE : 0; }
bool mNoExposure
Definition: expmtlControl.h:346
#define MTLREQ_NOEXPOSURE
Do not do the tone-op (ie, for matte/shadow material, etc)
Definition: MtlBase.h:119
bool isInvertSelfIllum ( ) const
inline
294 { return !mNoExposure & mInvertSelfIllum; }
bool mInvertSelfIllum
Definition: expmtlControl.h:347
bool mNoExposure
Definition: expmtlControl.h:346
bool isInvertReflect ( ) const
inline
295 { return !mNoExposure & mInvertReflect; }
bool mInvertReflect
Definition: expmtlControl.h:348
bool mNoExposure
Definition: expmtlControl.h:346
bool isInvertRefract ( ) const
inline
296 { return !mNoExposure & mInvertRefract; }
bool mInvertRefract
Definition: expmtlControl.h:349
bool mNoExposure
Definition: expmtlControl.h:346
IOResult Save ( ISave isave)
inline
Remarks
Save the plugin parameters to disk.
This is implemented by the system to save the exposure parameters, any child classes that override this function should explicitly call the parent classes Save. An example of how to do this is as follows
MyMaterial::Save(ISave* isave) {
// Do my saving here
isave->BeginChunk(PARENT_DATA_CHUNK);
isave->EndChunk();
}
The ExposureMaterialControl implementation is as follows
353 {
354  isave->BeginChunk(DATA_CHUNK);
355  IOResult res;
356  if ((res = write(isave, mNoExposure)) == IO_OK
357  && (res = write(isave, mInvertSelfIllum)) == IO_OK
358  && (res = write(isave, mInvertReflect)) == IO_OK)
359  res = write(isave, mInvertRefract);
360  isave->EndChunk();
361  return res;
362 }
IOResult write(ISave *isave, bool &b)
Definition: expmtlControl.h:385
bool mInvertSelfIllum
Definition: expmtlControl.h:347
bool mInvertRefract
Definition: expmtlControl.h:349
bool mInvertReflect
Definition: expmtlControl.h:348
virtual void BeginChunk(USHORT id)=0
The result was acceptable - no errors.
Definition: maxtypes.h:273
bool mNoExposure
Definition: expmtlControl.h:346
Definition: expmtlControl.h:340
virtual void EndChunk()=0
IOResult
Definition: maxtypes.h:270
IOResult Load ( ILoad iload)
inline
Remarks
Load the plugin parameters.
This is implemented by the system to load the exposure parameters, any child classes that override this function should explicitly call the parent classes Load. An example of how to do this is as follows
MyMaterial::Load(ILoad* iload) {
IOResult res;
USHORT id;
while (IO_OK==(res=iload->OpenChunk())) {
switch(id = iload->CurChunkID()) {
// Any other data chunks need to go here too
case PARENT_DATA_CHUNK:
break;
}
iload->CloseChunk();
if (res!=IO_OK)
return res;
}
return IO_OK;
}
The ExposureMaterialControl implementation is as follows
365 {
366  IOResult res;
367  USHORT id;
368  while (IO_OK==(res=iload->OpenChunk())) {
369  switch(id = iload->CurChunkID()) {
370  case DATA_CHUNK:
371  if ((res = read(iload, mNoExposure)) == IO_OK
372  && (res = read(iload, mInvertSelfIllum)) == IO_OK
373  && (res = read(iload, mInvertReflect)) == IO_OK)
374  res = read(iload, mInvertRefract);
375  break;
376  }
377 
378  iload->CloseChunk();
379  if (res!=IO_OK)
380  return res;
381  }
382  return IO_OK;
383 }
bool mInvertSelfIllum
Definition: expmtlControl.h:347
virtual USHORT CurChunkID()=0
virtual IOResult OpenChunk()=0
bool mInvertRefract
Definition: expmtlControl.h:349
bool mInvertReflect
Definition: expmtlControl.h:348
virtual IOResult CloseChunk()=0
The result was acceptable - no errors.
Definition: maxtypes.h:273
IOResult read(ILoad *iload, bool &b)
Definition: expmtlControl.h:394
bool mNoExposure
Definition: expmtlControl.h:346
Definition: expmtlControl.h:340
IOResult
Definition: maxtypes.h:270
IOResult write ( ISave isave,
bool &  b 
)
inlineprotected
386 {
387  DWORD n;
388  IOResult res = isave->Write(&b, sizeof(b), &n);
389  if (res != IO_OK)
390  return res;
391  return n == sizeof(b) ? IO_OK : IO_ERROR;
392 }
IOResult Write(const char *buf, ULONG nbytes, ULONG *nwrit)
Definition: ioapi.h:230
The result was acceptable - no errors.
Definition: maxtypes.h:273
Returned when an error occurred.
Definition: maxtypes.h:281
IOResult
Definition: maxtypes.h:270
IOResult read ( ILoad iload,
bool &  b 
)
inlineprotected
395 {
396  DWORD n;
397  IOResult res = iload->Read(&b, sizeof(b), &n);
398  if (res != IO_OK)
399  return res;
400  return n == sizeof(b) ? IO_OK : IO_ERROR;
401 }
The result was acceptable - no errors.
Definition: maxtypes.h:273
Returned when an error occurred.
Definition: maxtypes.h:281
IOResult Read(const char *buf, ULONG nbytes, ULONG *nwrit)
Definition: ioapi.h:517
IOResult
Definition: maxtypes.h:270

Member Data Documentation

bool mNoExposure
protected
bool mInvertSelfIllum
protected
bool mInvertReflect
protected
bool mInvertRefract
protected