本文整理汇总了C++中Geom::GetTransform方法的典型用法代码示例。如果您正苦于以下问题:C++ Geom::GetTransform方法的具体用法?C++ Geom::GetTransform怎么用?C++ Geom::GetTransform使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Geom
的用法示例。
在下文中一共展示了Geom::GetTransform方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TraceRay
void CollisionSpace::TraceRay(const vector3d &start, const vector3d &dir, double len, CollisionContact *c, Geom *ignore)
{
vector3d invDir(1.0/dir.x, 1.0/dir.y, 1.0/dir.z);
c->dist = len;
BvhNode *vn_stack[16];
BvhNode *node = m_staticObjectTree->m_root;
int stackPos = -1;
for (;node;) {
// do we hit it?
{
isect_t isect;
isect.dist = float(c->dist);
isect.triIdx = -1;
if (!node->CollideRay(start, invDir, &isect)) goto pop_jizz;
}
if (node->geomStart) {
// it is a leaf node
// collide with all geoms
for (int i=0; i<node->numGeoms; i++) {
Geom *g = node->geomStart[i];
const matrix4x4d &invTrans = g->GetInvTransform();
vector3d ms = invTrans * start;
vector3d md = invTrans.ApplyRotationOnly(dir);
vector3f modelStart = vector3f(ms.x, ms.y, ms.z);
vector3f modelDir = vector3f(md.x, md.y, md.z);
isect_t isect;
isect.dist = float(c->dist);
isect.triIdx = -1;
g->GetGeomTree()->TraceRay(modelStart, modelDir, &isect);
if (isect.triIdx != -1) {
c->pos = start + dir*double(isect.dist);
vector3f n = g->GetGeomTree()->GetTriNormal(isect.triIdx);
c->normal = vector3d(n.x, n.y, n.z);
c->normal = g->GetTransform().ApplyRotationOnly(c->normal);
c->depth = len - isect.dist;
c->triIdx = isect.triIdx;
c->userData1 = g->GetUserData();
c->userData2 = 0;
c->geomFlag = g->GetGeomTree()->GetTriFlag(isect.triIdx);
c->dist = isect.dist;
}
}
} else if (node->kids[0]) {
vn_stack[++stackPos] = node->kids[0];
node = node->kids[1];
continue;
}
pop_jizz:
if (stackPos < 0) break;
node = vn_stack[stackPos--];
}
for (std::list<Geom*>::iterator i = m_geoms.begin(); i != m_geoms.end(); ++i) {
if ((*i) == ignore) continue;
if ((*i)->IsEnabled()) {
const matrix4x4d &invTrans = (*i)->GetInvTransform();
vector3d ms = invTrans * start;
vector3d md = invTrans.ApplyRotationOnly(dir);
vector3f modelStart = vector3f(ms.x, ms.y, ms.z);
vector3f modelDir = vector3f(md.x, md.y, md.z);
isect_t isect;
isect.dist = float(c->dist);
isect.triIdx = -1;
(*i)->GetGeomTree()->TraceRay(modelStart, modelDir, &isect);
if (isect.triIdx != -1) {
c->pos = start + dir*double(isect.dist);
vector3f n = (*i)->GetGeomTree()->GetTriNormal(isect.triIdx);
c->normal = vector3d(n.x, n.y, n.z);
c->normal = (*i)->GetTransform().ApplyRotationOnly(c->normal);
c->depth = len - isect.dist;
c->triIdx = isect.triIdx;
c->userData1 = (*i)->GetUserData();
c->userData2 = 0;
c->geomFlag = (*i)->GetGeomTree()->GetTriFlag(isect.triIdx);
c->dist = isect.dist;
}
}
}
{
isect_t isect;
isect.dist = float(c->dist);
isect.triIdx = -1;
CollideRaySphere(start, dir, &isect);
if (isect.triIdx != -1) {
c->pos = start + dir*double(isect.dist);
c->normal = vector3d(0.0);
c->depth = len - isect.dist;
c->triIdx = -1;
c->userData1 = sphere.userData;
c->userData2 = 0;
//.........这里部分代码省略.........