source file REDIMeshShape.h

Go to the documentation of this file.

#ifndef RED_IMESHSHAPE_H
#define RED_IMESHSHAPE_H

#include "REDObject.h"
#include "REDSTL.h"
#include "REDVector3.h"


//******************************************************************************
//*** RED::IMeshShape interface ************************************************
//******************************************************************************

namespace RED
{
  class State;
  class Matrix;
  
  
  // IMeshShape types:
  // -----------------
  
  enum MESH_FORMAT { MFT_ZERO       = 0,
                     MFT_UBYTE      = 1,
                     MFT_SHORT      = 2,
                     MFT_INT        = 3,
                     MFT_FLOAT      = 4,
                     MFT_DOUBLE     = 5,
                     MFT_HALF_FLOAT = 6 };
  
  
  enum MESH_CHANNEL { MCL_VERTEX = 0,
                      MCL_USER0  = 1,
                      MCL_NORMAL = 2,
                      MCL_COLOR  = 3,
                      MCL_USER1  = 4,
                      MCL_USER2  = 5,
                      MCL_USER3  = 6,
                      MCL_USER4  = 7,
                      MCL_TEX0   = 8,
                      MCL_TEX1   = 9,
                      MCL_TEX2   = 10,
                      MCL_TEX3   = 11,
                      MCL_TEX4   = 12,
                      MCL_TEX5   = 13,
                      MCL_TEX6   = 14,
                      MCL_TEX7   = 15,
                      MCL_SIZE   = 16 };
  

  enum MESH_TEXCOORD_MAPPING { MTCM_PLANAR           = 0,
                               MTCM_SPHERICAL        = 1,
                               MTCM_CYLINDRICAL      = 2,
                               MTCM_CYLINDRICAL_CAP  = 3,
                               MTCM_BOX              = 4 };
  

  enum POLYGON_WINDING_RULE { PWR_ODD         = 0,
                              PWR_NON_ZERO    = 1,
                              PWR_POSITIVE    = 2,
                              PWR_NEGATIVE    = 3,
                              PWR_ABS_GEQ_TWO = 4 };
  
  
  // IMeshShape interface:
  // ---------------------
  
  class REDFullExp IMeshShape : public IREDObject
  {
    public:
    
    // Typing information:
    // -------------------
    
    SET_CID( CID_class_REDIMeshShape );
    
    
    // Mesh data query:
    // ----------------
    
