nbohr1more
Newcomer
Hello,
The Dark Mod's new procedural model generator cannot currently scale Collision Models only standard geometry. The coder who is working on the problem has posted the code segment that currently does rotation and translation in response to a forum poster who questioned the difficulty of modifying the code for scaling size.
Do any of the Math-savvy folk here see an obvious solution?
The Dark Mod's new procedural model generator cannot currently scale Collision Models only standard geometry. The coder who is working on the problem has posted the code segment that currently does rotation and translation in response to a forum poster who questioned the difficulty of modifying the code for scaling size.
Feedback:
To be honest, don't understand the problem...
If you want to scale it by constant factor C isotropically then you can multiply everything with coordinate and scale sense by C and do nothing with things like normals. To my mind it should work correct.
The anisotropic scale is a bit worse. If you scale each vector (x,y,z) by factor (Cx, Cy, Cz), then each normal (Nx, Ny, Nz) should transform into (Nx/Cx, Ny/Cy, Nz/Cz). If there is a plane, then its normal is transformed as stated and its distance is not changed. Just remember to change it when you renormalize the normal (it does not have unit length no more).
In general case: there is a plane with equation in homogenous coordinates in form (Nx, Ny, Nz, d) dot (x, y, z, 1) = 0. You want to transform the world by multiplying it on the 4x4 matrix A. It is well known from shader programming (applying modelview transformation to normals) that the "plane vector" must be multiplied by inverse of transpose of A. So the new plane parameters are (A^{-1})^T * (Nx, Ny, Nz, d). The correctness can be checked by noticing that dot product of transformed plane vector on transformed point vector remains the same. Notice that combined rotation, translation and arbitrary scaling are included in this case.
I hope that I'm not mistaken about the formulas above :laugh: If you find a way to change all the coordinate parameters, then the formulas how to change them are indeed obtainable.
Response:
Here is the code for Rotation/Translation:
Code:idTraceModel::Translate ============ */ void idTraceModel::Translate( const idVec3 &translation ) { int i; for ( i = 0; i < numVerts; i++ ) { verts[i] += translation; } for ( i = 0; i < numPolys; i++ ) { polys[i].dist += polys[i].normal * translation; polys[i].bounds[0] += translation; polys[i].bounds[1] += translation; } offset += translation; bounds[0] += translation; bounds[1] += translation; } /* ============ idTraceModel::Rotate ============ */ void idTraceModel::Rotate( const idMat3 &rotation ) { int i, j, edgeNum; for ( i = 0; i < numVerts; i++ ) { verts[i] *= rotation; } bounds.Clear(); for ( i = 0; i < numPolys; i++ ) { polys[i].normal *= rotation; polys[i].bounds.Clear(); edgeNum = 0; for ( j = 0; j < polys[i].numEdges; j++ ) { edgeNum = polys[i].edges[j]; polys[i].bounds.AddPoint( verts[edges[abs(edgeNum)].v[ INTSIGNBITSET(edgeNum)]] ); } polys[i].dist = polys[i].normal * verts[edges[abs(edgeNum)].v[ INTSIGNBITSET(edgeNum)]]; bounds += polys[i].bounds; } GenerateEdgeNormals(); }
Now for Scale? :smile:
Do any of the Math-savvy folk here see an obvious solution?