00001
00002 #include "BuggyCar.h"
00003 #include "ResourceManager.h"
00004 #include "random_utils/LogManager.h"
00005 #include "vrsode/PhysicsManager.h"
00006 #include "vrsode/CylinderShape.h"
00007 #include "vrsode/BoxShape.h"
00008 #include "vrsode/SphereShape.h"
00009
00010 #include <vrs/box.h>
00011 #include <vrs/color.h>
00012 #include <vrs/torus.h>
00013 #include <vrs/vector.h>
00014 #include <vrs/scaling.h>
00015 #include <vrs/opengl/shapematerialgl.h>
00016 #include <vrs/translation.h>
00017 #include <vrs/io/threedsreader.h>
00018 #include <vrs/sg/sceneadjuster.h>
00019 #include <vrs/tf.h>
00020
00021 using namespace vrsode;
00022
00023 namespace random_racer
00024 {
00025
00026 BuggyCar::BuggyCar(VRS::SO<VRS::SceneThing> p_parent) : Car(p_parent)
00027 {
00028 m_wheelMu = 999;
00029 m_wheelSlip1 = 0.1;
00030 m_wheelSlip2 = 0.1;
00031
00032 m_springLengthFront = 0.1;
00033
00034 m_springPowerFront = 20;
00035 m_springSpeedFront = 1.4;
00036 m_springLengthRear = 0.2;
00037 m_springPowerRear = 20;
00038 m_springSpeedRear = 1.4;
00039
00040 m_wheelRad = 0.5;
00041 m_wheelWidth = 1.0;
00042
00043 m_suspensionSoftness = 0.0;
00044 m_steeringRadius = 0.4;
00045
00046 m_carMaxSpeed = 30;
00047 m_carPower = 25;
00048
00049 m_wheelMass = 0.01;
00050 m_bodyMass = 8.0;
00051 m_helperMass = 0.01;
00052
00053 m_steerOffsetFL = VRS::Vector( 1.0, -0.12, -1.8);
00054 m_steerOffsetFR = VRS::Vector(-1.0, -0.12, -1.8);
00055
00056 m_chassisOffset = VRS::Vector( 0, 0, 0);
00057 m_wheelOffsetFL = VRS::Vector( 1.0, -0.12, -1.8);
00058 m_wheelOffsetFR = VRS::Vector(-1.0, -0.12, -1.8);
00059 m_wheelOffsetRL = VRS::Vector( 1.25, -0.08, 0.9);
00060 m_wheelOffsetRR = VRS::Vector(-1.25, -0.08, 0.9);
00061
00062 m_axisOffsetFL = VRS::Vector( 1.25, -0.12, -1.8);
00063 m_axisOffsetFR = VRS::Vector(-1.25, -0.12, -1.8);
00064 m_axisOffsetRL = VRS::Vector( 1.25, -0.08, 0.9);
00065 m_axisOffsetRR = VRS::Vector(-1.25, -0.08, 0.9);
00066
00067 m_suspensionOffsetFL = VRS::Vector( 0.45, -0.02, -1.8);
00068 m_suspensionOffsetFR = VRS::Vector(-0.45, -0.02, -1.8);
00069 m_suspensionOffsetRL = VRS::Vector( 0.59, -0.12, 0.7);
00070 m_suspensionOffsetRR = VRS::Vector(-0.59, -0.12, 0.7);
00071
00072 m_suspensionSoftnessOffsetFL = VRS::Vector( 0.6, -0.12, -1.8);
00073 m_suspensionSoftnessOffsetFR = VRS::Vector(-0.6, -0.12, -1.8);
00074 m_suspensionSoftnessOffsetRL = VRS::Vector( 0.6, -0.12, -1.8);
00075 m_suspensionSoftnessOffsetRR = VRS::Vector(-0.6, -0.12, -1.8);
00076
00077
00078 VRS::SO<VRS::SceneThing> federLV;
00079 VRS::SO<VRS::SceneThing> federRV;
00080 VRS::SO<VRS::SceneThing> federLH;
00081 VRS::SO<VRS::SceneThing> federRH;
00082
00083 VRS::SO<VRS::SceneThing> federInnenLV;
00084 VRS::SO<VRS::SceneThing> federInnenRV;
00085 VRS::SO<VRS::SceneThing> federInnenLH;
00086 VRS::SO<VRS::SceneThing> federInnenRH;
00087
00088 VRS::SO<VRS::SceneThing> achseLV;
00089 VRS::SO<VRS::SceneThing> achseRV;
00090 VRS::SO<VRS::SceneThing> achseLH;
00091 VRS::SO<VRS::SceneThing> achseRH;
00092
00093 VRS::SO<VRS::SceneThing> radLV;
00094 VRS::SO<VRS::SceneThing> radRV;
00095 VRS::SO<VRS::SceneThing> radLH;
00096 VRS::SO<VRS::SceneThing> radRH;
00097
00098 VRS::SO<VRS::SceneThing> body;
00099
00100 m_rootNode = new VRS::SceneThing(p_parent);
00101
00102 VRS::SO<VRS::SceneThing> carNode = new VRS::SceneThing();
00103
00104 m_rootNode->append(carNode);
00105
00106 VRS::SO<VRS::SceneThing> tmp;
00107 VRS::SO<VRS::SceneThing> modelRootThing =
00108 ResourceManager::get()->load3ds("model/model.3ds");
00109
00110 if(!modelRootThing)
00111 std::cerr << "ERROR: cannot load mesh" << std::endl;
00112
00113
00114 tmp = (VRS::SceneThing*)modelRootThing->object(1);
00115 tmp = (VRS::SceneThing*)tmp->object(2);
00116 tmp = (VRS::SceneThing*)tmp->object(2);
00117 federLV = tmp;
00118
00119 tmp = (VRS::SceneThing*)modelRootThing->object(1);
00120 tmp = (VRS::SceneThing*)tmp->object(3);
00121 tmp = (VRS::SceneThing*)tmp->object(2);
00122 federInnenLV = tmp;
00123
00124 tmp = (VRS::SceneThing*)modelRootThing->object(1);
00125 tmp = (VRS::SceneThing*)tmp->object(4);
00126 tmp = (VRS::SceneThing*)tmp->object(2);
00127 achseLV = tmp;
00128
00129 tmp = (VRS::SceneThing*)modelRootThing->object(1);
00130 tmp = (VRS::SceneThing*)tmp->object(6);
00131 tmp = (VRS::SceneThing*)tmp->object(2);
00132 radLH = tmp;
00133
00134 tmp = (VRS::SceneThing*)modelRootThing->object(1);
00135 tmp = (VRS::SceneThing*)tmp->object(7);
00136 tmp = (VRS::SceneThing*)tmp->object(2);
00137 radRV = tmp;
00138
00139 tmp = (VRS::SceneThing*)modelRootThing->object(1);
00140 tmp = (VRS::SceneThing*)tmp->object(8);
00141 tmp = (VRS::SceneThing*)tmp->object(2);
00142 radLV = tmp;
00143
00144 tmp = (VRS::SceneThing*)modelRootThing->object(1);
00145 tmp = (VRS::SceneThing*)tmp->object(5);
00146 tmp = (VRS::SceneThing*)tmp->object(2);
00147 tmp = (VRS::SceneThing*)tmp->object(2);
00148 tmp = (VRS::SceneThing*)tmp->object(2);
00149 radRH = tmp;
00150
00151 tmp = (VRS::SceneThing*)modelRootThing->object(1);
00152 tmp = (VRS::SceneThing*)tmp->object(9);
00153 tmp = (VRS::SceneThing*)tmp->object(1);
00154 body = tmp;
00155
00156 tmp = (VRS::SceneThing*)modelRootThing->object(1);
00157 tmp = (VRS::SceneThing*)tmp->object(10);
00158 tmp = (VRS::SceneThing*)tmp->object(2);
00159 achseRV = tmp;
00160
00161 tmp = (VRS::SceneThing*)modelRootThing->object(1);
00162 tmp = (VRS::SceneThing*)tmp->object(11);
00163 tmp = (VRS::SceneThing*)tmp->object(1);
00164 federInnenRV = tmp;
00165
00166 tmp = (VRS::SceneThing*)modelRootThing->object(1);
00167 tmp = (VRS::SceneThing*)tmp->object(12);
00168 tmp = (VRS::SceneThing*)tmp->object(1);
00169 federRV = tmp;
00170
00171 tmp = (VRS::SceneThing*)modelRootThing->object(1);
00172 tmp = (VRS::SceneThing*)tmp->object(13);
00173 tmp = (VRS::SceneThing*)tmp->object(2);
00174 achseRH = tmp;
00175
00176 tmp = (VRS::SceneThing*)modelRootThing->object(1);
00177 tmp = (VRS::SceneThing*)tmp->object(14);
00178 tmp = (VRS::SceneThing*)tmp->object(2);
00179 federLH = tmp;
00180
00181 tmp = (VRS::SceneThing*)modelRootThing->object(1);
00182 tmp = (VRS::SceneThing*)tmp->object(15);
00183 tmp = (VRS::SceneThing*)tmp->object(2);
00184 federInnenLH = tmp;
00185
00186 tmp = (VRS::SceneThing*)modelRootThing->object(1);
00187 tmp = (VRS::SceneThing*)tmp->object(16);
00188 tmp = (VRS::SceneThing*)tmp->object(1);
00189 federInnenRH = tmp;
00190
00191 tmp = (VRS::SceneThing*)modelRootThing->object(1);
00192 tmp = (VRS::SceneThing*)tmp->object(17);
00193 tmp = (VRS::SceneThing*)tmp->object(1);
00194 federRH = tmp;
00195
00196 tmp = (VRS::SceneThing*)modelRootThing->object(1);
00197 tmp = (VRS::SceneThing*)tmp->object(18);
00198 tmp = (VRS::SceneThing*)tmp->object(2);
00199 achseLH = tmp;
00200
00201
00202 VRS::SO<VRS::SceneThing> st;
00203
00204 st = new VRS::SceneThing(carNode);
00205 m_chassis = new PhysicsBody(st, new BoxShape(VRS::Bounds(
00206 VRS::Vector(-0.2, -0.2, -0.4), VRS::Vector(0.2, 0.2, 0.4))), true);
00207
00208 VRS::SO<VRS::SceneThing> chassisSceneThing = new VRS::SceneThing(st);
00209 chassisSceneThing->append(new VRS::Scaling(0.003, 0.003, 0.003));
00210 chassisSceneThing->append(body);
00211
00212 VRS::SO<VRS::SceneThing> federLVSceneThing = new VRS::SceneThing(st);
00213 federLVSceneThing->append(new VRS::Scaling(0.003, 0.003, 0.003));
00214 federLVSceneThing->append(federLV);
00215 VRS::SO<VRS::SceneThing> federRVSceneThing = new VRS::SceneThing(st);
00216 federRVSceneThing->append(new VRS::Scaling(0.003, 0.003, 0.003));
00217 federRVSceneThing->append(federRV);
00218 VRS::SO<VRS::SceneThing> federLHSceneThing = new VRS::SceneThing(st);
00219 federLHSceneThing->append(new VRS::Scaling(0.003, 0.003, 0.003));
00220 federLHSceneThing->append(federLH);
00221 VRS::SO<VRS::SceneThing> federRHSceneThing = new VRS::SceneThing(st);
00222 federRHSceneThing->append(new VRS::Scaling(0.003, 0.003, 0.003));
00223 federRHSceneThing->append(federRH);
00224
00225 st = new VRS::SceneThing(carNode);
00226 m_wheelFL = new PhysicsBody(st, new SphereShape(VRS::Bounds(
00227 VRS::Vector(-0.4, -0.4, -0.4), VRS::Vector(0.4, 0.4, 0.4))), true);
00228
00229
00230
00231 st->append(new VRS::Scaling(0.003, 0.003, 0.003));
00232 st->append(radLV);
00233
00234 st = new VRS::SceneThing(carNode);
00235 m_wheelFR = new PhysicsBody(st, new SphereShape(VRS::Bounds(
00236 VRS::Vector(-0.4, -0.4, -0.4), VRS::Vector(0.4, 0.4, 0.4))), true);
00237
00238
00239
00240 st->append(new VRS::Scaling(0.003, 0.003, 0.003));
00241 st->append(radRV);
00242
00243 st = new VRS::SceneThing(carNode);
00244 m_wheelRL = new PhysicsBody(st, new SphereShape(VRS::Bounds(
00245 VRS::Vector(-0.4, -0.4, -0.4), VRS::Vector(0.4, 0.4, 0.4))), true);
00246
00247
00248
00249 st->append(new VRS::Scaling(0.003, 0.003, 0.003));
00250 st->append(radLH);
00251
00252 st = new VRS::SceneThing(carNode);
00253 m_wheelRR = new PhysicsBody(st, new SphereShape(VRS::Bounds(
00254 VRS::Vector(-0.4, -0.4, -0.4), VRS::Vector(0.4, 0.4, 0.4))), true);
00255
00256
00257
00258 st->append(new VRS::Scaling(0.003, 0.003, 0.003));
00259 st->append(radRH);
00260
00261 VRS::SO<VRS::SceneThing> suspensionThingFL;
00262 VRS::SO<VRS::SceneThing> suspensionThingFR;
00263
00264 st = new VRS::SceneThing(carNode);
00265 m_suspensionFL = new PhysicsBody(st, CS_None, true);
00266 st->append(new VRS::Scaling(0.003, 0.003, 0.003));
00267 st->append(achseLV);
00268
00269
00270 st = new VRS::SceneThing(carNode);
00271 m_suspensionFR = new PhysicsBody(st, CS_None, true);
00272 st->append(new VRS::Scaling(0.003, 0.003, 0.003));
00273 st->append(achseRV);
00274
00275
00276 st = new VRS::SceneThing(carNode);
00277 m_suspensionRL = new PhysicsBody(st, CS_None, true);
00278 st->append(new VRS::Scaling(0.003, 0.003, 0.003));
00279 st->append(achseLH);
00280
00281
00282 st = new VRS::SceneThing(carNode);
00283 m_suspensionRR = new PhysicsBody(st, CS_None, true);
00284 st->append(new VRS::Scaling(0.003, 0.003, 0.003));
00285 st->append(achseRH);
00286
00287
00288 st = new VRS::SceneThing(carNode);
00289 m_springFL = new PhysicsBody(st, CS_None, true);
00290 st->append(new VRS::Scaling(0.003, 0.003, 0.003));
00291 st->append(federInnenLV);
00292
00293 st = new VRS::SceneThing(carNode);
00294 m_springFR = new PhysicsBody(st, CS_None, true);
00295 st->append(new VRS::Scaling(0.003, 0.003, 0.003));
00296 st->append(federInnenRV);
00297
00298
00299 st = new VRS::SceneThing(carNode);
00300 m_springRL = new PhysicsBody(st, CS_None, true);
00301 st->append(new VRS::Scaling(0.003, 0.003, 0.003));
00302 st->append(federInnenLH);
00303
00304 st = new VRS::SceneThing(carNode);
00305 m_springRR = new PhysicsBody(st, CS_None, true);
00306 st->append(new VRS::Scaling(0.003, 0.003, 0.003));
00307 st->append(federInnenRH);
00308
00309
00310 st = new VRS::SceneThing(carNode);
00311 m_steerFL = new PhysicsBody(st, CS_None);
00312
00313 st = new VRS::SceneThing(carNode);
00314 m_steerFR = new PhysicsBody(st, CS_None);
00315
00316 m_chassis->setPosition(m_chassisOffset);
00317 m_wheelFL->setPosition(m_wheelOffsetFL);
00318 m_wheelFR->setPosition(m_wheelOffsetFR);
00319 m_wheelRL->setPosition(m_wheelOffsetRL);
00320 m_wheelRR->setPosition(m_wheelOffsetRR);
00321
00322
00323
00324
00325
00326
00327
00328
00329
00330
00331
00332
00333
00334
00335 m_suspensionFL->setPosition(m_suspensionOffsetFL);
00336 m_suspensionFR->setPosition(m_suspensionOffsetFR);
00337 m_suspensionRL->setPosition(m_suspensionOffsetRL);
00338 m_suspensionRR->setPosition(m_suspensionOffsetRR);
00339
00340 m_wheelFL->setRotation(VRS::Vector(0,0,1), -90);
00341 m_wheelFR->setRotation(VRS::Vector(0,0,1), 90);
00342 m_wheelRL->setRotation(VRS::Vector(0,0,1), -90);
00343 m_wheelRR->setRotation(VRS::Vector(0,0,1), 90);
00344
00345 m_axisFL = new PhysicsJointHinge(m_steerFL, m_wheelFL,
00346 m_axisOffsetFL, VRS::Vector(1,0,0));
00347
00348 m_axisFR = new PhysicsJointHinge(m_steerFR, m_wheelFR,
00349 m_axisOffsetFR, VRS::Vector(1,0,0));
00350
00351 m_axisRL = new PhysicsJointHinge(m_suspensionRL, m_wheelRL,
00352 m_axisOffsetRL, VRS::Vector(1,0,0));
00353
00354 m_axisRR = new PhysicsJointHinge(m_suspensionRR, m_wheelRR,
00355 m_axisOffsetRR, VRS::Vector(1,0,0));
00356
00357 m_springSliderFL = new PhysicsJointSlider(
00358 m_chassis, m_springFL, VRS::Vector(0.2,1,0));
00359 m_springSliderFR = new PhysicsJointSlider(
00360 m_chassis, m_springFR, VRS::Vector(-0.2,1,0));
00361
00362 m_springSliderRL = new PhysicsJointSlider(
00363 m_chassis, m_springRL, VRS::Vector(0.2,1,0));
00364 m_springSliderRR = new PhysicsJointSlider(
00365 m_chassis, m_springRR, VRS::Vector(-0.2,1,0));
00366
00367 m_springSliderFL->setHighStop(0.05);
00368 m_springSliderFL->setLowStop(-m_springLengthFront);
00369 m_springSliderFL->setMotorVelocity(m_springSpeedFront);
00370 m_springSliderFL->setMotorMaxForce(m_springPowerFront);
00371
00372 m_springSliderFR->setHighStop(0.05);
00373 m_springSliderFR->setLowStop(-m_springLengthFront);
00374 m_springSliderFR->setMotorVelocity(m_springSpeedFront);
00375 m_springSliderFR->setMotorMaxForce(m_springPowerFront);
00376
00377 m_springSliderRL->setHighStop(0.0);
00378 m_springSliderRL->setLowStop(-m_springLengthRear);
00379 m_springSliderRL->setMotorVelocity(m_springSpeedRear);
00380 m_springSliderRL->setMotorMaxForce(m_springPowerRear);
00381
00382 m_springSliderRR->setHighStop(0.0);
00383 m_springSliderRR->setLowStop(-m_springLengthRear);
00384 m_springSliderRR->setMotorVelocity(m_springSpeedRear);
00385 m_springSliderRR->setMotorMaxForce(m_springPowerRear);
00386
00387 m_suspensionSoftnessFL = new PhysicsJointHinge(
00388 m_springFL, m_suspensionFL,
00389 m_suspensionSoftnessOffsetFL, VRS::Vector(0,0,1));
00390 m_suspensionSoftnessFL->setHighStop(m_suspensionSoftness);
00391 m_suspensionSoftnessFL->setLowStop(-m_suspensionSoftness);
00392
00393 m_suspensionSoftnessFR = new PhysicsJointHinge(
00394 m_springFR, m_suspensionFR,
00395 m_suspensionSoftnessOffsetFR, VRS::Vector(0,0,1));
00396 m_suspensionSoftnessFR->setHighStop(m_suspensionSoftness);
00397 m_suspensionSoftnessFR->setLowStop(-m_suspensionSoftness);
00398
00399 m_suspensionSoftnessRL = new PhysicsJointHinge(
00400 m_springRR, m_suspensionRL,
00401 m_suspensionSoftnessOffsetRL, VRS::Vector(0,0,1));
00402 m_suspensionSoftnessRL->setHighStop(m_suspensionSoftness);
00403 m_suspensionSoftnessRL->setLowStop(-m_suspensionSoftness);
00404
00405 m_suspensionSoftnessRR = new PhysicsJointHinge(
00406 m_springRL, m_suspensionRR,
00407 m_suspensionSoftnessOffsetRR, VRS::Vector(0,0,1));
00408 m_suspensionSoftnessRR->setHighStop(m_suspensionSoftness);
00409 m_suspensionSoftnessRR->setLowStop(-m_suspensionSoftness);
00410
00411 m_steerControlFL = new PhysicsJointHinge(m_steerFL, m_suspensionFR,
00412 m_steerOffsetFL, VRS::Vector(0,1,0));
00413 m_steerControlFR = new PhysicsJointHinge(m_steerFR, m_suspensionFL,
00414 m_steerOffsetFR, VRS::Vector(0,1,0));
00415
00416 m_steerControlFL->setHighStop(0);
00417 m_steerControlFL->setLowStop( 0);
00418 m_steerControlFR->setHighStop(0);
00419 m_steerControlFR->setLowStop( 0);
00420
00421 st = new VRS::SceneThing(carNode);
00422 m_hook = new PhysicsBody(st, new SphereShape(
00423 VRS::Bounds(VRS::Vector(0.1,0.1,0.1), VRS::Vector(0.1,0.1,0.1))), true);
00424 m_hook->setPosition(m_chassisOffset + VRS::Vector(0,0,0));
00425 m_hook->surface()->setGhostMode(true);
00426
00427 m_hook->setRotation(VRS::Vector(0,1,0), 90);
00428
00429 m_hookJoint = new PhysicsJointSlider(
00430 m_chassis, m_hook, VRS::Vector(0,1,0));
00431
00432 m_hookJoint->setHighStop(0.0);
00433 m_hookJoint->setLowStop(0.0);
00434
00435 m_wheelFL->setMass(m_wheelMass);
00436 m_wheelFR->setMass(m_wheelMass);
00437 m_wheelRL->setMass(m_wheelMass);
00438 m_wheelRR->setMass(m_wheelMass);
00439 m_chassis->setMass(m_bodyMass);
00440 m_springFL->setMass(m_helperMass);
00441 m_springFR->setMass(m_helperMass);
00442 m_springRL->setMass(m_helperMass);
00443 m_springRR->setMass(m_helperMass);
00444
00445 m_suspensionFL->setMass(m_helperMass);
00446 m_suspensionFR->setMass(m_helperMass);
00447 m_suspensionRL->setMass(m_helperMass);
00448 m_suspensionRR->setMass(m_helperMass);
00449
00450 m_steerFL->setMass(m_helperMass);
00451 m_steerFR->setMass(m_helperMass);
00452
00453 m_wheelFL->setHighSpeedRotationAxis(VRS::Vector(1,0,0));
00454 m_wheelFR->setHighSpeedRotationAxis(VRS::Vector(1,0,0));
00455 m_wheelRL->setHighSpeedRotationAxis(VRS::Vector(1,0,0));
00456 m_wheelRR->setHighSpeedRotationAxis(VRS::Vector(1,0,0));
00457
00458 m_wheelFL->setHighSpeedRotationMode(true);
00459 m_wheelFR->setHighSpeedRotationMode(true);
00460 m_wheelRL->setHighSpeedRotationMode(true);
00461 m_wheelRR->setHighSpeedRotationMode(true);
00462
00463
00464 }
00465
00466 BuggyCar::~BuggyCar()
00467 {
00468
00469 }
00470
00471 void
00472 BuggyCar::accelerate(double p_amount)
00473 {
00474 enableAllBodies();
00475
00476 if(p_amount)
00477 {
00478 m_axisRL->setMotorVelocity(m_carMaxSpeed * p_amount);
00479 m_axisRR->setMotorVelocity(m_carMaxSpeed * p_amount);
00480 m_axisRL->setMotorMaxForce(m_carPower);
00481 m_axisRR->setMotorMaxForce(m_carPower);
00482 }
00483 else
00484 {
00485 m_axisRL->setMotorVelocity(m_carMaxSpeed);
00486 m_axisRR->setMotorVelocity(m_carMaxSpeed);
00487 m_axisRL->setMotorMaxForce(0);
00488 m_axisRR->setMotorMaxForce(0);
00489 }
00490 }
00491
00492 void
00493 BuggyCar::steer(double p_amount)
00494 {
00495 enableAllBodies();
00496 m_steerControlFL->setHighStop(m_steeringRadius * p_amount);
00497 m_steerControlFL->setLowStop(m_steeringRadius * p_amount);
00498 m_steerControlFR->setHighStop(m_steeringRadius * p_amount);
00499 m_steerControlFR->setLowStop(m_steeringRadius * p_amount);
00500 }
00501
00502 void
00503 BuggyCar::nitro(double p_amount)
00504 {
00505
00506
00507
00508
00509 std::cerr << "ERROR: nitro not implemented" << std::endl;
00510 }
00511
00512 void
00513 BuggyCar::handBreak(double p_enable)
00514 {
00515 enableAllBodies();
00516 if(p_enable == 1.0)
00517 {
00518 m_axisFL->setMotorVelocity(0);
00519 m_axisFR->setMotorVelocity(0);
00520 m_axisFL->setMotorMaxForce(15);
00521 m_axisFR->setMotorMaxForce(15);
00522 m_axisRL->setMotorVelocity(0);
00523 m_axisRR->setMotorVelocity(0);
00524 m_axisRL->setMotorMaxForce(200);
00525 m_axisRR->setMotorMaxForce(200);
00526 }
00527 else
00528 {
00529 m_axisFL->setMotorVelocity(100);
00530 m_axisFR->setMotorVelocity(100);
00531 m_axisFL->setMotorMaxForce(0);
00532 m_axisFR->setMotorMaxForce(0);
00533 m_axisRL->setMotorVelocity(100);
00534 m_axisRR->setMotorVelocity(100);
00535 m_axisRL->setMotorMaxForce(0);
00536 m_axisRR->setMotorMaxForce(0);
00537 }
00538 }
00539
00540 VRS::SO<VRS::SceneThing>
00541 BuggyCar::sceneThing()
00542 {
00543 return m_chassis->sceneThing();
00544 }
00545
00546 void
00547 BuggyCar::attachCamera(VRS::SO<VRS::Camera> p_camera)
00548 {
00549
00550 }
00551
00552 void
00553 BuggyCar::enableAllBodies()
00554 {
00555 m_chassis->setEnabled(true);
00556
00557 m_wheelFL->setEnabled(true);
00558 m_wheelFR->setEnabled(true);
00559 m_wheelRL->setEnabled(true);
00560 m_wheelRR->setEnabled(true);
00561
00562 m_suspensionFL->setEnabled(true);
00563 m_suspensionFR->setEnabled(true);
00564 m_suspensionRL->setEnabled(true);
00565 m_suspensionRR->setEnabled(true);
00566
00567 m_steerFL->setEnabled(true);
00568 m_steerFR->setEnabled(true);
00569
00570 m_springFL->setEnabled(true);
00571 m_springFR->setEnabled(true);
00572 m_springRL->setEnabled(true);
00573 m_springRR->setEnabled(true);
00574 }
00575
00576 void
00577 BuggyCar::setPosition(VRS::Vector p_position)
00578 {
00579
00580 m_chassis->setPosition(m_chassisOffset + p_position);
00581 m_chassis->setLinearVelocity(VRS::Vector(0,0,0));
00582 m_chassis->setAngularVelocity(VRS::Vector(0,0,0));
00583
00584 m_springFL->setPosition(p_position);
00585 m_springFR->setPosition(p_position);
00586 m_springRL->setPosition(p_position);
00587 m_springRR->setPosition(p_position);
00588
00589
00590
00591 m_wheelFL->setPosition(m_wheelOffsetFL + p_position);
00592 m_wheelFR->setPosition(m_wheelOffsetFR + p_position);
00593 m_wheelRL->setPosition(m_wheelOffsetRL + p_position);
00594 m_wheelRR->setPosition(m_wheelOffsetRR + p_position);
00595 m_wheelFL->setLinearVelocity(VRS::Vector(0,0,0));
00596 m_wheelFR->setLinearVelocity(VRS::Vector(0,0,0));
00597 m_wheelRL->setLinearVelocity(VRS::Vector(0,0,0));
00598 m_wheelRR->setLinearVelocity(VRS::Vector(0,0,0));
00599 m_wheelFL->setAngularVelocity(VRS::Vector(0,0,0));
00600 m_wheelFR->setAngularVelocity(VRS::Vector(0,0,0));
00601 m_wheelRL->setAngularVelocity(VRS::Vector(0,0,0));
00602 m_wheelRR->setAngularVelocity(VRS::Vector(0,0,0));
00603
00604
00605 m_steerFL->setPosition(m_steerOffsetFL + p_position);
00606 m_steerFR->setPosition(m_steerOffsetFR + p_position);
00607 m_steerFL->setLinearVelocity(VRS::Vector(0,0,0));
00608 m_steerFR->setLinearVelocity(VRS::Vector(0,0,0));
00609 m_steerFL->setAngularVelocity(VRS::Vector(0,0,0));
00610 m_steerFR->setAngularVelocity(VRS::Vector(0,0,0));
00611
00612
00613 m_suspensionFL->setPosition(m_suspensionOffsetFL + p_position);
00614 m_suspensionFR->setPosition(m_suspensionOffsetFR + p_position);
00615 m_suspensionRL->setPosition(m_suspensionOffsetRL + p_position);
00616 m_suspensionRR->setPosition(m_suspensionOffsetRR + p_position);
00617 m_suspensionFL->setLinearVelocity(VRS::Vector(0,0,0));
00618 m_suspensionFR->setLinearVelocity(VRS::Vector(0,0,0));
00619 m_suspensionRL->setLinearVelocity(VRS::Vector(0,0,0));
00620 m_suspensionRR->setLinearVelocity(VRS::Vector(0,0,0));
00621 m_suspensionFL->setAngularVelocity(VRS::Vector(0,0,0));
00622 m_suspensionFR->setAngularVelocity(VRS::Vector(0,0,0));
00623 m_suspensionRL->setAngularVelocity(VRS::Vector(0,0,0));
00624 m_suspensionRR->setAngularVelocity(VRS::Vector(0,0,0));
00625 }
00626
00627 void
00628 BuggyCar::setPosition(double p_x, double p_y, double p_z)
00629 {
00630
00631 }
00632
00633 VRS::Vector
00634 BuggyCar::position()
00635 {
00636
00637 return m_chassis->translationNode()->getTranslate();
00638 }
00639
00640 }