Ask a Question related to Macromedia Director 3D, Design and Development.
-
StevenAdams #1
how to "bounce" sphere relative to world
:confused;
Hi all...I'm a total newbie to 3D, but have a 2D understanding of what I'm
looking for...I want to create a spehere that "bounces" or rebounds off of the
bounds of the 3D world...At this point, the sphere could be constrained to the
x & y axis...spinning would be good, but not necessary.
like this:
[url]http://www.adveract.com/shokbobl/baubles/jumpball.htm[/url]
I can do this in 2D, but have no clue how to translate that math to the
position of the model in 3D....is this possible?
Or do I require collision detection and some sort of havok world to "bounce"
the sphere off of?
Here is my 2D lingo:
property sp
property xVelocity, yVelocity
on beginsprite(me)
sp = sprite(me.spritenum)
xVelocity = 5
yVelocity = 3
end
on exitframe()
if sp.loch > (the stage).rect.width or sp.loch < 0 then
xVelocity = -xVelocity
end if
if sp.locv > (the stage).rect.height or sp.locv < 0 then
yVelocity = -yVelocity
end if
sp.loch = sp.loch + xVelocity
sp.locv = sp.locv + yVelocity
end
StevenAdams Guest
-
Message "Insecure world writable dir ..."
When File.popen() is passed an executable whose path contains a world writable directory, it produces a warning message. While I think this is a... -
"Send for Review" Changes Relative Links
Hi, When a user sends a file for review and the said document is then review and published all the relative links have been changed to absolute... -
Relative path in "foldexists" method
I tried to check whether the folder exist before writing a file. I tried to use the relative path for easier transfer to other server. I set up... -
what is javascript syntax of 'member("world").model.count'?
hi... what is javascript syntax of 'member("world").model.count'? and, what is javascript syntax of 'member("world").model("box")'? (it's not... -
"hello world" using SWIG or inline.pm ?
Can somebody teach me how to mix perl code with c++ ? That is, how can I use "inline.pm" or the SWIG package to write a c++ program which takes... -
hondo3000 #2
Re: how to "bounce" sphere relative to world
i think that it is a good idea to use the havok xtra for this kind of movement,
because you can have a fast collision detection. to start with it you can try
this code. you will need:
- a shockwave3D member on the stage
- a havok member named "havok"
make a behavior out of this script and attach it to the 3D member on the stage.
code:
property pSprite, pMember, pHavok
on beginsprite me
puppettempo=60
pSprite=sprite(me.spritenum)
pMember=pSprite.member
pMember.resetworld()
pHavok=member("havok")
pHavok.initialize(pMember, 1, 1)
pHavok.gravity=vector(0,-981,0)
sphere_res=pMember.newmodelresource("sphere",#sphe re, #front)
sphere_res.resolution=25
sphere_res.radius=25
sphere01=pMember.newmodel("sphere01", sphere_res)
sphere01.addmodifier(#meshdeform)
hsphere=pHavok.makeMovableRigidBody(sphere01.name, 10, true, #sphere)
--hsphere=pHavok.makeMovableRigidBody(sphere01.name, 1, false)
hsphere.friction=0
hsphere.restitution=1
ground_res=pMember.newmodelresource("ground", #box, #front)
ground_res.height =250
ground_res.width=250
ground_res.length=250
ground=pMember.newmodel("ground", ground_res)
ground.transform.position=vector(0,-225,0)
ground.addmodifier(#meshdeform)
hground=pHavok.makeFixedRigidBody(ground.name, true, #box)
hground.friction=0
hground.restitution=0.9
end
on endsprite me
pHavok.shutdown()
end
on exitframe me
pHavok.step(0.0167, 4)
go the frame
end
i hope it will work for you.
hondo3000 Guest



Reply With Quote

