DCDecomp
A decompilation of Dark Cloud for the PlayStation 2
Loading...
Searching...
No Matches
mapobject.cpp
1#pragma helper_mask_gpr 0x30
2#pragma helper_mask_fpr 0x1000
3
4#include "mapobject.hpp"
5
6#include <libvu0.h>
7
8#include "frame.hpp"
9#include "framevu1.hpp"
10#include "mglib.hpp"
11
13 if (this->draw_on == 0) {
14 return NULL;
15 }
16
17 if (this->collision_frame == NULL) {
18 return NULL;
19 }
20
21 this->collision_frame->SetPosition(this->pos);
22 this->collision_frame->SetRotation(this->rotation.x, this->rotation.y, this->rotation.z);
23 this->collision_frame->SetScale(this->scale[0], this->scale[1], this->scale[2]);
24 return this->collision_frame;
25}
26
27void CMapObject::FrameObjectOnOff(char *name, int on) {
28 int i;
29 CFrame *found;
30
31 if (name == NULL) {
32 return;
33 }
34
35 for (i = 0; i < 4; i++) {
36 if (this->frame[i] != NULL) {
37 found = this->frame[i]->SearchFrame(name);
38
39 if (found != NULL) {
40 found->attr.draw_on = on;
41 }
42 }
43 }
44
45 if (this->shadow_frame != NULL) {
46 found = this->shadow_frame->SearchFrame(name);
47
48 if (found != NULL) {
49 found->attr.draw_on = on;
50 }
51 }
52
53 if (this->shade_frame != NULL) {
54 found = this->shade_frame->SearchFrame(name);
55
56 if (found != NULL) {
57 found->attr.draw_on = on;
58 }
59 }
60
61 if (this->collision_frame != NULL) {
62 found = this->collision_frame->SearchFrame(name);
63
64 if (found != NULL) {
65 found->flags = on;
66 }
67 }
68
69 if (this->camera_frame != NULL) {
70 found = this->camera_frame->SearchFrame(name);
71
72 if (found != NULL) {
73 found->flags = on;
74 }
75 }
76}
77
78void CMapObject::Draw() {
79 if (this->draw_on == 0) {
80 return;
81 }
82
83 if (this->handle < 0) {
84 return;
85 }
86
87 CObjectFrame::Draw();
88}
89
90void CMapObject::DrawLOD(float *distance, int lowest, int highest, int *out_level) {
91 int level;
92
93 if (this->draw_on == 0) {
94 return;
95 }
96
97 if (this->handle < 0) {
98 return;
99 }
100
101 CObjectFrame::DrawLOD(distance, lowest, highest, &level);
102
103 if (out_level != NULL) {
104 *out_level = level;
105 }
106}
107
108void CMapObject::DrawShadow(int fast) {
109 sceVu0FVECTOR transform;
110
111 if (this->draw_on == 0) {
112 return;
113 }
114
115 if (this->shadow_frame == NULL) {
116 return;
117 }
118
119 // The shadow takes the angle and the position of the object, then drops by
120 // the offset so that it lies on the ground rather than inside the model.
121 sceVu0FVECTOR light = {0.0f, 1.0f, 0.0f, 0.0f};
122
123 GetRotation(transform);
124
125 CFrame *shadow = this->shadow_frame;
126 shadow->SetRotation(transform[0], transform[1], transform[2]);
127 sceVu0CopyVector(transform, this->pos);
128 this->shadow_frame->SetPosition(transform);
129
130 if (fast) {
131 transform[1] += this->shadow_offset;
132 MGDrawShadowFast2(this->shadow_frame, transform, light);
133 } else {
134 transform[1] += this->shadow_offset;
135 MGDrawShadow(this->shadow_frame, transform, light);
136 }
137}
138
140 sceVu0FVECTOR transform;
141
142 if (this->draw_on == 0) {
143 return;
144 }
145
146 if (this->shade_frame == NULL) {
147 return;
148 }
149
150 GetRotation(transform);
151 this->shade_frame->SetRotation(transform[0], transform[1], transform[2]);
152 sceVu0CopyVector(transform, this->pos);
153 this->shade_frame->SetPosition(transform);
154 MGDrawShade(this->shade_frame);
155}
156
157void CMapObject::Initialize() {
159 this->category_no = this->handle = -1;
160 this->shadow_frame = NULL;
161 this->shade_frame = NULL;
162 this->collision_frame = NULL;
163 this->camera_frame = NULL;
164 this->shadow_offset = -8.0f;
165}
166
167CMapObject::CMapObject() {
168 Initialize();
169}
short draw_on
Definition frame.hpp:27
int flags
Definition frame.hpp:60
CFrameAttr attr
Definition frame.hpp:65
float shadow_offset
Definition op_b.cpp:94
CFrameVu1 * collision_frame
Definition op_b.cpp:90
int handle
Definition op_b.cpp:96
CFrameVu1 * shadow_frame
Definition op_b.cpp:91
virtual void DrawLOD(float *distance, int lowest, int highest, int *out_level)
Definition mapobject.cpp:90
int category_no
Definition title.cpp:134
CFrameVu1 * shade_frame
Definition op_b.cpp:92
CFrame * GetCollisionFrame()
Definition mapobject.cpp:12
CFrameVu1 * camera_frame
Definition op_b.cpp:93
virtual void FrameObjectOnOff(char *name, int on)
Definition mapobject.cpp:27
void DrawShade()
void Initialize(CFrameVu1 *frame)
virtual void DrawLOD(float *distance, int lowest, int highest, int *out_level)
CFrameVu1 * frame[4]
Definition op_b.cpp:76
s32 draw_on
Definition op_b.cpp:78
float scale[4]
Definition object.hpp:26
CVector3_f_ rotation
Definition object.hpp:23
virtual CVector3_f_ * GetRotation()
Definition object.cpp:150
float pos[4]
Definition object.hpp:18