📄 object.h
字号:
virtual float GetEnvRange(TimeValue t, int which, Interval& valid = Interval(0,0))=0;
virtual void SetEnvDisplay(BOOL b, int notify=TRUE)=0;
virtual BOOL GetEnvDisplay(void)=0;
virtual void RenderApertureChanged(TimeValue t)=0;
virtual void UpdateTargDistance(TimeValue t, INode* inode) {}
};
/*-------------------------------------------------------------------
LightObject:
---------------------------------------------------------------------*/
#define LIGHT_ATTEN_START 0
#define LIGHT_ATTEN_END 1
struct LightState {
LightType type;
Matrix3 tm;
Color color;
float intens; // multiplier value
float hotsize;
float fallsize;
int useNearAtten;
float nearAttenStart;
float nearAttenEnd;
int useAtten;
float attenStart;
float attenEnd;
int shape;
float aspect;
BOOL overshoot;
BOOL shadow;
BOOL on; // light is on
BOOL affectDiffuse;
BOOL affectSpecular;
BOOL ambientOnly; // affect only ambient component
DWORD extra;
};
class LightDesc;
class RendContext;
// This is a callback class that can be given to a ObjLightDesc
// to have a ray traced through the light volume.
class LightRayTraversal {
public:
// This is called for every step (return FALSE to halt the integration).
// t0 and t1 define the segment in terms of the given ray.
// illum is the light intensity over the entire segment. It can be
// assumed that the light intensty is constant for the segment.
virtual BOOL Step(float t0, float t1, Color illum, float distAtten)=0;
};
// Flags passed to TraverseVolume
#define TRAVERSE_LOWFILTSHADOWS (1<<0)
#define TRAVERSE_HIFILTSHADOWS (1<<1)
#define TRAVERSE_USESAMPLESIZE (1<<2)
// A light must be able to create one of these to give to the renderer.
// The Illuminate() method (inherited from LightDesc) is called by the renderer
// to illuminate a surface point.
class ObjLightDesc : public LightDesc {
public:
// This data will be set up by the default implementation of Update()
LightState ls;
INode *inode;
BOOL uniformScale; // for optimizing
Point3 lightPos;
Matrix3 lightToWorld;
Matrix3 worldToLight;
Matrix3 lightToCam; // updated in UpdateViewDepParams
Matrix3 camToLight; // updated in UpdateViewDepParams
int renderNumber; // set by the renderer. Used in RenderInstance::CastsShadowsFrom()
CoreExport ObjLightDesc(INode *n);
CoreExport virtual ~ObjLightDesc();
virtual NameTab* GetExclList() { return NULL; }
// update light state that depends on position of objects&lights in world.
CoreExport virtual int Update(TimeValue t, const RendContext &rc, RenderGlobalContext *rgc, BOOL shadows, BOOL shadowGeomChanged);
// update light state that depends on global light level.
CoreExport virtual void UpdateGlobalLightLevel(Color globLightLevel) {}
// update light state that depends on view matrix.
CoreExport virtual int UpdateViewDepParams(const Matrix3& worldToCam);
// default implementation
CoreExport virtual Point3 LightPosition() { return lightPos; }
// This function traverses a ray through the light volume.
// 'ray' defines the parameter line that will be traversed.
// 'minStep' is the smallest step size that caller requires, Note that
// the callback may be called in smaller steps if they light needs to
// take smaller steps to avoid under sampling the volume.
// 'tStop' is the point at which the traversal will stop (ray.p+tStop*ray.dir).
// Note that the traversal can terminate earlier if the callback returns FALSE.
// 'proc' is the callback object.
//
// attenStart/End specify a percent of the light attenuation distances
// that should be used for lighting durring the traversal.
//
// The shade context passed in should only be used for state (like are
// shadows globaly disabled). The position, normal, etc. serve no purpose.
virtual void TraverseVolume(
ShadeContext& sc,
const Ray &ray, int samples, float tStop,
float attenStart, float attenEnd,
DWORD flags,
LightRayTraversal *proc) {}
};
// Values returned from GetShadowMethod()
#define LIGHTSHADOW_NONE 0
#define LIGHTSHADOW_MAPPED 1
#define LIGHTSHADOW_RAYTRACED 2
class LightObject: public Object {
public:
SClass_ID SuperClassID() { return LIGHT_CLASS_ID; }
int IsRenderable() { return(0);}
virtual void InitNodeName(TSTR& s) { s = _T("Light"); }
// Methods specific to Lights:
virtual RefResult EvalLightState(TimeValue time, Interval& valid, LightState *ls)=0;
virtual ObjLightDesc *CreateLightDesc(INode *n) {return NULL;}
virtual void SetUseLight(int onOff)=0;
virtual BOOL GetUseLight(void)=0;
virtual void SetHotspot(TimeValue time, float f)=0;
virtual float GetHotspot(TimeValue t, Interval& valid = Interval(0,0))=0;
virtual void SetFallsize(TimeValue time, float f)=0;
virtual float GetFallsize(TimeValue t, Interval& valid = Interval(0,0))=0;
virtual void SetAtten(TimeValue time, int which, float f)=0;
virtual float GetAtten(TimeValue t, int which, Interval& valid = Interval(0,0))=0;
virtual void SetTDist(TimeValue time, float f)=0;
virtual float GetTDist(TimeValue t, Interval& valid = Interval(0,0))=0;
virtual void SetConeDisplay(int s, int notify=TRUE)=0;
virtual BOOL GetConeDisplay(void)=0;
virtual int GetShadowMethod() {return LIGHTSHADOW_NONE;}
virtual void SetRGBColor(TimeValue t, Point3& rgb) {}
virtual Point3 GetRGBColor(TimeValue t, Interval &valid = Interval(0,0)) {return Point3(0,0,0);}
virtual void SetIntensity(TimeValue time, float f) {}
virtual float GetIntensity(TimeValue t, Interval& valid = Interval(0,0)) {return 0.0f;}
virtual void SetAspect(TimeValue t, float f) {}
virtual float GetAspect(TimeValue t, Interval& valid = Interval(0,0)) {return 0.0f;}
virtual void SetUseAtten(int s) {}
virtual BOOL GetUseAtten(void) {return FALSE;}
virtual void SetAttenDisplay(int s) {}
virtual BOOL GetAttenDisplay(void) {return FALSE;}
virtual void Enable(int enab) {}
virtual void SetMapBias(TimeValue t, float f) {}
virtual float GetMapBias(TimeValue t, Interval& valid = Interval(0,0)) {return 0.0f;}
virtual void SetMapRange(TimeValue t, float f) {}
virtual float GetMapRange(TimeValue t, Interval& valid = Interval(0,0)) {return 0.0f;}
virtual void SetMapSize(TimeValue t, int f) {}
virtual int GetMapSize(TimeValue t, Interval& valid = Interval(0,0)) {return 0;}
virtual void SetRayBias(TimeValue t, float f) {}
virtual float GetRayBias(TimeValue t, Interval& valid = Interval(0,0)) {return 0.0f;}
virtual int GetUseGlobal() {return 0;}
virtual void SetUseGlobal(int a) {}
virtual int GetShadow() {return 0;}
virtual void SetShadow(int a) {}
virtual int GetShadowType() {return 0;}
virtual void SetShadowType(int a) {}
virtual int GetAbsMapBias() {return 0;}
virtual void SetAbsMapBias(int a) {}
virtual int GetOvershoot() {return 0;}
virtual void SetOvershoot(int a) {}
virtual int GetProjector() {return 0;}
virtual void SetProjector(int a) {}
virtual NameTab* GetExclList() {return NULL;}
virtual BOOL Include() {return FALSE;}
virtual Texmap* GetProjMap() {return NULL;}
virtual void SetProjMap(Texmap* pmap) {}
virtual void UpdateTargDistance(TimeValue t, INode* inode) {}
};
/*-------------------------------------------------------------------
HelperObject:
---------------------------------------------------------------------*/
class HelperObject: public Object {
public:
SClass_ID SuperClassID() { return HELPER_CLASS_ID; }
int IsRenderable() { return(0); }
virtual void InitNodeName(TSTR& s) { s = _T("Helper"); }
virtual int UsesWireColor() { return FALSE; } // TRUE if the object color is used for display
virtual BOOL NormalAlignVector(TimeValue t,Point3 &pt, Point3 &norm) {pt=Point3(0,0,0);norm=Point3(0,0,-1);return TRUE;}
};
/*-------------------------------------------------------------------
ConstObject:
---------------------------------------------------------------------*/
#define GRID_PLANE_NONE -1
#define GRID_PLANE_TOP 0
#define GRID_PLANE_LEFT 1
#define GRID_PLANE_FRONT 2
#define GRID_PLANE_BOTTOM 3
#define GRID_PLANE_RIGHT 4
#define GRID_PLANE_BACK 5
class ConstObject: public HelperObject {
private:
bool m_transient;
public:
ConstObject():m_transient(false){};
// Override this function in HelperObject!
int IsConstObject() { return 1; }
// Methods specific to construction grids:
virtual void GetConstructionTM( TimeValue t, INode* inode, ViewExp *vpt, Matrix3 &tm ) = 0; // Get the transform for this view
virtual void SetConstructionPlane(int which, int notify=TRUE) = 0;
virtual int GetConstructionPlane(void) = 0;
virtual Point3 GetSnaps( TimeValue t ) = 0; // Get snap values
virtual void SetSnaps(TimeValue t, Point3 p) = 0;
virtual BOOL NormalAlignVector(TimeValue t,Point3 &pt, Point3 &norm) {pt=Point3(0,0,0);norm=Point3(0,0,-1);return TRUE;}
//JH 09/28/98 for design ver
bool IsTransient()const {return m_transient;}
void SetTransient(bool state = true) {m_transient = state;}
//JH 11/16/98
virtual void SetExtents(TimeValue t, Point3 halfbox)=0;
virtual Point3 GetExtents(TimeValue t)=0;
//JH 09/28/98 for design ver
// bool IsImplicit()const {return m_implicit;}
// void SetImplicit(bool state = true) {m_implicit = state;}
};
/*-------------------------------------------------------------------
GeomObject: these are the Renderable objects.
---------------------------------------------------------------------*/
class GeomObject: public Object {
public:
virtual void InitNodeName(TSTR& s) { s = _T("Object"); }
SClass_ID SuperClassID() { return GEOMOBJECT_CLASS_ID; }
virtual int IsRenderable() { return(1); }
// If an object creates different meshes depending on the
// particular instance (view-dependent) it should return 1.
virtual int IsInstanceDependent() { return 0; }
// GetRenderMesh should be implemented by all renderable GeomObjects.
// set needDelete to TRUE if the render should delete the mesh, FALSE otherwise
// Primitives that already have a mesh cached can just return a pointer
// to it (and set needDelete = FALSE).
CoreExport virtual Mesh* GetRenderMesh(TimeValue t, INode *inode, View& view, BOOL& needDelete);
// If this returns NULL, then GetRenderMesh will be called
CoreExport virtual PatchMesh* GetRenderPatchMesh(TimeValue t, INode *inode, View& view, BOOL& needDelete);
CoreExport Class_ID PreferredCollapseType();
virtual BOOL CanDoDisplacementMapping() { return 0; }
private:
};
//-- Particle Systems ---------------------------------------------------
// A force field can be applied to a particle system by a SpaceWarp.
// The force field provides a function of position in space, velocity
// and time that gives a force.
// The force is then used to compute an acceleration on a particle
// which modifies its velocity. Typically, particles are assumed to
// to have a normalized uniform mass==1 so the acceleration is F/M = F.
class ForceField {
public:
virtual Point3 Force(TimeValue t,const Point3 &pos, const Point3 &vel, int index)=0;
virtual void DeleteThis() {}
};
// A collision object can be applied to a particle system by a SpaceWarp.
// The collision object checks a particle's position and velocity and
// determines if the particle will colide with it in the next dt amount of
// time. If so, it modifies the position and velocity.
class CollisionObject {
public:
// Check for collision. Return TRUE if there was a collision and the position and velocity have been modified.
virtual BOOL CheckCollision(TimeValue t,Point3 &pos, Point3 &vel, float dt,int index, float *ct=NULL, BOOL UpdatePastCollide=TRUE)=0;
virtual Object *GetSWObject()=0;
};
// Values returned from ParticleCenter()
#define PARTCENTER_HEAD 1 // Particle geometry lies behind the particle position
#define PARTCENTER_CENTER 2 // Particle geometry is centered around particle position
#define PARTCENTER_TAIL 3 // Particle geometry lies in front of the particle position
// The particle system class derived from GeomObject and still has
// GEOMOBJECT_CLASS_ID as its super class.
//
// Given an object, to determine if it is a ParticleObject, call
// GetInterface() with the ID I_PARTICLEOBJ or use the macro
// GetParticleInterface(anim) which returns a ParticleObject* or NULL.
class ParticleObject: public GeomObject {
public:
BOOL IsParticleSystem() {return TRUE;}
virtual void ApplyForceField(ForceField *ff)=0;
virtual BOOL ApplyCollisionObject(CollisionObject *co)=0; // a particle can choose no to support this and return FALSE
// A particle object IS deformable, but does not let itself be
// deformed using the usual GetPoint/SetPoint methods. Instead
// a space warp must apply a force field to deform the particle system.
int IsDeformable() {return TRUE;}
// Particle objects don't actually do a shallow copy and therefore
// cannot be cached.
BOOL CanCacheObject() {return FALSE;}
virtual BOOL NormalAlignVector(TimeValue t,Point3 &pt, Point3 &norm) {pt=Point3(0,0,0);norm=Point3(0,0,-1);return TRUE;}
// These methods provide information about individual particles
virtual Point3 ParticlePosition(TimeValue t,int i) {return Point3(0,0,0);}
virtual Point3 ParticleVelocity(TimeValue t,int i) {return Point3(0,0,0);}
virtual float ParticleSize(TimeValue t,int i) {return 0.0f;}
virtual int ParticleCenter(TimeValue t,int i) {return PARTCENTER_CENTER;}
virtual TimeValue ParticleAge(TimeValue t, int i) {return -1;}
virtual TimeValue ParticleLife(TimeValue t, int i) {return -1;}
// This tells the renderer if the ParticleObject's topology doesn't change over time
// so it can do better motion blur. This means the correspondence of vertex id to
// geometrical vertex must be invariant.
virtual BOOL HasConstantTopology() { return FALSE; }
};
//----------------------------------------------------------------------
/*-------------------------------------------------------------------
ShapeObject: these are the open or closed hierarchical shape objects.
---------------------------------------------------------------------*/
class PolyShape;
class BezierShape;
class MeshCapInfo;
class PatchCapInfo;
class ShapeHierarchy;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -