MCPcopy Create free account
hub / github.com/BZFlag-Dev/bzflag / dumpToModel

Method dumpToModel

tools/modeltool/Q3BSP.cpp:77–405  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

75}
76
77bool Quake3Level::dumpToModel(CModel& model) {
78 model.clear();
79
80 for (int i = 0; i < mNumShaders; i++) {
81 CMaterial material;
82
83 char temp[128];
84 strcpy(temp, mShaders[i].name);
85 if (strrchr(temp, '.')) {
86 *(strrchr(temp, '.')) = 0;
87 }
88
89 material.texture = temp;
90 material.texture += ".png";
91
92 model.materials[std::string(temp)] = material;
93 }
94
95 for (int i = 0; i < mNumFaces; i++) {
96 switch (mFaces[i].type) {
97 case 1: // polygon face
98 case 3: { // mesh face
99 CMesh mesh;
100
101 // add in the verts and normals and UVs
102 for (int j = 0; j < mFaces[i].vert_count; j++) {
103 CVector3 vert;
104 CVector3 norm;
105 CVector2 coord;
106
107 int index = mFaces[i].vert_start + j;
108 if (index > 0 && index < mNumVertices) {
109 vert.x = mVertices[index].point[0] * bzpScale;
110 vert.y = mVertices[index].point[1] * bzpScale;
111 vert.z = mVertices[index].point[2] * bzpScale;
112
113 norm.x = mVertices[index].normal[0];
114 norm.y = mVertices[index].normal[1];
115 norm.z = mVertices[index].normal[2];
116
117 coord.u = mVertices[index].texture[0];
118 coord.v = mVertices[index].texture[1];
119 }
120 mesh.verts.push_back(vert);
121 mesh.normals.push_back(norm);
122 mesh.texCoords.push_back(coord);
123 }
124
125 // now do the face
126 CFace face;
127
128 bool skipFace = false;
129
130 if (mFaces[i].shader > 0 && mFaces[i].shader < mNumShaders) {
131 char temp[128];
132 if (strlen(mShaders[mFaces[i].shader].name)) {
133 strcpy(temp, mShaders[mFaces[i].shader].name);
134 char* p = strrchr(temp, '.');

Callers 1

mainFunction · 0.80

Calls 7

tolowerFunction · 0.85
c_strMethod · 0.80
tokenizeFunction · 0.50
formatFunction · 0.50
clearMethod · 0.45
push_backMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected