2 #include "BlockEngine/BlockCoordinate.h" 3 #include "math/ShapeAABB.h" 4 #include "BMaxFrameNode.h" 5 #include "ParaXModel/ParaXModel.h" 11 typedef TiXmlDocument BMaxXMLDocument;
12 typedef TiXmlElement BMaxXMLElement;
13 typedef TiXmlNode BMaxXMLNode;
21 struct ModelAnimation;
23 class BMaxAnimGenerator;
34 TransparentBlockId = 118,
38 BlockModelBlockId = 254,
41 BMaxParser(
const char* pBuffer, int32 nSize,
const char* filename = NULL,
BMaxParser* pParent = NULL);
44 CParaXModel* ParseParaXModel(uint32 nMaxTriangleCount);
46 const std::string& GetFilename()
const;
47 void SetFilename(
const std::string& val);
52 int GetAnimationsCount();
53 BMaxParser* GetParent()
const {
return m_pParent; }
54 void SetParent(
BMaxParser* val) { m_pParent = val; }
56 void SetAutoScale(
bool value);
58 const Vector3& GetCenterPos()
const;
60 void MergeCoplanerBlockFace();
62 void FindCoplanerFace(
BMaxNode* node, uint32 nFaceIndex);
63 void FindNeighbourFace(
Rectangle *rectangle, uint32 i, uint32 nFaceIndex);
65 void CalculateLod(uint32 nMaxTriangleCount);
66 void GetLodTable(uint32 faceCount, vector<uint32>&lodTable);
68 void CalculateAABB(vector<BMaxNodePtr>&nodes);
69 void CalculateLodNode(map<int64, BMaxNodePtr> &nodeMap,
int x,
int y,
int z);
71 inline uint64 GetNodeIndex(uint16 x, uint16 y, uint16 z)
73 return (uint64)x + ((uint64)z << 16) + ((uint64)y << 32);
76 BMaxNode* GetBMaxNode(
int x,
int y,
int z);
78 inline BMaxNode* GetNode(uint16 x, uint16 y, uint16 z)
80 uint64 index = GetNodeIndex(x, y, z);
81 auto iter = m_nodes.find(index);
82 return (iter != m_nodes.end()) ? iter->second.get() : NULL;
84 inline BMaxNode* GetNodeByIndex(int64 index)
86 auto iter = m_nodes.find(index);
87 return (iter != m_nodes.end()) ? iter->second.get() : NULL;
91 void Load(
const char* pBuffer, int32 nSize);
92 void ParseBlocks(BMaxXMLDocument& doc);
93 void ParseBlocks_Internal(
const char* value);
95 void ParseVisibleBlocks();
96 void ParseHead(BMaxXMLDocument& doc);
98 void ParseBlockFrames();
100 void CreateDefaultAnimations();
102 void AutoAddWalkAnimation(
int nAnimID,
int nStartTime,
int nEndTime,
float fMoveSpeed=4.f,
bool bMoveForward =
true);
107 void CalculateBoneWeights();
109 void CalculateBoneWeightFromNeighbours(
BMaxNode* node);
121 void ParseBlockAnimations(BMaxXMLDocument& doc);
122 void ParseBlockAnimationSet(BMaxXMLElement* node);
123 void ParseBlockAnimation(BMaxXMLElement* node);
124 void ParseBlockAnimationKeys(uint16 x, uint16 y, uint16 z, BMaxXMLElement* node,
int nIndex);
125 void ParseBlockAnimationKey(BMaxXMLElement* node,
Bone* bone,
const std::string propertyType);
129 void FillVerticesAndIndices();
132 int GetBoneIndex(uint16 x, uint16 y, uint16 z);
134 float CalculateScale(
float length);
135 int64 GetIndexFromXmlElement(BMaxXMLElement* node,
const char* name,
int& x,
int& y,
int& z);
137 bool ReadValue(BMaxXMLElement* node,
const char* name, int32_t& value);
138 bool ReadValue(BMaxXMLElement* node,
const char* name,
float& value);
139 bool ReadValue(BMaxXMLElement* node,
const char* name,
Vector3& value);
140 bool ReadValue(BMaxXMLElement* node,
const char* name, std::string& value);
141 bool ReadValue(BMaxXMLElement* node,
const char* name,
Vector4& value);
156 std::string m_filename;
157 std::vector<BlockModel*> m_blockModels;
158 std::map<uint64, BMaxNodePtr> m_nodes;
159 std::map<std::string, ref_ptr<CParaXModel> > m_refModels;
166 std::map<std::string, int> m_name_occurances;
168 bool m_bHasBoneBlock;
170 map<BlockModel*, BMaxNode*> m_blockModelsMapping;
171 vector<ModelAnimation> m_anims;
172 bool m_bHasAnimation;
174 vector<ModelVertex> m_vertices;
175 vector<RectanglePtr>m_rectangles;
176 vector<uint16> m_indices;
177 std::vector<ModelGeoset> m_geosets;
178 std::vector<ModelRenderPass> m_renderPasses;
192 static const int MaxBoneLengthHorizontal;
193 static const int MaxBoneLengthVertical;
int m_nHelperBlockId
the block id used to extend AABB.
Definition: BMaxParser.h:188
CShapeBox m_blockAABB
aabb in block world coordinate
Definition: BMaxParser.h:180
4-dimensional homogeneous vector.
Definition: ParaVector4.h:10
Vector3 m_centerPos
the center point in block world coordinate
Definition: BMaxParser.h:182
Definition: Rectangle.h:7
different physics engine has different winding order.
Definition: EventBinding.h:32
BMax Animation generator.
Definition: BMaxAnimGenerator.h:78
a single animated bone, it contains both the bone instance data and all animation data of the bone...
Definition: ParaXBone.h:15
Standard 3-dimensional vector.
Definition: ParaVector3.h:16
block model node in bmax
Definition: BMaxBlockModelNode.h:9
One material + render operation.
Definition: modelheaders.h:247
base class for a block in bmax model
Definition: BMaxNode.h:14
bool IsFileNameRecursiveLoaded(const std::string &filename)
check if the given filename belongs to one of its parent's filename
Definition: BMaxParser.cpp:1477
vector< BMaxFrameNodePtr > m_bones
array of bone nodes, array index is the bone index.
Definition: BMaxParser.h:164
int FindRootBoneIndex()
find the first root bone index.
Definition: BMaxParser.cpp:1390
CParaXModel * CreateGetRefModel(const std::string &sFilename)
filename is relative to current world directory.
Definition: BMaxParser.cpp:1543
Block Max file format parser.
Definition: BMaxParser.h:27
BlockIDNum
block id
Definition: BMaxParser.h:31
Definition: enum_maker.hpp:46
int64 InsertNode(BMaxNodePtr &nodePtr)
return node index
Definition: BMaxParser.cpp:329
void CalculateBoneWeightForBlock(BMaxFrameNode *pBoneNode, BMaxNode *node, bool bMustBeSameColor=true)
Definition: BMaxParser.cpp:1345
int GetNameAppearanceCount(const std::string &name, bool bAdd=true)
how many times that a given name has appeared.
Definition: BMaxParser.cpp:1160
ParaX model is the model file for character animation, etc in the game world.
Definition: ParaXModel.h:30
Definition: ModelRenderPass.h:9
bone node in bmax
Definition: BMaxFrameNode.h:9
Definition: modelheaders.h:165
a min max box.
Definition: ShapeAABB.h:190