DCDecomp
A decompilation of Dark Cloud for the PlayStation 2
Loading...
Searching...
No Matches
candleeffect.cpp
1#include "candleeffect.hpp"
2
3#include <libvu0.h>
4
5#include "mglib.hpp"
6#include "rect.hpp"
7#include "snd.hpp"
8#include "texture.hpp"
9
11 this->enabled = true;
12 this->animation_frame = 0.0f;
13 this->half_height = 1.0f;
14 this->half_width = 1.0f;
15 this->texture = NULL;
16}
17
21
22void CCandleEffect::SetTexture(CTexture *flame_texture) {
23 this->texture = flame_texture;
24}
25
26void CCandleEffect::SetScale(float half_width, float half_height) {
27 this->half_width = half_width;
28 this->half_height = half_height;
29}
30
31void CCandleEffect::SetPosition(float *world) {
32 sceVu0CopyVector(this->position, (float *) world);
33}
34
36 this->animation_frame += 0.3f;
37
38 if (this->animation_frame > 8.0f) {
39 this->animation_frame = 0.0f;
40 }
41}
42
44 if (texture == NULL || enabled == 0) {
45 return;
46 }
47
48 float world[4];
49 int top_left[4];
50 int bottom_right[4];
51
52 world[0] = position[0];
53 world[1] = position[1];
54 world[2] = position[2];
55 world[3] = 1.0f;
56
57 if (MGRotTransPers3DSprite(top_left, bottom_right, world, half_width, half_height, 0) == 0) {
58 return;
59 }
60
61 bottom_right[1] = top_left[1] + ((bottom_right[1] - top_left[1]) >> 1);
62
63 spRGBA color = {128, 128, 128, 128};
64 sceGsAlpha alpha = mgAlpha;
65 alpha.bits.a = 0;
66 alpha.bits.b = 2;
67 alpha.bits.c = 0;
68 alpha.bits.d = 1;
69 sceGsZbuf zbuf = mgZBuffer;
70 zbuf.bits.zmsk = 1;
71 MGSetGsZBUF(&zbuf);
72
73 int frame = 7 - (int) animation_frame;
74 int column = (frame % 4) * 32;
75 int row = (frame / 4) * 32;
76 MGSetGsALPHA(&alpha);
77 CRect_i_ source(column, row, 32, 32);
78 set3DSprite(GetVif1Packet(), texture, source, top_left, bottom_right, &color);
79
80 MGSetGsALPHA(&mgAlpha);
81 MGSetGsZBUF(&mgZBuffer);
82}
void SetScale(float half_width, float half_height)
void SetPosition(float *world)
float position[4]
void SetTexture(CTexture *flame_texture)
CTexture * texture