Added orbit command
This commit is contained in:
parent
b920b4205a
commit
7f67c63e22
|
@ -178,6 +178,18 @@ Command* CommandParser::parseCommand()
|
|||
paramList->getNumber("duration", duration);
|
||||
cmd = new CommandChangeDistance(duration, rate);
|
||||
}
|
||||
else if (commandName == "orbit")
|
||||
{
|
||||
double rate = 0.0;
|
||||
double duration = 1.0;
|
||||
Vec3d axis;
|
||||
paramList->getNumber("duration", duration);
|
||||
paramList->getNumber("rate", rate);
|
||||
paramList->getVector("axis", axis);
|
||||
cmd = new CommandOrbit(duration,
|
||||
Vec3f((float) axis.x, (float) axis.y, (float) axis.z),
|
||||
(float) rate);
|
||||
}
|
||||
else if (commandName == "setposition")
|
||||
{
|
||||
Vec3d base, offset;
|
||||
|
|
|
@ -42,7 +42,8 @@ CommandSelect::~CommandSelect()
|
|||
|
||||
void CommandSelect::process(Simulation* sim, Renderer* renderer)
|
||||
{
|
||||
sim->selectBody(target);
|
||||
Selection sel = sim->findObject(target);
|
||||
sim->setSelection(sel);
|
||||
}
|
||||
|
||||
|
||||
|
@ -160,7 +161,7 @@ void CommandSetTimeRate::process(Simulation* sim, Renderer* renderer)
|
|||
|
||||
|
||||
////////////////
|
||||
// Change distance command change the distance from the selected object
|
||||
// Change distance command: change the distance from the selected object
|
||||
|
||||
CommandChangeDistance::CommandChangeDistance(double _duration, double _rate) :
|
||||
TimedCommand(_duration),
|
||||
|
@ -174,6 +175,27 @@ void CommandChangeDistance::process(Simulation* sim, Renderer* renderer, double
|
|||
}
|
||||
|
||||
|
||||
////////////////
|
||||
// Oribt command: rotate about the selected object
|
||||
|
||||
CommandOrbit::CommandOrbit(double _duration, const Vec3f& axis, float rate) :
|
||||
TimedCommand(_duration),
|
||||
spin(axis * rate)
|
||||
{
|
||||
}
|
||||
|
||||
void CommandOrbit::process(Simulation* sim, Renderer* rend, double t, double dt)
|
||||
{
|
||||
float v = spin.length();
|
||||
if (v != 0.0f)
|
||||
{
|
||||
Quatf q;
|
||||
q.setAxisAngle(spin / v, (float) (v * dt));
|
||||
sim->orbit(q);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
////////////////
|
||||
// Set position command: set the position of the camera
|
||||
|
||||
|
@ -188,7 +210,7 @@ void CommandSetPosition::process(Simulation* sim, Renderer* renderer)
|
|||
|
||||
|
||||
////////////////
|
||||
// Set position command: set the position of the camera
|
||||
// Set orientation command: set the orientation of the camera
|
||||
|
||||
CommandSetOrientation::CommandSetOrientation(const Vec3f& _axis, float _angle) :
|
||||
axis(_axis), angle(_angle)
|
||||
|
|
|
@ -174,6 +174,17 @@ class CommandChangeDistance : public TimedCommand
|
|||
};
|
||||
|
||||
|
||||
class CommandOrbit : public TimedCommand
|
||||
{
|
||||
public:
|
||||
CommandOrbit(double _duration, const Vec3f& axis, float rate);
|
||||
void process(Simulation*, Renderer*, double t, double dt);
|
||||
|
||||
private:
|
||||
Vec3f spin;
|
||||
};
|
||||
|
||||
|
||||
class CommandSetPosition : public InstantaneousCommand
|
||||
{
|
||||
public:
|
||||
|
|
Loading…
Reference in a new issue