MCPcopy Create free account
hub / github.com/InteractiveComputerGraphics/PositionBasedDynamics / readScene

Method readScene

Utils/SceneLoader.cpp:11–142  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9
10
11void SceneLoader::readScene(const std::string &fileName, SceneData &sceneData)
12{
13 LOG_INFO << "Load scene file: " << fileName;
14 try
15 {
16 std::ifstream input_file(fileName);
17 if (!input_file.is_open())
18 {
19 LOG_ERR << "Cannot open file!\n";
20 return;
21 }
22 m_json << input_file;
23
24 std::string basePath = FileSystem::getFilePath(fileName);
25
26 readValue(m_json, "Name", sceneData.m_sceneName);
27
28 sceneData.m_camPosition = Vector3r(5.0, 10.0, 30.0);
29 readVector(m_json, "cameraPosition", sceneData.m_camPosition);
30 sceneData.m_camLookat = Vector3r(5.0, 0.0, 0.0);
31 readVector(m_json, "cameraLookat", sceneData.m_camLookat);
32
33 //////////////////////////////////////////////////////////////////////////
34 // read general
35 //////////////////////////////////////////////////////////////////////////
36 sceneData.m_timeStepSize = 0.005;
37 sceneData.m_gravity = Vector3r(0, -9.81, 0);
38 if (m_json.find("Simulation") != m_json.end())
39 readSimulation(m_json, "Simulation", sceneData);
40
41 //////////////////////////////////////////////////////////////////////////
42 // read rigid bodies
43 //////////////////////////////////////////////////////////////////////////
44 if (m_json.find("RigidBodies") != m_json.end())
45 readRigidBodies(m_json, "RigidBodies", basePath, sceneData);
46
47 //////////////////////////////////////////////////////////////////////////
48 // read triangle models
49 //////////////////////////////////////////////////////////////////////////
50 if (m_json.find("TriangleModels") != m_json.end())
51 readTriangleModels(m_json, "TriangleModels", basePath, sceneData);
52
53 //////////////////////////////////////////////////////////////////////////
54 // read tet models
55 //////////////////////////////////////////////////////////////////////////
56 if (m_json.find("TetModels") != m_json.end())
57 readTetModels(m_json, "TetModels", basePath, sceneData);
58
59 //////////////////////////////////////////////////////////////////////////
60 // read ball joints
61 //////////////////////////////////////////////////////////////////////////
62 if (m_json.find("BallJoints") != m_json.end())
63 readBallJoints(m_json, "BallJoints", sceneData);
64
65 //////////////////////////////////////////////////////////////////////////
66 // read ball-on-line joints
67 //////////////////////////////////////////////////////////////////////////
68 if (m_json.find("BallOnLineJoints") != m_json.end())

Callers

nothing calls this directly

Calls 3

whatMethod · 0.80
findMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected