changed add<Object>() methods to take refptr objects as arguments
git-svn-id: svn://anubis/misc/OdeWorld@198 bd8a9e45-a331-0410-811e-c64571078777
This commit is contained in:
parent
71788d0707
commit
bee7a098bc
64
OdeWorld.cc
64
OdeWorld.cc
@ -249,71 +249,73 @@ dGeomID OdeWorld::Object::cloneGeom(dGeomID geom, dBodyID body)
|
|||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool OdeWorld::Object::addCube(const vector<float> args)
|
bool OdeWorld::Object::addCube(refptr< std::vector<float> > args)
|
||||||
{
|
{
|
||||||
if (args.size() != 9)
|
if (args->size() != 9)
|
||||||
return false;
|
return false;
|
||||||
dGeomID id = dCreateBox(0,
|
dGeomID id = dCreateBox(0,
|
||||||
m_scale * args[0],
|
m_scale * (*args)[0],
|
||||||
m_scale * args[1],
|
m_scale * (*args)[1],
|
||||||
m_scale * args[2]);
|
m_scale * (*args)[2]);
|
||||||
dMass mass;
|
dMass mass;
|
||||||
dMassSetBox(&mass, 1.0,
|
dMassSetBox(&mass, 1.0,
|
||||||
m_scale * args[0],
|
m_scale * (*args)[0],
|
||||||
m_scale * args[1],
|
m_scale * (*args)[1],
|
||||||
m_scale * args[2]);
|
m_scale * (*args)[2]);
|
||||||
setupGeom(id, &mass,
|
setupGeom(id, &mass,
|
||||||
args[3], args[4], args[5],
|
(*args)[3], (*args)[4], (*args)[5],
|
||||||
args[6], args[7], args[8]);
|
(*args)[6], (*args)[7], (*args)[8]);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool OdeWorld::Object::addSphere(const vector<float> args)
|
bool OdeWorld::Object::addSphere(refptr< std::vector<float> > args)
|
||||||
{
|
{
|
||||||
if (args.size() != 4)
|
if (args->size() != 4)
|
||||||
return false;
|
return false;
|
||||||
dGeomID id = dCreateSphere(0, m_scale * args[0]);
|
dGeomID id = dCreateSphere(0, m_scale * (*args)[0]);
|
||||||
dMass mass;
|
dMass mass;
|
||||||
dMassSetSphere(&mass, 1.0, m_scale * args[0]);
|
dMassSetSphere(&mass, 1.0, m_scale * (*args)[0]);
|
||||||
setupGeom(id, &mass,
|
setupGeom(id, &mass,
|
||||||
args[1], args[2], args[3],
|
(*args)[1], (*args)[2], (*args)[3],
|
||||||
0.0, 0.0, 0.0);
|
0.0, 0.0, 0.0);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool OdeWorld::Object::addCylinder(const vector<float> args)
|
bool OdeWorld::Object::addCylinder(refptr< std::vector<float> > args)
|
||||||
{
|
{
|
||||||
if (args.size() != 8)
|
if (args->size() != 8)
|
||||||
return false;
|
return false;
|
||||||
dGeomID id = dCreateCylinder(0, m_scale * args[0], m_scale * args[1]);
|
dGeomID id = dCreateCylinder(0, m_scale * (*args)[0], m_scale * (*args)[1]);
|
||||||
dMass mass;
|
dMass mass;
|
||||||
dMassSetCylinder(&mass, 1.0, 3, m_scale * args[0], m_scale * args[1]);
|
dMassSetCylinder(&mass, 1.0, 3, m_scale * (*args)[0], m_scale * (*args)[1]);
|
||||||
setupGeom(id, &mass,
|
setupGeom(id, &mass,
|
||||||
args[2], args[3], args[4],
|
(*args)[2], (*args)[3], (*args)[4],
|
||||||
args[5], args[6], args[7]);
|
(*args)[5], (*args)[6], (*args)[7]);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool OdeWorld::Object::addCCylinder(const vector<float> args)
|
bool OdeWorld::Object::addCCylinder(refptr< std::vector<float> > args)
|
||||||
{
|
{
|
||||||
if (args.size() != 8)
|
if (args->size() != 8)
|
||||||
return false;
|
return false;
|
||||||
dGeomID id = dCreateCCylinder(0, m_scale * args[0], m_scale * args[1]);
|
dGeomID id = dCreateCCylinder(0,
|
||||||
|
m_scale * (*args)[0], m_scale * (*args)[1]);
|
||||||
dMass mass;
|
dMass mass;
|
||||||
dMassSetCappedCylinder(&mass, 1.0, 3, m_scale * args[0], m_scale * args[1]);
|
dMassSetCappedCylinder(&mass, 1.0, 3, m_scale * (*args)[0],
|
||||||
|
m_scale * (*args)[1]);
|
||||||
setupGeom(id, &mass,
|
setupGeom(id, &mass,
|
||||||
args[2], args[3], args[4],
|
(*args)[2], (*args)[3], (*args)[4],
|
||||||
args[5], args[6], args[7]);
|
(*args)[5], (*args)[6], (*args)[7]);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool OdeWorld::Object::addPlane(const vector<float> args)
|
bool OdeWorld::Object::addPlane(refptr< std::vector<float> > args)
|
||||||
{
|
{
|
||||||
if (args.size() != 6)
|
if (args->size() != 6)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
dMatrix3 r;
|
dMatrix3 r;
|
||||||
dRFromEulerAngles(r, args[3], args[4], args[5]);
|
dRFromEulerAngles(r, (*args)[3], (*args)[4], (*args)[5]);
|
||||||
dVector3 default_plane_direction = {0, 0, 1, 0};
|
dVector3 default_plane_direction = {0, 0, 1, 0};
|
||||||
dVector3 rotated_plane_direction;
|
dVector3 rotated_plane_direction;
|
||||||
dMultiply0(rotated_plane_direction, default_plane_direction, r, 1, 3, 3);
|
dMultiply0(rotated_plane_direction, default_plane_direction, r, 1, 3, 3);
|
||||||
@ -321,7 +323,7 @@ bool OdeWorld::Object::addPlane(const vector<float> args)
|
|||||||
float a = rotated_plane_direction[0];
|
float a = rotated_plane_direction[0];
|
||||||
float b = rotated_plane_direction[1];
|
float b = rotated_plane_direction[1];
|
||||||
float c = rotated_plane_direction[2];
|
float c = rotated_plane_direction[2];
|
||||||
float d = m_scale * (a * args[0] + b * args[1] + c * args[2]);
|
float d = m_scale * (a * (*args)[0] + b * (*args)[1] + c * (*args)[2]);
|
||||||
|
|
||||||
dGeomID id = dCreatePlane(m_space, a, b, c, d);
|
dGeomID id = dCreatePlane(m_space, a, b, c, d);
|
||||||
m_geoms.push_back(id);
|
m_geoms.push_back(id);
|
||||||
|
11
OdeWorld.h
11
OdeWorld.h
@ -6,6 +6,7 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
#include "refptr/refptr.h"
|
||||||
|
|
||||||
class OdeWorld
|
class OdeWorld
|
||||||
{
|
{
|
||||||
@ -28,11 +29,11 @@ class OdeWorld
|
|||||||
void setRotation(dReal x, dReal y, dReal z);
|
void setRotation(dReal x, dReal y, dReal z);
|
||||||
const dReal * getPosition();
|
const dReal * getPosition();
|
||||||
const dReal * getRotation();
|
const dReal * getRotation();
|
||||||
bool addCube(const std::vector<float> args);
|
bool addCube(refptr< std::vector<float> > args);
|
||||||
bool addSphere(const std::vector<float> args);
|
bool addSphere(refptr< std::vector<float> > args);
|
||||||
bool addCylinder(const std::vector<float> args);
|
bool addCylinder(refptr< std::vector<float> > args);
|
||||||
bool addCCylinder(const std::vector<float> args);
|
bool addCCylinder(refptr< std::vector<float> > args);
|
||||||
bool addPlane(const std::vector<float> args);
|
bool addPlane(refptr< std::vector<float> > args);
|
||||||
void addForce(dReal fx, dReal fy, dReal fz);
|
void addForce(dReal fx, dReal fy, dReal fz);
|
||||||
void addRelForce(dReal fx, dReal fy, dReal fz);
|
void addRelForce(dReal fx, dReal fy, dReal fz);
|
||||||
void addTorque(dReal fx, dReal fy, dReal fz);
|
void addTorque(dReal fx, dReal fy, dReal fz);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user