Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ include(GNUInstallDirs)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

find_package(X11)
find_package(pxr REQUIRED)
find_package(OpenGL REQUIRED)

Expand Down
8 changes: 7 additions & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,13 @@ int main(int argc, char** argv)
glEnable(GL_DEPTH_TEST);

pxr::Model model;
pxr::MainWindow mainWindow(&model);
std::vector<std::string> params;
for (int i =0; i < argc; i++)
{
params.emplace_back(argv[i]);
}

pxr::MainWindow mainWindow(&model, params);

while (!glfwWindowShouldClose(window)) {
glfwPollEvents();
Expand Down
27 changes: 25 additions & 2 deletions src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,23 @@
#include "views/usdsessionlayer.h"
#include "views/view.h"
#include "views/viewport.h"

#include <assert.h>
#include <iostream>
PXR_NAMESPACE_OPEN_SCOPE

MainWindow::MainWindow(Model* model) : _model(model)
MainWindow::MainWindow(Model* model, const std::vector<std::string>& params) : _model(model)
{
ResetDefaultViews();
if (params.size()>1)
{
const auto & usdFileName = params[1];
auto views = GetViewsOfType(UsdSessionLayer::VIEW_TYPE);
assert(!views.empty());
UsdSessionLayer* sessionLayerPtr = dynamic_cast<UsdSessionLayer*>(views.front());
assert(sessionLayerPtr);
std::cout << "Loading "<< usdFileName << std::endl;
sessionLayerPtr->LoadUsdStage(usdFileName);
}
};

void MainWindow::Update()
Expand Down Expand Up @@ -89,4 +100,16 @@ void MainWindow::AddView(const string viewType)
}
}

vector<View*> MainWindow::GetViewsOfType(const string viewType)
{
vector<View*> viewptrs;
for (auto &view:_views){
if (view->GetViewType() == viewType)
{
viewptrs.emplace_back(view);
}
}
return viewptrs;
}

PXR_NAMESPACE_CLOSE_SCOPE
11 changes: 10 additions & 1 deletion src/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@ class MainWindow {
* @brief Construct a new Main Window object
*
* @param model the Model of the new Main Window
* @param application arguments
*/
MainWindow(Model* model);
MainWindow(Model* model, const std::vector<std::string>& args);

/**
* @brief Update the draw call of the main window
Expand All @@ -53,7 +54,15 @@ class MainWindow {
*/
void AddView(const string viewType);

/**
* @brief Gets views of given type
*
* @param viewType the type of the retrieved view
*/
vector<View*> GetViewsOfType(const string viewType);

private:

vector<View*> _views;
Model* _model;
};
Expand Down
5 changes: 3 additions & 2 deletions src/views/usdsessionlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ UsdSessionLayer::UsdSessionLayer(Model* model, const string label)
GetModel()->AddSceneIndexBase(sceneIndices.finalSceneIndex);

_SetEmptyStage();

}

const string UsdSessionLayer::GetViewType()
Expand Down Expand Up @@ -92,7 +93,7 @@ void UsdSessionLayer::_Draw()
if (ImGuiFileDialog::Instance()->Display("LoadFile")) {
if (ImGuiFileDialog::Instance()->IsOk()) {
string filePath = ImGuiFileDialog::Instance()->GetFilePathName();
_LoadUsdStage(filePath);
LoadUsdStage(filePath);
}
ImGuiFileDialog::Instance()->Close();
}
Expand Down Expand Up @@ -121,7 +122,7 @@ void UsdSessionLayer::_SetEmptyStage()
GetModel()->SetStage(_stage);
}

void UsdSessionLayer::_LoadUsdStage(const string usdFilePath)
void UsdSessionLayer::LoadUsdStage(const string usdFilePath)
{
if (!ifstream(usdFilePath)) {
TF_RUNTIME_ERROR(
Expand Down
14 changes: 8 additions & 6 deletions src/views/usdsessionlayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,13 @@ class UsdSessionLayer : public View {
*/
ImGuiWindowFlags _GetGizmoWindowFlags() override;

/**
* @brief Load a Usd Stage based on the given Usd file path
*
* @param usdFilePath a string containing a Usd file path
*/
void LoadUsdStage(const string usdFilePath);

private:
TextEditor _editor;
bool _isEditing;
Expand All @@ -63,12 +70,7 @@ class UsdSessionLayer : public View {
*/
void _Draw() override;

/**
* @brief Load a Usd Stage based on the given Usd file path
*
* @param usdFilePath a string containing a Usd file path
*/
void _LoadUsdStage(const string usdFilePath);


/**
* @brief Set the model to an empty stage
Expand Down