DCDecomp
A decompilation of Dark Cloud for the PlayStation 2
Loading...
Searching...
No Matches
healeffect.cpp
1
#include "healeffect.hpp"
2
3
#include <libvu0.h>
4
5
#include <cmath>
6
#include <cstdio>
7
#include <cstdlib>
8
9
#include "
character.hpp
"
10
#include "dun/gameloop.hpp"
11
#include "
hitmark.hpp
"
12
#include "shot_freefuncs.hpp"
13
#include "texture.hpp"
14
15
void
CHealEffect::Set
(
float
*world) {
16
sceVu0CopyVector(this->
position
, world);
17
this->
active
=
true
;
18
19
for
(
int
i = 0; i < 32; i++) {
20
this->
radius
[i] = 3.0f + 6.0f * (float) rand() / 2.1474836e9f;
21
this->
angle
[i] = TWO_PI * (float) rand() / 2.1474836e9f - PI;
22
this->
angular_velocity
[i] = 0.034906585f * (5.0f * (float) rand() / 2.1474836e9f);
23
this->
size
[i] = 0.4f + 0.6f * (float) rand() / 2.1474836e9f;
24
this->
alpha
[i] = 0.0f;
25
// The drawn phase is the one below; the value rolled here is discarded.
26
this->
phase
[i] = 0.1f * (float) rand() / 2.1474836e9f;
27
this->
phase
[i] = 0.0f;
28
this->
particle_offset
[i][1] = 2.0f + 10.0f * (float) rand() / 2.1474836e9f;
29
}
30
}
31
32
void
CHealEffect::Step
() {
33
if
(this->
active
!= 0) {
34
float
offset[4] = {0.0f, 0.0f, 1.0f, 1.0f};
35
sceVu0FMATRIX unit;
36
sceVu0FMATRIX rotation;
37
int
expired = 0;
38
39
for
(
int
i = 0; i < 32; i++) {
40
if
(this->
phase
[i] < PI) {
41
// The phase runs a half sine, so the particle rises and fades once.
42
float
rise = sinf(this->
phase
[i]);
43
44
this->
phase
[i] += 0.052359879f;
45
this->
alpha
[i] = 128.0f * rise - 32.0f;
46
47
if
(this->
alpha
[i] <= 0.0f) {
48
this->
alpha
[i] = 0.0f;
49
}
50
51
this->
angle
[i] += this->
angular_velocity
[i];
52
53
if
(this->
angle
[i] > PI) {
54
this->
angle
[i] -= TWO_PI;
55
}
56
57
if
(this->
angle
[i] < -PI) {
58
this->
angle
[i] += TWO_PI;
59
}
60
61
offset[0] = 0.0f;
62
offset[1] = this->
particle_offset
[i][1] + 0.3f * (float) rand() / 2.1474836e9f;
63
offset[2] = rise * this->
radius
[i];
64
sceVu0UnitMatrix(unit);
65
sceVu0RotMatrixY(rotation, unit, this->
angle
[i]);
66
sceVu0ApplyMatrix(offset, rotation, offset);
67
sceVu0CopyVector(this->
particle_offset
[i], offset);
68
}
else
{
69
expired++;
70
71
if
(expired == 32) {
72
this->
active
=
false
;
73
printf(
"emd!!\n"
);
74
}
75
}
76
}
77
}
78
}
79
80
void
CHealEffect::Draw
() {
81
if
(this->
active
!= 0) {
82
float
world[4];
83
// Unread; Step builds its particle offsets from the same template.
84
float
offset[4] = {0.0f, 0.0f, 1.0f, 1.0f};
85
CTexture
*texture = TexManager.GetTexture(
HealEffectTextureName
, -1);
86
87
sceVu0CopyVector(this->
position
, CharaMain.
pos
);
88
89
for
(
int
i = 0; i < 32; i++) {
90
if
(this->
phase
[i] < PI) {
91
world[0] = this->
position
[0] + this->
particle_offset
[i][0];
92
world[1] = this->
position
[1] + this->particle_offset[i][1];
93
world[2] = this->
position
[2] + this->particle_offset[i][2];
94
BtSet3DCellModel(world, texture, this->
size
[i], 0x10, 0, 0x20, 0x20, (
int
) this->
alpha
[i]);
95
}
96
}
97
}
98
}
character.hpp
CHealEffect::Draw
void Draw()
Definition
healeffect.cpp:80
CHealEffect::radius
float radius[32]
Definition
healeffect.hpp:14
CHealEffect::size
float size[32]
Definition
healeffect.hpp:17
CHealEffect::angular_velocity
float angular_velocity[32]
Definition
healeffect.hpp:13
CHealEffect::angle
float angle[32]
Definition
healeffect.hpp:12
CHealEffect::active
s32 active
Definition
healeffect.hpp:18
CHealEffect::phase
float phase[32]
Definition
healeffect.hpp:16
CHealEffect::Step
void Step()
Definition
healeffect.cpp:32
CHealEffect::alpha
float alpha[32]
Definition
healeffect.hpp:15
CHealEffect::particle_offset
float particle_offset[32][4]
Definition
healeffect.hpp:11
CHealEffect::position
float position[4]
Definition
healeffect.hpp:10
CHealEffect::Set
void Set(float *world)
Definition
healeffect.cpp:15
CObject::pos
float pos[4]
Definition
object.hpp:18
CTexture
Definition
texture.hpp:50
hitmark.hpp
HealEffectTextureName
char HealEffectTextureName[]
ps2
src
healeffect.cpp
Generated by
1.9.8