Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "zcommon.acs"
- #include "commonFuncs.h"
- function int magnitudeThree_f(int x, int y, int z)
- {
- int len, ang;
- ang = VectorAngle(x, y);
- if (((ang + 0.125) % 0.5) > 0.25) { len = FixedDiv(y, sin(ang)); }
- else { len = FixedDiv(x, cos(ang)); }
- ang = VectorAngle(len, z);
- if (((ang + 0.125) % 0.5) > 0.25) { len = FixedDiv(z, sin(ang)); }
- else { len = FixedDiv(len, cos(ang)); }
- return len;
- }
- function int distance(int x1, int y1, int z1, int x2, int y2, int z2)
- {
- return magnitudeThree_f(x2-x1, y2-y1, z2-z1);
- }
- #define BEZIER 392
- /* Each coordinate is in the form of (x, y, z).
- *
- * Specification format: "[AR] # - <purpose>"
- * A means absolute, R means relative to source, # is index
- *
- * Given:
- * A 0 - the source point
- * A 1 - the target point
- * A 2 - the middle point
- *
- * Calculated:
- * R 3 - source to middle
- * R 4 - target to middle
- * A 5 - point between source and middle
- * A 6 - point between middle and target
- * R 7 - point 5 to point 6
- * A 8 - the final bezier point
- *
- * Coordinate 8 is what you want, in the end.
- */
- int coords[9][3];
- script BEZIER (void)
- {
- int i, dist, distPerc;
- coords[0][0] = source_x;
- coords[0][1] = source_y;
- coords[0][2] = source_z;
- coords[1][0] = target_x;
- coords[1][1] = target_y;
- coords[1][2] = target_z;
- coords[2][0] = middle_x;
- coords[2][1] = middle_y;
- coords[2][2] = middle_z;
- coords[3][0] = coords[2][0] - coords[0][0];
- coords[3][1] = coords[2][1] - coords[0][1];
- coords[3][2] = coords[2][2] - coords[0][2];
- coords[4][0] = coords[2][0] - coords[1][0];
- coords[4][1] = coords[2][1] - coords[1][1];
- coords[4][2] = coords[2][2] - coords[1][2];
- for (i = 12; i <= dist; i += 12)
- {
- if (i < 24) { continue; }
- distPerc = FixedDiv(itof(i), itof(dist));
- coords[5][0] = coords[0][0] + FixedMul(coords[3][0], distPerc);
- coords[5][1] = coords[0][1] + FixedMul(coords[3][1], distPerc);
- coords[5][2] = coords[0][2] + FixedMul(coords[3][2], distPerc);
- coords[6][0] = coords[1][0] + FixedMul(coords[4][0], 1.0-distPerc);
- coords[6][1] = coords[1][1] + FixedMul(coords[4][1], 1.0-distPerc);
- coords[6][2] = coords[1][2] + FixedMul(coords[4][2], 1.0-distPerc);
- coords[7][0] = coords[6][0] - coords[5][0];
- coords[7][1] = coords[6][1] - coords[5][1];
- coords[7][2] = coords[6][2] - coords[5][2];
- coords[8][0] = coords[5][0] + FixedMul(coords[7][0], distPerc);
- coords[8][1] = coords[5][1] + FixedMul(coords[7][1], distPerc);
- coords[8][2] = coords[5][2] + FixedMul(coords[7][2], distPerc);
- // do shit with the bezier point here
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement