how to "bounce" sphere relative to world

Ask a Question related to Macromedia Director 3D, Design and Development.

  1. #1

    Default 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

  2. Similar Questions and Discussions

    1. 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...
    2. "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...
    3. 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...
    4. 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...
    5. "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...
  3. #2

    Default 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

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139