mirror of
https://github.com/ApfelTeeSaft/PlanetFleet.git
synced 2026-08-26 19:33:38 +00:00
removed many Irrlicht references
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
#include <model.h>
|
||||
|
||||
#include "shell.h"
|
||||
#include "defConfigs.h"
|
||||
#include "projectileData.h"
|
||||
@@ -6,13 +8,13 @@
|
||||
|
||||
using namespace game::core;
|
||||
using namespace game::util;
|
||||
using namespace irr::core;
|
||||
using namespace vb01;
|
||||
|
||||
namespace game{
|
||||
namespace content{
|
||||
Shell::Shell(Unit *unit, vector3df pos, vector3df dir, vector3df left, vector3df up, int id, int weaponTypeId, int weaponId) : Projectile(unit, nullptr, pos, dir, left, up, id, weaponTypeId, weaponId) {
|
||||
Shell::Shell(Unit *unit, Vector3 pos, Vector3 dir, Vector3 left, Vector3 up, int id, int weaponTypeId, int weaponId) : Projectile(unit, nullptr, pos, dir, left, up, id, weaponTypeId, weaponId) {
|
||||
this->speed = projectileData::speed[id][weaponTypeId][weaponId];
|
||||
node->setScale(vector3df(1, 1, 1) * projectileData::scale[id][weaponTypeId][weaponId]);
|
||||
node->setScale(Vector3(1, 1, 1) * projectileData::scale[id][weaponTypeId][weaponId]);
|
||||
initTime = getTime();
|
||||
}
|
||||
|
||||
@@ -20,24 +22,26 @@ namespace game{
|
||||
//x=v*cos(a)*t
|
||||
//y=v*sin(a)*t+0.5(g*t^2)
|
||||
Projectile::update();
|
||||
vector3df straightVec = vector3df(dirVec.X, 0, dirVec.Z).normalize();
|
||||
double time = double(getTime() - initTime)/1000,
|
||||
offsetX=speed * cos(angle) * time,
|
||||
offsetY=speed * sin(angle) * time - .5 * (g * time * time);
|
||||
pos = initPos + straightVec * offsetX + vector3df(0, offsetY, 0);
|
||||
Vector3 straightVec = Vector3(dirVec.x, 0, dirVec.z).norm();
|
||||
double time = double(getTime() - initTime) / 1000,
|
||||
offsetX = speed * cos(angle) * time,
|
||||
offsetY = speed * sin(angle) * time - .5 * (g * time * time);
|
||||
pos = initPos + straightVec * offsetX + Vector3(0, offsetY, 0);
|
||||
node->setPosition(pos);
|
||||
updateVecs(straightVec, time);
|
||||
checkForCollision();
|
||||
}
|
||||
|
||||
void Shell::updateVecs(vector3df straightVec, float time) {
|
||||
void Shell::updateVecs(Vector3 straightVec, float time) {
|
||||
// f'(t)=dy/dx=(v*sin(a)+g*t)/(v*cos(a))
|
||||
float tanAngle = -atan((speed * sin(angle) + g * time) / (speed * cos(angle)));
|
||||
quaternion rotQuat = rotQuat.fromAngleAxis( tanAngle, leftVec);
|
||||
dirVec = rotQuat*straightVec, upVec = rotQuat * vector3df(0, 1, 0);
|
||||
vector3df rotVec=node->getRotation();
|
||||
Quaternion rotQuat = Quaternion(tanAngle, leftVec);
|
||||
dirVec = rotQuat*straightVec, upVec = rotQuat * Vector3(0, 1, 0);
|
||||
/*
|
||||
Vector3 rotVec = node->getOrientation();
|
||||
rotVec=vector3df(tanAngle/PI*180,rotVec.Y,rotVec.Z);
|
||||
node->setRotation(rotVec);
|
||||
*/
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user