Пример #1
0
func main() {
	ode.Init(0, ode.AllAFlag)

	world = ode.NewWorld()
	space = ode.NilSpace().NewHashSpace()
	body = make([]ode.Body, numSpheres)
	joint = make([]ode.BallJoint, numSpheres-1)
	ctGrp = ode.NewJointGroup(1000000)
	sphere = make([]ode.Sphere, numSpheres)
	mass = ode.NewMass()

	world.SetGravity(ode.V3(0, 0, -0.5))
	space.NewPlane(ode.V4(0, 0, 1, 0))

	for i := 0; i < numSpheres; i++ {
		k := float64(i) * sideLen
		body[i] = world.NewBody()
		body[i].SetPosition(ode.V3(k, k, k+0.4))
		mass.SetBox(1, ode.V3(sideLen, sideLen, sideLen))
		mass.Adjust(sphereMass)
		body[i].SetMass(mass)
		sphere[i] = space.NewSphere(sphereRadius)
		sphere[i].SetBody(body[i])
	}

	for i := 0; i < numSpheres-1; i++ {
		joint[i] = world.NewBallJoint(ode.JointGroup(0))
		joint[i].Attach(body[i], body[i+1])
		k := (float64(i) + 0.5) * sideLen
		joint[i].SetAnchor(ode.V3(k, k, k+0.4))
	}

	if err := qml.Run(run); err != nil {
		fmt.Fprintf(os.Stderr, "error: %v\n", err)
		os.Exit(1)
	}
}
Пример #2
0
func init() {
	/* Initialize Open Dynamics Engine */
	ode.Init(0, ode.AllAFlag)
}