2001-11-27 18:50:04 -07:00
|
|
|
// simulation.h
|
2007-11-22 18:37:35 -07:00
|
|
|
//
|
2001-11-27 18:50:04 -07:00
|
|
|
// Copyright (C) 2001, Chris Laurel <claurel@shatters.net>
|
|
|
|
//
|
|
|
|
// This program is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU General Public License
|
|
|
|
// as published by the Free Software Foundation; either version 2
|
|
|
|
// of the License, or (at your option) any later version.
|
|
|
|
|
2003-02-11 09:41:17 -07:00
|
|
|
#ifndef _CELENGINE_SIMULATION_H_
|
|
|
|
#define _CELENGINE_SIMULATION_H_
|
2001-11-27 18:50:04 -07:00
|
|
|
|
2019-08-05 11:31:02 -06:00
|
|
|
#include <memory>
|
2001-11-27 18:50:04 -07:00
|
|
|
#include <celengine/texture.h>
|
2002-01-07 15:48:32 -07:00
|
|
|
#include <celengine/universe.h>
|
2001-11-27 18:50:04 -07:00
|
|
|
#include <celengine/astro.h>
|
|
|
|
#include <celengine/galaxy.h>
|
2008-09-20 08:17:39 -06:00
|
|
|
#include <celengine/globular.h>
|
2001-11-27 18:50:04 -07:00
|
|
|
#include <celengine/texmanager.h>
|
2003-02-11 09:41:17 -07:00
|
|
|
#include <celengine/frame.h>
|
|
|
|
#include <celengine/observer.h>
|
2009-07-21 22:53:15 -06:00
|
|
|
#include <Eigen/Core>
|
|
|
|
#include <vector>
|
2001-11-27 18:50:04 -07:00
|
|
|
|
|
|
|
|
2009-10-04 08:12:59 -06:00
|
|
|
class Renderer;
|
|
|
|
|
2001-11-27 18:50:04 -07:00
|
|
|
class Simulation
|
|
|
|
{
|
|
|
|
public:
|
2002-01-07 15:48:32 -07:00
|
|
|
Simulation(Universe*);
|
2001-11-27 18:50:04 -07:00
|
|
|
~Simulation();
|
|
|
|
|
2002-05-02 01:58:00 -06:00
|
|
|
double getTime() const; // Julian date
|
2018-09-22 07:13:49 -06:00
|
|
|
void setTime(double jd);
|
2001-11-27 18:50:04 -07:00
|
|
|
|
2002-05-02 01:58:00 -06:00
|
|
|
double getRealTime() const;
|
|
|
|
double getArrivalTime() const;
|
|
|
|
|
2001-11-27 18:50:04 -07:00
|
|
|
void update(double dt);
|
|
|
|
void render(Renderer&);
|
2008-03-24 18:23:16 -06:00
|
|
|
void draw(Renderer&);
|
2003-02-11 09:41:17 -07:00
|
|
|
void render(Renderer&, Observer&);
|
2001-11-27 18:50:04 -07:00
|
|
|
|
2018-11-13 13:31:07 -07:00
|
|
|
Selection pickObject(const Eigen::Vector3f& pickRay, uint64_t renderFlags, float tolerance = 0.0f);
|
2001-11-27 18:50:04 -07:00
|
|
|
|
2002-01-07 15:48:32 -07:00
|
|
|
Universe* getUniverse() const;
|
2001-11-27 18:50:04 -07:00
|
|
|
|
2009-07-21 22:53:15 -06:00
|
|
|
void orbit(const Eigen::Quaternionf& q);
|
|
|
|
void rotate(const Eigen::Quaternionf& q);
|
2001-11-27 18:50:04 -07:00
|
|
|
void changeOrbitDistance(float d);
|
|
|
|
void setTargetSpeed(float s);
|
|
|
|
float getTargetSpeed();
|
|
|
|
|
|
|
|
Selection getSelection() const;
|
|
|
|
void setSelection(const Selection&);
|
2002-01-10 17:03:39 -07:00
|
|
|
Selection getTrackedObject() const;
|
|
|
|
void setTrackedObject(const Selection&);
|
|
|
|
|
2001-11-27 18:50:04 -07:00
|
|
|
void selectPlanet(int);
|
2005-07-19 15:31:04 -06:00
|
|
|
Selection findObject(std::string s, bool i18n = false);
|
|
|
|
Selection findObjectFromPath(std::string s, bool i18n = false);
|
2021-05-12 23:39:40 -06:00
|
|
|
std::vector<std::string> getObjectCompletion(std::string s, bool i18n, bool withLocations = false);
|
2001-11-27 18:50:04 -07:00
|
|
|
void gotoSelection(double gotoTime,
|
2018-03-11 07:12:58 -06:00
|
|
|
const Eigen::Vector3f& up,
|
2009-07-21 22:53:15 -06:00
|
|
|
ObserverFrame::CoordinateSystem upFrame);
|
2001-11-27 18:50:04 -07:00
|
|
|
void gotoSelection(double gotoTime, double distance,
|
2009-07-21 22:53:15 -06:00
|
|
|
const Eigen::Vector3f& up,
|
|
|
|
ObserverFrame::CoordinateSystem upFrame);
|
2001-11-27 18:50:04 -07:00
|
|
|
void gotoSelectionLongLat(double gotoTime,
|
|
|
|
double distance,
|
|
|
|
float longitude, float latitude,
|
2009-07-21 22:53:15 -06:00
|
|
|
const Eigen::Vector3f& up);
|
|
|
|
void gotoLocation(const UniversalCoord& toPosition,
|
|
|
|
const Eigen::Quaterniond& toOrientation,
|
|
|
|
double duration);
|
2001-11-27 18:50:04 -07:00
|
|
|
void getSelectionLongLat(double& distance,
|
|
|
|
double& longitude,
|
|
|
|
double& latitude);
|
2003-02-11 09:41:17 -07:00
|
|
|
void gotoSurface(double duration);
|
2001-11-27 18:50:04 -07:00
|
|
|
void centerSelection(double centerTime = 0.5);
|
2003-09-10 10:22:51 -06:00
|
|
|
void centerSelectionCO(double centerTime = 0.5);
|
2001-11-27 18:50:04 -07:00
|
|
|
void follow();
|
|
|
|
void geosynchronousFollow();
|
2002-03-14 14:48:51 -07:00
|
|
|
void phaseLock();
|
2002-03-18 18:07:24 -07:00
|
|
|
void chase();
|
2001-11-27 18:50:04 -07:00
|
|
|
void cancelMotion();
|
|
|
|
|
2002-01-09 16:03:03 -07:00
|
|
|
Observer& getObserver();
|
|
|
|
void setObserverPosition(const UniversalCoord&);
|
2009-07-21 22:53:15 -06:00
|
|
|
void setObserverOrientation(const Eigen::Quaternionf&);
|
2003-01-01 16:51:19 -07:00
|
|
|
void reverseObserverOrientation();
|
2002-01-09 16:03:03 -07:00
|
|
|
|
2003-02-11 09:41:17 -07:00
|
|
|
Observer* addObserver();
|
|
|
|
void removeObserver(Observer*);
|
|
|
|
Observer* getActiveObserver();
|
|
|
|
void setActiveObserver(Observer*);
|
|
|
|
|
2001-11-27 18:50:04 -07:00
|
|
|
SolarSystem* getNearestSolarSystem() const;
|
|
|
|
|
2003-02-21 23:49:37 -07:00
|
|
|
double getTimeScale() const;
|
2001-11-27 18:50:04 -07:00
|
|
|
void setTimeScale(double);
|
2003-02-21 23:49:37 -07:00
|
|
|
bool getSyncTime() const;
|
|
|
|
void setSyncTime(bool);
|
2003-03-11 02:59:20 -07:00
|
|
|
void synchronizeTime();
|
2007-11-03 03:49:29 -06:00
|
|
|
bool getPauseState() const;
|
|
|
|
void setPauseState(bool);
|
2001-11-27 18:50:04 -07:00
|
|
|
|
|
|
|
float getFaintestVisible() const;
|
|
|
|
void setFaintestVisible(float);
|
|
|
|
|
2003-02-11 09:41:17 -07:00
|
|
|
void setObserverMode(Observer::ObserverMode);
|
|
|
|
Observer::ObserverMode getObserverMode() const;
|
2001-11-27 18:50:04 -07:00
|
|
|
|
2018-03-11 07:12:58 -06:00
|
|
|
void setFrame(ObserverFrame::CoordinateSystem, const Selection& refObject, const Selection& targetObject);
|
2008-02-08 14:46:02 -07:00
|
|
|
void setFrame(ObserverFrame::CoordinateSystem, const Selection& refObject);
|
2019-08-05 11:31:02 -06:00
|
|
|
const ObserverFrame::SharedConstPtr& getFrame() const;
|
2001-11-27 18:50:04 -07:00
|
|
|
|
|
|
|
private:
|
|
|
|
SolarSystem* getSolarSystem(const Star* star);
|
|
|
|
|
|
|
|
private:
|
2018-09-22 07:13:49 -06:00
|
|
|
double realTime{ 0.0 };
|
|
|
|
double timeScale{ 1.0 };
|
|
|
|
double storedTimeScale{ 1.0 };
|
|
|
|
bool syncTime{ true };
|
2001-11-27 18:50:04 -07:00
|
|
|
|
2002-01-07 15:48:32 -07:00
|
|
|
Universe* universe;
|
2001-11-27 18:50:04 -07:00
|
|
|
|
2018-09-22 07:13:49 -06:00
|
|
|
SolarSystem* closestSolarSystem{ nullptr };
|
2001-11-27 18:50:04 -07:00
|
|
|
Selection selection;
|
|
|
|
|
2003-02-11 09:41:17 -07:00
|
|
|
Observer* activeObserver;
|
|
|
|
std::vector<Observer*> observers;
|
2001-11-27 18:50:04 -07:00
|
|
|
|
2018-09-22 07:13:49 -06:00
|
|
|
float faintestVisible{ 5.0f };
|
|
|
|
bool pauseState{ false };
|
2001-11-27 18:50:04 -07:00
|
|
|
};
|
|
|
|
|
2003-02-11 09:41:17 -07:00
|
|
|
#endif // _CELENGINE_SIMULATION_H_
|