iSkinPose.h

Go to the documentation of this file.
00001 /**********************************************************************
00002  
00003     FILE: iSkinPose.h
00004 
00005     DESCRIPTION:  Public interface for setting and getting a special,
00006     non-animated, transformation pose, SkinPose.
00007 
00008     CREATED BY: Jianmin Zhao, Discreet
00009 
00010     HISTORY: - created November 09, 2001
00011 
00012  *> Copyright (c) 1998-2001, All Rights Reserved.
00013  **********************************************************************/
00014 
00015 #pragma once
00016 
00017 #include "iFnPub.h"
00018 #include "maxtypes.h"
00019 #include "euler.h"
00020 #include "control.h"
00021 #include "inode.h"
00022 #include "trig.h"
00023 
00024 #define SKINPOSE_INTERFACE Interface_ID(0x66f226de, 0x37ff3962)
00025 
00031 class ISkinPose : public FPMixinInterface {
00032 public:
00033     // Utilities:
00043     static ISkinPose* GetISkinPose(INode& n) {
00044         return static_cast<ISkinPose*>(n.GetInterface(SKINPOSE_INTERFACE)); }
00045 
00052     virtual Point3  SkinPos() const =0;
00060     virtual RotationValue SkinRot() const=0;
00069     virtual ScaleValue SkinScale() const =0;
00076     virtual void    SetSkinPos(const Point3&) =0;
00084     virtual void    SetSkinRot(const RotationValue&) =0;
00085     // Set the skin rotation via Euler angles:
00092     virtual void    SetSkinRot(const Point3&) =0;
00100     virtual void    SetSkinScaleFactors(const Point3&) =0;
00107     virtual void    SetSkinScaleOrient(const Quat&) =0;
00108 
00115     virtual bool    IsSkinPosEnabled() const =0;
00122     virtual bool    IsSkinRotEnabled() const =0;
00129     virtual bool    IsSkinScaleEnabled() const =0;
00140     virtual bool    SkinPoseMode() const =0;
00148     virtual void    EnableSkinPos(bool) =0;
00156     virtual void    EnableSkinRot(bool) =0;
00164     virtual void    EnableSkinScale(bool) =0;
00172     virtual void    SetSkinPoseMode(bool) =0;
00173 
00183     virtual void    SetSkinPose(TimeValue) =0;
00192     virtual void    AssumeSkinPose(TimeValue) =0;
00204     virtual void    TMSetValue(TimeValue, SetXFormPacket&) =0;
00205 
00206     // Derived methods. They are all inline'd at the end of the file.
00207     //
00208     // SkinRotAngles() returns Euler angles of order XYZ.
00214     Point3          SkinRotAngles() const;
00221     Point3          SkinScaleFactors() const;
00228     Quat            SkinScaleOrient() const;
00235     void            SetSkinScale(const ScaleValue& sv);
00242     void            SetSkinRotAngles(const Point3&);
00252     bool            ShowSkinPos() const;
00262     bool            ShowSkinRot() const;
00271     bool            ShowSkinScale() const;
00279     bool            IsACompEnabled() const;
00280 
00288     virtual bool        NeedToSave() const =0;
00299     virtual IOResult    Save(ISave*) const =0;
00310     virtual IOResult    Load(ILoad*) =0;
00318     virtual void        Copy(const ISkinPose&) =0;
00319 
00320     // Used by implementation class:
00332     virtual const void* ObjectOf(void*) const =0;
00344     virtual       void* ObjectOf(void*) =0;
00345 
00346     // Due to FPMixinInterface:
00352     FPInterfaceDesc* GetDesc() { return GetDescByID(SKINPOSE_INTERFACE); }
00353 
00354     // Function publishings:
00355     //
00356     enum FuncID {
00357         kSkinPosGet, kSkinPosSet,
00358         kSkinRotGet, kSkinRotSet,
00359         kSkinScaleGet, kSkinScaleSet,
00360         kSkinScaleOrientGet, kSkinScaleOrientSet,
00361         // When SkinPosEnabled is false, SkinPoseMode, SetSkinPose, and
00362         // AssumeSkinPose will disregard the position component.
00363         // Similar to SkinRotEnabled and SkinScaleEnabled.
00364         kSkinPosEnabledGet, kSkinPosEnabledSet,
00365         kSkinRotEnabledGet, kSkinRotEnabledSet,
00366         kSkinScaleEnabledGet, kSkinScaleEnabledSet,
00367         kSkinPoseModeGet, kSkinPoseModeSet,
00368         kSetSkinPose,
00369         kAssumeSkinPose
00370     };
00371     #pragma warning(push)
00372     #pragma warning(disable:4238)
00373     BEGIN_FUNCTION_MAP
00374         PROP_FNS(kSkinPosGet, SkinPos, kSkinPosSet, SetSkinPos, TYPE_POINT3_BV)
00375         PROP_FNS(kSkinRotGet, SkinRotAngles, kSkinRotSet, SetSkinRotAngles, TYPE_POINT3_BV)
00376         PROP_FNS(kSkinScaleGet, SkinScaleFactors, kSkinScaleSet, SetSkinScaleFactors, TYPE_POINT3_BV)
00377         PROP_FNS(kSkinScaleOrientGet, SkinScaleOrient, kSkinScaleOrientSet, SetSkinScaleOrient, TYPE_QUAT_BV)
00378         PROP_FNS(kSkinPosEnabledGet, IsSkinPosEnabled, kSkinPosEnabledSet, EnableSkinPos, TYPE_bool)
00379         PROP_FNS(kSkinRotEnabledGet, IsSkinRotEnabled, kSkinRotEnabledSet, EnableSkinRot, TYPE_bool)
00380         PROP_FNS(kSkinScaleEnabledGet, IsSkinScaleEnabled, kSkinScaleEnabledSet, EnableSkinScale, TYPE_bool)
00381         PROP_FNS(kSkinPoseModeGet, SkinPoseMode, kSkinPoseModeSet, SetSkinPoseMode, TYPE_bool)
00382         VFNT_0(kSetSkinPose, SetSkinPose)
00383         VFNT_0(kAssumeSkinPose, AssumeSkinPose)
00384     END_FUNCTION_MAP
00385     #pragma warning(pop)
00386 };
00387 
00388 // inlines for derived methods
00389 //
00390 inline Point3 ISkinPose::SkinRotAngles() const
00391 {
00392     return SkinRot().Euler() * RAD_TO_DEG;
00393 }
00394 
00395 inline Point3 ISkinPose::SkinScaleFactors() const
00396 {
00397     return SkinScale().s;
00398 }
00399 
00400 inline Quat ISkinPose::SkinScaleOrient() const
00401 {
00402     return SkinScale().q;
00403 }
00404 
00405 inline void ISkinPose::SetSkinScale(const ScaleValue& sv)
00406 {
00407     SetSkinScaleFactors(sv.s);
00408     SetSkinScaleOrient(sv.q);
00409 }
00410 
00411 inline void ISkinPose::SetSkinRotAngles(const Point3& p)
00412 {
00413     SetSkinRot(p * DEG_TO_RAD);
00414 }
00415 
00416 inline bool ISkinPose::ShowSkinPos() const
00417 {
00418     return SkinPoseMode() && IsSkinPosEnabled();
00419 }
00420 
00421 inline bool ISkinPose::ShowSkinRot() const
00422 {
00423     return SkinPoseMode() && IsSkinRotEnabled();
00424 }
00425 
00426 inline bool ISkinPose::ShowSkinScale() const
00427 {
00428     return SkinPoseMode() && IsSkinScaleEnabled();
00429 }
00430 
00431 inline bool ISkinPose::IsACompEnabled() const
00432 {
00433     return (IsSkinPosEnabled() || IsSkinRotEnabled() || IsSkinScaleEnabled());
00434 }
00435