Changeset 416

Show
Ignore:
Timestamp:
11/01/11 11:39:31 (7 months ago)
Author:
Carsten
Message:

Model code / GuiSys:
Replaced obsolete class ModelProxyT in the GuiSys's ModelWindowT class with new model code.

Location:
cafu/trunk
Files:
5 modified

Legend:

Unmodified
Added
Removed
  • cafu/trunk/CaWE/GuiEditor/Commands/ModifyWindow.cpp

    r415 r416  
    2828#include "MaterialSystem/Renderer.hpp" 
    2929#include "MaterialSystem/MaterialManager.hpp" 
    30 #include "Fonts/FontTT.hpp" 
     30#include "Models/Model_cmdl.hpp" 
    3131 
    3232 
     
    126126    else if (m_PropertyName=="Model") 
    127127    { 
     128        std::string ErrorMsg; 
    128129        cf::GuiSys::ModelWindowT* ModelWindow=dynamic_cast<cf::GuiSys::ModelWindowT*>(m_Window); 
    129130        wxASSERT(ModelWindow!=NULL); 
    130131 
    131         ModelProxyT& Model=ModelWindow->GetModel(); 
    132  
    133         m_OldString=Model.GetFileName(); 
    134  
    135         Model=ModelProxyT(m_NewString); 
     132        m_OldString=ModelWindow->GetModel()->GetFileName(); 
     133 
     134        ModelWindow->SetModel(m_NewString, ErrorMsg); 
    136135    } 
    137136    else 
     
    195194    else if (m_PropertyName=="Model") 
    196195    { 
     196        std::string ErrorMsg; 
    197197        cf::GuiSys::ModelWindowT* ModelWindow=dynamic_cast<cf::GuiSys::ModelWindowT*>(m_Window); 
    198198        wxASSERT(ModelWindow!=NULL); 
    199199 
    200         ModelWindow->GetModel()=ModelProxyT(m_OldString); 
     200        ModelWindow->SetModel(m_OldString, ErrorMsg); 
    201201    } 
    202202    else 
  • cafu/trunk/CaWE/GuiEditor/Windows/EditorModelWindow.cpp

    r367 r416  
    2727#include "GuiSys/WindowModel.hpp" 
    2828#include "GuiSys/WindowCreateParams.hpp" 
     29#include "Models/Model_cmdl.hpp" 
    2930 
    3031#include "wx/propgrid/manager.h" 
     
    4546    EditorWindowT::FillInPG(PropMan); 
    4647 
    47     PropMan->Append(new wxStringProperty("Model", wxPG_LABEL, m_ModelWindow->GetModel().GetFileName())); 
     48    PropMan->Append(new wxStringProperty("Model", wxPG_LABEL, m_ModelWindow->GetModel()->GetFileName())); 
    4849 
    4950    PropMan->Append(new wxIntProperty("ModelSequNr", wxPG_LABEL, m_ModelWindow->GetModelSequNr())); 
     
    7475    wxString PropName=Property->GetName(); 
    7576 
    76          if (PropName=="Model")         Property->SetValueFromString(m_ModelWindow->GetModel().GetFileName()); 
     77         if (PropName=="Model")         Property->SetValueFromString(m_ModelWindow->GetModel()->GetFileName()); 
    7778    else if (PropName=="ModelSequNr")   Property->SetValue(m_ModelWindow->GetModelSequNr()); 
    7879    else if (PropName=="ModelPos.x")    Property->SetValue(m_ModelWindow->GetModelPos().x); 
     
    181182    cf::GuiSys::ModelWindowT        Default(Params); 
    182183 
    183     if (m_ModelWindow->GetModel().GetFileName()!=Default.GetModel().GetFileName()) 
    184         OutFile << "    self:SetModel(\"" << m_ModelWindow->GetModel().GetFileName() << "\");\n"; 
     184    if (m_ModelWindow->GetModel()->GetFileName()!=Default.GetModel()->GetFileName()) 
     185        OutFile << "    self:SetModel(\"" << m_ModelWindow->GetModel()->GetFileName() << "\");\n"; 
    185186 
    186187    if (m_ModelWindow->GetModelSequNr()!=Default.GetModelSequNr()) 
  • cafu/trunk/Libs/GuiSys/WindowModel.cpp

    r285 r416  
    2525#include "MaterialSystem/Renderer.hpp" 
    2626#include "Math3D/Matrix.hpp" 
     27#include "Models/AnimPose.hpp" 
     28#include "Models/Model_cmdl.hpp" 
    2729 
    2830extern "C" 
     
    6466ModelWindowT::ModelWindowT(const cf::GuiSys::WindowCreateParamsT& Params) 
    6567    : WindowT(Params), 
    66       Model(""), 
    67       ModelSequNr(0), 
    68       ModelFrameNr(0.0f), 
     68      m_Model(NULL), 
     69      m_Pose(NULL), 
    6970      ModelPos(0, 0, 0), 
    7071      ModelScale(1.0f), 
     
    7273      CameraPos(0, -200.0f, 0) 
    7374{ 
     75    std::string ErrorMsg; 
     76 
     77    SetModel("dummy", ErrorMsg); 
    7478    FillMemberVars(); 
    7579} 
     
    7882ModelWindowT::ModelWindowT(const ModelWindowT& Window, bool Recursive) 
    7983    : WindowT(Window, Recursive), 
    80       Model(Window.Model), 
    81       ModelSequNr(Window.ModelSequNr), 
    82       ModelFrameNr(Window.ModelFrameNr), 
     84      m_Model(NULL), 
     85      m_Pose(NULL), 
    8386      ModelPos(Window.ModelPos), 
    8487      ModelScale(Window.ModelScale), 
     
    8689      CameraPos(Window.CameraPos) 
    8790{ 
     91    std::string ErrorMsg; 
     92 
     93    SetModel(Window.m_Model->GetFileName(), ErrorMsg); 
    8894    FillMemberVars(); 
    8995} 
     
    98104ModelWindowT::~ModelWindowT() 
    99105{ 
     106    delete m_Pose; 
     107} 
     108 
     109 
     110void ModelWindowT::SetModel(const std::string& FileName, std::string& ErrorMsg) 
     111{ 
     112    const CafuModelT* PrevModel=m_Model; 
     113 
     114    m_Model=m_Gui.GetGuiResources().GetModel(FileName, ErrorMsg); 
     115 
     116    if (m_Pose==NULL || PrevModel!=m_Model) 
     117    { 
     118        delete m_Pose; 
     119        m_Pose=new AnimPoseT(*m_Model, 0, 0.0f); 
     120    } 
     121} 
     122 
     123 
     124int ModelWindowT::GetModelSequNr() const 
     125{ 
     126    return m_Pose->GetSequNr(); 
    100127} 
    101128 
     
    128155    MatSys::Renderer->SetCurrentEyePosition(CameraPos.x, CameraPos.y, CameraPos.z);     // Required in some ambient shaders. 
    129156 
    130     Model.Draw(ModelSequNr, ModelFrameNr, 0.0f, NULL); 
     157    m_Pose->Draw(-1 /*default skin*/, 0.0f); 
    131158 
    132159    MatSys::Renderer->PopMatrix(MatSys::RendererI::PROJECTION    ); 
     
    138165bool ModelWindowT::OnClockTickEvent(float t) 
    139166{ 
    140     ModelFrameNr=Model.AdvanceFrameNr(ModelSequNr, ModelFrameNr, t, true); 
     167    m_Pose->Advance(t, true); 
    141168 
    142169    return WindowT::OnClockTickEvent(t); 
     
    148175    WindowT::FillMemberVars(); 
    149176 
    150     MemberVars["modelSequNr"]=MemberVarT(ModelSequNr); 
    151     MemberVars["modelFrameNr"]=MemberVarT(ModelFrameNr); 
    152177    MemberVars["modelPos.x"]=MemberVarT(ModelPos.x); 
    153178    MemberVars["modelPos.y"]=MemberVarT(ModelPos.y); 
     
    165190int ModelWindowT::SetModel(lua_State* LuaState) 
    166191{ 
    167     ModelWindowT* ModelWin=(ModelWindowT*)cf::GuiSys::GuiImplT::GetCheckedObjectParam(LuaState, 1, TypeInfo); 
    168  
    169     ModelWin->Model=ModelProxyT(luaL_checkstring(LuaState, 2)); 
     192    std::string   ErrorMsg; 
     193    ModelWindowT* ModelWin=(ModelWindowT*)cf::GuiSys::GuiImplT::GetCheckedObjectParam(LuaState, 1, TypeInfo); 
     194 
     195    ModelWin->SetModel(luaL_checkstring(LuaState, 2), ErrorMsg); 
     196 
     197    if (ErrorMsg!="") return luaL_error(LuaState, "%s", ErrorMsg.c_str()); 
    170198    return 0; 
    171199} 
     
    176204    ModelWindowT* ModelWin=(ModelWindowT*)cf::GuiSys::GuiImplT::GetCheckedObjectParam(LuaState, 1, TypeInfo); 
    177205 
    178     lua_pushinteger(LuaState, ModelWin->Model.GetNrOfSequences()); 
     206    lua_pushinteger(LuaState, ModelWin->m_Model->GetAnims().Size()); 
    179207    return 1; 
    180208} 
     
    185213    ModelWindowT* ModelWin=(ModelWindowT*)cf::GuiSys::GuiImplT::GetCheckedObjectParam(LuaState, 1, TypeInfo); 
    186214 
    187     ModelWin->ModelSequNr=luaL_checkinteger(LuaState, 2); 
     215    ModelWin->m_Pose->SetSequNr(luaL_checkinteger(LuaState, 2)); 
    188216    return 0; 
    189217} 
  • cafu/trunk/Libs/GuiSys/WindowModel.hpp

    r367 r416  
    2424 
    2525#include "Window.hpp" 
    26 #include "Models/Model_proxy.hpp" 
     26#include "Math3D/Vector3.hpp" 
     27 
     28 
     29class CafuModelT; 
     30class AnimPoseT; 
    2731 
    2832 
     
    4751            ~ModelWindowT(); 
    4852 
    49             /// Returns the model this window shows. 
    50             ModelProxyT& GetModel() { return Model; } 
    51  
    52             int              GetModelSequNr() const { return ModelSequNr; }     ///< Returns the animation sequence number that is used for the model. 
    53          // float            GetModelFrameNr() const { return ModelFrameNr; }   ///< Returns the frame number of the sequence. The only variable that is not set by script, but advanced automatically. 
     53            const CafuModelT* GetModel() const { return m_Model; } 
     54            void SetModel(const std::string& FileName, std::string& ErrorMsg); 
     55            int              GetModelSequNr() const; 
    5456            const Vector3fT& GetModelPos() const { return ModelPos; }           ///< Returns the position of the model in world space. 
    5557            float            GetModelScale() const { return ModelScale; }       ///< Returns the scale factor applied to the model coordinates when converted to world space. 
     
    7678            private: 
    7779 
    78             ModelProxyT Model;          ///< The model instance rendered by this window. 
    79             int         ModelSequNr;    ///< The animation sequence number that is used for the model. 
    80             float       ModelFrameNr;   ///< The frame number of the sequence. The only variable that is not set by script, but advanced automatically. 
    81             Vector3fT   ModelPos;       ///< The position of the model in world space. 
    82             float       ModelScale;     ///< The scale factor applied to the model coordinates when converted to world space. 
    83             Vector3fT   ModelAngles;    ///< The angles around the axes that determine the orientation of the model in world space. 
    84             Vector3fT   CameraPos;      ///< The position of the camera in world space. 
     80            const CafuModelT* m_Model;      ///< The model instance rendered by this window. 
     81            AnimPoseT*        m_Pose;       ///< The pose of the model. 
     82            Vector3fT         ModelPos;     ///< The position of the model in world space. 
     83            float             ModelScale;   ///< The scale factor applied to the model coordinates when converted to world space. 
     84            Vector3fT         ModelAngles;  ///< The angles around the axes that determine the orientation of the model in world space. 
     85            Vector3fT         CameraPos;    ///< The position of the camera in world space. 
    8586 
    8687 
  • cafu/trunk/Libs/Models/AnimPose.hpp

    r415 r416  
    105105    ~AnimPoseT(); 
    106106 
     107    int GetSequNr() const { return m_SequNr; } 
     108 
    107109    /// @param SequNr   The number of the animation sequence to use, -1 for the bind pose. 
    108110    void SetSequNr(int SequNr);