Exemplo n.º 1
0
// ImpulseToForce converts an impulse to a force over a step duration.
func (w World) ImpulseToForce(stepSize float64, impulse Vector3) Vector3 {
	force := NewVector3()
	C.dWorldImpulseToForce(w.c(), C.dReal(stepSize),
		C.dReal(impulse[0]), C.dReal(impulse[1]), C.dReal(impulse[2]),
		(*C.dReal)(&force[0]))
	return force
}
Exemplo n.º 2
0
// SetParams sets the mass parameters.
func (m *Mass) SetParams(mass float64, com Vector3, inert Matrix3) {
	c := &C.dMass{}
	C.dMassSetParameters(c, C.dReal(mass),
		C.dReal(com[0]), C.dReal(com[1]), C.dReal(com[2]),
		C.dReal(inert[0][0]), C.dReal(inert[1][1]), C.dReal(inert[2][2]),
		C.dReal(inert[0][1]), C.dReal(inert[0][2]), C.dReal(inert[1][3]))
	m.fromC(c)
}
Exemplo n.º 3
0
// Build builds a heightfield data set.
func (h Heightfield) Build(data HeightfieldData, heightSamples Matrix,
	width, depth, scale, offset, thickness float64, doWrap bool) {

	numWidthSamp, numDepthSamp := len(heightSamples), 0
	var heightSamplesPtr *C.double
	if numDepthSamp > 0 {
		numWidthSamp = len(heightSamples[0])
		if numWidthSamp > 0 {
			heightSamplesPtr = (*C.double)(&heightSamples[0][0])
		}
	}
	C.dGeomHeightfieldDataBuildDouble(data.c(), heightSamplesPtr, 1,
		C.dReal(width), C.dReal(depth), C.int(numWidthSamp), C.int(numDepthSamp),
		C.dReal(scale), C.dReal(offset), C.dReal(thickness), C.int(btoi(doWrap)))
}
Exemplo n.º 4
0
func (g *ContactGeom) toC(c *C.dContactGeom) {
	Vector(g.Pos).toC((*C.dReal)(&c.pos[0]))
	Vector(g.Normal).toC((*C.dReal)(&c.normal[0]))
	c.depth = C.dReal(g.Depth)
	c.g1 = g.G1.c()
	c.g2 = g.G2.c()
	c.side1 = C.int(g.Side1)
	c.side2 = C.int(g.Side2)
}
Exemplo n.º 5
0
Arquivo: ode.go Projeto: bfosberry/ode
func (v Vector) convertC(c *C.dReal, toC bool) {
	for i := range v {
		if toC {
			*c = C.dReal(v[i])
		} else {
			v[i] = float64(*c)
		}
		c = (*C.dReal)(unsafe.Pointer(uintptr(unsafe.Pointer(c)) + unsafe.Sizeof(*c)))
	}
}
Exemplo n.º 6
0
Arquivo: ode.go Projeto: bfosberry/ode
func (m Matrix) convertC(c *C.dReal, toC bool) {
	for i := range m {
		for j := 0; j < cap(m[i]); j++ {
			if j < len(m[i]) {
				if toC {
					*c = C.dReal(m[i][j])
				} else {
					m[i][j] = float64(*c)
				}
			}
			c = (*C.dReal)(unsafe.Pointer(uintptr(unsafe.Pointer(c)) + unsafe.Sizeof(*c)))
		}
	}
}
Exemplo n.º 7
0
// SetContactSurfaceLayer sets the depth of the surface layer around all
// geometry objects.
func (w World) SetContactSurfaceLayer(depth float64) {
	C.dWorldSetContactSurfaceLayer(w.c(), C.dReal(depth))
}
Exemplo n.º 8
0
// SetContactMaxCorrectingVelocity sets the maximum correcting velocity that
// contacts are allowed to generate.
func (w World) SetContactMaxCorrectingVelocity(overRelaxation float64) {
	C.dWorldSetContactMaxCorrectingVel(w.c(), C.dReal(overRelaxation))
}
Exemplo n.º 9
0
Arquivo: mass.go Projeto: krux02/gode
func (m *Mass) SetTrimesh(density Real, g *Geom) {
	C.dMassSetTrimesh((*C.dMass)(m), C.dReal(density), (C.dGeomID)((*C.struct_dxGeom)(g)))
}
Exemplo n.º 10
0
// SetCFM sets the constraint force mixing value.
func (w World) SetCFM(cfm float64) {
	C.dWorldSetCFM(w.c(), C.dReal(cfm))
}
Exemplo n.º 11
0
// SetGravity sets the gravity vector.
func (w World) SetGravity(grav Vector3) {
	C.dWorldSetGravity(w.c(), C.dReal(grav[0]), C.dReal(grav[1]), C.dReal(grav[2]))
}
Exemplo n.º 12
0
// SetAngularDampingThreshold sets the angular damping threshold.
func (w World) SetAngularDampingThreshold(threshold float64) {
	C.dWorldSetAngularDampingThreshold(w.c(), C.dReal(threshold))
}
Exemplo n.º 13
0
// SetAutoDisableTime sets the auto disable time.
func (w World) SetAutoDisableTime(time float64) {
	C.dWorldSetAutoDisableTime(w.c(), C.dReal(time))
}
Exemplo n.º 14
0
func (s *SurfaceParameters) toC(c *C.dSurfaceParameters) {
	c.mode = C.int(s.Mode)
	c.mu = C.dReal(s.Mu)
	c.mu2 = C.dReal(s.Mu2)
	c.rho = C.dReal(s.Rho)
	c.rho2 = C.dReal(s.Rho2)
	c.rhoN = C.dReal(s.RhoN)
	c.bounce = C.dReal(s.Bounce)
	c.bounce_vel = C.dReal(s.BounceVel)
	c.soft_erp = C.dReal(s.SoftErp)
	c.soft_cfm = C.dReal(s.SoftCfm)
	c.motion1 = C.dReal(s.Motion1)
	c.motion2 = C.dReal(s.Motion2)
	c.motionN = C.dReal(s.MotionN)
	c.slip1 = C.dReal(s.Slip1)
	c.slip2 = C.dReal(s.Slip2)
}
Exemplo n.º 15
0
Arquivo: mass.go Projeto: krux02/gode
func (m *Mass) Translate(v Vector3) {
	C.dMassTranslate((*C.dMass)(m), C.dReal(v[0]), C.dReal(v[1]), C.dReal(v[2]))
}
Exemplo n.º 16
0
Arquivo: mass.go Projeto: krux02/gode
func (m *Mass) Adjust(newmass Real) {
	C.dMassAdjust((*C.dMass)(m), C.dReal(newmass))
}
Exemplo n.º 17
0
Arquivo: mass.go Projeto: krux02/gode
func (m *Mass) SetTrimeshTotal(total_mass Real, g *Geom) {
	C.dMassSetTrimeshTotal((*C.dMass)(m), C.dReal(total_mass), (C.dGeomID)((*C.struct_dxGeom)(g)))
}
Exemplo n.º 18
0
// SetAutoDisableLinearThreshold sets the auto disable linear average threshold.
func (w World) SetAutoDisableLinearThreshold(linearThreshold float64) {
	C.dWorldSetAutoDisableLinearThreshold(w.c(), C.dReal(linearThreshold))
}
Exemplo n.º 19
0
// SetAutoDisableAngularThreshold sets the auto disable angular average threshold.
func (w World) SetAutoDisableAngularThreshold(angularThreshold float64) {
	C.dWorldSetAutoDisableAngularThreshold(w.c(), C.dReal(angularThreshold))
}
Exemplo n.º 20
0
Arquivo: misc.go Projeto: krux02/gode
func (m *Matrix6) Random(absmax Real) {
	C.dMakeRandomMatrix((*C.dReal)(&m[0]), 6, 6, C.dReal(absmax))
}
Exemplo n.º 21
0
// SetAngularDamping sets the angular damping scale.
func (w World) SetAngularDamping(scale float64) {
	C.dWorldSetAngularDamping(w.c(), C.dReal(scale))
}
Exemplo n.º 22
0
Arquivo: misc.go Projeto: krux02/gode
func (v *Vector3) Random(absmax Real) {
	C.dMakeRandomVector((*C.dReal)(&v[0]), 3, C.dReal(absmax))
}
Exemplo n.º 23
0
// SetMaxAngularSpeed sets the maximum angular speed.
func (w World) SetMaxAngularSpeed(maxSpeed float64) {
	C.dWorldSetMaxAngularSpeed(w.c(), C.dReal(maxSpeed))
}
Exemplo n.º 24
0
// QuickStep executes a simulation quick step, and returns whether the
// operation succeeded.
func (w World) QuickStep(stepSize float64) bool {
	return C.dWorldQuickStep(w.c(), C.dReal(stepSize)) != 0
}
Exemplo n.º 25
0
// SetERP sets the error reduction parameter.
func (w World) SetERP(erp float64) {
	C.dWorldSetERP(w.c(), C.dReal(erp))
}
Exemplo n.º 26
0
// SetBounds sets the minimum and maximum height.
func (h Heightfield) SetBounds(data HeightfieldData, minHeight, maxHeight float64) {
	C.dGeomHeightfieldDataSetBounds(data.c(), C.dReal(minHeight), C.dReal(maxHeight))
}
Exemplo n.º 27
0
Arquivo: mass.go Projeto: krux02/gode
func (m *Mass) SetBox(density, lx, ly, lz Real) {
	C.dMassSetBox((*C.dMass)(m), C.dReal(density), C.dReal(lx), C.dReal(ly), C.dReal(lz))
}
Exemplo n.º 28
0
Arquivo: mass.go Projeto: krux02/gode
func (m *Mass) SetBoxTotal(total_mass, lx, ly, lz Real) {
	C.dMassSetBoxTotal((*C.dMass)(m), C.dReal(total_mass), C.dReal(lx), C.dReal(ly), C.dReal(lz))
}
Exemplo n.º 29
0
// Point returns a point on the specified triangle at the given barycentric coordinates.
func (t TriMesh) Point(index int, u, v float64) Vector3 {
	pt := NewVector3()
	C.dGeomTriMeshGetPoint(t.c(), C.int(index), C.dReal(u), C.dReal(v), (*C.dReal)(&pt[0]))
	return pt
}
Exemplo n.º 30
0
// SetQuickStepW sets the over-relaxation parameter.
func (w World) SetQuickStepW(overRelaxation float64) {
	C.dWorldSetQuickStepW(w.c(), C.dReal(overRelaxation))
}