⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tsmesh.h

📁 五行MMORPG引擎系统V1.0
💻 H
字号:
//-----------------------------------------------------------------------------
// Torque Game Engine
// Copyright (C) GarageGames.com, Inc.
//-----------------------------------------------------------------------------

#ifndef _TSMESH_H_
#define _TSMESH_H_

#ifndef _PLATFORM_H_
#include "platform/platform.h"
#endif
#ifndef _STREAM_H_
#include "core/stream.h"
#endif
#ifndef _MMATH_H_
#include "math/mMath.h"
#endif
#ifndef _TVECTOR_H_
#include "core/tVector.h"
#endif
#ifndef _MATERIALLIST_H_
#include "dgl/materialList.h"
#endif
#ifndef _ABSTRACTPOLYLIST_H_
#include "collision/abstractPolyList.h"
#endif

// when working with 3dsmax, we want some things to be vectors that otherwise
// are pointers to non-resizeable blocks of memory
#if defined(TORQUE_LIB)
#define ToolVector Vector
#else
template<class A> class ToolVector
{
   public:
      A * addr;
      U32 sz;
      void increment(U32 p = 1) { sz += p; }
      void decrement(U32 p = 1) { sz -= p; }
      U32 size() const { return sz; }
      bool empty() const { return sz==0; }
      A & operator[](U32 idx) { return addr[idx]; }
      A const & operator[](U32 idx) const { return addr[idx]; }
      A * address() { return addr; }
      void set(void * _addr, U32 _sz) { addr = (A*)_addr; sz = _sz; }
};
#endif

class TSMaterialList;
class TSShapeInstance;
struct RayInfo;
class ConvexFeature;

struct TSDrawPrimitive
{
   enum
   {
      Triangles    = 0 << 30, ///< bits 30 and 31 index element type
      Strip        = 1 << 30, ///< bits 30 and 31 index element type
      Fan          = 2 << 30, ///< bits 30 and 31 index element type
      Indexed      = BIT(29), ///< use glDrawElements if indexed, glDrawArrays o.w.
      NoMaterial   = BIT(28), ///< set if no material (i.e., texture missing)
      MaterialMask = ~(Strip|Fan|Triangles|Indexed|NoMaterial),
      TypeMask     = Strip|Fan|Triangles
   };

   S16 start;
   S16 numElements;
   S32 matIndex;    ///< holds material index & element type (see above enum)
};

class TSMesh
{
  protected:
   U32 meshType;
   Box3F mBounds;
   Point3F mCenter;
   F32 mRadius;

   static F32 overrideFadeVal;

  public:

   enum
   {
      /// types...
      StandardMeshType = 0,
      SkinMeshType     = 1,
      DecalMeshType    = 2,
      SortedMeshType   = 3,
      NullMeshType     = 4,
      TypeMask = StandardMeshType|SkinMeshType|DecalMeshType|SortedMeshType|NullMeshType,

      /// flags (stored with meshType)...
      Billboard = BIT(31), HasDetailTexture = BIT(30),
      BillboardZAxis = BIT(29), UseEncodedNormals = BIT(28),
      FlagMask = Billboard|BillboardZAxis|HasDetailTexture|UseEncodedNormals
   };

   U32 getMeshType() { return meshType & TypeMask; }
   void setFlags(U32 flag) { meshType |= flag; }
   void clearFlags(U32 flag) { meshType &= ~flag; }
   U32 getFlags(U32 flag = 0xFFFFFFFF) { return meshType & flag; }

   const Point3F * getNormals(S32 firstVert);

   S32 parentMesh; ///< index into shapes mesh list
   S32 numFrames;
   S32 numMatFrames;
   S32 vertsPerFrame;

   ToolVector<Point3F> verts;
   ToolVector<Point3F> norms;
   ToolVector<Point2F> tverts;
   ToolVector<TSDrawPrimitive> primitives;
   ToolVector<U8> encodedNorms;
   ToolVector<U16> indices;
   ToolVector<U16> mergeIndices; ///< the last so many verts merge with these
                                 ///< verts to form the next detail level
                                 ///< NOT IMPLEMENTED YET

   /// billboard data
   Point3F billboardAxis;

   /// @name Convex Hull Data
   /// Convex hulls are convex (no angles >= 180

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -