Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
CppRaytracer
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
Yoel
CppRaytracer
Commits
d1ad2747
Commit
d1ad2747
authored
2 years ago
by
Yoel
Browse files
Options
Downloads
Patches
Plain Diff
Build hierarchy in obj
parent
b96a808b
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
RayTracer/Main.cpp
+45
-1
45 additions, 1 deletion
RayTracer/Main.cpp
RayTracer/shape/Triangle.h
+1
-2
1 addition, 2 deletions
RayTracer/shape/Triangle.h
with
46 additions
and
3 deletions
RayTracer/Main.cpp
+
45
−
1
View file @
d1ad2747
...
...
@@ -51,7 +51,7 @@ int tree_recurs(const std::vector<shapes::TriMeshNode>& hierarchy,
return
d
;
}
int
main
()
{
#if
tru
e
#if
fals
e
cout
<<
"Start"
<<
endl
;
// Image img = Image (100, 100);
...
...
@@ -132,6 +132,50 @@ int main() {
cout
<<
i
<<
" {"
<<
hier
.
left
<<
" "
<<
hier
.
right
<<
" "
<<
hier
.
leaves_i
<<
" "
<<
hier
.
leaves_size
<<
"}"
<<
endl
;
i
++
;
for
(
int
i
=
0
;
i
<
hier
.
leaves_size
;
i
++
)
{
cout
<<
mesh
.
leaves
[
hier
.
leaves_i
+
i
].
p1
.
position
<<
" "
<<
mesh
.
leaves
[
hier
.
leaves_i
+
i
].
p2
.
position
<<
" "
<<
mesh
.
leaves
[
hier
.
leaves_i
+
i
].
p3
.
position
<<
endl
;
}
}
cout
<<
endl
;
for
(
auto
hier
:
mesh
.
hierarchy
)
{
std
::
vector
<
util
::
Vertex
>
v
;
std
::
vector
<
std
::
tuple
<
int
,
int
,
int
>
>
f
;
for
(
int
i
=
0
;
i
<
hier
.
leaves_size
;
i
++
)
{
auto
tri
=
mesh
.
leaves
[
hier
.
leaves_i
+
i
];
int
p1_i
=
-
1
;
int
p2_i
=
-
1
;
int
p3_i
=
-
1
;
for
(
int
j
=
0
;
j
<
v
.
size
();
j
++
)
{
auto
p
=
v
[
j
];
if
(
p
.
position
==
tri
.
p1
.
position
)
p1_i
=
j
+
1
;
if
(
p
.
position
==
tri
.
p2
.
position
)
p2_i
=
j
+
1
;
if
(
p
.
position
==
tri
.
p3
.
position
)
p3_i
=
j
+
1
;
}
if
(
p1_i
==
-
1
)
{
v
.
push_back
(
tri
.
p1
);
p1_i
=
v
.
size
();
}
if
(
p2_i
==
-
1
)
{
v
.
push_back
(
tri
.
p2
);
p2_i
=
v
.
size
();
}
if
(
p3_i
==
-
1
)
{
v
.
push_back
(
tri
.
p3
);
p3_i
=
v
.
size
();
}
f
.
push_back
({
p1_i
,
p2_i
,
p3_i
});
}
for
(
auto
x
:
v
)
{
cout
<<
"v "
<<
x
.
position
[
0
]
<<
".000000 "
<<
x
.
position
[
1
]
<<
".000000 "
<<
x
.
position
[
2
]
<<
".000000"
<<
endl
;
}
for
(
auto
x
:
f
)
{
cout
<<
"f "
<<
std
::
get
<
0
>
(
x
)
<<
" "
<<
std
::
get
<
1
>
(
x
)
<<
" "
<<
std
::
get
<
2
>
(
x
)
<<
endl
;
}
cout
<<
endl
;
}
cout
<<
tree_recurs
(
mesh
.
hierarchy
,
mesh
.
hierarchy
[
0
])
<<
endl
;
...
...
This diff is collapsed.
Click to expand it.
RayTracer/shape/Triangle.h
+
1
−
2
View file @
d1ad2747
...
...
@@ -25,8 +25,7 @@ class Triangle : public Light, public Shape {
const
util
::
Vec3
&
dl_out
)
const
override
;
const
std
::
shared_ptr
<
material
::
Material
>&
material
;
private:
// public:
const
util
::
Vertex
p1
;
const
util
::
Vertex
p2
;
const
util
::
Vertex
p3
;
...
...
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