TrinityCore
M2Structure.h
Go to the documentation of this file.
1/*
2 * This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#ifndef TRINITY_M2STRUCTURE_H
19#define TRINITY_M2STRUCTURE_H
20
21#include "Common.h"
22
23#include <G3D/Vector3.h>
24#include <G3D/AABox.h>
25
26// Structures using to access raw DBC data and required packing to portability
27#pragma pack(push, 1)
28// Structures for M2 file. Source: https://wowdev.wiki
29template<typename T>
31{
32 T p0;
33 T p1;
34 T p2;
35};
36
38{
39 char Magic[4]; // "MD20"
40 uint32 Version; // The version of the format.
41 uint32 lName; // Length of the model's name including the trailing \0
42 uint32 ofsName; // Offset to the name, it seems like models can get reloaded by this name.should be unique, i guess.
43 uint32 GlobalModelFlags; // 0x0001: tilt x, 0x0002: tilt y, 0x0008: add 2 fields in header, 0x0020: load .phys data (MoP+), 0x0080: has _lod .skin files (MoP?+), 0x0100: is camera related.
45 uint32 ofsGlobalSequences; // A list of timestamps.
47 uint32 ofsAnimations; // Information about the animations in the model.
49 uint32 ofsAnimationLookup; // Mapping of global IDs to the entries in the Animation sequences block.
50 uint32 nBones; // MAX_BONES = 0x100
51 uint32 ofsBones; // Information about the bones in this model.
53 uint32 ofsKeyBoneLookup; // Lookup table for key skeletal bones.
55 uint32 ofsVertices; // Vertices of the model.
56 uint32 nViews; // Views (LOD) are now in .skins.
58 uint32 ofsSubmeshAnimations; // Submesh color and alpha animations definitions.
60 uint32 ofsTextures; // Textures of this model.
62 uint32 ofsTransparency; // Transparency of textures.
66 uint32 ofsTexReplace; // Replaceable Textures.
68 uint32 ofsRenderFlags; // Blending modes / render flags.
70 uint32 ofsBoneLookupTable; // A bone lookup table.
72 uint32 ofsTexLookup; // The same for textures.
73 uint32 nTexUnits; // possibly removed with cata?!
74 uint32 ofsTexUnits; // And texture units. Somewhere they have to be too.
76 uint32 ofsTransLookup; // Everything needs its lookup. Here are the transparencies.
79 G3D::AABox BoundingBox; // min/max( [1].z, 2.0277779f ) - 0.16f seems to be the maximum camera height
81 G3D::AABox CollisionBox;
84 uint32 ofsBoundingTriangles; // Our bounding volumes. Similar structure like in the old ofsViews.
90 uint32 ofsAttachments; // Attachments are for weapons etc.
92 uint32 ofsAttachLookup; // Of course with a lookup.
94 uint32 ofsEvents; // Used for playing sounds when dying and a lot else.
96 uint32 ofsLights; // Lights are mainly used in loginscreens but in wands and some doodads too.
97 uint32 nCameras; // Format of Cameras changed with version 271!
98 uint32 ofsCameras; // The cameras are present in most models for having a model in the Character-Tab.
100 uint32 ofsCameraLookup; // And lookup-time again.
102 uint32 ofsRibbonEmitters; // Things swirling around. See the CoT-entrance for light-trails.
104 uint32 ofsParticleEmitters; // Spells and weapons, doodads and loginscreens use them. Blood dripping of a blade? Particles.
105 uint32 nBlendMaps; // This has to deal with blending. Exists IFF (flags & 0x8) != 0. When set, textures blending is overriden by the associated array. See M2/WotLK#Blend_mode_overrides
106 uint32 ofsBlendMaps; // Same as above. Points to an array of uint16 of nBlendMaps entries -- From WoD information.};
107};
108
110{
111 uint32_t number;
113};
115{
120};
121
123{
124 uint32_t type; // 0: portrait, 1: characterinfo; -1: else (flyby etc.); referenced backwards in the lookup table.
125 float far_clip;
127 M2Track positions; // How the camera's position moves. Should be 3*3 floats.
128 G3D::Vector3 position_base;
129 M2Track target_positions; // How the target moves. Should be 3*3 floats.
131 M2Track rolldata; // The camera can have some roll-effect. Its 0 to 2*Pi.
132 M2Track fovdata; // FoV for this segment
133};
134#pragma pack(pop)
135
136#endif
uint32_t uint32
Definition: Define.h:142
uint32 offset_elements
Definition: M2Structure.h:112
uint32_t number
Definition: M2Structure.h:111
M2Track target_positions
Definition: M2Structure.h:129
G3D::Vector3 target_position_base
Definition: M2Structure.h:130
M2Track positions
Definition: M2Structure.h:127
float near_clip
Definition: M2Structure.h:126
M2Track fovdata
Definition: M2Structure.h:132
G3D::Vector3 position_base
Definition: M2Structure.h:128
M2Track rolldata
Definition: M2Structure.h:131
float far_clip
Definition: M2Structure.h:125
uint32_t type
Definition: M2Structure.h:124
uint32 nAnimations
Definition: M2Structure.h:46
uint32 nParticleEmitters
Definition: M2Structure.h:103
uint32 nCameras
Definition: M2Structure.h:97
uint32 ofsSubmeshAnimations
Definition: M2Structure.h:58
G3D::AABox CollisionBox
Definition: M2Structure.h:81
uint32 ofsKeyBoneLookup
Definition: M2Structure.h:53
uint32 lName
Definition: M2Structure.h:41
uint32 nLights
Definition: M2Structure.h:95
uint32 nBoundingTriangles
Definition: M2Structure.h:83
uint32 nTexReplace
Definition: M2Structure.h:65
uint32 ofsBoundingVertices
Definition: M2Structure.h:86
uint32 nTexUnits
Definition: M2Structure.h:73
uint32 nEvents
Definition: M2Structure.h:93
uint32 ofsVertices
Definition: M2Structure.h:55
uint32 ofsAnimationLookup
Definition: M2Structure.h:49
uint32 nRibbonEmitters
Definition: M2Structure.h:101
uint32 GlobalModelFlags
Definition: M2Structure.h:43
uint32 ofsRibbonEmitters
Definition: M2Structure.h:102
uint32 nTransparency
Definition: M2Structure.h:61
uint32 ofsBoundingNormals
Definition: M2Structure.h:88
uint32 ofsBones
Definition: M2Structure.h:51
uint32 nTransLookup
Definition: M2Structure.h:75
float BoundingSphereRadius
Definition: M2Structure.h:80
uint32 ofsLights
Definition: M2Structure.h:96
uint32 nViews
Definition: M2Structure.h:56
uint32 nAnimationLookup
Definition: M2Structure.h:48
uint32 ofsTexUnits
Definition: M2Structure.h:74
uint32 ofsTexLookup
Definition: M2Structure.h:72
uint32 ofsBlendMaps
Definition: M2Structure.h:106
uint32 ofsUVAnimLookup
Definition: M2Structure.h:78
uint32 nUVAnimation
Definition: M2Structure.h:63
uint32 nTextures
Definition: M2Structure.h:59
uint32 ofsBoneLookupTable
Definition: M2Structure.h:70
uint32 nGlobalSequences
Definition: M2Structure.h:44
uint32 ofsUVAnimation
Definition: M2Structure.h:64
uint32 ofsTransLookup
Definition: M2Structure.h:76
G3D::AABox BoundingBox
Definition: M2Structure.h:79
uint32 ofsTransparency
Definition: M2Structure.h:62
uint32 nTexLookup
Definition: M2Structure.h:71
uint32 nRenderFlags
Definition: M2Structure.h:67
uint32 ofsGlobalSequences
Definition: M2Structure.h:45
uint32 ofsAttachments
Definition: M2Structure.h:90
uint32 nAttachments
Definition: M2Structure.h:89
char Magic[4]
Definition: M2Structure.h:39
uint32 Version
Definition: M2Structure.h:40
uint32 nAttachLookup
Definition: M2Structure.h:91
uint32 nBlendMaps
Definition: M2Structure.h:105
uint32 nBoundingVertices
Definition: M2Structure.h:85
float CollisionSphereRadius
Definition: M2Structure.h:82
uint32 ofsRenderFlags
Definition: M2Structure.h:68
uint32 nUVAnimLookup
Definition: M2Structure.h:77
uint32 ofsCameras
Definition: M2Structure.h:98
uint32 ofsParticleEmitters
Definition: M2Structure.h:104
uint32 nSubmeshAnimations
Definition: M2Structure.h:57
uint32 nKeyBoneLookup
Definition: M2Structure.h:52
uint32 ofsTexReplace
Definition: M2Structure.h:66
uint32 nBoneLookupTable
Definition: M2Structure.h:69
uint32 ofsName
Definition: M2Structure.h:42
uint32 ofsCameraLookup
Definition: M2Structure.h:100
uint32 ofsAttachLookup
Definition: M2Structure.h:92
uint32 nBones
Definition: M2Structure.h:50
uint32 nVertices
Definition: M2Structure.h:54
uint32 ofsTextures
Definition: M2Structure.h:60
uint32 ofsBoundingTriangles
Definition: M2Structure.h:84
uint32 ofsAnimations
Definition: M2Structure.h:47
uint32 nBoundingNormals
Definition: M2Structure.h:87
uint32 nCameraLookup
Definition: M2Structure.h:99
uint32 ofsEvents
Definition: M2Structure.h:94
M2Array timestamps
Definition: M2Structure.h:118
M2Array values
Definition: M2Structure.h:119
uint16_t interpolation_type
Definition: M2Structure.h:116
uint16_t global_sequence
Definition: M2Structure.h:117