MCPcopy Create free account
hub / github.com/davideberly/GeometricTools / CreateScene

Method CreateScene

GTE/Samples/SceneGraphs/Picking/PickingWindow3.cpp:87–165  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

85}
86
87void PickingWindow3::CreateScene()
88{
89 std::string path = mEnvironment.GetPath("Checkerboard.png");
90 std::shared_ptr<Texture2> texture = WICFileIO::Load(path, false);
91
92 mScene = std::make_shared<Node>();
93
94 VertexFormat vformat0;
95 vformat0.Bind(VASemantic::POSITION, DF_R32G32B32_FLOAT, 0);
96 vformat0.Bind(VASemantic::TEXCOORD, DF_R32G32_FLOAT, 0);
97
98 // The torus and dodecahedron are created by the mesh factory in which
99 // the 'visual' model bounds are computed. The points and segments
100 // primitives are created explicitly here, so we need to compute their
101 // model bounds to be used by the picking system.
102 MeshFactory mf;
103 mf.SetVertexFormat(vformat0);
104
105 mTorus = mf.CreateTorus(16, 16, 4.0f, 1.0f);
106 auto effect = std::make_shared<Texture2Effect>(mProgramFactory, texture,
107 SamplerState::Filter::MIN_L_MAG_L_MIP_P, SamplerState::Mode::CLAMP, SamplerState::Mode::CLAMP);
108 mTorus->SetEffect(effect);
109 mPVWMatrices.Subscribe(mTorus->worldTransform, effect->GetPVWMatrixConstant());
110 mScene->AttachChild(mTorus);
111
112 mDodecahedron = mf.CreateDodecahedron();
113 effect = std::make_shared<Texture2Effect>(mProgramFactory, texture,
114 SamplerState::Filter::MIN_L_MAG_L_MIP_P, SamplerState::Mode::CLAMP,
115 SamplerState::Mode::CLAMP);
116 mDodecahedron->SetEffect(effect);
117 mPVWMatrices.Subscribe(mDodecahedron->worldTransform, effect->GetPVWMatrixConstant());
118 mScene->AttachChild(mDodecahedron);
119
120 VertexFormat vformat1;
121 vformat1.Bind(VASemantic::POSITION, DF_R32G32B32_FLOAT, 0);
122 auto vbuffer = std::make_shared<VertexBuffer>(vformat1, 4);
123 auto* vertices = vbuffer->Get<Vector3<float>>();
124 vertices[0] = { 1.0f, 1.0f, 4.0f };
125 vertices[1] = { 1.0f, 2.0f, 5.0f };
126 vertices[2] = { 2.0f, 2.0f, 6.0f };
127 vertices[3] = { 2.0f, 1.0f, 7.0f };
128 auto ibuffer = std::make_shared<IndexBuffer>(IP_POLYPOINT, 4);
129 auto cceffect = std::make_shared<ConstantColorEffect>(mProgramFactory,
130 Vector4<float>{ 0.5f, 0.0f, 0.0f, 1.0f });
131 mPoints = std::make_shared<Visual>(vbuffer, ibuffer, cceffect);
132 mPoints->UpdateModelBound();
133 mPVWMatrices.Subscribe(mPoints->worldTransform, cceffect->GetPVWMatrixConstant());
134 mScene->AttachChild(mPoints);
135
136 vbuffer = std::make_shared<VertexBuffer>(vformat1, 4);
137 vertices = vbuffer->Get<Vector3<float>>();
138 vertices[0] = { -1.0f, -1.0f, 4.0f };
139 vertices[1] = { -1.0f, -2.0f, 5.0f };
140 vertices[2] = { -2.0f, -1.0f, 6.0f };
141 vertices[3] = { -2.0f, -2.0f, 7.0f };
142 ibuffer = std::make_shared<IndexBuffer>(IP_POLYSEGMENT_CONTIGUOUS, 3, sizeof(int32_t));
143 ibuffer->SetSegment(0, 0, 1);
144 ibuffer->SetSegment(1, 1, 2);

Callers

nothing calls this directly

Calls 13

GetPathMethod · 0.80
SetVertexFormatMethod · 0.80
SetEffectMethod · 0.80
SubscribeMethod · 0.80
AttachChildMethod · 0.80
UpdateModelBoundMethod · 0.80
AttachMethod · 0.80
BindMethod · 0.45
CreateTorusMethod · 0.45
CreateDodecahedronMethod · 0.45
SetSegmentMethod · 0.45
CreateSphereMethod · 0.45

Tested by

no test coverage detected