Public Member Functions

XYZGen Class Reference

This reference page is linked to from the following overview topics: Principal Classes for Materials and Textures.


Search for all occurrences

Detailed Description

See also:
Class MtlBase, Class ShadeContext, Class Point3.

Description:
This class generates Point3 coordinates based on the ShadeContext. A reference to one of these is referenced by all 3D texture maps. XYZGen does for 3D Texmaps what UVGen does for 2D Texmaps. It puts up the 3D "Coordinates" rollup, and supplies the 3D Texmap with transformed 3D coordinates. All methods of this class are implemented by the system.

#include <imtl.h>

Inheritance diagram for XYZGen:
Inheritance graph
[legend]

List of all members.

Public Member Functions

virtual void  GetXYZ (ShadeContext &sc, Point3 &p, Point3 &dp)=0
SClass_ID  SuperClassID ()
  Retrieves a constant representing the type of the plugin.
virtual void  SetRollupOpen (BOOL open)=0
virtual BOOL  GetRollupOpen ()=0
virtual BOOL  IsStdXYZGen ()
virtual void  GetBumpDP (ShadeContext &sc, Point3 *dP)
CoreExport SvGraphNodeReference  SvTraverseAnimGraph (IGraphObjectManager *gom, Animatable *owner, int id, DWORD flags)
CoreExport MSTR  SvGetName (IGraphObjectManager *gom, IGraphNode *gNode, bool isBeingEdited)

Member Function Documentation

virtual void GetXYZ ( ShadeContext sc,
Point3 p,
Point3 dp 
) [pure virtual]
Remarks:
This method retrieves coordinates and derivatives for antialiasing. It returns the coordinates in the "Object Coordinate System", scaled and rotated by the parameters given in the Coordinates rollup. The default transformation is the identity transform, so you just get Object coordinates. For instance, if you have a sphere of radius 100, you will get coordinates ranging from -100 to +100.

A developer might wonder why 3ds Max don't use some normalized coordinates space. This was considered, but it has some real problems. Say you make something by assembling several boxes, of varying sizes, and then apply a wood texture to the whole thing. You want the wood texture to be at the same scale for all the pieces, not smaller on the smaller pieces, and thus that doesn't work.
Parameters:
ShadeContext& sc

Describes the properties of the point to be shaded.

Point3& p

The 3D point is returned here.

Point3& dp

The derivative of the 3D point is returned here.
SClass_ID SuperClassID ( ) [inline, virtual]

Retrieves a constant representing the type of the plugin.

Returns:
A super class id that uniquely identifies the type (category) of the plugin. Note that several plugin classes can be of the same type, thus return the same super class id. Plugins are uniquely identified by their class ids. List of Super Class IDs.
See also:
SClass_ID

Reimplemented from ReferenceTarget.

{ return XYZGEN_CLASS_ID; }
virtual void SetRollupOpen ( BOOL  open ) [pure virtual]
Remarks:
Sets the XYZGen rollup state to open or closed.
Parameters:
BOOL open

TRUE for open; FALSE for closed.
virtual BOOL GetRollupOpen ( ) [pure virtual]
Remarks:
Returns the open or closed state of the XYZGen rollup.
Returns:
TRUE is open; FALSE is closed.
virtual BOOL IsStdXYZGen ( ) [inline, virtual]

Reimplemented in StdXYZGen.

{ return FALSE; } // class StdXYZGen implements this to return TRUE
virtual void GetBumpDP ( ShadeContext sc,
Point3 dP 
) [inline, virtual]
Remarks:
This method returns the transformed bump unit vectors for 3D bump mapping. The 3D textures need to use these in computing the gradient.
Parameters:
ShadeContext& sc

Describes the properties of the point to be shaded.

Point3* dP

The 3 unit vectors for computing differentials are returned here.
Default Implementation:
{}
Sample Code:
Here is a typical use of XYZGen->GetBumpDP() to compute the bump mapping for a 3D texture:

            Point3 Marble::EvalNormalPerturb(ShadeContext& sc) {
                float del,d;
                Point3 p,dp;
                if (!sc.doMaps) 
                    return Point3(0,0,0);
                if (gbufID) 
                    sc.SetGBufferID(gbufID);
                xyzGen->GetXYZ(sc,p,dp);
                if (size==0.0f) 
                    size=.0001f;
                p *= FACT/size;
                d = MarbleFunc(p);
                del = 20.0f;
                Point3 np;
                Point3 M[3];
                xyzGen->GetBumpDP(sc,M);
                np.x = (MarbleFunc(p+del*M[0]) - d)/del;
                np.y = (MarbleFunc(p+del*M[1]) - d)/del;
                np.z = (MarbleFunc(p+del*M[2]) - d)/del;
                np *= 100.0f;
                return sc.VectorFrom(np,REF_OBJECT);
            }
{}; // returns 3 unit vectors for computing differentials
CoreExport SvGraphNodeReference SvTraverseAnimGraph ( IGraphObjectManager gom,
Animatable owner,
int  id,
DWORD  flags 
) [virtual]
Remarks:
This method is available in release 3.0 and later only.

This method traverses the graph of objects in the 3ds Max scene, adding desired objects to the schematic view. Developers can specialize this behaviour by overriding this method and adding whatever objects are interesting to the schematic view. Objects are added to the schematic view by calling IGraphObjectManager::AddAnimatable(...). Reference lines are added to the schematic view by calling IGraphObjectManager::AddReference(...). Implementers of this method should call it recursively to process other objects in the scene.

See Class IGraphObjectManager.
Parameters:
gom Points to the schematic view window manager.
owner The owning animatable.
id This is usually the sub-anim number (but can actually be any value the developer chooses).
flags See List of Schematic %View AddAnimatable Flags.
Returns:
A SvGraphNodeReference object.

Reimplemented from MtlBase.

CoreExport MSTR SvGetName ( IGraphObjectManager gom,
IGraphNode gNode,
bool  isBeingEdited 
) [inline, virtual]
Remarks:
Returns the name of the object as it appears in the schematic view.
Parameters:
gom Points to the schematic view window manager.
gNode Points to this node in the schematic view.
isBeingEdited TRUE if the item is being edited; FALSE if not.
Default Implementation:
        {
            Animatable *owner;
            int subNum;
            MSTR name;
            owner = gNode->GetOwner();
            subNum = gNode->GetID();
            name = owner->SubAnimName(subNum);
            return name;
        }

Reimplemented from MtlBase.

        {
             return Animatable::SvGetName(gom, gNode, isBeingEdited);
          }

XYZGen XYZGen XYZGen XYZGen XYZGen XYZGen XYZGen XYZGen XYZGen XYZGen
XYZGen XYZGen XYZGen XYZGen XYZGen XYZGen XYZGen XYZGen XYZGen XYZGen