Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
RoFIbots
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Marek Trtík
RoFIbots
Commits
dd450f18
There was an error fetching the commit references. Please try again later.
Commit
dd450f18
authored
1 year ago
by
Martin Štourač
Browse files
Options
Downloads
Patches
Plain Diff
added cube vertices with normals (indexed)
parent
b412bf65
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/gfx/src/render.cpp
+4
-3
4 additions, 3 deletions
src/gfx/src/render.cpp
src/gfx/src/vao.cpp
+1
-1
1 addition, 1 deletion
src/gfx/src/vao.cpp
src/studio/src/simulator.cpp
+70
-46
70 additions, 46 deletions
src/studio/src/simulator.cpp
with
75 additions
and
50 deletions
src/gfx/src/render.cpp
+
4
−
3
View file @
dd450f18
...
...
@@ -46,7 +46,7 @@ void gfx_draw(Shader &myShader,
glClear
(
GL_COLOR_BUFFER_BIT
|
GL_DEPTH_BUFFER_BIT
|
GL_STENCIL_BUFFER_BIT
);
ASSUMPTION
(
glGetError
()
==
GL_NO_ERROR
);
Frame
lightPos
(
glm
::
vec3
(
1.2
f
,
1.0
f
,
2
.0
f
),
glm
::
vec3
(
0.0
f
,
0.0
f
,
0.0
f
));
Frame
lightPos
(
glm
::
vec3
(
1.2
f
,
1
0
.0
f
,
10
.0
f
),
glm
::
vec3
(
0.0
f
,
0.0
f
,
0.0
f
));
myShader
.
use
();
myShader
.
setVec3
(
"objectColor"
,
glm
::
vec3
(
1.0
f
,
0.5
f
,
0.31
f
));
...
...
@@ -70,8 +70,9 @@ void gfx_draw(Shader &myShader,
/* ---------------------------------------------------------------- */
glm
::
mat4
model
=
glm
::
mat4
(
1.0
f
);
model
=
obj_frame
.
getRotationMat
()
*
model
;
model
=
glm
::
translate
(
model
,
obj_frame
.
getPosition
());
glm
::
mat4
rotated
=
obj_frame
.
getRotationMat
()
*
model
;
glm
::
mat4
translated
=
glm
::
translate
(
model
,
obj_frame
.
getPosition
());
model
=
translated
*
rotated
;
glm
::
mat4
view
;
...
...
This diff is collapsed.
Click to expand it.
src/gfx/src/vao.cpp
+
1
−
1
View file @
dd450f18
...
...
@@ -12,7 +12,7 @@ VAO::~VAO()
Delete
();
}
void
VAO
::
LinkVBO
(
unsigned
int
layout_loc
)
void
VAO
::
LinkVBO
(
unsigned
int
layout_loc
)
// TO DO: change to getUniform
{
ASSUMPTION
(
ID
!=
0
);
glVertexAttribPointer
(
layout_loc
,
3
,
GL_FLOAT
,
GL_FALSE
,
3
*
sizeof
(
float
),
(
void
*
)
0
);
...
...
This diff is collapsed.
Click to expand it.
src/studio/src/simulator.cpp
+
70
−
46
View file @
dd450f18
...
...
@@ -41,60 +41,84 @@ std::vector<unsigned int> obj_indices =
1
,
2
,
5
,
2
,
5
,
6
};
std
::
vector
<
float
>
lit_cube_vertices
=
{
-
1.0
f
,
1.0
f
,
-
1.0
f
,
1.0
f
,
1.0
f
,
-
1.0
f
,
-
1.0
f
,
1.0
f
,
1.0
f
,
1.0
f
,
1.0
f
,
1.0
f
,
// +Y
-
1.0
f
,
-
1.0
f
,
-
1.0
f
,
1.0
f
,
-
1.0
f
,
-
1.0
f
,
-
1.0
f
,
-
1.0
f
,
1.0
f
,
1.0
f
,
-
1.0
f
,
1.0
f
,
// -Y
1.0
f
,
1.0
f
,
1.0
f
,
1.0
f
,
1.0
f
,
-
1.0
f
,
1.0
f
,
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
0.0
f
,
1.0
f
,
0.0
f
,
0.0
f
,
1.0
f
,
0.0
f
,
0.0
f
,
1.0
f
,
0.0
f
,
0.0
f
,
-
1.0
f
,
0.0
f
,
0.0
f
,
-
1.0
f
,
0.0
f
,
0.0
f
,
-
1.0
f
,
0.0
f
,
0.0
f
,
-
1.0
f
};
std
::
vector
<
float
>
getnormals
(
std
::
vector
<
unsigned
int
>
&
indices
,
std
::
vector
<
float
>
&
vertices
)
{
std
::
vector
<
float
>
normals
;
for
(
int
i
=
0
;
i
<
indices
.
size
();
i
+=
3
)
{
glm
::
vec3
v1
(
vertices
[
indices
[
i
]
*
3
],
vertices
[
indices
[
i
]
*
3
+
1
],
vertices
[
indices
[
i
]
*
3
+
2
]);
glm
::
vec3
v2
(
vertices
[
indices
[
i
+
1
]
*
3
],
vertices
[
indices
[
i
+
1
]
*
3
+
1
],
vertices
[
indices
[
i
+
1
]
*
3
+
2
]);
glm
::
vec3
v3
(
vertices
[
indices
[
i
+
2
]
*
3
],
vertices
[
indices
[
i
+
2
]
*
3
+
1
],
vertices
[
indices
[
i
+
2
]
*
3
+
2
]);
glm
::
vec3
normal
=
glm
::
normalize
(
glm
::
cross
(
v2
-
v1
,
v3
-
v1
));
for
(
int
j
=
0
;
j
<
3
;
j
++
)
{
normals
.
push_back
(
normal
.
x
);
normals
.
push_back
(
normal
.
y
);
normals
.
push_back
(
normal
.
z
);
}
}
return
normals
;
}
Simulator
::
Simulator
()
:
osi
::
Simulator
()
// camera frame, object frame, camera, object
,
myShader
{
"./data/shaders/lightshader.vert"
,
"./data/shaders/lightshader.frag"
}
,
camera
{
60.0
f
}
,
object
{{
0
,
0
,
0
,
1
,
-
0.2
f
,
0
,
1
,
0.2
f
,
0
,
0
,
0
,
0
,
-
0.2
f
,
2
,
0
,
0.2
f
,
2
,
0
,
0
,
0
,
0
,
-
0.2
f
,
0
,
3
,
0.2
f
,
0
,
3
,
},
{
0
,
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
},
{
0
,
1
,
1
,
0
,
0
,
-
1
,
0
,
0
,
-
1
,
0
,
1
,
1
,
0
,
0
,
-
1
,
0
,
0
,
-
1
,
0
,
1
,
1
,
1
,
0
,
0
,
1
,
0
,
0
}
}
,
object
{
lit_cube_vertices
,
lit_cube_indices
,
lit_cube_normals
}
// , object{{
// 0, 0, 0, 1, -0.2f, 0, 1, 0.2f, 0,
// 0, 0, 0, -0.2f, 2, 0, 0.2f, 2, 0,
// 0, 0, 0, -0.2f, 0, 3, 0.2f, 0, 3,
// },
// {
// 0, 1, 2,
// 3, 4, 5,
// 6, 7, 8
// },
// {
// 0, 0, -1, 0, 0, -1, 0, 0, -1,
// 0, 0, -1, 0, 0, -1, 0, 0, -1,
// 0, 1, 0, 0, 1, 0, 0, 1, 0
// }
// }
,
cam_frame
{{
0.0
f
,
0.0
f
,
3.0
f
},
{
0.0
f
,
-
90.0
f
,
0.0
f
}}
// Setting camera rotation currently does nothing
,
obj_frame
{{
0.0
f
,
0.0
f
,
0.0
f
},
{
0.0
f
,
0.0
f
,
0.0
f
}}
,
cam_control
{
cam_frame
}
,
obj_control
{
obj_frame
}
// , object{{ 1.0f, -1.0f, 0.0f },
// {
// // positions
// //front
// 0.2f, 0.2f, 0.2f, // top right
// 0.2f, -0.2f, 0.2f, // bottom right
// -0.2f, -0.2f, 0.2f, // bottom left
// -0.2f, 0.2f, 0.2f, // top left
// //back
// 0.2f, 0.2f, -0.2f, // top right
// 0.2f, -0.2f, -0.2f, // bottom right
// -0.2f, -0.2f, -0.2f, // bottom left
// -0.2f, 0.2f, -0.2f // top left
// },
// {
// // front
// 0, 1, 3, 1, 2, 3,
// // back
// 4, 5, 7, 5, 6, 7,
// // right
// 0, 1, 4, 1, 4, 5,
// // left
// 2, 3, 7, 2, 6, 7,
// // top
// 0, 3, 4, 3, 4, 7,
// // bottom
// 1, 2, 5, 2, 5, 6
// }}
{
camera
.
setWindowSize
(
window
().
size
());
//obj_control.rotate(glm::vec3(0.0f, 50.0f, 0.0f));
...
...
@@ -108,7 +132,7 @@ void Simulator::update()
process_input
();
process_mouse
();
//obj_control.rotate(glm::vec3(1.0f, 0.0f, 0.0f)); // Rotation around x-axis demo
//
obj_control.rotate(glm::vec3(1.0f, 0.0f, 0.0f)); // Rotation around x-axis demo
}
void
Simulator
::
present
()
...
...
@@ -144,7 +168,7 @@ void Simulator::process_input()
cam_control
.
move
(
keyboard
().
down
());
}
int
fill_mode
=
keyboard
().
down
().
contains
(
"X"
)
?
GL_
FILL
:
GL_
LINE
;
// TO DO: change
int
fill_mode
=
keyboard
().
down
().
contains
(
"X"
)
?
GL_
LINE
:
GL_
FILL
;
// TO DO: change
glPolygonMode
(
GL_FRONT_AND_BACK
,
fill_mode
);
ASSUMPTION
(
glGetError
()
==
GL_NO_ERROR
);
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment