Code: Select all
scene::ILightSceneNode* l = smgr->addLightSceneNode(0, core::vector3df(100.f,100.f,100.f),
video::SColorf(1.f, 1.f, 1.f, 1.0f), 600.0f);
l->setLightType(video::ELT_POINT);
smgr->setAmbientLight(video::SColorf(.4f, .4f, .4f, 1.0f));
Code: Select all
scene::IMesh* cylinderMesh = smgr->getGeometryCreator()->createCylinderMesh(
size.X, /*radius*/ size.Y/2.f, /*length*/ 64, // tesselation
video::SColor(255, 255, 255, 255), /*color*/ true, /*closeTop*/ 0.0f /*oblique*/);
node = smgr->addMeshSceneNode(cylinderMesh,
0, /*parent*/ -1, // id
core::vector3df(0, 0, 0), /*position*/ core::vector3df(0, 0, 0), //rotation
core::vector3df(1.f,1.f,1.f) /*scale*/);
node->setMaterialTexture(0, driver->getTexture("./data/metal.jpg"));
smgr->getMeshManipulator()->recalculateNormals(cylinderMesh);
node->setMaterialFlag(video::EMF_NORMALIZE_NORMALS, true);
I don't know if it makes a difference but I'm moving the nodes like this
Code: Select all
bodypos = dBodyGetPosition(p->body);
p->node->setPosition(core::vector3df(bodypos[0],bodypos[1],bodypos[2]));
q = dBodyGetQuaternion(p->body);
dReal w=q[0];
x=q[1];
y=q[2];
z=q[3];
sx = x*x;
sy = y*y;
sz = z*z;
sw = w*w;
rot.X = (atan2(2.0 * (x*w + y*z ),(-sx - sy + sz + sw)) * irr::core::RADTODEG);
rot.Y = (asin(-2.0 * (x*z - y*w)) * irr::core::RADTODEG);
rot.Z = (atan2(2.0 * (x*y + z*w),(sx - sy - sz + sw)) * irr::core::RADTODEG);
if (p->shape==physObj::ShapeType::cylinder) rot.X+=90;
p->node->setRotation(rot);
any clues as to what I might be doing wrong would be gratefully received