ContainedCastRay not intersecting at proper coordinates
by Kathryn Mumm · in Torque Game Engine · 04/29/2005 (8:47 pm) · 2 replies
I'm working on a construction tool that creates objects (such as beams/spines) on fire. The basic functionality is that it casts a ray in the direction of the muzzle vector. If there are no existing beams/spines in the path of the ray, it simply creates a new beam if the player was pointing at terrain. If it detects a beam, it finds out which part of the beam it is pointing at, and it snaps a new beam on accordingly. This process I have is kind of complicated and since I write my code very sloppy, most people won't fully understand what I'm doing, so I'll just cut right to the chase. When a player points at the top of the box, the Z coordinate of the point of intersection from the castRay should be equal to the maxZ value of the box (returned from getWorldBox()). However, this is not the case. The maxZ value of the box keeps turning out to be .5 - .7 larger than the Z coordinate of the intersection. Originally I thought this problem was because of my collision mesh (since ContainedRayCast intersects only with collision meshes), but I re-did the beam model and the collision mesh is exactly/perfectly fitted on the beam. So, I still have the problem. I also have this innaccuracy problem with the X and Y axes.
Also, while I'm here, I guess I'll ask this too - is there a more accurate way to find the coordinates of the location that the player is looking at? The gun vector method seems to be very innacurate at short distances. I was trying to use getEyeVector() but I was unsure of how to obtain the parameter. Any help greatly appreciated.
Also, while I'm here, I guess I'll ask this too - is there a more accurate way to find the coordinates of the location that the player is looking at? The gun vector method seems to be very innacurate at short distances. I was trying to use getEyeVector() but I was unsure of how to obtain the parameter. Any help greatly appreciated.
#2
Sounds a bit like what you are looking for.
04/30/2005 (10:44 pm)
Hi Kath, try looking at getCameraTransform in the vehicle class. In there they get the eye transform and cast a ray backwards for camera placement.Sounds a bit like what you are looking for.
Torque Owner Kathryn Mumm