    virtual RED_RC GetVerticesCount( int& oCount,
                                     int iStateNumber = -1 ) const = 0;
    
    
    virtual RED_RC GetVertexArray( const void*&      oArray,
                                   int&              oSize,
                                   RED::MESH_FORMAT& oFormat,
                                   int               iStateNumber = -1 ) const = 0;
    
    
    virtual RED_RC GetVertexArray( void*&            oArray,
                                   int&              oSize,
                                   RED::MESH_FORMAT& oFormat,
                                   const RED::State& iState ) = 0;
    
    
    virtual RED_RC GetNormalArray( const void*&      oArray,
                                   int&              oSize,
                                   RED::MESH_FORMAT& oFormat,
                                   int               iStateNumber = -1 ) const = 0;
    
    
    virtual RED_RC GetNormalArray( void*&            oArray,
                                   int&              oSize,
                                   RED::MESH_FORMAT& oFormat,
                                   const RED::State& iState ) = 0;
    
    
    virtual RED_RC GetColorArray( const void*&      oArray,
                                  int&              oSize,
                                  RED::MESH_FORMAT& oFormat,
                                  int               iStateNumber = -1 ) const = 0;
    
    
    virtual RED_RC GetColorArray( void*&            oArray,
                                  int&              oSize,
                                  RED::MESH_FORMAT& oFormat,
                                  const RED::State& iState ) = 0;
    
    
    virtual RED_RC GetTextureArray( const void*&      oArray,
                                    int&              oSize,
                                    RED::MESH_FORMAT& oFormat,
                                    int               iTexNum,
                                    int               iStateNumber = -1 ) const = 0;
    
    
    virtual RED_RC GetTextureArray( void*&            oArray,
                                    int&              oSize,
                                    RED::MESH_FORMAT& oFormat,
                                    int               iTexNum,
                                    const RED::State& iState ) = 0;
    
    
    virtual RED_RC GetUserArray( const void*&      oArray,
                                 int&              oSize,
                                 RED::MESH_FORMAT& oFormat,
                                 int               iUserNum,
                                 int               iStateNumber = -1 ) const = 0;
    
    
    virtual RED_RC GetUserArray( void*&            oArray,
                                 int&              oSize,
                                 RED::MESH_FORMAT& oFormat,
                                 int               iUserNum,
                                 const RED::State& iState ) = 0;
    
    
    virtual RED_RC GetArray( const void*&      oArray, 
                             int&              oSize, 
                             RED::MESH_FORMAT& oFormat,
                             RED::MESH_CHANNEL iChannelId, 
                             int               iStateNumber = -1 ) const = 0;
    
    
    virtual RED_RC GetArray( void*&            oArray, 
                             int&              oSize, 
                             RED::MESH_FORMAT& oFormat,
                             RED::MESH_CHANNEL iChannelId, 
                             const RED::State& iState ) = 0;
    
    
    virtual RED_RC GetArray( const void*&      oData,
                             RED::MESH_CHANNEL iChannelId,
                             int               iStateNumber = -1 ) const = 0;
    
    
    virtual RED_RC GetArray( void*&            oData,
                             RED::MESH_CHANNEL iChannelId,
                             const RED::State& iState ) = 0;
    
    
    virtual RED_RC IsSharedArray( bool&             oShared,
                                  RED::MESH_CHANNEL iChannelId,
                                  int               iStateNumber = -1 ) const = 0;
    
    
    // Mesh indexed triangle list access:
    // ----------------------------------
    
    virtual RED_RC GetTriangles( const int*& oTriIndex,
                                 int&        oTriCount,
                                 int         iStateNumber = -1 ) const = 0;
    
    
    virtual RED_RC GetTriangles( int*&             oTriIndex,
                                 int&              oTriCount,
                                 const RED::State& iState ) = 0;
    
    
    virtual RED_RC GetTrianglesCount( int& oCount,
                                      int  iStateNumber = -1 ) const = 0;
    
    
    virtual RED_RC IsSharedTriangles( bool& oShared,
                                      int   iStateNumber = -1 ) const = 0;
    
    
    virtual RED_RC IsTrianglesAdjacency( bool& oAdjacency,
                                         int   iStateNumber = -1 ) const = 0;
    
    
    // Mesh data setup:
    // ----------------
    
    virtual RED_RC SetArray( RED::MESH_CHANNEL iChannelId,
                             const void*       iData,
                             int               iVerticesCount,
                             int               iSize,
                             RED::MESH_FORMAT  iFormat,
                             const RED::State& iState ) = 0;
    
    
    virtual RED_RC SetSharedArray( RED::MESH_CHANNEL iChannelId,
                                   const void*       iData,
                                   int               iVerticesCount,
                                   int               iSize,
                                   RED::MESH_FORMAT  iFormat,
                                   const RED::State& iState ) = 0;
    
    
    virtual RED_RC SetOwnedArray( RED::MESH_CHANNEL iChannelId,
                                  const void*       iData,
                                  int               iVerticesCount,
                                  int               iSize,
                                  RED::MESH_FORMAT  iFormat,
                                  const RED::State& iState ) = 0;
    
    
    virtual RED_RC DeleteArray( RED::MESH_CHANNEL iChannelId,
                                const RED::State& iState ) = 0;
    
    
    virtual RED_RC DeleteAllArrays( const RED::State& iState ) = 0;
    
    
    // Mesh tessellation setup:
    // ------------------------
    
