29 using System.Collections.Generic;
33 using NUnit.Framework;
36 using OpenSim.Framework;
37 using OpenSim.Region.PhysicsModule.BulletS;
38 using OpenSim.Region.PhysicsModules.SharedBase;
39 using OpenSim.Tests.Common;
52 BSPrim TestVehicle {
get; set; }
53 Vector3 TestVehicleInitPosition {
get; set; }
54 float simulationTimeStep = 0.089f;
59 Dictionary<string, string> engineParams =
new Dictionary<string, string>();
60 engineParams.Add(
"VehicleEnableAngularVerticalAttraction",
"true");
61 engineParams.Add(
"VehicleAngularVerticalAttractionAlgorithm",
"1");
62 PhysicsScene = BulletSimTestsUtil.CreateBasicPhysicsEngine(engineParams);
65 Vector3 pos =
new Vector3(100.0f, 100.0f, 0f);
66 pos.Z = PhysicsScene.TerrainManager.GetTerrainHeightAtXYZ(pos) + 2f;
67 TestVehicleInitPosition = pos;
68 Vector3 size =
new Vector3(1f, 1f, 1f);
70 Quaternion rot = Quaternion.Identity;
74 PhysicsScene.AddPrimShape(
"testPrim", pbs, pos, size, rot, isPhys, localID);
75 TestVehicle = (
BSPrim)PhysicsScene.PhysObjects[localID];
77 PhysicsScene.ProcessTaints();
87 PhysicsScene.Dispose();
92 [TestCase(2f, 0.2f, 0.25f, 0.25f, 0.25f)]
93 [TestCase(2f, 0.2f, -0.25f, 0.25f, 0.25f)]
94 [TestCase(2f, 0.2f, 0.25f, -0.25f, 0.25f)]
95 [TestCase(2f, 0.2f, -0.25f, -0.25f, 0.25f)]
107 int simSteps = (int)(timeScale / simulationTimeStep) + 1;
110 Quaternion initOrientation = Quaternion.CreateFromEulers(initRoll, initPitch, initYaw);
111 TestVehicle.Orientation = initOrientation;
113 TestVehicle.Position = TestVehicleInitPosition;
119 BSDynamics vehicleActor = TestVehicle.GetVehicleActor(
true );
120 if (vehicleActor != null)
122 vehicleActor.ProcessFloatVehicleParam(Vehicle.VERTICAL_ATTRACTION_EFFICIENCY, efficiency);
123 vehicleActor.ProcessFloatVehicleParam(Vehicle.VERTICAL_ATTRACTION_TIMESCALE, timeScale);
126 TestVehicle.IsPhysical =
true;
127 PhysicsScene.ProcessTaints();
130 for (
int ii = 0; ii < simSteps; ii++)
132 vehicleActor.ForgetKnownVehicleProperties();
133 vehicleActor.ComputeAngularVerticalAttraction();
134 vehicleActor.PushKnownChanged();
136 PhysicsScene.Simulate(simulationTimeStep);
140 TestVehicle.IsPhysical =
false;
141 PhysicsScene.ProcessTaints();
152 Vector3 upPointer = Vector3.UnitZ * TestVehicle.Orientation;
153 Assert.That(upPointer.Z, Is.GreaterThan(0.99f));
void AngularVerticalAttraction(float timeScale, float efficiency, float initRoll, float initPitch, float initYaw)
Interactive OpenSim region server