Changeset 434 for cafu/trunk

Show
Ignore:
Timestamp:
11/27/11 14:23:03 (6 months ago)
Author:
Carsten
Message:

Model Editor:
Added a tool for fixing models that did not bring proper UV-coordinates, or none at all.

Location:
cafu/trunk
Files:
2 added
2 modified

Legend:

Unmodified
Added
Removed
  • cafu/trunk/CaWE/ModelEditor/ElementsList.cpp

    r396 r434  
    2727#include "Commands/Rename.hpp" 
    2828#include "Commands/Select.hpp" 
     29#include "Commands/UpdateUVCoords.hpp" 
    2930#include "../ArtProvider.hpp" 
    3031 
    3132#include "MaterialSystem/Material.hpp" 
    3233#include "Models/Model_cmdl.hpp" 
     34 
     35#include "wx/numdlg.h" 
    3336 
    3437 
     
    293296        ID_MENU_INSPECT_EDIT=wxID_HIGHEST+1+100, 
    294297        ID_MENU_RENAME, 
    295         ID_MENU_ADD_NEW 
     298        ID_MENU_ADD_NEW, 
     299        ID_MENU_PROJECT_UV_COORDS 
    296300    }; 
    297301 
     
    302306    if (m_TYPE==GFIX || m_TYPE==SKIN || m_TYPE==CHAN) Menu.Append(ID_MENU_ADD_NEW, "Add/create new"); 
    303307 
    304     /* if (m_TYPE==MESH) 
    305     { 
    306         Append(..., "Remove unused Vertices"); 
    307         Append(..., "Remove unused Weights"); 
    308     } */ 
     308    if (m_TYPE==MESH) 
     309    { 
     310        Menu.AppendSeparator(); 
     311        // Menu.Append(..., "Remove unused Vertices"); 
     312        // Menu.Append(..., "Remove unused Weights"); 
     313        Menu.Append(ID_MENU_PROJECT_UV_COORDS, "Project new UV-coords...", "Project UV-coordinates onto the mesh"); 
     314    } 
    309315 
    310316    switch (GetPopupMenuSelectionFromUser(Menu)) 
     
    333339                default: break; 
    334340            } 
     341            break; 
     342        } 
     343 
     344        case ID_MENU_PROJECT_UV_COORDS: 
     345        { 
     346            if (m_TYPE!=MESH) break; 
     347            if (m_ModelDoc->GetSelection(m_TYPE).Size()==0) break; 
     348 
     349            const unsigned int MeshNr=m_ModelDoc->GetSelection(m_TYPE)[0]; 
     350 
     351            const long Scale=wxGetNumberFromUser( 
     352                "This is a tool for fixing models that did not bring proper UV-coordinates, or none at all.\n" 
     353                "The right solution is to assign UV-coordinates in your favourite 3D mesh modelling software\n" 
     354                "and then to re-import the model, whereas this tool is meant as a very quick and very simple\n" 
     355                "means for a hot-fix (that sometimes may suffice nevertheless).", 
     356                "Enter UV-vector scale:", 
     357                wxString::Format("Project UV-coordinates onto mesh %u", MeshNr), 
     358                12, 
     359                1, 
     360                1024); 
     361 
     362            m_MainFrame->SubmitCommand(new CommandUpdateUVCoordsT(m_ModelDoc, 
     363                MeshNr, 
     364                m_ModelDoc->GetAnimState().Pose, 
     365                Vector3fT(Scale, 0, 0), 
     366                Vector3fT(0, 0, Scale))); 
    335367            break; 
    336368        } 
  • cafu/trunk/Libs/Models/Model_cmdl.hpp

    r429 r434  
    5151namespace ModelEditor { class CommandUpdateGuiFixtureT; } 
    5252namespace ModelEditor { class CommandUpdateTriangleT; } 
     53namespace ModelEditor { class CommandUpdateUVCoordsT; } 
    5354 
    5455 
     
    306307    friend class ModelEditor::CommandUpdateGuiFixtureT; 
    307308    friend class ModelEditor::CommandUpdateTriangleT; 
     309    friend class ModelEditor::CommandUpdateUVCoordsT; 
    308310 
    309311    CafuModelT(const CafuModelT&);                  ///< Use of the Copy    Constructor is not allowed.