Index: DarkMod/ModelGenerator.cpp =================================================================== --- DarkMod/ModelGenerator.cpp (revision 4515) +++ DarkMod/ModelGenerator.cpp (working copy) @@ -588,7 +588,7 @@ //gameLocal.Warning(" Offset %0.2f, %0.2f, %0.2f LOD %i.\n", op.offset.x, op.offset.y, op.offset.z, op.lod ); // precompute these - idMat4 a = op.angles.ToMat4(); +/* idMat4 a = op.angles.ToMat4(); idMat4 at = op.angles.ToRotation().ToMat4(); if (at.InverseSelf()) { @@ -600,7 +600,7 @@ } idVec3 scale = op.scale; - idMat4 vMat = idMat4( op.angles.ToRotation().ToMat3(), op.offset ); + idMat4 vMat = idMat4( op.angles.ToRotation().ToMat3(), op.offset );*/ const idRenderModel* source = LODs->Ptr()[op.lod]; @@ -715,7 +715,7 @@ #else idDrawVert *vs = &(surf->geometry->verts[j]); - // copy-and-modify at once +/* // copy-and-modify at once // scale - rotate - translate v->xyz[0] = vs->xyz[0] * scale.x; v->xyz[1] = vs->xyz[1] * scale.y; @@ -727,12 +727,36 @@ v->tangents[0] = vs->tangents[0] * at; v->tangents[1] = vs->tangents[1] * at; v->SetColor( newColor ); - v->st = vs->st; -#endif - + v->st = vs->st;*/ // seems unnec.? //v->Normalize(); + //copy + *v = *vs; + //scale + for (int d = 0; d<3; d++) { + v->xyz[d] *= op.scale[d]; + v->normal[d] /= op.scale[d]; + v->tangents[0][d] /= op.scale[d]; + v->tangents[1][d] /= op.scale[d]; + } + //rotate + idMat3 mRot = op.angles.ToMat3(); + v->xyz *= mRot; + v->normal *= mRot; + v->tangents[0] *= mRot; + v->tangents[1] *= mRot; + //translate + v->xyz += op.offset; + //scale tangent space basis to make |normal| = 1 + float nLen = v->normal.Length(); + v->normal /= nLen; + v->tangents[0] /= nLen; + v->tangents[1] /= nLen; + //NOTE (in case of non-isotropic scaling): + //if tangents are normalized then bumpmapped surface will look different +#endif + /* if (o == 1 || o == 2) { gameLocal.Printf ("Vert %i (%i): xyz %s st %s tangent %s %s normal %s color %i %i %i %i.\n",