Game Development Community

TSShape instance cast ray

by Nathan Bowhay - ESAL · in Torque 3D Professional · 03/20/2013 (12:24 pm) · 2 replies

I am making a custom gui based on guiShapeEdPreview (Shape Editor) and trying to get the nodes to only render if they are visible (not covered by the rest of the model). Inside my render function I loop through all the nodes and above the loop I have this:
MatrixF camMat;
bool haveCamPos = getCameraTransform(&camMat);
RayInfo info;

Then in the loop I have this:
if(!haveCamPos || !mModel->castRay(camMat.getPosition(), mModel->mNodeTransforms[i].getPosition(), &info, mCurrentDL))
{
	renderNodeAxes( i, ColorF::RED );
}

But for some reason castRay never seems to collide with anything? is it because there are no collision meshes on the model? are my transforms in worldspace when they shouldn't be?

I'm trying to figure out why all the nodes render.

#1
03/25/2013 (6:18 am)
Make sure your node transform is updated (animated). I believe you should call animate() on your animation thread.
You should pay an attention if your logic is client or server side, because if this is on the server, then you have to animate on server.
Your are testing against the collision mesh or the visible mesh ?
Use helpers like lines to track your logic.
#2
03/25/2013 (1:21 pm)
This is just inherited from guiShapeEdPreview (Shape Editor) and from what it looks like in render world it calls animate. I am pretty sure it is all done on the client as it's just all for previewing models. I'm calling it on a TSShapeInstance, it looks like it is looping through all visible meshes of that detail level so not the collision mesh, but I may be mistaken. I will try and use helper lines to figure it out, it's just everything I am using is in torque already so it's not like there is that much of my own code to really look at.