119 {
120 Vtx_t* vtxBuffer;
121 Vtx_t* vtx;
122
123 f32 boneLength;
124 s32 boneCount;
125
126 f32 angle;
127 f32 nextAngle;
128 f32 curAngle1;
129 f32 curAngle2;
130
131 f32 alphaCoord;
132 f32 alphaFrac;
133 s32 nearest;
134
135 s32 numPoints;
136 s32 i, j;
137
138 f32 deltaX, deltaY;
139 f32 posX, posY, posZ;
140
141 if (N(VineRenderState) == -1) {
142 return;
143 }
144
145 if (N(VineRenderState) == 0) {
149
150 switch (i) {
151 default:
152 return;
153 case 0:
154 boneCount = 9;
155 boneLength = 10.0f;
156 break;
157 case 1:
158 boneCount = 7;
159 boneLength = 8.0f;
160 break;
161 case 2:
162 boneCount = 7;
163 boneLength = 8.0f;
164 break;
165 case 3:
166 boneCount = 5;
167 boneLength = 8.0f;
168 break;
169 }
170
173
174 for (j = 0; j < boneCount; j++) {
175 if (j == (boneCount - 1)) {
177 } else {
179 nextAngle = vine->
boneRot[j + 1];
180 if (nextAngle - curAngle1 > 180.0f) {
181 curAngle1 += 360.0f;
182 } else if (nextAngle - curAngle1 < -180.0f) {
183 nextAngle += 360.0f;
184 }
185
186 vine->
boneRot[j] = ((curAngle1 + nextAngle) / 2.0) + 90.0;
187 }
188 }
189
191 }
192
193 N(VineRenderState) = 1;
194 }
195
197 gSPDisplayList(
gMainGfxPos++, N(lava_piranha_vine_gfx));
198
202
206
207
208
209
210
215
216 for (j = 0; j < numPoints; j++) {
220
221 alphaCoord = ((f32) j * boneCount) / numPoints;
222 nearest = (s32) alphaCoord;
223 alphaFrac = alphaCoord - (f32)nearest;
224
225 if (nearest + 1 >= boneCount) {
226 angle = vine->
boneRot[boneCount - 1];
227 } else {
228 curAngle2 = vine->
boneRot[nearest];
229 nextAngle = vine->
boneRot[nearest + 1];
230 if (nextAngle - curAngle2 > 180.0f) {
231 nextAngle -= 360.0f;
232 }
233 if (nextAngle - curAngle2 < -180.0f) {
234 nextAngle += 360.0f;
235 }
236 angle = ((nextAngle - curAngle2) * alphaFrac) + curAngle2;
237 }
238
239 deltaX =
sin_deg(angle) * boneLength;
240 deltaY = -
cos_deg(angle) * boneLength;
241
242 vtx->ob[0] = posX + deltaX;
243 vtx->ob[1] = posY + deltaY;
244 vtx->ob[2] = posZ;
245 vtx->tc[0] = j * 0x140;
246 vtx->tc[1] = 0;
247 vtx->cn[0] = j * 50;
248 vtx->cn[1] = j * 120;
249 vtx->cn[2] = j * 30;
250 vtx++;
251
252 vtx->ob[0] = posX - deltaX;
253 vtx->ob[1] = posY - deltaY;
254 vtx->ob[2] = posZ;
255 vtx->tc[0] = j * 0x140;
256 vtx->tc[1] = 0x400;
257 vtx->cn[0] = j * 50;
258 vtx->cn[1] = j * 120;
259 vtx->cn[2] = j * 30;
260 vtx++;
261 }
262
263 for (j = 0; j < numPoints - 1; j++) {
265 gSP2Triangles(
gMainGfxPos++, 1, 0, 2, 0, 1, 2, 3, 0);
266 }
267 }
268
270}
s32 evt_get_variable(Evt *script, Bytecode var)
void N make_vine_interpolation(LavaPiranhaVine *vine)