This repository has been archived by the owner on Dec 2, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
RenderScene.cpp
101 lines (83 loc) · 2.85 KB
/
RenderScene.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
/*
* This file is part of Basic Model Viewer (visualization package)
*
* Copyright (c) 2015, Lakshman Anumolu
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1 as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#include "RenderScene.h"
RenderScene::RenderScene()
{
}
RenderScene::~RenderScene()
{
}
bool RenderScene::InitializeScene()
{
if (!this->InitializeShaders())
return false;
// Initialize default objects
if (!this->drawing_room.LocalInitialize())
return false;
if (!this->cubehandle_obj.LocalInitialize("../Resources/cubehandle0fix.obj"))
return false;
this->cubehandle_obj.show_wire_frame(false);
this->cubehandle_obj.show_normals(false);
if (!this->teapot_obj.LocalInitialize("../Resources/teapot.obj"))
return false;
/*if (!this->teapot_obj.LocalInitialize("../personal_resources/3.obj"))
return false;*/
this->teapot_obj.show_wire_frame(true);
/* Edit default light info */
Light light_for_teapot;
light_for_teapot.position = QVector3D(0.0, 0.0, 10.0);
light_for_teapot.color_ambient = QVector3D(0.75, 0.6, 0.5);
light_for_teapot.color_diffuse = QVector3D(0.75, 0.6, 0.5);
light_for_teapot.color_specular = QVector3D(1.0, 1.0, 1.0);
this->teapot_obj.EditLight(light_for_teapot);
//obj_models.AddObj(&cubehandle_obj);
obj_models.AddObj(&teapot_obj);
return true;
}
bool RenderScene::InitializeShaders()
{
return shaders_list.InitializeDefaultShaders();
}
bool RenderScene::Draw(
const QMatrix4x4 &projection,
const QMatrix4x4 &modelview_cam,
QMatrix4x4 modelview,
QOpenGLShaderProgram *shader_
)
{
if (!drawing_room.Draw(projection, modelview_cam, modelview, shader_))
return false;
/*if (!cubehandle_obj.Draw(projection, modelview_cam, modelview, shader_))
return false;
QMatrix4x4 mv_tmp_ = modelview;
modelview.translate(QVector3D(5.0, 5.0,-2.0));
if (!teapot_obj.Draw(projection, modelview_cam, modelview, shader_))
return false;
modelview = mv_tmp_;*/
if (!this->obj_models.Draw(projection, modelview_cam, modelview, shader_))
return false;
return true;
}
void RenderScene::TakeDown()
{
this->shaders_list.TakeDown();
this->drawing_room.TakeDown();
this->obj_models.TakeDown();
//this->cubehandle_obj.TakeDown();
//this->teapot_obj.TakeDown();
}