Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
part2.inc.c File Reference

Go to the source code of this file.

Macros

#define PIRANHA_DMA_ENTRY(name)
 

Functions

voidmake_vine_interpolation (LavaPiranhaVine *vine)
 
voidappendGfx_piranha_vines (void *data)
 
voidworker_render_piranha_vines (void)
 

Macro Definition Documentation

◆ PIRANHA_DMA_ENTRY

#define PIRANHA_DMA_ENTRY ( name)
Value:

Definition at line 5 of file part2.inc.c.

5#define PIRANHA_DMA_ENTRY(name) \
6 (s32) world_model_anim_kzn_##name##_ROM_START,\
7 (s32) world_model_anim_kzn_##name##_ROM_END,\
8 (s32) world_model_anim_kzn_##name##_VRAM

Function Documentation

◆ make_vine_interpolation()

void N make_vine_interpolation ( LavaPiranhaVine * vine)

Definition at line 50 of file part2.inc.c.

50 {
53 s32 args[4];
54 s32 count;
55
56 // setup dummy call to LoadPath
57 args[0] = 3 * vine->boneCount; // generate three output samples per input
58 args[1] = (s32) &vine->bonePos; // points
59 args[2] = vine->boneCount; // num vectors
60 args[3] = EASING_LINEAR;
61 dummyEvtPtr->ptrReadPos = args;
63
64 count = 0;
65 do {
67 vine->points[count].x = evt_get_float_variable(dummyEvtPtr, LVar1);
68 vine->points[count].y = evt_get_float_variable(dummyEvtPtr, LVar2);
69 vine->points[count].z = evt_get_float_variable(dummyEvtPtr, LVar3);
70 count++;
71 } while (dummyEvtPtr->varTable[0] != 0);
72 vine->numPoints = count;
73}
@ EASING_LINEAR
Definition enums.h:510
f32 evt_get_float_variable(Evt *script, Bytecode var)
Definition evt.c:1970
ApiStatus LoadPath(Evt *script, b32 isInitialCall)
ApiStatus GetNextPathPos(Evt *script, b32 isInitialCall)
#define LVar2
Definition macros.h:151
#define LVar1
Definition macros.h:150
#define LVar3
Definition macros.h:152

Referenced by appendGfx_piranha_vines().

◆ appendGfx_piranha_vines()

void N appendGfx_piranha_vines ( void * data)

Definition at line 118 of file part2.inc.c.

118 {
120 Vtx_t* vtx;
121
122 f32 boneLength;
123 s32 boneCount;
124
125 f32 angle;
129
132 s32 nearest;
133
134 s32 numPoints;
135 s32 i, j;
136
138 f32 posX, posY, posZ;
139
140 if (N(VineRenderState) == -1) {
141 return;
142 }
143
144 if (N(VineRenderState) == 0) {
145 for (i = 0; i < NUM_VINES; i++) {
148
149 switch (i) {
150 default:
151 return;
152 case 0:
153 boneCount = 9;
154 boneLength = 10.0f;
155 break;
156 case 1:
157 boneCount = 7;
158 boneLength = 8.0f;
159 break;
160 case 2:
161 boneCount = 7;
162 boneLength = 8.0f;
163 break;
164 case 3:
165 boneCount = 5;
166 boneLength = 8.0f;
167 break;
168 }
169
170 vine->boneCount = boneCount;
171 vine->boneLength = boneLength;
172
173 for (j = 0; j < boneCount; j++) {
174 if (j == (boneCount - 1)) {
175 vine->boneRot[j] += 90.0f;
176 } else {
177 curAngle1 = vine->boneRot[j];
178 nextAngle = vine->boneRot[j + 1];
179 if (nextAngle - curAngle1 > 180.0f) {
180 curAngle1 += 360.0f;
181 } else if (nextAngle - curAngle1 < -180.0f) {
182 nextAngle += 360.0f;
183 }
184 // average cur and next angles
185 vine->boneRot[j] = ((curAngle1 + nextAngle) / 2.0) + 90.0;
186 }
187 }
188
190 }
191
192 N(VineRenderState) = 1;
193 }
194
197
198 for (i = 0; i < NUM_VINES; i++) {
201
202 boneLength = vine->boneLength;
203 boneCount = vine->boneCount;
204 numPoints = vine->numPoints;
205
206 // we'll build the vertex data and place it in the display list, so jump forward
207 // here and leave space behind for the gSPBranchList command followed by two vertices
208 // for each point in numPoints
209
210 vtxBuffer = (Vtx_t*)(gMainGfxPos + 1);
211 gSPBranchList(gMainGfxPos, &gMainGfxPos[1 + 2 * (2 * numPoints)]);
212 vtx = (Vtx_t*) (++gMainGfxPos);
213 gMainGfxPos = &gMainGfxPos[2 * (2 * numPoints)];
214
215 for (j = 0; j < numPoints; j++) {
216 posX = vine->points[j].x;
217 posY = vine->points[j].y;
218 posZ = vine->points[j].z;
219
220 alphaCoord = ((f32) j * boneCount) / numPoints;
223
224 if (nearest + 1 >= boneCount) {
225 angle = vine->boneRot[boneCount - 1];
226 } else {
227 curAngle2 = vine->boneRot[nearest];
228 nextAngle = vine->boneRot[nearest + 1];
229 if (nextAngle - curAngle2 > 180.0f) {
230 nextAngle -= 360.0f;
231 }
232 if (nextAngle - curAngle2 < -180.0f) {
233 nextAngle += 360.0f;
234 }
235 angle = ((nextAngle - curAngle2) * alphaFrac) + curAngle2;
236 }
237
238 deltaX = sin_deg(angle) * boneLength;
239 deltaY = -cos_deg(angle) * boneLength;
240
241 vtx->ob[0] = posX + deltaX;
242 vtx->ob[1] = posY + deltaY;
243 vtx->ob[2] = posZ;
244 vtx->tc[0] = j * 0x140;
245 vtx->tc[1] = 0;
246 vtx->cn[0] = j * 50;
247 vtx->cn[1] = j * 120;
248 vtx->cn[2] = j * 30;
249 vtx++;
250
251 vtx->ob[0] = posX - deltaX;
252 vtx->ob[1] = posY - deltaY;
253 vtx->ob[2] = posZ;
254 vtx->tc[0] = j * 0x140;
255 vtx->tc[1] = 0x400;
256 vtx->cn[0] = j * 50;
257 vtx->cn[1] = j * 120;
258 vtx->cn[2] = j * 30;
259 vtx++;
260 }
261
262 for (j = 0; j < numPoints - 1; j++) {
263 gSPVertex(gMainGfxPos++, &vtxBuffer[2*j], 4, 0);
264 gSP2Triangles(gMainGfxPos++, 1, 0, 2, 0, 1, 2, 3, 0);
265 }
266 }
267
269}
#define sin_deg
#define cos_deg
s32 evt_get_variable(Evt *script, Bytecode var)
Definition evt.c:1730
@ NUM_VINES
Definition part1.inc.c:6
void N make_vine_interpolation(LavaPiranhaVine *vine)
Definition part2.inc.c:50
Gfx * gMainGfxPos
Definition cam_main.c:14

Referenced by worker_render_piranha_vines().

◆ worker_render_piranha_vines()

void N worker_render_piranha_vines ( void )

Definition at line 271 of file part2.inc.c.

271 {
273
275 renderTask.appendGfxArg = 0;
276 renderTask.dist = 10;
278
280}
#define queue_render_task
@ RENDER_MODE_SURFACE_OPA
Definition enums.h:3298
void N appendGfx_piranha_vines(void *data)
Definition part2.inc.c:118
void(* appendGfx)(void *)