Pyrogenesis  13997
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
MikktspaceWrap.h
Go to the documentation of this file.
1 /* Copyright (C) 2012 Wildfire Games.
2  * This file is part of 0 A.D.
3  *
4  * 0 A.D. is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * 0 A.D. is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with 0 A.D. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #ifndef INCLUDED_MIKKWRAP
19 #define INCLUDED_MIKKWRAP
20 
21 
23 
24 // Disable useless MSVC warning
25 #if MSC_VERSION
26 # pragma warning(disable:4512) // "assignment operator could not be generated"
27 #endif
28 
30 {
31 
32 public:
33 
34  MikkTSpace(const CModelDefPtr& m, std::vector<float>& v, bool gpuSkinning);
35 
36  void generate();
37 
38 private:
39 
42 
44 
45  std::vector<float>& m_NewVertices;
47 
48 
49  // Returns the number of faces (triangles/quads) on the mesh to be processed.
50  static int getNumFaces(const SMikkTSpaceContext *pContext);
51 
52 
53  // Returns the number of vertices on face number iFace
54  // iFace is a number in the range {0, 1, ..., getNumFaces()-1}
55  static int getNumVerticesOfFace(const SMikkTSpaceContext *pContext, const int iFace);
56 
57 
58  // returns the position/normal/texcoord of the referenced face of vertex number iVert.
59  // iVert is in the range {0,1,2} for triangles and {0,1,2,3} for quads.
60  static void getPosition(const SMikkTSpaceContext *pContext,
61  float fvPosOut[], const int iFace, const int iVert);
62 
63  static void getNormal(const SMikkTSpaceContext *pContext,
64  float fvNormOut[], const int iFace, const int iVert);
65 
66  static void getTexCoord(const SMikkTSpaceContext *pContext,
67  float fvTexcOut[], const int iFace, const int iVert);
68 
69 
70  // This function is used to return tangent space results to the application.
71  // fvTangent and fvBiTangent are unit length vectors and fMagS and fMagT are their
72  // true magnitudes which can be used for relief mapping effects.
73  // fvBiTangent is the "real" bitangent and thus may not be perpendicular to fvTangent.
74  // However, both are perpendicular to the vertex normal.
75  // For normal maps it is sufficient to use the following simplified version of the bitangent which is generated at pixel/vertex level.
76  // fSign = bIsOrientationPreserving ? 1.0f : (-1.0f);
77  // bitangent = fSign * cross(vN, tangent);
78  static void setTSpace(const SMikkTSpaceContext * pContext, const float fvTangent[],
79  const float fvBiTangent[], const float fMagS, const float fMagT,
80  const tbool bIsOrientationPreserving, const int iFace, const int iVert);
81 
82 
83 };
84 
85 
86 #endif // INCLUDED_MIKKWRAP
bool m_GpuSkinning
static void setTSpace(const SMikkTSpaceContext *pContext, const float fvTangent[], const float fvBiTangent[], const float fMagS, const float fMagT, const tbool bIsOrientationPreserving, const int iFace, const int iVert)
const CModelDefPtr & m_Model
static int getNumFaces(const SMikkTSpaceContext *pContext)
std::vector< float > & m_NewVertices
SMikkTSpaceContext m_Context
static void getTexCoord(const SMikkTSpaceContext *pContext, float fvTexcOut[], const int iFace, const int iVert)
static void getNormal(const SMikkTSpaceContext *pContext, float fvNormOut[], const int iFace, const int iVert)
static void getPosition(const SMikkTSpaceContext *pContext, float fvPosOut[], const int iFace, const int iVert)
MikkTSpace(const CModelDefPtr &m, std::vector< float > &v, bool gpuSkinning)
int tbool
Copyright (C) 2011 by Morten S.
Definition: mikktspace.h:62
static int getNumVerticesOfFace(const SMikkTSpaceContext *pContext, const int iFace)
SMikkTSpaceInterface m_Interface
boost::shared_ptr< CModelDef > CModelDefPtr
Definition: MeshManager.h:27