Skip to content

Commit

Permalink
build 180708. model instance position and rotation adjustment in scen…
Browse files Browse the repository at this point in the history
…ery editor, support for event launcher activation with mouse click, minor refactoring
  • Loading branch information
tmj-fstate committed Jul 8, 2018
1 parent 293787c commit ff1a85f
Show file tree
Hide file tree
Showing 29 changed files with 601 additions and 238 deletions.
6 changes: 1 addition & 5 deletions AnimModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ TAnimModel::TAnimModel( scene::node_data const &Nodedata ) : basic_node( Nodedat

TAnimModel::~TAnimModel()
{
delete pAdvanced; // nie ma zaawansowanej animacji
SafeDelete(pAdvanced); // nie ma zaawansowanej animacji
SafeDelete(pRoot);
}

Expand Down Expand Up @@ -630,10 +630,6 @@ int TAnimModel::Flags()

//---------------------------------------------------------------------------

bool TAnimModel::TerrainLoaded()
{ // zliczanie kwadratów kilometrowych (główna linia po Next) do tworznia tablicy
return (this ? pModel != NULL : false);
};
int TAnimModel::TerrainCount()
{ // zliczanie kwadratów kilometrowych (główna linia po Next) do tworznia tablicy
return pModel ? pModel->TerrainCount() : 0;
Expand Down
13 changes: 9 additions & 4 deletions AnimModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,8 @@ class TAnimModel : public scene::basic_node {
bool Load(cParser *parser, bool ter = false);
TAnimContainer * AddContainer(std::string const &Name);
TAnimContainer * GetContainer(std::string const &Name = "");
void RaAnglesSet( glm::vec3 Angles ) {
vAngle = { Angles }; };
void LightSet( int const n, float const v );
void AnimationVND( void *pData, double a, double b, double c, double d );
bool TerrainLoaded();
int TerrainCount();
TSubModel * TerrainSquare(int n);
int Flags();
Expand All @@ -154,6 +151,14 @@ class TAnimModel : public scene::basic_node {
TModel3d *
Model() const {
return pModel; }
inline
void
Angles( glm::vec3 const &Angles ) {
vAngle = Angles; }
inline
glm::vec3
Angles() const {
return vAngle; }
// members
static TAnimContainer *acAnimList; // lista animacji z eventem, które muszą być przeliczane również bez wyświetlania

Expand All @@ -178,7 +183,7 @@ class TAnimModel : public scene::basic_node {
int iNumLights { 0 };
TSubModel *LightsOn[ iMaxNumLights ]; // Ra: te wskaźniki powinny być w ramach TModel3d
TSubModel *LightsOff[ iMaxNumLights ];
Math3D::vector3 vAngle; // bazowe obroty egzemplarza względem osi
glm::vec3 vAngle; // bazowe obroty egzemplarza względem osi
material_data m_materialdata;

std::string asText; // tekst dla wyświetlacza znakowego
Expand Down
6 changes: 0 additions & 6 deletions Camera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,9 +237,3 @@ void TCamera::RaLook()
m_rotationoffsets.x = 0.0;
}
};

void TCamera::Stop()
{ // wyłącznie bezwładnego ruchu po powrocie do kabiny
Type = tp_Follow;
Velocity = Math3D::vector3(0, 0, 0);
};
1 change: 0 additions & 1 deletion Camera.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ class TCamera {
Math3D::vector3 GetDirection();
bool SetMatrix(glm::dmat4 &Matrix);
void RaLook();
void Stop();

TCameraType Type;
double Pitch;
Expand Down
21 changes: 12 additions & 9 deletions EU07.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ Stele, firleju, szociu, hunter, ZiomalCl, OLI_EU and others

#include "World.h"
#include "simulation.h"
#include "sceneeditor.h"
#include "Globals.h"
#include "timer.h"
#include "Logs.h"
Expand Down Expand Up @@ -127,23 +128,25 @@ void window_resize_callback(GLFWwindow *window, int w, int h)

void cursor_pos_callback(GLFWwindow *window, double x, double y)
{
input::Mouse.move( x, y );

if( true == Global.ControlPicking ) {
glfwSetCursorPos( window, x, y );
}
else {
if( false == Global.ControlPicking ) {
glfwSetCursorPos( window, 0, 0 );
}

// give the potential event recipient a shot at it, in the virtual z order
if( true == scene::Editor.on_mouse_move( x, y ) ) { return; }
input::Mouse.move( x, y );
}

void mouse_button_callback( GLFWwindow* window, int button, int action, int mods ) {

if( ( button == GLFW_MOUSE_BUTTON_LEFT )
|| ( button == GLFW_MOUSE_BUTTON_RIGHT ) ) {
if( ( button != GLFW_MOUSE_BUTTON_LEFT )
&& ( button != GLFW_MOUSE_BUTTON_RIGHT ) ) {
// we don't care about other mouse buttons at the moment
input::Mouse.button( button, action );
return;
}
// give the potential event recipient a shot at it, in the virtual z order
if( true == scene::Editor.on_mouse_button( button, action ) ) { return; }
input::Mouse.button( button, action );
}

void key_callback( GLFWwindow *window, int key, int scancode, int action, int mods ) {
Expand Down
53 changes: 31 additions & 22 deletions EvLaunch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,11 @@ bool TEventLauncher::Load(cParser *parser)
return true;
}

bool TEventLauncher::check_conditions()
{ //"renderowanie" wyzwalacza
bool TEventLauncher::check_activation() {

auto bCond { false };
if (iKey != 0) {

if( iKey != 0 ) {
if( iKey > 255 ) {
// key and modifier
auto const modifier = ( iKey & 0xff00 ) >> 8;
Expand All @@ -151,37 +152,45 @@ bool TEventLauncher::check_conditions()
bCond = ( Console::Pressed( iKey & 0xff ) ); // czy klawisz wciśnięty
}
}
if (DeltaTime > 0)
{
if (UpdatedTime > DeltaTime)
{
if( DeltaTime > 0 ) {
if( UpdatedTime > DeltaTime ) {
UpdatedTime = 0; // naliczanie od nowa
bCond = true;
}
else
UpdatedTime += Timer::GetDeltaTime(); // aktualizacja naliczania czasu
else {
// aktualizacja naliczania czasu
UpdatedTime += Timer::GetDeltaTime();
}
}
else
{ // jeśli nie cykliczny, to sprawdzić czas
if (simulation::Time.data().wHour == iHour)
{
if (simulation::Time.data().wMinute == iMinute)
{ // zgodność czasu uruchomienia
if (UpdatedTime < 10)
{
else {
// jeśli nie cykliczny, to sprawdzić czas
if( simulation::Time.data().wHour == iHour ) {
if( simulation::Time.data().wMinute == iMinute ) {
// zgodność czasu uruchomienia
if( UpdatedTime < 10 ) {
UpdatedTime = 20; // czas do kolejnego wyzwolenia?
bCond = true;
}
}
}
else
else {
UpdatedTime = 1;
}
}
if (bCond) // jeśli spełniony został warunek
{
if ((iCheckMask != 0) && MemCell) // sprawdzanie warunku na komórce pamięci
bCond = MemCell->Compare(szText, fVal1, fVal2, iCheckMask);

return bCond;
}

bool TEventLauncher::check_conditions() {

auto bCond { true };

if( ( iCheckMask != 0 )
&& ( MemCell != nullptr ) ) {
// sprawdzanie warunku na komórce pamięci
bCond = MemCell->Compare( szText, fVal1, fVal2, iCheckMask );
}

return bCond; // sprawdzanie dRadius w Ground.cpp
}

Expand Down
1 change: 1 addition & 0 deletions EvLaunch.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class TEventLauncher : public scene::basic_node {

// methods
bool Load( cParser *parser );
bool check_activation();
// checks conditions associated with the event. returns: true if the conditions are met
bool check_conditions();
bool IsGlobal() const;
Expand Down
2 changes: 1 addition & 1 deletion Event.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -894,7 +894,7 @@ event_manager::update() {
// test list of global events for possible new additions to the queue
for( auto *launcher : m_launcherqueue ) {

if( true == launcher->check_conditions() ) {
if( true == ( launcher->check_activation() && launcher->check_conditions() ) ) {
// NOTE: we're presuming global events aren't going to use event2
WriteLog( "Eventlauncher " + launcher->name() );
if( launcher->Event1 ) {
Expand Down
17 changes: 1 addition & 16 deletions Segment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,8 @@ obtain one at

//---------------------------------------------------------------------------

// helper, restores content of a 3d vector from provided input stream
// TODO: review and clean up the helper routines, there's likely some redundant ones
Math3D::vector3 LoadPoint( cParser &Input ) {
// pobranie współrzędnych punktu
Input.getTokens( 3 );
Math3D::vector3 point;
Input
>> point.x
>> point.y
>> point.z;

return point;
}


void
segment_data::deserialize( cParser &Input, Math3D::vector3 const &Offset ) {
segment_data::deserialize( cParser &Input, glm::dvec3 const &Offset ) {

points[ segment_data::point::start ] = LoadPoint( Input ) + Offset;
Input.getTokens();
Expand Down
2 changes: 1 addition & 1 deletion Segment.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ struct segment_data {
// constructors
segment_data() = default;
// methods
void deserialize( cParser &Input, Math3D::vector3 const &Offset );
void deserialize( cParser &Input, glm::dvec3 const &Offset );
};

class TSegment
Expand Down
4 changes: 2 additions & 2 deletions Track.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ void TTrack::ConnectNextNext(TTrack *pTrack, int typ)
}
}

void TTrack::Load(cParser *parser, Math3D::vector3 pOrigin)
void TTrack::Load(cParser *parser, glm::dvec3 const &pOrigin)
{ // pobranie obiektu trajektorii ruchu
Math3D::vector3 pt, vec, p1, p2, cp1, cp2, p3, p4, cp3, cp4; // dodatkowe punkty potrzebne do skrzyżowań
double a1, a2, r1, r2, r3, r4;
Expand Down Expand Up @@ -862,7 +862,7 @@ void TTrack::Load(cParser *parser, Math3D::vector3 pOrigin)
}

// calculate path location
m_area.center = ( glm::dvec3{ (
location( { (
CurrentSegment()->FastGetPoint_0()
+ CurrentSegment()->FastGetPoint( 0.5 )
+ CurrentSegment()->FastGetPoint_1() )
Expand Down
17 changes: 2 additions & 15 deletions Track.h
Original file line number Diff line number Diff line change
Expand Up @@ -170,20 +170,7 @@ class TTrack : public scene::basic_node {
m_events1,
m_events2;
bool m_events { false }; // Ra: flaga informująca o obecności eventów
/*
TEvent *evEventall0 = nullptr; // McZapkie-140302: wyzwalany gdy pojazd stoi
TEvent *evEventall1 = nullptr;
TEvent *evEventall2 = nullptr;
TEvent *evEvent0 = nullptr; // McZapkie-280503: wyzwalany tylko gdy headdriver
TEvent *evEvent1 = nullptr;
TEvent *evEvent2 = nullptr;
std::string asEventall0Name; // nazwy eventów
std::string asEventall1Name;
std::string asEventall2Name;
std::string asEvent0Name;
std::string asEvent1Name;
std::string asEvent2Name;
*/

int iNextDirection = 0; // 0:Point1, 1:Point2, 3:do odchylonego na zwrotnicy
int iPrevDirection = 0; // domyślnie wirtualne odcinki dołączamy stroną od Point1
TTrackType eType = tt_Normal; // domyślnie zwykły
Expand Down Expand Up @@ -246,7 +233,7 @@ class TTrack : public scene::basic_node {
SwitchExtension != nullptr ?
SwitchExtension->iRoads - 1 :
1 ); }
void Load(cParser *parser, Math3D::vector3 pOrigin);
void Load(cParser *parser, glm::dvec3 const &pOrigin);
bool AssignEvents();
bool AssignForcedEvents(TEvent *NewEventPlus, TEvent *NewEventMinus);
void QueueEvents( event_sequence const &Events, TDynamicObject const *Owner );
Expand Down
11 changes: 0 additions & 11 deletions Traction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,17 +91,6 @@ jawnie nazwę sekcji, ewentualnie nazwę zasilacza (zostanie zastąpiona wskazan
sekcji z sąsiedniego przęsła).
*/

glm::dvec3 LoadPoint( cParser &Input ) {
// pobranie współrzędnych punktu
glm::dvec3 point;
Input.getTokens( 3 );
Input
>> point.x
>> point.y
>> point.z;
return point;
}

TTraction::TTraction( scene::node_data const &Nodedata ) : basic_node( Nodedata ) {}

void
Expand Down
9 changes: 9 additions & 0 deletions maszyna.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,12 @@
<ClCompile Include="station.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="stb_vorbis.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="sceneeditor.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="Globals.h">
Expand Down Expand Up @@ -467,6 +473,9 @@
<ClInclude Include="station.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="sceneeditor.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="maszyna.rc">
Expand Down
Loading

0 comments on commit ff1a85f

Please sign in to comment.