OSDN Git Service

-elevator object positioning cleanups
authorryan <>
Fri, 25 Sep 2015 01:52:18 +0000 (01:52 +0000)
committerryan <>
Fri, 25 Sep 2015 01:52:18 +0000 (01:52 +0000)
-elevator music sound is now positioned properly on startup, instead of at start of play
-misc positioning fixes and cleanups
-elevator motor sounds are now children of shafts, fixing movement issues, where they were moving along with the elevator
-added Relative Position item to Move Object window, and realigned text boxes

codeblocks/wxsmith/MoveObject.wxs
src/frontend/moveobject.cpp
src/frontend/moveobject.h
src/sbs/elevator.cpp
src/sbs/floor.cpp
src/sbs/floor.h
src/sbs/model.cpp
src/sbs/object.cpp
src/sbs/sound.cpp
src/sbs/sound.h

index 1a42279..91c9867 100644 (file)
                                                                                                <option>1</option>
                                                                                        </object>
                                                                                        <object class="sizeritem">
-                                                                                               <object class="wxStaticText" name="ID_STATICTEXT2" variable="StaticText2" member="yes">
-                                                                                                       <label>Rotation:</label>
+                                                                                               <object class="wxStaticText" name="ID_lblPosition" variable="lblPosition" member="yes">
+                                                                                                       <label>0, 0, 0</label>
+                                                                                                       <style>wxST_NO_AUTORESIZE|wxALIGN_CENTRE</style>
+                                                                                               </object>
+                                                                                               <flag>wxALL|wxEXPAND|wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL</flag>
+                                                                                               <border>5</border>
+                                                                                               <option>1</option>
+                                                                                       </object>
+                                                                                       <object class="sizeritem">
+                                                                                               <object class="wxStaticText" name="ID_STATICTEXT3" variable="StaticText3" member="yes">
+                                                                                                       <label>Relative Position:</label>
                                                                                                        <style>wxALIGN_CENTRE</style>
                                                                                                </object>
                                                                                                <flag>wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL</flag>
                                                                                                <option>1</option>
                                                                                        </object>
                                                                                        <object class="sizeritem">
-                                                                                               <object class="wxStaticText" name="ID_lblPosition" variable="lblPosition" member="yes">
+                                                                                               <object class="wxStaticText" name="ID_STATICTEXT4" variable="lblRelPosition" member="yes">
                                                                                                        <label>0, 0, 0</label>
-                                                                                                       <style>wxST_NO_AUTORESIZE|wxALIGN_CENTRE</style>
+                                                                                                       <style>wxALIGN_CENTRE</style>
                                                                                                </object>
                                                                                                <flag>wxALL|wxEXPAND|wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL</flag>
                                                                                                <border>5</border>
                                                                                                <option>1</option>
                                                                                        </object>
                                                                                        <object class="sizeritem">
+                                                                                               <object class="wxStaticText" name="ID_STATICTEXT2" variable="StaticText2" member="yes">
+                                                                                                       <label>Rotation:</label>
+                                                                                                       <style>wxALIGN_CENTRE</style>
+                                                                                               </object>
+                                                                                               <flag>wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL</flag>
+                                                                                               <border>5</border>
+                                                                                               <option>1</option>
+                                                                                       </object>
+                                                                                       <object class="sizeritem">
                                                                                                <object class="wxStaticText" name="ID_lblRotation" variable="lblRotation" member="yes">
                                                                                                        <label>0, 0, 0</label>
                                                                                                        <style>wxST_NO_AUTORESIZE|wxALIGN_CENTRE</style>
index 0572b30..6861fb8 100644 (file)
@@ -39,8 +39,10 @@ extern Skyscraper *skyscraper;
 
 //(*IdInit(MoveObject)
 const long MoveObject::ID_STATICTEXT1 = wxNewId();
-const long MoveObject::ID_STATICTEXT2 = wxNewId();
 const long MoveObject::ID_lblPosition = wxNewId();
+const long MoveObject::ID_STATICTEXT3 = wxNewId();
+const long MoveObject::ID_STATICTEXT4 = wxNewId();
+const long MoveObject::ID_STATICTEXT2 = wxNewId();
 const long MoveObject::ID_lblRotation = wxNewId();
 const long MoveObject::ID_STATICLINE2 = wxNewId();
 const long MoveObject::ID_rPosition = wxNewId();
