| 59 | float MeshSceneNode::RadarLodScale = 1.0f; |
| 60 | |
| 61 | MeshSceneNode::MeshSceneNode(const MeshObstacle* _mesh) { |
| 62 | mesh = _mesh; |
| 63 | |
| 64 | lodCount = 0; |
| 65 | lods = NULL; |
| 66 | |
| 67 | xformList = INVALID_GL_LIST_ID; |
| 68 | |
| 69 | if (mesh == NULL) { |
| 70 | return; |
| 71 | } |
| 72 | |
| 73 | drawInfo = mesh->getDrawInfo(); |
| 74 | if (drawInfo == NULL) { |
| 75 | return; |
| 76 | } |
| 77 | |
| 78 | drawMgr = drawInfo->getDrawMgr(); |
| 79 | if (drawMgr == NULL) { |
| 80 | return; |
| 81 | } |
| 82 | |
| 83 | // disable the plane |
| 84 | noPlane = true; |
| 85 | plane.x = plane.y = plane.z = plane.w = 0.0f; |
| 86 | |
| 87 | // setup the extents, sphere, and lengthPerPixel adjustment |
| 88 | float lengthAdj = 1.0f; |
| 89 | const Extents& diExts = drawInfo->getExtents(); |
| 90 | const MeshTransform::Tool* xformTool = drawInfo->getTransformTool(); |
| 91 | if (xformTool == NULL) { |
| 92 | extents = drawInfo->getExtents(); |
| 93 | setSphere(drawInfo->getSphere()); |
| 94 | } |
| 95 | else { |
| 96 | // sloppy way to recalcuate the transformed extents |
| 97 | fvec3 c[8]; |
| 98 | c[0].x = c[6].x = c[5].x = c[3].x = diExts.mins.x; |
| 99 | c[7].x = c[1].x = c[2].x = c[4].x = diExts.maxs.x; |
| 100 | c[0].y = c[1].y = c[5].y = c[4].y = diExts.mins.y; |
| 101 | c[7].y = c[6].y = c[2].y = c[3].y = diExts.maxs.y; |
| 102 | c[0].z = c[1].z = c[2].z = c[3].z = diExts.mins.z; |
| 103 | c[7].z = c[6].z = c[5].z = c[4].z = diExts.maxs.z; |
| 104 | extents.reset(); |
| 105 | for (int v = 0; v < 8; v++) { |
| 106 | xformTool->modifyVertex(c[v]); |
| 107 | extents.expandToPoint(c[v]); |
| 108 | } |
| 109 | // lengthPerPixel adjustment |
| 110 | lengthAdj = +MAXFLOAT; |
| 111 | for (int a = 0; a < 3; a++) { |
| 112 | const float oldWidth = diExts.maxs[a] - diExts.mins[a]; |
| 113 | const fvec3& s = c[0]; // all mins |
| 114 | // mins, except: c[1] -> max[0], c[3] -> max[1], c[5] -> max[2] |
| 115 | const fvec3& e = c[(a * 2) + 1]; |
| 116 | const float newWidth = (s - e).length(); |
| 117 | if (oldWidth > 0.0f) { |
| 118 | const float scale = (newWidth / oldWidth); |
nothing calls this directly
no test coverage detected