Clipping volumes
by Brett Fattori · in Torque Game Engine · 02/23/2004 (8:59 am) · 1 replies
Was looking at some code in the engine in SceneState.cc in the "isObjectRendered()" method. It seems to generate a clipping volume that originates at the near plane and extends to the far plane (or fogging distance, can't remember exactly). Then, with a little searching, I found some code in fxFoliageReplicator that does something similar to create a view volume to determine if a quadrant should show or not. It's nicely commmented, but I'm still kinda baffled.
Well, I need something similar, but not exactly like it.. :-)
I need a volume that originates at a light's position (let's call it lightPos) and stretches to the near plane. Thus, I would have a view volume for what the light can see. I need this to determine which objects clip a light for determining if a shadow becomes z-fail. I've been having a hell of a time with this, so any help would be appreciated.
Thanks,
- Brett
Well, I need something similar, but not exactly like it.. :-)
I need a volume that originates at a light's position (let's call it lightPos) and stretches to the near plane. Thus, I would have a view volume for what the light can see. I need this to determine which objects clip a light for determining if a shadow becomes z-fail. I've been having a hell of a time with this, so any help would be appreciated.
Thanks,
- Brett
Associate Matt Fairfax
PopCap
ClippedPolyList polyList; polyList.mPlaneList.clear(); polyList.mNormal.set(0,0,0); polyList.mPlaneList.setSize(6); polyList.mPlaneList[0].set(box.min,VectorF(-1,0,0)); polyList.mPlaneList[1].set(box.max,VectorF(0,1,0)); polyList.mPlaneList[2].set(box.max,VectorF(1,0,0)); polyList.mPlaneList[3].set(box.min,VectorF(0,-1,0)); polyList.mPlaneList[4].set(box.min,VectorF(0,0,-1)); polyList.mPlaneList[5].set(box.max,VectorF(0,0,1)); CollisionWorkingList& rList = mConvex.getWorkingList(); CollisionWorkingList* pList = rList.wLink.mNext; while (pList != &rList) { Convex* pConvex = pList->mConvex; if ((pConvex->getObject()->getType() & StaticObjectType) != 0) { Box3F convexBox = pConvex->getBoundingBox(); if (box.isOverlapped(convexBox)) { // The object is partially inside the volume pConvex->getPolyList(&polyList); } } pList = pList->wLink.mNext; }