Professional Web Applications Themes

step and havok physics - Macromedia Director 3D

I'm teaching physics and want to get correct gravity and accelerations etz. If I make with lingo world with ground and body and set: (frame tempo is 30) on startmovie .... hk.step(0.0333,0) hk.initialize(pscene,0.3,1) hk.gravity=vector(0,-9.81,0) .... makebox 1 , 3, 1 ,Vector(0,40,0), 10 .... end the box falls correct. if I write hk.step(0.0333,1) the box falls with not quite right acceleration But if I make the world in 3ds and set in beginsprite behavior that hk.step(0.0333,0) bos dont move at all. And hk.step(0.0333,1) seems not to work quite right. So 1)why different step in beginsprite and in startmovie? 2) is it ...

  1. #1

    Default step and havok physics

    I'm teaching physics and want to get correct gravity and accelerations etz.
    If I make with lingo world with ground and body and set: (frame tempo is 30)

    on startmovie
    ....
    hk.step(0.0333,0)
    hk.initialize(pscene,0.3,1)
    hk.gravity=vector(0,-9.81,0)
    ....
    makebox 1 , 3, 1 ,Vector(0,40,0), 10
    ....
    end

    the box falls correct.

    if I write hk.step(0.0333,1) the box falls with not quite right acceleration

    But if I make the world in 3ds and set in beginsprite behavior that
    hk.step(0.0333,0)
    bos dont move at all. And hk.step(0.0333,1) seems not to work quite right.


    So
    1)why different step in beginsprite and in startmovie?
    2) is it bad to use startmovie and make bodys there (calling methods)?

    Olavi (Finland, Kuopio music high school)



    olavi Lappalainen Guest

  2. #2

    Default Re: step and havok physics

    maybe i did not get the problem, but as far as i know you use the
    havok.step(0.3333,0) thing in a exitframe or enterframe or stepframe handler.
    not in the beginsprite, startmovie or any initialazion handler.

    it should look like this:

    property pMember, pHavok, spritenum


    on beginsprite me
    puppettempo 60
    pMember=sprite(spritenum).member
    pMember.resetworld()

    pHavok=member("havok")

    pHavok.shutdown()
    pHavok.initialize(pMember, 1,1)
    pHavok.gravity=vector(0,-98.1,0)

    --## make a movable box

    boxres=pMember.newmodelresource("box_res", #box, #front)
    boxres.height=10
    boxres.width=10
    boxres.length=10

    box01=pMember.newmodel("box01", boxres)
    box01.worldposition=vector(0,200,0)
    box01.addmodifier(#meshdeform)

    hke_box=pHavok.makemovablerigidbody(box01.name, 100, true, #box)

    --## make ground box

    ground_res=pMember.newmodelresource("ground_res", #box, #front)
    ground_res.height=10
    ground_res.width=100
    ground_res.length=100

    ground=pMember.newmodel("ground", ground_res)
    ground.worldposition=vector(0,100,0)
    ground.addmodifier(#meshdeform)

    hke_box=pHavok.makefixedrigidbody(ground.name,true ,#box)
    end

    on exitframe me
    pHavok.step(0.0167,4)
    go the frame
    end

    if you specifie no substeps the simulation will not run, you have to make at
    least one substep. to make the simulation more accurate use more substeps. and
    use puppettempo to speed up your animation, at 30fps you are running a very
    unexact simulation.

    hondo3000 Guest

  3. #3

    Default Re: step and havok physics

    thanks hondo3000!

    Some questions more.
    1)when should i use havok.shutdown() ?

    2) i need exact and realistic gravity so when a body falls its velocity
    must increase 9,81 m/s every second. .
    more substeps make more exact but when i try
    spHavok.step(0.0167,5) velocity don't increase excact 9,81 m/s every
    second..
    spHavok.step(0.0167,1) gives more realistic fall but body may jitter..How
    can i use 5 substeps without loosing realistic falling?

    3) must i call pHavok.step(0.0167,4) in exitframe? I drag in director fron
    library palette havok physics(No hke) to 3dsprite and then in popup choose
    timeIncrement and substeps.




    olavi Lappalainen Guest

  4. #4

    Default Re: step and havok physics

    1)when should i use havok.shutdown() ?

    havok shutdown() is similar to resetworld() wich you can use in the beginning
    of the scene or on its end, or when you want it to be erased from memory. i use
    it on the same place with the resetworld() command. it can be used on
    endsprite, beginsprite, startmovie, stopmovie. but because the havok xtra is in
    some situations a littel bit buggy it is always better to make a shutdown
    somewhere to be sure it is not in memory anymore.

    2) at the moment i had not the time to check for physical correctness, the
    problem is that it is a realtime physics engine wich is allways a little bit
    unprecise because its optimized for realtime calculations and much collision
    detection. but maybe you should check if there are dragparameters applied to
    the world, this could slowdown the movable body. but be carefull with setting
    dragparameters, you can only do it once you load the project into director,
    setting it a second time without reloading the project leads in s fatal error,
    this is a bug.

    3) i never got lucky with using the libary behaviors because it need too much
    time to understand the code. i put here a simple demo file that is displaying
    the speed of the box in the messagewindow.
    download as zip:
    [url]http://kisd.de/~lutz/crap/fallingbox.zip[/url]

    so maybe you can mesure a little bit around and change the gravity value until
    it fit to your needs. or you build your own physics simulation with the
    collision modifier.

    hondo3000 Guest

Similar Threads

  1. Havok Physics is causing publishing problems in my file
    By CStudent in forum Macromedia Director 3D
    Replies: 1
    Last Post: May 3rd, 02:39 AM
  2. Shockwave requiring havok physics scene
    By Nocky35 in forum Macromedia Director 3D
    Replies: 12
    Last Post: March 10th, 06:46 PM
  3. Havok qestions (car physics)
    By mrMoonlight in forum Macromedia Director 3D
    Replies: 0
    Last Post: February 1st, 08:08 PM
  4. Havok physics: how to stop a submarine from spinning
    By Zeno Vugt in forum Macromedia Director 3D
    Replies: 0
    Last Post: December 16th, 11:26 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not 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