    virtual RED_RC AddTriangles( const int*      iTriIndex, 
                                 int             iTriCount, 
                                 const RED::State& iState ) = 0;
    
    
    virtual RED_RC AddTrianglesAdjacency( const int*      iTriIndex, 
                                          int             iTriCount, 
                                          const RED::State& iState ) = 0;
    
    
    virtual RED_RC SetTriangle( int iNumTri, 
                                int iP0, 
                                int iP1, 
                                int iP2, 
                                const RED::State& iState ) = 0;
    
    
    virtual RED_RC SetTriangleAdjacency( int iNumTri,
                                         int iV0,
                                         int iV1,
                                         int iV2,
                                         int iV3,
                                         int iV4,
                                         int iV5,
                                         const RED::State& iState ) = 0;
    
    
    virtual RED_RC SetSharedTriangles( const int*        iTriIndex,
                                       int               iTriCount,
                                       const RED::State& iState ) = 0;
    
    
    virtual RED_RC SetOwnedTriangles( const int*        iTriIndex,
                                      int               iTriCount,
                                      const RED::State& iState ) = 0;
    
    
    virtual RED_RC SetSharedTrianglesAdjacency( const int*        iTriIndex,
                                                int               iTriCount,
                                                const RED::State& iState ) = 0;
    
    
    virtual RED_RC SetOwnedTrianglesAdjacency( const int*        iTriIndex,
                                               int               iTriCount,
                                               const RED::State& iState ) = 0;
    
    
    virtual RED_RC DeleteTriangles( const RED::State& iState ) = 0;
    
    
    virtual RED_RC AddStrips( const int*        iStripIndex, 
                              const int*        iStripCount, 
                              int               iStripEntriesCount, 
                              const RED::State& iState ) = 0;
    
    
    virtual RED_RC AddFans( const int*        iFanIndex, 
                            const int*        iFanCount, 
                            int               iFanEntriesCount, 
                            const RED::State& iState ) = 0;
    

    // Primitive shapes creation methods:
    // ----------------------------------
    
    virtual RED_RC Quad( const RED::Vector3& iCenter,
                         float               iHalfSizeX,
                         float               iHalfSizeY,
                         const RED::State&   iState ) = 0;
    
    
    virtual RED_RC Box( const RED::Vector3& iCenter,
                        const RED::Vector3& iHalfSize,
                        const RED::State&   iState ) = 0;
    
    
    virtual RED_RC Sphere( const RED::Vector3& iCenter,
                           float               iRadius,
                           int                 iRDivCount,
                           int                 iHDivCount,
                           const RED::State&   iState ) = 0;
    
    
    virtual RED_RC Cylinder( const RED::Vector3& iCenter,
                             float               iRadius,
                             float               iHalfHeight,
                             int                 iRDivCount,
                             const RED::State&   iState ) = 0;
    
    
    virtual RED_RC Cone( const RED::Vector3& iCenter,
                         float               iRadius,
                         float               iHalfHeight,
                         int                 iRDivCount,
                         const RED::State&   iState ) = 0;
    
    
    virtual RED_RC Torus( const RED::Vector3& iCenter,
                          float               iRadius,
                          float               iRadius2,
                          int                 iDivCount,
                          int                 iDivCount2,
                          const RED::State&   iState ) = 0;

    
    virtual RED_RC Polygon( const RED::Vector< RED::Vector< double > >& iContourList,
                            const RED::State&                           iState ) = 0;
    
    
    virtual RED_RC Polygon( const RED::Vector< RED::Vector< float > >& iContourList,
                            const RED::State&                          iState ) = 0;
    
    
    virtual RED_RC Polygon( RED::Vector< double >&                      oVertexData,
                            const RED::Vector< RED::Vector< double > >& iContourList,
                            const RED::Vector< RED::Vector< double > >& iContourDataList,
                            RED::POLYGON_WINDING_RULE                   iWindingRule,
                            const RED::Vector3&                         iNormal,
                            const RED::State&                           iState ) = 0;
    
    
    virtual RED_RC Polygon( RED::Vector< double >&                      oVertexData,
                            const RED::Vector< RED::Vector< float > >&  iContourList,
                            const RED::Vector< RED::Vector< double > >& iContourDataList,
                            RED::POLYGON_WINDING_RULE                   iWindingRule,
                            const RED::Vector3&                         iNormal,
                            const RED::State&                           iState ) = 0;
    

