I'd use a setcollision callback handler to detect when your camera has hit
the wall and then move it back a little so there won't be anymore collision
detections unless of course the user proceeds to hit the wall again, but
first off what you have to do is make a dummy model and either make the
camera the child object of that dummy model or dummyModel.transform.position
= sprite(1).camera.transform.position; the purpose of making a dummy model
is because collision detection doesn't work on camera's so the dummy model
will be used to detect collisions of the camera of course you can set your
dummyModels.visibility = #none you could use a plane or box of sphere
primitive. The most important thing to remember is that each of your
objects that you want to have collisions detected on has to have the
collision modifier added to that object and several parameters set.
tResourceDummy = pMbr.newModelResource("DumSph", #sphere, #back)
tResourceDummy.resolution = 8 -- set it low
dummySph = pMbr.newModel("dSph1", tResourceDummy)
dummySph.transform.position = sprite(1).camera.transform.position
Well what I would do is use the setcollisioncallback handler for the car and
#collidewithany property set like:
dummySph.addModifier(#collision)
dummySph.collision.enabled = true
dummySph.collision.resolve = false -- otherwise your camera will stop
dummySph.collision.mode = #mesh
dummySph.collision.setCollisionCallBack(#Details, 0)
wallModel.addModifier(#collision)
wallModel.collision.enabled = true
wallModel.collision.resolve = false -- otherwise your camera will stop
wallModel.collision.mode = #mesh
global collisionFlag
on Details me, collisiondata
if collisiondata.modelb.name.char[1..4] = "wall" and
collisiondata.modela.name = "dummySph" then
member("3d").model(collisiondata.modela.name).collision.enabled = false
-- modela is your dummyModel set to false to stop getting 20 or so collision
-- detections
sprite(1).camera.transform.position = sprite(1).camera.transform.position +
vector(0,0,1)
-- set your camera back one unit if you were going in the -z direction
simple example
else if (collisiondata.modela.name.char[1..4] = "wall" and
collisiondata.modelb.name = "dummySph" then
sprite(1).camera.transform.position = sprite(1).camera.transform.position +
vector(0,0,1)
member("3d").model(collisiondata.modelb.name).collision.enabled = false
-- just to catch it in case you don't know which is modela or modelb which
you don't
-- set to false to stop getting 20 or so collision detections
end if
member("3d").model(collisiondata.modelb.name).collision.enabled = false
collisionFlag = 1
end
global dummySph, colllisionFlag
on exitFrame
if not voidP(dummySph) then
if collisionFlag = 1 then
dummySph.collision.enabled = true
-- set it back to true so the next time it hits your objects it will
-- "detect" them
end if
end if
end
I'll leave the direction that your camera should bounce back up to you maybe
you could use axisangle or anglebetween or whatever but I guess thats
another subject altogether right now.
This is the single most asked question about 3D with Director what happens
is there is a little bug in the collision detection so that's why I disable
collision detection in the collision callback handler and reset it in the
exitframe handler this is very important so you don't get 20 detections
every time you hit something and slow your movie to a crawl.
The other important thing to keep in mind is your mode property if you use
#sphere then you will get "big" collision detections if you use #mesh it is
a bit slower, so you have to experiment also read the release notes some
modes resolve to a certain kind I think mesh/sphere is really mesh/mesh etc.
There is a 3D Director specific mailing list that you should be on go to
www.directoru.com and click on the community center and then mailing list,
there are also 3D resources there including 3D examples "Glass World" is
very good, also www.director-online.com has 2 or 3 articles about the new 3D
features in Director.
Hope that helps you,
Alex Smith
PS I was just in Argentina, in BA and Rosario my wife is from there
[To remove yourself from this list, or to change to digest mode, go to
http://www.penworks.com/LUJ/lingo-l.cgi To post messages to the list,
email [EMAIL PROTECTED] (Problems, email [EMAIL PROTECTED])
Lingo-L is for learning and helping with programming Lingo. Thanks!]