VedaLibDemo/Object3DText.h

00001 #ifndef COM_M4NKIND_Object3DText_H
00002 #define COM_M4NKIND_Object3DText_H
00003 
00004 #include "Object3DVirtual.h"
00005 #include "PackObjectReference.h"
00006 #include "PackULong_Flags.h"
00007 #include "PackFloatByte_Limits.h"
00008 #include "PackList.h"
00009 #include "PackDynamicFloat.h"
00010 /*!
00011     \class  Scene3D
00012     \ingroup    BaseObjectInherited_VedaLibDemo
00013     \brief Class that stands for a playable 3D Scene defined by a list of objects and their cinematics.
00014     
00015 */
00016 
00017 class Object3DText : public Object3DVirtual
00018 {
00019 /*==================================================================
00020                                 PUBLIC
00021 ==================================================================*/
00022 public:
00023     /*!
00024         \brief  Constructor. There should only be members initialisation there.
00025     */
00026     Object3DText(void);
00027 
00028     /*!
00029         \brief  Class Inheritance Descriptors. Also forces a destructor. See BASEOBJECT_DECLARE_... in .cpp
00030     */
00031     BASEOBJECT_DEFINE_CLASS(Object3DText);
00032 #ifdef _ENGINE_EDITABLE_
00033     /*!
00034         \brief  a GUI could need to play, draw, print, or output from any way, a preview of a 
00035                 created object. This is done with this method. sub classes can implement it (or not) in
00036                 any way, to explicit current shape of an object.<br>
00037 
00038         \param  _frameDate a date, in second, which defines the effect cinematic.
00039         \param  _pPreviewViewPort the viewport to render. Can't be 0L.
00040         \param  _pPreviewConfiguration
00041     */
00042     virtual void ProcessPreview(double _frameDate,VirtualMachine::InternalViewPort *_pPreviewViewPort,const PreviewConfiguration *_pPreviewConfiguration);
00043 #endif
00044     /*!
00045         \brief  Process a real time computing and drawing. Can be extended.
00046         \param  _frameDate a date, in second, which defines the effect cinematic.
00047         \param  _pViewPort description of the viewport where to render.
00048         \param  _rgba red green blue alpha component.
00049         \param  _shapeIndex optional index for multiple shape objects. def to zero.
00050         \param _pModifierList optional ShapeModifierList pointer, to modify objects.
00051     */
00052     virtual void    RenderObject( double _frameDate, 
00053                                     VirtualMachine::InternalViewPort *_pViewPort,
00054                                     const float _rgba[4],
00055                                     unsigned int _shapeIndex=0,
00056                                     ShapeModifierList *_pModifierList=0L );
00057 /*==================================================================
00058                                 PROTECTED
00059 ==================================================================*/
00060 protected:
00061     enum {
00062         //! all lines return are ignored if true:
00063         eFlag_OneLine=1,
00064         //! all words have characters with same time delta.
00065         eFlag_MoveWords=2,
00066         //! letters get a random order
00067         eFlag_RandomOrder=4,
00068         //! all lines are shifted to the center:
00069         //eFlag_Center=8,
00070         //! all lines are shifted to the right:
00071         //eFlag_Right=16,
00072     };
00073     //! draw flags 
00074     PackULong_Flags     mSer_Flags;
00075     //! the alphabet used to draw the text
00076     PackObjectReference mSer_AlphabetRef;
00077     //! the text that define the scene.
00078     PackObjectReference mSer_TextRef;
00079     //! how sould the space width scale.
00080     PackFloatByte_Limits    mSer_InterSpace;
00081     //! how sould the space width scale.
00082     PackFloatByte_Limits    mSer_SpaceWidth;
00083     //! space between lines
00084     PackFloatByte_Limits    mSer_HeightSpace;
00085     //! how sould the height scale.
00086     PackFloatByte_Limits    mSer_HeightScale;
00087 
00088     //! maximum width in which the text is took.
00089     float m_HeightMax;
00090     //! maximum height in which the text is took.
00091     float m_WidthMax;
00092     typedef struct
00093     {
00094         float   m_xx,m_yy,m_zz;
00095         float   m_sx,m_sy,m_sz;
00096         float   m_zrotate;
00097         float   m_rgba[4];
00098         float   m_TimeDelta;
00099     } LetterState ;
00100     /*
00101         \class TextShadeComplex
00102         \brief  nested class. define a text shade.
00103     */
00104     class TextShadeComplex : public PackStruct
00105     { public:
00106         // constructor:
00107         TextShadeComplex();
00108         enum {
00109             bTSF_ShadeAlpha=1,
00110             bTSF_CharRelative=2,
00111         };
00112         //! Flags
00113         PackULong_Flags         mSer_Flags;
00114         PackFloat               mSer_BeginAt;
00115         PackFloat               mSer_EndAt;
00116         //! comin ratio.0= letter by letter, 1= all text go in the same time.
00117         PackFloatByte_Limits    mSer_OutGoingLetterRatio;
00118         PackDynamicFloat        mSer_EquForPosition;
00119         PackDynamicFloat        mSer_EquForRotation;
00120         PackDynamicFloat        mSer_EquForScale;
00121         PackDynamicFloat        mSer_EquForColor;
00122     };
00123     /*
00124         \class PackDynamicTextShadeIn
00125         \brief  the multiple shape a shade can take.
00126     */
00127     class PackDynamicTextShadeIn : public PackDynamicType
00128     { public:
00129         //! constructor
00130         PackDynamicTextShadeIn();
00131         //! first shape
00132         TextShadeComplex    mSer_TextShade;
00133         void    ComputeShadeIn(LetterState &_lstate,double _framedate);
00134         //!
00135     protected:
00136         void    ComputeShade(LetterState &_lstate,double _framedate,float characterRate);
00137     };
00138     /*
00139         \class PackDynamicTextShadeOut
00140         \brief  the multiple shape a shade can take.
00141     */
00142     class PackDynamicTextShadeOut : public PackDynamicTextShadeIn
00143     { public:
00144         //! constructor
00145         PackDynamicTextShadeOut();
00146         //!
00147         void    ComputeShadeOut(LetterState &_lstate,double _framedate);
00148     };
00149     /*
00150         \class PackDynamicTextShadeOut
00151         \brief  the multiple shape a shade can take.
00152     */
00153     class PackDynamicTextShade : public PackDynamicType
00154     { public:
00155 
00156     };
00157     /*!
00158         \brief  static method passed to the list to create new elements.
00159         \return a new  object.
00160     */
00161     //static BaseType *NewTextShade();
00162 
00163     //! shade to apply to make letter come in:
00164     PackDynamicTextShadeIn  mSer_ShadeIn;
00165     //! shade to apply to make letter go out:
00166     PackDynamicTextShadeOut mSer_ShadeOut;
00167     //!  shade to apply all the time:
00168     PackDynamicTextShade    mSer_Shade;
00169 
00170     /*!
00171         \brief  Method that really build the object using the serializable parameters.
00172                 Close() should close everything opened by CreateInternal().
00173     */
00174     virtual bool CreateInternal(void);
00175 
00176 #ifdef _ENGINE_EDITABLE_
00177     /*!
00178         \brief  that closes everything. Still, the object exist and can be rebuild the same using Create()
00179     */
00180     virtual void    CloseInternal(void);
00181 #endif
00182     /*!
00183         \brief  private nested class: precalculation.
00184     */
00185     class CharacterBase {
00186     public:
00187         //! shape index in the font.
00188         unsigned int m_ShapeIndex; 
00189         //! final position in text's space:
00190         float   m_xx;
00191         float   m_yy;
00192         float   m_zz;
00193         //! final scale in text's space:
00194         float   m_sx;
00195         float   m_sy;
00196         float   m_sz;
00197         //! time delta ratio in the text:
00198         float   m_TimeDelta;
00199     };
00200     //! precalculation of final position for all characters:
00201     CharacterBase   *m_pCharacterBase;
00202     //!
00203     unsigned int    m_CharacterUsed;
00204 
00205 };
00206 
00207 #endif

      /\/\        4         N         k         !         N         D
                      _______  _ __ ___  _____            ___ _ _  ____
     ___________  __//___   /________  |/    / ___________\_______/    \
    /   _   _   \/   _     /    _   /      _/_/____/    _       __     /
   /    /   /       /     /    /    \      \/     /    /    \   \     /
  \\___/___/___/    ¯    _____/_____/       ______\___/_____/\________\\
               \________/_ ___ __ l____\      /elD!  
                 http://www.m4nkind.com \____/