The camera flies between the stadium and its surroundings
Coming from the other view of the model, or laying the view back, the picture moves and zooms there in 0.7 seconds; with reduced motion it stands there at once. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
1 parent
c60b0e9b2c
commit
d9b0590705
3 files changed
+35
-3
No files matched your search
@@ -43,6 +43,18 @@ bool App::stadium_focus_action(const std::string &action,Rml::Element *target) {
|
||||
refresh();
|
||||
return true;
|
||||
}
|
||||
// The camera on its way: slow at both ends, only the place of the picture changes.
|
||||
void App::stadium_flight_tick() {
|
||||
if(menu_!="stadium"){stadium_seen_.clear();stadium_flying_=false;return;}
|
||||
if(!stadium_flying_)return;
|
||||
auto *world=element("stadium-world");
|
||||
if(!world){stadium_flying_=false;return;}
|
||||
const double t=std::min(1.0,double(SDL_GetTicks64()-stadium_flight_start_)/700.0),eased=t<.5?4*t*t*t:1-std::pow(-2*t+2,3)/2;
|
||||
for(size_t i=0;i<3;++i)stadium_now_[i]=stadium_from_[i]+(stadium_to_[i]-stadium_from_[i])*eased;
|
||||
if(t>=1){stadium_now_=stadium_to_;stadium_flying_=false;}
|
||||
world->SetProperty("left",pg(stadium_now_[1]));world->SetProperty("top",pg(stadium_now_[2]));world->SetProperty("transform","scale("+scalar(stadium_now_[0])+")");
|
||||
dirty_=true;
|
||||
}
|
||||
// Looking around on the stage: the wheel zooms towards the pointer, dragging moves the view,
|
||||
// and the pointer over a part shows what stands there. Only the place of the picture changes;
|
||||
// nothing is drawn anew.
|
||||
@@ -51,6 +63,8 @@ bool App::stadium_stage_event(Rml::Event &event) {
|
||||
if(!stage||!world)return false;
|
||||
const auto type=event.GetType();
|
||||
if(type!="mousemove"&&type!="mousedown"&&type!="mouseup"&&type!="mousescroll")return false;
|
||||
// while the camera flies the picture is not where the pointer would look for it
|
||||
if(stadium_flying_)return false;
|
||||
const bool outer=stadium_view_.value("view",std::string())=="panorama";
|
||||
// the pointer on the stage, in units of the page
|
||||
const double mx=(event.GetParameter<float>("mouse_x",0)-stage->GetAbsoluteLeft())/scale_/2.25,my=(event.GetParameter<float>("mouse_y",0)-stage->GetAbsoluteTop())/scale_/2.25;
|
||||
@@ -81,7 +95,7 @@ bool App::stadium_stage_event(Rml::Event &event) {
|
||||
cam[0]=std::clamp(cam[0],.75,3.2);
|
||||
cam[1]=std::clamp(cam[1],std::min(240.0,w-w*cam[0]-240),std::max(240.0,w-w*cam[0]-240));
|
||||
cam[2]=std::clamp(cam[2],std::min(240.0,h-h*cam[0]-240),std::max(240.0,h-h*cam[0]-240));
|
||||
stadium_cams_[outer?"panorama":"inside"]=cam;
|
||||
stadium_cams_[outer?"panorama":"inside"]=cam;stadium_now_=cam;
|
||||
world->SetProperty("left",pg(cam[1]));world->SetProperty("top",pg(cam[2]));world->SetProperty("transform","scale("+scalar(cam[0])+")");
|
||||
dirty_=true;
|
||||
};
|
||||
|
||||
@@ -88,7 +88,7 @@ std::string App::render_stadium() {
|
||||
const auto ground=overview.at("name").get<std::string>();
|
||||
page_title_=outer?"Peripherie – "+ground:ground+" – "+number(overview.at("capacity").get<int64_t>())+" Plätze";
|
||||
page_hint_=view=="data"?"Stadiondaten":std::string(outer?"ein Gebäude anklicken":"ein Bauteil anklicken")+(future?(outer?" · Stand nach Fertigstellung":" · geplante Kapazität"):"");
|
||||
if(view=="data")return render_stadium_data()+render_stadium_dialog();
|
||||
if(view=="data"){stadium_seen_="data";stadium_flying_=false;return render_stadium_data()+render_stadium_dialog();}
|
||||
// over the gate stands the first word of the ground's name
|
||||
auto sign=pg_upper(ground.substr(0,ground.find_first_of(" -")));
|
||||
if(sign.empty()||sign.size()>13)sign="STADION";
|
||||
@@ -114,7 +114,17 @@ std::string App::render_stadium() {
|
||||
}
|
||||
return state+(working(row)?" · im Bau":"");
|
||||
};
|
||||
const auto cam=stadium_cam(outer);
|
||||
// Coming from the other view of the model, or laying the view back, the camera flies
|
||||
// there in 0.7 seconds; with reduced motion it stands there at once.
|
||||
const auto landing=stadium_cam(outer);
|
||||
const bool calm=ui_preferences_.is_object()&&ui_preferences_.value("display",Json::object()).value("motion",std::string("full"))=="reduced";
|
||||
const bool other=(stadium_seen_=="inside"||stadium_seen_=="panorama")&&stadium_seen_!=view;
|
||||
if(!calm&&(other||(stadium_seen_==view&&!stadium_flying_&&stadium_now_!=landing))) {
|
||||
stadium_from_=stadium_now_;stadium_to_=landing;stadium_flying_=true;stadium_flight_start_=SDL_GetTicks64();
|
||||
} else if(stadium_flying_&&stadium_seen_==view)stadium_to_=landing;
|
||||
else {stadium_flying_=false;stadium_now_=landing;}
|
||||
stadium_seen_=view;
|
||||
const auto cam=stadium_now_;
|
||||
// The stage itself takes the pointer: which part lies under it is worked out from the
|
||||
// scene, because the picture is zoomed and its faces lie askew. The faces in the world only
|
||||
// show what is under the pointer or chosen; as buttons they serve the keyboard.
|
||||
|
||||
@@ -515,6 +515,13 @@ class App final : public Rml::EventListener {
|
||||
std::array<double, 2> stadium_tip_at_{}; // where its name is shown, in units of the page
|
||||
std::vector<stadium_scene::Hot> stadium_hots_; // the parts of the view that is shown
|
||||
std::array<double, 3> stadium_cam(bool outer);
|
||||
// the flight of the camera from one view of the model to the other: where it started,
|
||||
// where it is, where it lands; `stadium_seen_` is the view that was drawn last
|
||||
std::array<double, 3> stadium_from_{}, stadium_now_{}, stadium_to_{};
|
||||
bool stadium_flying_ = false;
|
||||
uint64_t stadium_flight_start_ = 0;
|
||||
std::string stadium_seen_;
|
||||
void stadium_flight_tick();
|
||||
std::string stadium_cam_style(const std::array<double, 3> &cam);
|
||||
bool stadium_stage_event(Rml::Event &);
|
||||
std::string render_stadium_data();
|
||||
@@ -1333,6 +1340,7 @@ class App final : public Rml::EventListener {
|
||||
void frame() {
|
||||
engine_create_poll();
|
||||
engine_files_poll();
|
||||
stadium_flight_tick();
|
||||
if (engine_mode_) { engine_frame(); return; }
|
||||
front_poll();
|
||||
flush_selects();
|
||||
|
||||
Reference in new issue
Block a user