tu# = phy get ray cast tu ( )
tv# = phy get ray cast tv ( )
Why are these (very useful it sounds like from the help file) commands in the help file, and not actually implemented in the dll!? (You can compile the program successfully then when this command is called you get:
"Could not find function '?dbPhyGetRayCastTU@@YAKXZ' in 60arkPhysics.dll.")
So, can some clever and crafty person please tell me how to do what I need to do without them, which is position an object on a 'wall' after raycasting from the camera position. I can put it in the right spot, but I need to figure out how to rotate it to match the normal of the 'wall'. Here's the code I currently have:
UpdateLaserPointer:
cx# = camera position x()
cy# = camera position y()
cz# = camera position z()
cax# = camera angle x()
cay# = camera angle y()
caz# = camera angle z()
` Move the camera forward by one so we
` can calculate a vector in the dir it's
` pointing for the raycast.
move camera 1.0
cx2# = camera position x()
cy2# = camera position y()
cz2# = camera position z()
` move camera back where it was
move camera -1.0
` figure out a direction vector for the camera (for the raycast)
vx# = cx2# - cx#
vy# = cy2# - cy#
vz# = cz2# - cz#
` do the (undocumented) raycast
value = phy ray cast all shapes ( cx#, cy#, cz#, vx#, vy#, vz#)
` if the ray hit something then
` put our 'laserPointer' object on the wall,
` then rotate it to to match the normal angle of the wall.
if phy get ray cast hit( )= 1
hx# = phy get ray cast hit point x ( )
hy# = phy get ray cast hit point y ( )
hz# = phy get ray cast hit point z ( )
position object lzr, hx#, hy#, hz#
nx# = phy get ray cast hit normal x ( )
ny# = phy get ray cast hit normal y ( )
nz# = phy get ray cast hit normal z ( )
text 1, 400, "Normal X: "+str$(nx#)
text 1, 420, "Normal Y: "+str$(ny#)
text 1, 440, "Normal Z: "+str$(nz#)
` this rotate obviously won't give me the desired results
` since the normal commands are returning a vector, not euler angles.
` Does anyone know how to convert this vector to eulers?
` I think I recall seeing it being done, just don't remember how
rotate object lzr, nx#, ny#, nz#
` for now I am just going to point it at the camera,
` but I'd rather like to get it facing flat against the wall the right way.
point object lzr, cx#, cy#, cz#
` move it out away from the wall a bit so it can be seen without zbuffering artifacts
move object lzr, 0.777
` GRR - these commands were left out of the DLL and they
` sound like exactly what I needed....
` tu# = phy get ray cast tu ( )
` tv# = phy get ray cast tv ( )
` text 1, 480, "Tu: " + str$(tu#)
` text 1, 500, "Tv: " + str$(tv#)
endif
return
For now I'm just
pointing the 'laser pointer' decal at the camera since I can't figure out how to convert the normal vector to euler angles. But of course it's less than optimal. Any help would be much appreciated.
Also, while I'm on the Raycasting topic:
value = phy ray cast all shapes ( cx#, cy#, cz#, vx#, vy#, vz#)
has no entry in the help file (neither the separate 'Reference.chm' nor when you hit f1 on the command.)
I'm really sorry to sound negative again, I don't like being negative, but I hate how everyday I run into something new with DarkPhysics that seems like they didn't get around to finishing, or didn't bother testing or documenting. Sorry Mike, but we are paying for a half-baked product here. Can you please finish everything and test everything and perhaps flesh out the help file a bit more and ship us an update? Thanks a bunch! (Is because you don't have a lot of DP customers that it ends up taking low priority?)
EDIT:
Since all I needed were the normals for right angles for the moment, I did this kludge to make it work (and it works fine as long as the walls are at right angles, but I still need the real thing since I want angled walls as well =)
if phy get ray cast hit( )= 1
hx# = phy get ray cast hit point x ( )
hy# = phy get ray cast hit point y ( )
hz# = phy get ray cast hit point z ( )
position object lzr, hx#, hy#, hz#
nx# = phy get ray cast hit normal x ( )
ny# = phy get ray cast hit normal y ( )
nz# = phy get ray cast hit normal z ( )
show object lzr
if nz# = -1
rotate object lzr, 0, 180, 0
else
if nz# = 1
rotate object lzr, 0, 0, 0
else
if nx# = -1
rotate object lzr, 0, -90, 0
else
if nx# = 1
rotate object lzr, 0, 90, 0
else
hide object lzr
endif
endif
endif
endif
Any ideas anybody?
World Famous 3D Screensavers
-- http://www.vrman3d.com --