Director: collisioni 3d

Di: emmecci | 26/09/2020 17:47:44
Ciao!
devo creare con director una navigazione 3d di un ambiente creato in MAYA... Ho letto diversi forum sull'argomento.. e tutti i link segnalati... ho studiato un po' di lingo e ho cercato (dato i tempi strettissimi) di metter insieme i vari suggerimenti..il risultato è questa pagina di codice.. che però mi segnala alcuni errori di script che non so risolvere!! HELP!!
property p3dMember
property pSprite
property pCamera
property pCameraSphere
property pUpArrow
property pDownArrow
property pLeftArrow
property pRightArrow
property pMouseDown
property pRightMouseDown
property pcollisionList
on beginSprite me
p3dMember = sprite(me.spriteNum).member
pSprite = sprite(me.spriteNum)
pCamera = pSprite.camera
pUpArrow = FALSE
pDownArrow = FALSE
pLeftArrow = FALSE
pRightArrow = FALSE
pMouseDown = FALSE
pRightMouseDown = FALSE
camSphereRes = p3dMember.newModelResource("camSphereRes",#sphere)
camSphereRes.radius = 2
pCameraSphere = p3dMember.newModel("pCameraSphere",camSphereRes)
pCamera.addChild(pCameraSphere,#preserveParent)
p3dMember.registerForEvent(#timeMS,#controlCamera,me,1000,10,0)
end
on keyDown
case the keycode of
123 : pLeftArrow = TRUE -- left arrow
124 : pRightArrow = TRUE -- right arrow
125 : pDownArrow = TRUE -- down arrow
126 : pUpArrow = TRUE -- up arrow
end case
end
on keyUp
pLeftArrow = FALSE
pRightArrow = FALSE
pUpArrow = FALSE
pDownArrow = FALSE
end
on mouseDown
pMouseDown = TRUE
end
on mouseUp
pMouseDown = FALSE
end
on rightMouseDown
pRightMouseDown = TRUE
end
on rightMouseUp
pRightMouseDown = FALSE
end
on controlCamera me
if pLeftArrow then pCamera.translate(-1,0,0)
if pRightArrow then pCamera.translate(1,0,0)
if pUpArrow then pCamera.translate(0,0,-1)
if pDownArrow then pCamera.translate(0,0,1)
if pMouseDown then pCamera.rotate(0,-1,0)
if pRightMouseDown then pCamera.rotate(0,1,0)
end
on collisionDetect me
collisionList = p3dMember.modelsUnderRay(pCamera.worldPosition,-pCamera.transform.xAxis,#detailed)
if (collisionList.count) then
me.checkForCollision(collisionList[1])
end if
collisionList = p3dMember.modelsUnderRay(pCamera.worldPosition,pCamera.transform.xAxis,#detailed)
if (collisionList.count) then
me.checkForCollision(collisionList[1])
end if
collisionList = p3dMember.modelsUnderRay(pCamera.worldPosition,-pCamera.transform.zAxis,#detailed)
if (collisionList.count) then
me.checkForCollision(collisionList[1])
end if
collisionList = p3dMember.modelsUnderRay(pCamera.worldPosition,pCamera.transform.zAxis,#detailed)
if (collisionList.count) then
me.checkForCollision(collisionList[1])
end if
end
on checkForCollision me, thisData
dist = thisData.distance
if (dist < pCamera.resource.radius) then
diff = pCamera.resource.radius - dist
tVector = thisData.isectNormal * diff
pCamera.translate(tVector,#world)
end if
end
E' una vera EMERGENZA!! GRAZIE!!!!!!!!!

Risposte


Nessuna risposta trovata!