changed addPlane() to accept 4 parameters to directly specify a, b, c, d
git-svn-id: svn://anubis/misc/OdeWorld@203 bd8a9e45-a331-0410-811e-c64571078777
This commit is contained in:
parent
9f0955b5af
commit
70355ffe6c
36
OdeWorld.cc
36
OdeWorld.cc
@ -311,19 +311,31 @@ bool OdeWorld::Object::addCapsule(refptr< std::vector<float> > args)
|
|||||||
|
|
||||||
bool OdeWorld::Object::addPlane(refptr< std::vector<float> > args)
|
bool OdeWorld::Object::addPlane(refptr< std::vector<float> > args)
|
||||||
{
|
{
|
||||||
if (args->size() != 6)
|
float a, b, c, d;
|
||||||
|
if (args->size() == 6)
|
||||||
|
{
|
||||||
|
dMatrix3 r;
|
||||||
|
dRFromEulerAngles(r, (*args)[3], (*args)[4], (*args)[5]);
|
||||||
|
dVector3 default_plane_direction = {0, 0, 1, 0};
|
||||||
|
dVector3 rotated_plane_direction;
|
||||||
|
dMultiply0(rotated_plane_direction, default_plane_direction, r, 1, 3, 3);
|
||||||
|
|
||||||
|
a = rotated_plane_direction[0];
|
||||||
|
b = rotated_plane_direction[1];
|
||||||
|
c = rotated_plane_direction[2];
|
||||||
|
d = m_scale * (a * (*args)[0] + b * (*args)[1] + c * (*args)[2]);
|
||||||
|
}
|
||||||
|
else if (args->size() == 4)
|
||||||
|
{
|
||||||
|
a = (*args)[0];
|
||||||
|
b = (*args)[1];
|
||||||
|
c = (*args)[2];
|
||||||
|
d = (*args)[3];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
dMatrix3 r;
|
|
||||||
dRFromEulerAngles(r, (*args)[3], (*args)[4], (*args)[5]);
|
|
||||||
dVector3 default_plane_direction = {0, 0, 1, 0};
|
|
||||||
dVector3 rotated_plane_direction;
|
|
||||||
dMultiply0(rotated_plane_direction, default_plane_direction, r, 1, 3, 3);
|
|
||||||
|
|
||||||
float a = rotated_plane_direction[0];
|
|
||||||
float b = rotated_plane_direction[1];
|
|
||||||
float c = rotated_plane_direction[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);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user