    // Skeleton related methods:
    // -------------------------

    
    virtual RED_RC AddBone( unsigned int&      oBoneIndex,
                            const RED::Matrix& iNeutralMatrix,
                            int                iParentBone,
                            const RED::String& iName,
                            const RED::State&  iState ) = 0;


    virtual RED_RC GetBonesCount( unsigned int& oCount,
                                  int           iStateNumber = -1 ) const = 0;


    virtual RED_RC SetBoneMatrix( unsigned int       iBoneIndex,
                                  const RED::Matrix& iBoneMatrix,
                                  const RED::State&  iState ) = 0;

    
    virtual RED_RC GetBoneMatrix( const RED::Matrix*& oBoneMatrix,
                                  unsigned int        iBoneIndex,
                                  int                 iStateNumber = -1 ) const = 0;


    virtual RED_RC GetBoneNeutralPose( const RED::Matrix*& oBoneMatrix,
                                       unsigned int        iBoneIndex,
                                       int                 iStateNumber = -1 ) const = 0;


    virtual RED_RC GetBoneParent( int&         oParentIndex,
                                  unsigned int iBoneIndex,
                                  int          iStateNumber = -1 ) const = 0;


    virtual RED_RC GetBoneName( const RED::String*& oBoneName,
                                unsigned int        iBoneIndex,
                                int                 iStateNumber = -1 ) const = 0;


    virtual RED_RC GetBoneChildrenCount( unsigned int& oCount,
                                         unsigned int  iBoneIndex,
                                         int           iStateNumber = -1 ) const = 0;


    virtual RED_RC GetBoneChild( unsigned int& oChildIndex,
                                 unsigned int  iBoneIndex,
                                 unsigned int  iChildIndex,
                                 int           iStateNumber = -1 ) const = 0;


    // Skinning methods:
    // -----------------

    virtual RED_RC SetSkinBonesCount( unsigned int      iSkinBonesCount,
                                      const RED::State& iState ) = 0;
    

    virtual RED_RC GetSkinBonesCount( unsigned int& oSkinBonesCount,
                                      int           iStateNumber = -1 ) const = 0;
    

    virtual RED_RC SetSkinBone( unsigned int       iSkinBoneIndex,
                                unsigned int       iBoneIndex,
                                const RED::Matrix& iInverseReferenceMatrix,
                                const RED::State&  iState ) = 0;
    

    virtual RED_RC GetSkinBone( unsigned int&       oBoneIndex,
                                const RED::Matrix*& oInverseReferenceMatrix,
                                unsigned int        iSkinBoneIndex,
                                int                 iStateNumber = -1 ) const = 0;

    
    virtual RED_RC SetSkinVerticesCount( unsigned int      iSkinVerticesCount,
                                         const RED::State& iState ) = 0;
    
    
    virtual RED_RC GetSkinVerticesCount( unsigned int& oSkinVerticesCount,
                                         int           iStateNumber = -1 ) const = 0; 


    virtual RED_RC SetSkinVertex( unsigned int      iSkinVertexIndex,
                                  unsigned int      iVertexIndex,
                                  const RED::State& iState ) = 0;
    

    virtual RED_RC GetSkinVertex( unsigned int& oVertexIndex,
                                  unsigned int  iSkinVertexIndex,
                                  int           iStateNumber = -1 ) const = 0;


    virtual RED_RC SetBoneInfluencesCount( unsigned int      iSkinVertexIndex,
                                           unsigned int      iBoneInfluencesCount,
                                           const RED::State& iState ) = 0;
    

    virtual RED_RC GetBoneInfluencesCount( unsigned int& oBoneInfluencesCount,
                                           unsigned int  iSkinVertexIndex,
                                           int           iStateNumber = -1 ) const = 0;

    
    virtual RED_RC SetBoneInfluence( unsigned int      iSkinVertexIndex,
                                     unsigned int      iBoneInfluenceIndex,
                                     unsigned int      iSkinBoneIndex,
                                     double            iWeight,
                                     const RED::State& iState ) = 0;
    
    
    virtual RED_RC GetBoneInfluence( unsigned int& oSkinBoneIndex,
                                     double&       oWeight,
                                     unsigned int  iSkinVertexIndex,
                                     unsigned int  iBoneInfluenceIndex,
                                     int           iStateNumber = -1 ) const = 0;

    
    virtual RED_RC InitializeSkinning( const RED::State& iState ) = 0;

    
    virtual RED_RC DoSkinning( const RED::State& iState ) = 0;


