Hi Chris,
Sorry about the delay.
I think your demo code is outdated, this is what I have:
Rem Project: Raycast
Rem Created: Tuesday, February 28, 2012
Rem ***** Main Source File *****
//-- Be sure to add "PhysX Constants.dba" to your solution.
sync on
sync rate 60
autocam off
position camera 0, 50, -100
point camera 0, 0, 0
make object box 1, 100, 10, 100
make object sphere 2, 10
make object sphere 3, 10
position object 1, 0, -5, 0
position object 2, 0, 50, 50
position object 3, 0, 100, 0
color object 1, rgb(255, 0, 0)
color object 2, rgb(0, 255, 0)
color object 3, rgb(0, 0, 255)
DYN START
//--Turn on visualization
DYN SET PARAMETER 9, 1.0
//--Collision shapes
DYN SET PARAMETER 39, 1.0
DYN SET GRAVITY 0, -9.8, 0
DYN MAKE BOX 1, 0.0
DYN MAKE SPHERE 2, 0.1
DYN MAKE SPHERE 3, 0.1
DYN SET SHAPE GROUP 2, 0, 1
DYN SET SHAPE GROUP 3, 0, 2
rayPosVec = 1
rayDirVec = 2
x = make vector3 (rayPosVec)
x = make vector3 (rayDirVec)
set vector3 rayPosVec, 0, 5, -50
set vector3 rayDirVec, 0, 0, 1
DYN SIMULATE
do
DYN FETCH RESULTS
DYN DEBUG RENDER
DYN UPDATE
//-- Y position for text
y = 0
//-- Which groups to cast against, this will speed up the raycast operation when there
//-- are alot of objects in the scene. Set to -1 for all groups.
groupFlag = 1<<1 || 1<<2
//-- 1 - Static
//-- 2 - Dynamic
//-- 3 - All - NX_ALL_SHAPES
//-- All the following raycast commands collect hit data.
//-- 'AllShapes' and 'AllBounds' can provide multiple hits with one raycast.
//-- Bounds are faster but not as accurate.
DYN RAYCAST ALL SHAPES rayPosVec, rayDirVec, NX_ALL_SHAPES, groupFlag
//DYN RAYCAST ALL BOUNDS rayPosVec, rayDirVec, NX_ALL_SHAPES, groupFlag
//DYN RAYCAST CLOSEST SHAPE rayPosVec, rayDirVec, NX_ALL_SHAPES, groupFlag
//DYN RAYCAST CLOSEST BOUNDS rayPosVec, rayDirVec, NX_ALL_SHAPES, groupFlag
while DYN RAYCAST HIT GET DATA()
center text screen width() / 2, y, "RAYCAST ALL SHAPES HIT... OBJECT:"
obj = DYN RAYCAST HIT GET OBJECT()
center text screen width() / 2 + 150, y, str$(obj)
y = y + 15
//dist# = DYN RAYCAST HIT GET DISTANCE()
//print dist#
endwhile
y = y + 30
//-- The following raycast commands are the fastest but do not collect hit data,
//-- they simple return true or false.
//-- AnyBounds is faster than AnyShape but less accurate.
rayHit = DYN RAYCAST ANY BOUNDS(rayPosVec, rayDirVec, NX_ALL_SHAPES, groupFlag)
//rayHit = DYN RAYCAST ANY SHAPE(rayPosVec, rayDirVec, NX_ALL_SHAPES, groupFlag)
if rayHit
center text screen width() / 2, y, "RAYCAST ANY SHAPE HIT... OBJECT: UNKNOWN"
endif
DYN SIMULATE
sync
loop
DYN FETCH RESULTS
DYN STOP
This works for me. The main difference is here:
DYN SET SHAPE GROUP 2, 0, 1
DYN SET SHAPE GROUP 3, 0, 2
This should work for you if you are running the latest version.