Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
Projet INF443 Maé
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Noé ARTRU
Projet INF443 Maé
Commits
528b402f
Commit
528b402f
authored
1 year ago
by
Marie AUDOUARD
Browse files
Options
Downloads
Patches
Plain Diff
corrected dragon breath + trajectory
parent
1b83f0e7
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
projet-code/scenes_inf443/base/src/dragon.cpp
+12
-6
12 additions, 6 deletions
projet-code/scenes_inf443/base/src/dragon.cpp
projet-code/scenes_inf443/base/src/scene.cpp
+7
-9
7 additions, 9 deletions
projet-code/scenes_inf443/base/src/scene.cpp
with
19 additions
and
15 deletions
projet-code/scenes_inf443/base/src/dragon.cpp
+
12
−
6
View file @
528b402f
...
...
@@ -42,18 +42,24 @@ void dragon::update_mvt()
timer_mvt
.
update
();
float
t
=
timer_mvt
.
t
;
// clear trajectory when
the timer restart + begin going in a circle
if
(
t
<
timer_mvt
.
t_min
+
0.2
f
)
//modified (was originally +0.1f so we are sure it passes through, even with low FPS
)
// clear trajectory when
gone past the first point
if
(
t
>
keyframe
.
key_times
[
1
]
)
{
keyframe
.
trajectory
.
clear
();
// Forget there was a first point so it goes in circles
if
(
timer_mvt
.
t_min
==
0
)
{
timer_mvt
.
t_min
=
keyframe
.
key_times
[
1
];
timer_mvt
.
t
=
keyframe
.
key_times
[
1
]
+
t
;
t
=
keyframe
.
key_times
[
1
]
+
t
;
keyframe
.
key_positions
[
0
]
=
keyframe
.
key_positions
[
1
];
keyframe
.
key_times
[
0
]
=
keyframe
.
key_times
[
1
];
numarray
<
vec3
>
key_positions
;
numarray
<
float
>
key_times
;
key_positions
.
resize
(
keyframe
.
key_positions
.
size
()
-
1
);
key_times
.
resize
(
keyframe
.
key_positions
.
size
()
-
1
);
for
(
int
i
=
0
;
i
<
keyframe
.
key_positions
.
size
()
-
1
;
i
++
)
{
key_positions
[
i
]
=
keyframe
.
key_positions
[
i
+
1
];
key_times
[
i
]
=
keyframe
.
key_times
[
i
+
1
];
}
keyframe
.
key_positions
=
key_positions
;
keyframe
.
key_times
=
key_times
;
}
}
...
...
This diff is collapsed.
Click to expand it.
projet-code/scenes_inf443/base/src/scene.cpp
+
7
−
9
View file @
528b402f
...
...
@@ -95,8 +95,8 @@ void scene_structure::initialize()
float
dragon_size
=
0.5
f
;
numarray
<
vec3
>
dragon_keypos
;
dragon_keypos
.
resize
(
14
);
dragon_keypos
[
0
]
=
{
cos
(
-
1
)
*
terrain_length
()
/
2
,
sin
(
-
1
)
*
terrain_length
()
/
2
,
evaluate_terrain_height
(
terrain_length
()
/
2
,
terrain_length
()
/
2
)
};
for
(
int
i
=
1
;
i
<
14
;
i
++
)
dragon_keypos
[
i
]
=
{
cos
(
2
*
Pi
*
double
(
i
%
7
-
3
)
/
3.0
)
*
terrain_length
()
/
3
,
sin
(
2
*
Pi
*
double
(
i
%
7
-
3
)
/
3.0
)
*
terrain_length
()
/
3
,
0
};
dragon_keypos
[
0
]
=
{
cos
(
0
)
*
terrain_length
()
/
2
,
sin
(
0
)
*
terrain_length
()
/
2
,
evaluate_terrain_height
(
terrain_length
()
/
2
,
terrain_length
()
/
2
)
};
for
(
int
i
=
1
;
i
<
14
;
i
++
)
dragon_keypos
[
i
]
=
{
cos
(
2
*
Pi
*
double
(
i
)
/
1
3.0
)
*
terrain_length
()
/
3
,
sin
(
2
*
Pi
*
double
(
i
)
/
1
3.0
)
*
terrain_length
()
/
3
,
0
};
numarray
<
float
>
dragon_keytimes
=
{
0.0
f
,
10.0
f
,
20.0
f
,
30.0
f
,
40.0
f
,
50.0
f
,
60.0
f
,
70.0
f
,
80.0
f
,
90.0
f
,
100.0
f
,
110.0
f
,
120.0
f
,
130.0
f
};
dragons
.
add_dragon
(
dragon_pos
,
dragon_size
,
dragon_keypos
,
dragon_keytimes
);
...
...
@@ -164,7 +164,7 @@ void scene_structure::initialize()
smoke
.
texture
.
initialize_texture_2d_on_gpu
(
smoke_grid
[
0
],
GL_REPEAT
,
GL_REPEAT
);
//DRAGON FIRE
mesh
fire_mesh
=
mesh_primitive_cone
(
3
,
15
,
{
0
,
0
,
0
},
{
-
1
,
0
,
0
},
false
);
mesh
fire_mesh
=
mesh_primitive_cone
(
3
,
15
,
{
18
,
0
,
0
},
{
-
1
,
0
,
0
},
false
);
image_structure
fire_breath_animation
;
fire_breath_animation
=
image_load_file
(
"assets/dragon/fire.png"
);
fire_breath_grid
=
image_split_grid
(
fire_breath_animation
,
6
,
5
);
...
...
@@ -218,14 +218,13 @@ void scene_structure::display_frame()
numarray
<
vec3
>
dragon_keypos
;
dragon_keypos
.
resize
(
14
);
float
phase
=
rand_interval
(
0
,
5
);
dragon_keypos
[
0
]
=
{
cos
(
-
1
+
phase
)
*
terrain_length
()
/
2
,
sin
(
-
1
+
phase
)
*
terrain_length
()
/
2
,
evaluate_terrain_height
(
terrain_length
()
/
2
,
terrain_length
()
/
2
)
};
for
(
int
i
=
1
;
i
<
14
;
i
++
)
dragon_keypos
[
i
]
=
{
cos
(
phase
+
2
*
Pi
*
double
(
i
%
7
-
3
)
/
3.0
)
*
terrain_length
()
/
3
,
sin
(
phase
+
2
*
Pi
*
double
(
i
%
7
-
3
)
/
3.0
)
*
terrain_length
()
/
3
,
0
};
dragon_keypos
[
0
]
=
{
cos
(
phase
)
*
terrain_length
()
/
2
,
sin
(
phase
)
*
terrain_length
()
/
2
,
evaluate_terrain_height
(
terrain_length
()
/
2
,
terrain_length
()
/
2
)
};
for
(
int
i
=
1
;
i
<
14
;
i
++
)
dragon_keypos
[
i
]
=
{
cos
(
phase
+
2
*
Pi
*
double
(
i
)
/
1
3.0
)
*
terrain_length
()
/
3
,
sin
(
phase
+
2
*
Pi
*
double
(
i
)
/
1
3.0
)
*
terrain_length
()
/
3
,
0
};
numarray
<
float
>
dragon_keytimes
=
{
0.0
f
,
10.0
f
,
20.0
f
,
30.0
f
,
40.0
f
,
50.0
f
,
60.0
f
,
70.0
f
,
80.0
f
,
90.0
f
,
100.0
f
,
110.0
f
,
120.0
f
,
130.0
f
};
dragons
.
add_dragon
(
dragon_pos
,
dragon_size
,
dragon_keypos
,
dragon_keytimes
);
//If it's the start of a new day, make bats go away
for
(
int
i
=
0
;
i
<
bats
.
N
;
i
++
)
{
std
::
cout
<<
"bat go away"
;
if
(
!
bats
.
bats_prop
[
i
].
isdead
)
{
bats
.
bats_prop
[
i
].
keyframe
.
key_positions
=
{
bats
.
bats_prop
[
i
].
pos
,
bats
.
bats_prop
[
i
].
pos
+
vec3
(
5
,
5
,
15
),
bats
.
bats_prop
[
i
].
pos
+
vec3
(
15
,
15
,
30
),
bats
.
bats_prop
[
i
].
pos
+
vec3
(
35
,
35
,
70
)
};
bats
.
bats_prop
[
i
].
keyframe
.
key_times
=
{
0
,
5
,
10
,
20
};
...
...
@@ -239,7 +238,6 @@ void scene_structure::display_frame()
//once they are far enough, remove bats
if
(
day_time
()
>
8
&&
day_time
()
<
9
)
{
bats
.
reset
();
std
::
cout
<<
"bat removed"
;
}
display_bats
();
...
...
@@ -409,9 +407,9 @@ void scene_structure::display_fire_breath(vec3 pos, rotation_transform rot, floa
glDepthMask
(
false
);
int
frame
=
3
*
t
;
//cast to int
fire_breath
.
texture
.
update
(
fire_breath_grid
[
frame
]);
fire_breath
.
model
.
scaling_xyz
=
{
double
(
9
*
t
+
20
)
/
(
9
*
duration
+
20
),
1
,
1
}
;
fire_breath
.
model
.
translation
=
pos
;
fire_breath
.
model
.
rotation
=
rot
;
fire_breath
.
model
.
translation
=
pos
+
20
*
double
(
9
*
t
+
20
)
/
(
9
*
duration
+
20
)
*
rot
*
vec3
(
1
,
0
,
0
)
;
fire_breath
.
model
.
scaling_xyz
=
{
double
(
9
*
t
+
20
)
/
(
9
*
duration
+
20
)
,
1
,
1
}
;
draw
(
fire_breath
,
environment
);
glDepthMask
(
true
);
glDisable
(
GL_BLEND
);
...
...
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