@@ -107,10 +109,14 @@ MoveObject::MoveObject(wxWindow* parent,wxWindowID id, int object_number)
        GridSizer1 = new wxGridSizer(0, 2, 0, 0);
        StaticText1 = new wxStaticText(this, ID_STATICTEXT1, _("Position:"), wxDefaultPosition, wxDefaultSize, wxALIGN_CENTRE, _T("ID_STATICTEXT1"));
        GridSizer1->Add(StaticText1, 1, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
-       StaticText2 = new wxStaticText(this, ID_STATICTEXT2, _("Rotation:"), wxDefaultPosition, wxDefaultSize, wxALIGN_CENTRE, _T("ID_STATICTEXT2"));
-       GridSizer1->Add(StaticText2, 1, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
        lblPosition = new wxStaticText(this, ID_lblPosition, _("0, 0, 0"), wxDefaultPosition, wxDefaultSize, wxST_NO_AUTORESIZE|wxALIGN_CENTRE, _T("ID_lblPosition"));
        GridSizer1->Add(lblPosition, 1, wxALL|wxEXPAND|wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 5);
+       StaticText3 = new wxStaticText(this, ID_STATICTEXT3, _("Relative Position:"), wxDefaultPosition, wxDefaultSize, wxALIGN_CENTRE, _T("ID_STATICTEXT3"));
+       GridSizer1->Add(StaticText3, 1, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
+       lblRelPosition = new wxStaticText(this, ID_STATICTEXT4, _("0, 0, 0"), wxDefaultPosition, wxDefaultSize, wxALIGN_CENTRE, _T("ID_STATICTEXT4"));
+       GridSizer1->Add(lblRelPosition, 1, wxALL|wxEXPAND|wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 5);
+       StaticText2 = new wxStaticText(this, ID_STATICTEXT2, _("Rotation:"), wxDefaultPosition, wxDefaultSize, wxALIGN_CENTRE, _T("ID_STATICTEXT2"));
+       GridSizer1->Add(StaticText2, 1, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
        lblRotation = new wxStaticText(this, ID_lblRotation, _("0, 0, 0"), wxDefaultPosition, wxDefaultSize, wxST_NO_AUTORESIZE|wxALIGN_CENTRE, _T("ID_lblRotation"));
        GridSizer1->Add(lblRotation, 1, wxALL|wxEXPAND|wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL, 5);
        FlexGridSizer5->Add(GridSizer1, 1, wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
@@ -246,8 +252,10 @@ void MoveObject::Loop()
        if (object)
        {
                Ogre::Vector3 pos = object->GetPosition();
+               Ogre::Vector3 relpos = object->GetPosition(true);
                Ogre::Vector3 rot = object->GetRotation();
                lblPosition->SetLabel(TruncateNumber(pos.x, 2) + wxT(", ") + TruncateNumber(pos.y, 2) + wxT(", ") + TruncateNumber(pos.z, 2));
+               lblRelPosition->SetLabel(TruncateNumber(relpos.x, 2) + wxT(", ") + TruncateNumber(relpos.y, 2) + wxT(", ") + TruncateNumber(relpos.z, 2));
                lblRotation->SetLabel(TruncateNumber(rot.x, 2) + wxT(", ") + TruncateNumber(rot.y, 2) + wxT(", ") + TruncateNumber(rot.z, 2));
 
                //move if hold vector is not zero
index e6b4996..b36e0b2 100644 (file)
@@ -45,8 +45,10 @@ class MoveObject: public wxDialog
 
                //(*Identifiers(MoveObject)
                static const long ID_STATICTEXT1;
-               static const long ID_STATICTEXT2;
                static const long ID_lblPosition;
+               static const long ID_STATICTEXT3;
+               static const long ID_STATICTEXT4;
+               static const long ID_STATICTEXT2;
                static const long ID_lblRotation;
                static const long ID_STATICLINE2;
                static const long ID_rPosition;
@@ -136,10 +138,12 @@ class MoveObject: public wxDialog
                wxButton* bXPlus;
                wxStaticText* lblPosition;
                wxButton* bYNeg;
+               wxStaticText* lblRelPosition;
                wxStaticText* StaticText20;
                wxStaticText* StaticText1;
                wxStaticText* StaticText16;
                wxButton* bRotationZ;
+               wxStaticText* StaticText3;
                wxTextCtrl* txtRotationX;
                wxStaticText* StaticText23;
                wxButton* bXNeg;
index 1fef89f..954e70c 100644 (file)
@@ -577,20 +577,20 @@ Object* Elevator::CreateElevator(bool relative, float x, float z, int floor)
                Report("creating sound objects");
        carsound = new Sound(this, "Car", true);
        idlesound = new Sound(this, "Idle", true);
-       motorsound = new Sound(this, "Motor", true);
-       motoridlesound = new Sound(this, "Motor Idle", true);
+
+       std::string motorname = "Motor " + ToString2(Number);
+       motorsound = new Sound(GetShaft(), motorname.c_str(), true);
+       motorname += " Idle";
+       motoridlesound = new Sound(GetShaft(), motorname.c_str(), true);
+
        //move motor to top of shaft if location not specified, or to location
        if (MotorPosition != Ogre::Vector3(0, 0, 0))
                motorsound->SetPosition(Ogre::Vector3(MotorPosition.x + GetPosition().x, MotorPosition.y, MotorPosition.z + GetPosition().z));
        else
        {
-               Shaft* shaft = GetShaft();
-               if (shaft)
-               {
-                       Floor *floor = sbs->GetFloor(shaft->endfloor);
-                       if (floor)
-                               motorsound->SetPositionY(floor->GetBase());
-               }
+               Floor *floor = sbs->GetFloor(GetShaft()->endfloor);
+               if (floor)
+                       motorsound->SetPositionY(floor->GetBase());
        }
        MotorPosition = Ogre::Vector3(motorsound->GetPosition().x - GetPosition().x, motorsound->GetPosition().y, motorsound->GetPosition().z - GetPosition().z);
        motoridlesound->SetPosition(motorsound->GetPosition());
@@ -1201,8 +1201,17 @@ void Elevator::MonitorLoop()
                }
                HeightSet = true;
 
-               //update sound positions
-               MoveObjects(0);
+               //position sounds at top of elevator car
+               Ogre::Vector3 top = Ogre::Vector3(0, Height, 0);
+               idlesound->SetPositionRelative(top);
+               alarm->SetPositionRelative(top);
+               floorbeep->SetPositionRelative(top);
+               announcesnd->SetPositionRelative(top);
+
+               //set default music position to elevator height
+               if (MusicPosition == Ogre::Vector3(0, 0, 0) && Height > 0)
+                       MusicPosition = top;
+               musicsound->SetPositionRelative(MusicPosition);
        }
 
        //set random lobby level if not set
@@ -1334,10 +1343,6 @@ void Elevator::MonitorLoop()
                                        if (sbs->Verbose)
                                                Report("playing music");
 
-                                       if (MusicPosition == Ogre::Vector3(0, 0, 0) && Height > 0)
-                                               MusicPosition = Ogre::Vector3(0, Height, 0); //set default music position to elevator height
-
-                                       musicsound->SetPositionRelative(MusicPosition);
                                        musicsound->Loop(true);
                                        musicsound->Play(false);
                                }
@@ -2025,19 +2030,6 @@ void Elevator::MoveObjects(float offset)
        //move camera
        if (sbs->ElevatorSync == true && sbs->ElevatorNumber == Number)
                sbs->camera->MovePosition(vector);
-
-       //move sounds
-       Ogre::Vector3 top = Ogre::Vector3(0, Height, 0);
-       idlesound->SetPositionRelative(top);
-       alarm->SetPositionRelative(top);
-       floorbeep->SetPositionRelative(top);
-       announcesnd->SetPositionRelative(top);
-       musicsound->SetPositionRelative(MusicPosition);
-       for (int i = 0; i < (int)sounds.size(); i++)
-       {
-               if (sounds[i])
-                       sounds[i]->SetPositionY(elevposition.y + sounds[i]->PositionOffset.y);
-       }
 }
 
 void Elevator::SetFloor(int floor)
@@ -4167,7 +4159,7 @@ void Elevator::SetMessageSound(bool type, bool direction, const char *filename)
 
 Object* Elevator::AddSound(const char *name, const char *filename, Ogre::Vector3 position, bool loop, float volume, int speed, float min_distance, float max_distance, float doppler_level, float cone_inside_angle, float cone_outside_angle, float cone_outside_volume, Ogre::Vector3 direction)
 {
-       //create a looping sound object
+       //create a sound object
        Sound *sound = new Sound(this, name, false);
        sounds.push_back(sound);
 
index 57dfb7b..44a2b62 100644 (file)
@@ -213,14 +213,6 @@ Floor::~Floor()
                sbs->RemoveFloor(this);
 }
 
-void Floor::SetCameraFloor()
-{
-       //Moves camera to specified floor (sets altitude to the floor's base plus DefaultAltitude)
-
-       Ogre::Vector3 camlocation = sbs->camera->GetPosition();
-       sbs->camera->SetPosition(Ogre::Vector3(camlocation.x, GetBase() + sbs->camera->cfg_body_height + sbs->camera->cfg_legs_height, camlocation.z));
-}
-
 WallObject* Floor::AddFloor(const char *name, const char *texture, float thickness, float x1, float z1, float x2, float z2, float voffset1, float voffset2, bool reverse_axis, bool texture_direction, float tw, float th, bool isexternal, bool legacy_behavior)
 {
        //Adds a floor with the specified dimensions and vertical offset
index 9d9e9ad..2213e6b 100644 (file)
@@ -63,7 +63,6 @@ public:
        //functions
        Floor(int number);
        ~Floor();
-       void SetCameraFloor();
        WallObject* AddFloor(const char *name, const char *texture, float thickness, float x1, float z1, float x2, float z2, float voffset1, float voffset2, bool reverse_axis, bool texture_direction, float tw, float th, bool isexternal, bool legacy_behavior = false);
        WallObject* AddInterfloorFloor(const char *name, const char *texture, float thickness, float x1, float z1, float x2, float z2, float voffset1, float voffset2, bool reverse_axis, bool texture_direction, float tw, float th, bool legacy_behavior = false);
        WallObject* AddWall(const char *name, const char *texture, float thickness, float x1, float z1, float x2, float z2, float height_in1, float height_in2, float voffset1, float voffset2, float tw, float th, bool isexternal);
index d6f1338..bc2bd83 100644 (file)
@@ -58,8 +58,8 @@ Model::Model(Object *parent, const char *name, const char *filename, bool center
        Move(position);
        //SetRotation(rotation);
 
-       //set mesh object at specified offset
-       mesh->SetPosition(GetPosition() + Offset);
+       //move mesh object to specified offset
+       mesh->Move(Offset);
        mesh->SetRotation(rotation);
 }
 
index d90a8c7..003f3ea 100644 (file)
@@ -242,7 +242,6 @@ void Object::ShowBoundingBox(bool value)
 void Object::Move(const Ogre::Vector3 &vector, float speed)
 {
        //move an object
-       //if relative is true, vector is relative of parent object
 
        SetPosition(GetPosition() + (vector * speed));
 }
@@ -297,7 +296,6 @@ void Object::SetPositionRelative(float X, float Y, float Z)
 void Object::SetPositionY(float value)
 {
        //set position of only Y vector
-       //if relative is true, position is relative of parent object
 
        Ogre::Vector3 pos (GetPosition().x, value, GetPosition().z);
        SetPosition(pos);
index 06a1474..c5226a0 100644 (file)
@@ -37,7 +37,6 @@ Sound::Sound(Object *parent, const char *name, bool permanent)
        SetValues(this, parent, "Sound", name, permanent);
 
        //first set default values
-       PositionOffset = 0;
        Position = 0;
        Volume = sbs->GetConfigFloat("Skyscraper.SBS.Sound.Volume", 1.0);
        MaxDistance = sbs->GetConfigFloat("Skyscraper.SBS.Sound.MaxDistance", 10000.0);
index b18b778..b0d40fd 100644 (file)
@@ -30,7 +30,6 @@ class SBSIMPEXP Sound : public Object
 {
 public:
 
-       Ogre::Vector3 PositionOffset; //optional position offset, used only by other objects
        bool SetVelocity; //set sound velocity on move
 
        Sound(Object *parent, const char *name, bool permanent);