--The Robomanaic



{edit} -- I figured it out, i found the setLine function. If anyone wants me to post the code, just reply
Code: Select all
void CGameClass::shootShotgun()
{
if (device)
{
smgr = device->getSceneManager();
camera = smgr->getActiveCamera();
}
else
{
printf("device null");
//=wait();
exit(1);
}
if (!camera)
return;
SParticleImpact imp;
imp.when = 0;
// get line of camera
core::vector3df start = camera->getPosition();
core::vector3df end = (camera->getTarget() - start);
end.normalize();
end = start + (end * camera->getFarValue());
core::triangle3df triangle;
core::line3d<f32> line[4];
line[0].setLine(start, end + core::vector3df(200, 100, 0));
line[1].setLine(start, end + core::vector3df(100, -50, 0));
line[2].setLine(start, end + core::vector3df(0, 0, 0));
line[3].setLine(start, end + core::vector3df(-100, -50, 0));
line[4].setLine(start, end + core::vector3df(-200, 130, 0));
for (int i = 0; i < 5; i++)
{
// get intersection point with map
if (smgr->getSceneCollisionManager()->getCollisionPoint(
line[i], selector, end, triangle))
{
// collides with wall
core::vector3df out = triangle.getNormal();
out.setLength(0.03f);
imp.when = 1;
imp.outVector = out;
imp.pos = end;
}
else
{
// doesnt collide with wall
end = (camera->getTarget() - start);
end.normalize();
end = start + (end * 1000);
}
// create fire ball
scene::ISceneNode* node[4];
node[i] = smgr->addBillboardSceneNode(0,
core::dimension2d<f32>(25,25), start);
node[i]->setMaterialFlag(video::EMF_LIGHTING, false);
node[i]->setMaterialTexture(0, device->getVideoDriver()->getTexture("Data/Images/fireball.jpg"));
node[i]->setMaterialType(video::EMT_TRANSPARENT_ADD_COLOR);
f32 length = (f32)(end - start).getLength();
const f32 speed = 2.0f;
u32 time = (u32)(length / speed);
scene::ISceneNodeAnimator* anim = 0;
// set flight line
anim = smgr->createFlyStraightAnimator(start, end, time);
node[i]->addAnimator(anim);
anim->drop();
anim = smgr->createDeleteAnimator(time);
node[i]->addAnimator(anim);
anim->drop();
}
/*if (imp.when)
{
// create impact note
imp.when = device->getTimer()->getTime() + (time - 100);
Impacts.push_back(imp);
}*/
}