Using NewtonPhysics

From Micasim

Jump to: navigation, search


Project OpenSim Physics
Project Lead Rob Knop
Project Homepage NewtonPhysics

A Quick and Dirty Demonstration

Log in. Rez out a bunch prims. You can do this by creating one prim (a sphere, say), up in the air. Copy it. Select the two, and copy them. Select the four, and copy them. Repeat until you've got 32 or 64 prims.

Select all of the prims, "edit" them. Go into the "Object" tab and select the "Physics" box. Press ESC to stop selecting all of the prims.

You'll see them all start to fall towards each other as they mutually gravitate. Exciting!

Specifying Initial Conditions

I've written some scripts that allow you to specify initial conditions, both position and velocity, for stars. This has two components. First, there is a script you can place in stars that listens for command from a rezzer object that tell it where to go and what its initial velocity should be. It then listens for the command that tells it to start the sim. When it gets that command, it turns itself physical (so that it will be subject to the n-body simulator physics engine), and it uses the llApplyImpulse script function to give itself a kick that will give it the proper initial velocity.

Second, there's a scripted rezzer object that rezzes out the stars and tells them their initial conditions. Then it listens for commands on channel 1, and tells all of the stars to do things when you tell it to do things.

Here is the star script : Opensim_star.lsl

Here is a rezzer scirpt that rezzes two stars orbiting in a circle : Circularrezzer.lsl

Here is a rezzer script that rezzes 64 stars with a 1/r distribution : Clusterrezzer.lsl

You can modify the rezzer script for other initial conditions.

To use this:

  • Rez a single prim (a cube), and put the rezzer script in it.
  • Rez a single prim (a sphere), and put the star script in it.
  • Take the star into your inventory.
  • Copy the star into the inventory of the rezzer prim.
  • Move the rezzer script "fairly far" up into the air-- it should high enough that after rezzing, all of the stars will be off of the ground. For the scripts I've provided here, 100m up in the air should be high enough.
  • Fly up so you're near the rezzer cube. (It needs to be able to hear you.)
  • Type "/1 rez" into local chat. The stars should rez. It will take several seconds for them to rez and get to the right place.
  • Type "/1 go" to start the simulation.

Once the simulation is going, zoom around, zoom your camera, and watch the fun. There are other commands you can issue to the rezzer object:

  • Type "/1 stop" to stop the simulation.
  • Type "/1 start" to restart the simulation where it left off.
  • Type "/1 die" to delete all of the stars.