Open source Star Ruler 2 source code!

This commit is contained in:
Lucas de Vries
2018-07-17 14:15:37 +02:00
commit cc307720ff
4342 changed files with 2365070 additions and 0 deletions
@@ -0,0 +1,43 @@
#include "anim_projectile.h"
#include "scene/node.h"
#include "scene/beam_node.h"
#include <stdio.h>
extern double frameTime_s;
namespace scene {
ProjectileAnim::ProjectileAnim(const vec3d& Velocity) : velocity(Velocity) {
}
void ProjectileAnim::animate(Node* node) {
node->position += velocity * (frameTime_s - node->lastUpdate);
node->rebuildTransformation();
node->lastUpdate = frameTime_s;
}
void BeamAnim::animate(Node* node) {
BeamNode* beam = (BeamNode*)node;
if(beam->endPosition.zero())
return;
node->visible = true;
if(follow) {
node->position = follow->abs_position + offset;
node->rebuildTransformation();
}
float curLength = beam->abs_position.distanceTo(beam->endPosition);
beam->uvLength = curLength / length;
}
BeamAnim::BeamAnim(Node* Follow, vec3d Offset, float range) : follow(Follow), offset(Offset), length(range) {
if(Follow)
Follow->grab();
}
BeamAnim::~BeamAnim() {
if(follow)
follow->drop();
}
};