    virtual RED_RC ResetSkinning( const RED::State& iState ) = 0;


    virtual RED_RC HasSkinningData( bool& oHasSkinningData,
                                    int   iStateNumber = -1 ) const = 0;


    // Miscellaneous methods:
    // ----------------------
    
    virtual RED_RC ReverseTriangleWinding( const RED::State& iState ) = 0;
    
    
    virtual RED_RC BuildTangents( RED::MESH_CHANNEL iTargetChannel,
                                  RED::MESH_CHANNEL iTexChannel,
                                  const RED::State& iState ) = 0;
    

    virtual RED_RC BuildTextureCoordinates( RED::MESH_CHANNEL          iTargetChannel,
                                            RED::MESH_TEXCOORD_MAPPING iTextureMapping,
                                            const RED::Matrix&         iTransform,
                                            const RED::State&          iState ) = 0;
    
    
    virtual RED_RC BuildEdges( RED::Object*      oEdgeShape,
                               RED::MESH_CHANNEL iTargetVertexChannel,
                               RED::MESH_CHANNEL iSourceVertexChannel,
                               const RED::State& iState ) const = 0;
    
    
    virtual RED_RC BuildContourEdges( RED::Object*      oEdgeShape,
                                      RED::MESH_CHANNEL iTargetVertexChannel,
                                      RED::MESH_CHANNEL iTargetN1Channel,
                                      RED::MESH_CHANNEL iTargetN2Channel,
                                      RED::MESH_CHANNEL iSourceVertexChannel,
                                      const RED::State& iState ) const = 0;
    
    
    virtual RED_RC BuildBorderEdges( RED::Object*      oEdgeShape,
                                     RED::MESH_CHANNEL iTargetVertexChannel,
                                     RED::MESH_CHANNEL iSourceVertexChannel,
                                     const RED::State& iState ) const = 0;
    
    
    virtual RED_RC Shade( RED::MESH_CHANNEL iDestNormalChannel,
                          RED::MESH_FORMAT  iDestNormalFormat,
                          RED::MESH_CHANNEL iSourceVertexChannel,
                          const RED::State& iState ) = 0;
    
    
    virtual RED_RC ShadeTJunction( RED::MESH_CHANNEL iDestNormalChannel,
                                   RED::MESH_FORMAT  iDestNormalFormat,
                                   RED::MESH_CHANNEL iSourceVertexChannel,
                                   int               iLookupDepth,
                                   const RED::State& iState ) = 0;
    
    
    virtual RED_RC Collapse( double            iDistanceTolerance,
                             double            iAngleTolerance,
                             const RED::State& iState,
                             const RED::Vector< RED::MESH_CHANNEL >* iDistanceToleranceChannels = NULL,
                             const RED::Vector< RED::MESH_CHANNEL >* iAngleToleranceChannels = NULL ) = 0;
    
    
    virtual RED_RC BuildCutMesh( RED::Object*                       ioCutMesh,
                                 const RED::Vector< RED::Object* >& ioCutSection,
                                 const RED::Vector< RED::Object* >& ioCutContour,
                                 const RED::Vector< double >&       iPlane,
                                 double                             iTolerance,
                                 const RED::State&                  iState ) const = 0;
    
    
    virtual RED_RC SortPolygons( const RED::Vector3& iDirection,
                                 int                 iTrianglesCount,
                                 const RED::State&   iState ) = 0;
    
    
    virtual RED_RC BuildTrianglesAdjacency( const RED::State& iState ) = 0;
    
    
    virtual RED_RC RemoveTrianglesAdjacency( const RED::State& iState ) = 0;
    
    
    virtual RED_RC CopyFrom( const RED::Object& iMesh, 
                             const RED::State&  iState, 
                             int                iSrcStateNumber = -1 ) = 0;
  };
};


#endif