This Trac instance is not used for development anymore!

We migrated our development workflow to git and Gitea.
To test the future redirection, replace trac by ariadne in the page URL.

Changeset 9623 for ps


Ignore:
Timestamp:
06/16/11 23:21:33 (14 years ago)
Author:
ben
Message:

Adds rotation to starting camera (currently unused)

Location:
ps/trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • ps/trunk/binaries/data/mods/public/simulation/components/Player.js

    r9617 r9623  
    227227};
    228228
    229 Player.prototype.GetStartingCamera = function()
    230 {
    231     return this.startCam;
    232 }
    233 
    234 Player.prototype.SetStartingCamera = function(pos)
    235 {
    236     this.startCam = pos;
     229Player.prototype.GetStartingCameraPos = function()
     230{
     231    return this.startCam.position;
     232}
     233
     234Player.prototype.GetStartingCameraRot = function()
     235{
     236    return this.startCam.rotation;
     237}
     238
     239Player.prototype.SetStartingCamera = function(pos, rot)
     240{
     241    this.startCam = {"position": pos, "rotation": rot};
    237242}
    238243
  • ps/trunk/binaries/data/mods/public/simulation/helpers/Player.js

    r9617 r9623  
    130130            }
    131131           
    132             if (getSetting(pData, pDefs, "StartingCamera") !== undefined)
    133             {
    134                 player.SetStartingCamera(getSetting(pData, pDefs, "StartingCamera"));
     132            var startCam = getSetting(pData, pDefs, "StartingCamera");
     133            if (startCam !== undefined)
     134            {
     135                player.SetStartingCamera(startCam.Position, startCam.Rotation);
    135136            }
    136137        }
  • ps/trunk/source/graphics/MapReader.cpp

    r9617 r9623  
    289289        // Default to global camera (with constraints)
    290290        pGameView->ResetCameraTarget(pGameView->GetCamera()->GetFocus());
    291        
     291   
     292        // TODO: Starting rotation?
    292293        CmpPtr<ICmpPlayer> cmpPlayer(*pSimulation2, cmpPlayerManager->GetPlayerByID(m_PlayerID));
    293294        if (!cmpPlayer.null() && cmpPlayer->HasStartingCamera())
    294295        {
    295296            // Use player starting camera
    296             CFixedVector3D pos = cmpPlayer->GetStartingCamera();
     297            CFixedVector3D pos = cmpPlayer->GetStartingCameraPos();
    297298            pGameView->ResetCameraTarget(CVector3D(pos.X.ToFloat(), pos.Y.ToFloat(), pos.Z.ToFloat()));
    298299        }
  • ps/trunk/source/simulation2/components/ICmpPlayer.cpp

    r9617 r9623  
    5454    }
    5555
    56     virtual CFixedVector3D GetStartingCamera()
     56    virtual CFixedVector3D GetStartingCameraPos()
    5757    {
    58         return m_Script.Call<CFixedVector3D>("GetStartingCamera");
     58        return m_Script.Call<CFixedVector3D>("GetStartingCameraPos");
     59    }
     60
     61    virtual CFixedVector3D GetStartingCameraRot()
     62    {
     63        return m_Script.Call<CFixedVector3D>("GetStartingCameraRot");
    5964    }
    6065
  • ps/trunk/source/simulation2/components/ICmpPlayer.h

    r9617 r9623  
    3737
    3838    virtual CColor GetColour() = 0;
    39     virtual CFixedVector3D GetStartingCamera() = 0;
     39    virtual CFixedVector3D GetStartingCameraPos() = 0;
     40    virtual CFixedVector3D GetStartingCameraRot() = 0;
    4041
    4142    virtual bool HasStartingCamera() = 0;
  • ps/trunk/source/tools/atlas/AtlasUI/ScenarioEditor/Sections/Player/Player.cpp

    r9620 r9623  
    624624        if (player["StartingCamera"].defined())
    625625        {
    626             AtObj cam = *player["StartingCamera"];
    627626            sCameraInfo info;
    628             info.pX = wxAtof(*cam["x"]);
    629             info.pY = wxAtof(*cam["y"]);
    630             info.pZ = wxAtof(*cam["z"]);
     627            AtObj camPos = *player["StartingCamera"]["Position"];
     628            info.pX = wxAtof(*camPos["x"]);
     629            info.pY = wxAtof(*camPos["y"]);
     630            info.pZ = wxAtof(*camPos["z"]);
     631            AtObj camRot = *player["StartingCamera"]["Rotation"];
     632            info.rX = wxAtof(*camRot["x"]);
     633            info.rY = wxAtof(*camRot["y"]);
     634            info.rZ = wxAtof(*camRot["z"]);
    631635           
    632636            controls.page->SetCamera(info, true);
     
    719723        {
    720724            sCameraInfo cam = controls.page->GetCamera();
    721             camObj.setDouble("x", cam.pX);
    722             camObj.setDouble("y", cam.pY);
    723             camObj.setDouble("z", cam.pZ);
     725            AtObj camPos;
     726            camPos.setDouble("x", cam.pX);
     727            camPos.setDouble("y", cam.pY);
     728            camPos.setDouble("z", cam.pZ);
     729            camObj.set("Position", camPos);
     730
     731            AtObj camRot;
     732            camRot.setDouble("x", cam.rX);
     733            camRot.setDouble("y", cam.rY);
     734            camRot.setDouble("z", cam.rZ);
     735            camObj.set("Rotation", camRot);
    724736        }
    725737        player.set("StartingCamera", camObj);
  • ps/trunk/source/tools/atlas/GameInterface/Handlers/CameraCtrlHandlers.cpp

    r9617 r9623  
    2222#include "../View.h"
    2323
     24#include "maths/MathUtil.h"
    2425#include "maths/Vector3D.h"
    2526#include "maths/Quaternion.h"
     
    223224{
    224225    CVector3D focus = g_Game->GetView()->GetCamera()->GetFocus();
    225 
    226226    sCameraInfo info;
    227227
     
    230230    info.pZ = focus.Z;
    231231
    232     // TODO: Rotation
     232    CQuaternion quatRot = g_Game->GetView()->GetCamera()->m_Orientation.GetRotation();
     233    quatRot.Normalize();
     234    CVector3D rotation = quatRot.ToEulerAngles();
     235
     236    info.rX = RADTODEG(rotation.X);
     237    info.rY = RADTODEG(rotation.Y);
     238    info.rZ = RADTODEG(rotation.Z);
    233239
    234240    msg->info = info;
     
    246252
    247253    view->ResetCameraTarget(CVector3D(cam.pX, cam.pY, cam.pZ));
    248 }
    249 
    250 }
     254
     255    // TODO: Rotation
     256}
     257
     258}
Note: See TracChangeset for help on using the changeset viewer.