Skip to content

Physics

rust edited this page Mar 28, 2024 · 7 revisions

Physics determines when one virtual object collides with another. It can be useful to prevent an object representing a virtual avatar from walking through a virtual wall.

Physics works by associating an extra invisible shape with a given Model. To appear realistic, the physics shape is sized to be roughly the same as the virtual model.

    box := cene.AddModel("shd:pbr0", "msh:box0")           // create model
    box.SetScale(2, 2, 2).SetAt(lx, ly, lz)                // scale model
    box.AddToSimulation(vu.Box(2, 2, 2, vu.KinematicSim))  // add a physics body for the model 

The vu engine currently supports spheres and boxes.

See the Collision Resolution example.

eg/cr.go

Clone this wiki locally