public static float sol_test_body(float dt, float[] T, float[] V, s_ball up, s_file fp, s_body bp) { float u, t = dt; float[] U = new float[3]; float[] O = new float[3]; float[] W = new float[3]; s_node np = fp.m_nv[bp.m_ni]; sol_body_p(O, fp, bp); sol_body_v(W, fp, bp); if ((u = sol_test_node(t, U, up, fp, np, O, W)) < t) { Vec3.v_cpy(T, U); Vec3.v_cpy(V, W); t = u; } return(t); }
public static void game_draw_jumps(s_file fp, float[] M, float t) { int ji; GL.Enable(EnableCap.Texture2D); { for (ji = 0; ji < fp.m_jc; ji++) { Video.MODELVIEW_PushMatrix(); { Video.MODELVIEW_Translate(fp.m_jv[ji].m_p[0], fp.m_jv[ji].m_p[1], fp.m_jv[ji].m_p[2]); Part.part_draw_jump(M, fp.m_jv[ji].m_r, 1.0f, t); } Video.MODELVIEW_PopMatrix(); } } GL.Disable(EnableCap.Texture2D); for (ji = 0; ji < fp.m_jc; ji++) { fp.m_jv[ji].jump_draw(jump_e == 0 ? 1 : 0); } }
public static float sol_test_file(float dt, float[] T, float[] V, s_ball up, s_file fp) { float u, t = dt; float[] U = new float[3]; float[] W = new float[3]; int i; for (i = 0; i < fp.m_bc; i++) { s_body bp = fp.m_bv[i]; if ((u = sol_test_body(t, U, W, up, fp, bp)) < t) { Vec3.v_cpy(T, U); Vec3.v_cpy(V, W); t = u; } } return(t); }
public static void grow_step(s_file fp, float dt) { float dr; if (grow == 0) { return; } /* Calculate new size based on how long since you touched the coin... */ grow_t += dt; if (grow_t >= GROW_TIME) { grow = 0; grow_t = GROW_TIME; } dr = grow_strt + ((grow_goal - grow_strt) * (1.0f / (GROW_TIME / grow_t))); /* No sinking through the floor! Keeps ball's bottom constant. */ fp.m_uv[0].m_p[1] += (dr - fp.m_uv[0].m_r); fp.m_uv[0].m_r = dr; game_cmd_ballradius(); }
public static int sol_load_head(IntPtr fin, s_file fp) { int magic = 0; int version = 0; Binary.get_index(fin, ref magic); Binary.get_index(fin, ref version); if (magic != MAGIC || version != SOL_VERSION) { return(0); } Binary.get_index(fin, ref fp.m_ac); Binary.get_index(fin, ref fp.m_dc); #if false get_index(fin, fp.mc); get_index(fin, fp.vc); get_index(fin, fp.ec); get_index(fin, fp.sc); get_index(fin, fp.tc); get_index(fin, fp.gc); get_index(fin, fp.lc); get_index(fin, fp.nc); get_index(fin, fp.pc); get_index(fin, fp.bc); get_index(fin, fp.hc); get_index(fin, fp.zc); get_index(fin, fp.jc); get_index(fin, fp.xc); get_index(fin, fp.rc); get_index(fin, fp.uc); get_index(fin, fp.wc); get_index(fin, fp.ic); #endif FileSystem.fs_seek(fin, 18 * 4); if (fp.m_ac != 0) { FileSystem.fs_read(ref fp.m_av, fp.m_ac, fin); } if (fp.m_dc != 0) { int i; fp.m_dv = new s_dict[fp.m_dc]; for (i = 0; i < fp.m_dc; i++) { fp.m_dv[i] = new s_dict(); sol_load_dict(fin, fp.m_dv[i]);// + i); } } return(1); }
public static s_goal sol_goal_test(s_file fp, float[] p, int ui) { float[] ball_p = fp.m_uv[ui].m_p; float ball_r = fp.m_uv[ui].m_r; int zi; for (zi = 0; zi < fp.m_zc; zi++) { float[] r = new float[3]; r[0] = ball_p[0] - fp.m_zv[zi].m_p[0]; r[1] = ball_p[2] - fp.m_zv[zi].m_p[2]; r[2] = 0; if (Vec3.v_len(r) < fp.m_zv[zi].m_r - ball_r && ball_p[1] > fp.m_zv[zi].m_p[1] && ball_p[1] < fp.m_zv[zi].m_p[1] + Config.GOAL_HEIGHT / 2) { p[0] = fp.m_zv[zi].m_p[0]; p[1] = fp.m_zv[zi].m_p[1]; p[2] = fp.m_zv[zi].m_p[2]; return(fp.m_zv[zi]); } } return(null); }
public static void sol_body_p(float[] p, s_file fp, s_body bp) { float[] v = new float[3]; if (bp.m_pi >= 0) { s_path pp = fp.m_pv[bp.m_pi]; s_path pq = fp.m_pv[pp.m_pi]; if (pp.m_s != 0) { Vec3.v_sub(v, pq.m_p, pp.m_p); Vec3.v_mad(p, pp.m_p, v, erp(bp.m_t / pp.m_t)); } else { Vec3.v_sub(v, pq.m_p, pp.m_p); Vec3.v_mad(p, pp.m_p, v, bp.m_t / pp.m_t); } } else { p[0] = 0.0f; p[1] = 0.0f; p[2] = 0.0f; } }
public static void sol_body_v(float[] v, s_file fp, s_body bp) { if (bp.m_pi >= 0 && fp.m_pv[bp.m_pi].m_f != 0) { s_path pp = fp.m_pv[bp.m_pi]; s_path pq = fp.m_pv[pp.m_pi]; Vec3.v_sub(v, pq.m_p, pp.m_p); Vec3.v_scl(v, v, 1.0f / pp.m_t); if (pp.m_s != 0) { Vec3.v_scl(v, v, derp(bp.m_t / pp.m_t)); } } else { v[0] = 0.0f; v[1] = 0.0f; v[2] = 0.0f; } }
public static int sol_item_test(s_file fp, float[] p, float item_r) { float[] ball_p = fp.m_uv[0].m_p; float ball_r = fp.m_uv[0].m_r; int hi; for (hi = 0; hi < fp.m_hc; hi++) { float[] r = new float[3]; r[0] = ball_p[0] - fp.m_hv[hi].m_p[0]; r[1] = ball_p[1] - fp.m_hv[hi].m_p[1]; r[2] = ball_p[2] - fp.m_hv[hi].m_p[2]; if (fp.m_hv[hi].m_t != Solid.ITEM_NONE && Vec3.v_len(r) < ball_r + item_r) { p[0] = fp.m_hv[hi].m_p[0]; p[1] = fp.m_hv[hi].m_p[1]; p[2] = fp.m_hv[hi].m_p[2]; return(hi); } } return(-1); }
public void sol_shad_list(s_file fp) { if (draw_sl) { float[] p = new float[3]; solid_phys.sol_body_p(p, fp, this); Video.MODELVIEW_PushMatrix(); { /* Translate a moving body. */ Video.MODELVIEW_Translate(p[0], p[1], p[2]); /* Translate the shadow on a moving body. */ Video.TEXTURE_PushMatrix(); Video.TEXTURE_Translate(p[0], p[2], 0.0f); /* Draw the body. */ fp_bv_i_sl_draw(fp); /* Pop the shadow translation. */ Video.TEXTURE_PopMatrix(); } Video.MODELVIEW_PopMatrix(); } }
public static float sol_test_side(float dt, float[] T, s_ball up, s_file fp, s_lump lp, s_side sp, float[] o, float[] w) { float t = v_side(T, o, w, sp.m_n, sp.m_d, up.m_p, up.m_v, up.m_r); int i; if (t < dt) { for (i = 0; i < lp.m_sc; i++) { s_side sq = fp.m_sv[fp.m_iv[lp.m_s0 + i]]; if (sp != sq && Vec3.v_dot(T, sq.m_n) - Vec3.v_dot(o, sq.m_n) - Vec3.v_dot(w, sq.m_n) * t > sq.m_d) { return((float)LARGE); } } } return(t); }
public static void game_draw_balls(s_file fp, float[] bill_M, float t) { float[] c = new float[4] { 1.0f, 1.0f, 1.0f, 1.0f }; float[] ball_M = new float[16]; Vec3.m_basis(ball_M, fp.m_uv[0].m_e[0], fp.m_uv[0].m_e[1], fp.m_uv[0].m_e[2]); GL.PushAttrib(AttribMask.LightingBit); Video.MODELVIEW_PushMatrix(); { Video.MODELVIEW_Translate(fp.m_uv[0].m_p[0], fp.m_uv[0].m_p[1] + Ball.BALL_FUDGE, fp.m_uv[0].m_p[2]); Video.MODELVIEW_Scale(fp.m_uv[0].m_r, fp.m_uv[0].m_r, fp.m_uv[0].m_r); Video.Color(c); Ball.ball_draw(ball_M, bill_M, t); } Video.MODELVIEW_PopMatrix(); GL.PopAttrib(); }
void fp_bv_i_rl_draw(s_file fp) { s_mtrl mp = s_mtrl.default_mtrl; mp = fp.sol_draw_body(this, mp, Solid.M_REFLECTIVE, 0); mp = s_mtrl.default_mtrl.sol_draw_mtrl(mp); }
void sol_shad_lump(s_file fp, s_lump lp, int mi) { int i; for (i = 0; i < lp.m_gc; i++) { sol_shad_geom(fp, fp.m_gv[fp.m_iv[lp.m_g0 + i]], mi); } }
void fp_bv_i_tl_draw(s_file fp) { s_mtrl mp = s_mtrl.default_mtrl; mp = fp.sol_draw_body(this, mp, Solid.M_TRANSPARENT, Solid.M_DECAL); mp = fp.sol_draw_body(this, mp, Solid.M_TRANSPARENT, 0); mp = s_mtrl.default_mtrl.sol_draw_mtrl(mp); }
public static float sol_test_node(float dt, float[] T, s_ball up, s_file fp, s_node np, float[] o, float[] w) { float u, t = dt; float[] U = new float[3]; int i; /* Test all lumps */ for (i = 0; i < np.m_lc; i++) { s_lump lp = fp.m_lv[np.m_l0 + i]; if ((u = sol_test_lump(t, U, up, fp, lp, o, w)) < t) { Vec3.v_cpy(T, U); t = u; } } /* Test in front of this node */ if (np.m_ni >= 0 && sol_test_fore(t, up, fp.m_sv[np.m_si], o, w) != 0) { s_node nq = fp.m_nv[np.m_ni]; if ((u = sol_test_node(t, U, up, fp, nq, o, w)) < t) { Vec3.v_cpy(T, U); t = u; } } /* Test behind this node */ if (np.m_nj >= 0 && sol_test_back(t, up, fp.m_sv[np.m_si], o, w) != 0) { s_node nq = fp.m_nv[np.m_nj]; if ((u = sol_test_node(t, U, up, fp, nq, o, w)) < t) { Vec3.v_cpy(T, U); t = u; } } return(t); }
public static int sol_load_only_head(s_file fp, string filename) { IntPtr fin; int res = 0; if ((fin = FileSystem.fs_open(filename)) != IntPtr.Zero) { res = sol_load_head(fin, fp); FileSystem.fs_close(fin); } return(res); }
/* * Compute the positions of all balls after DT seconds have passed. */ public static void sol_ball_step(s_file fp, float dt) { int i; for (i = 0; i < fp.m_uc; i++) { s_ball up = fp.m_uv[i];// + i; Vec3.v_mad(up.m_p, up.m_p, up.m_v, dt); sol_rotate(up.m_e, up.m_w, dt); } }
public s_mtrl sol_back_bill(s_file fp, s_mtrl mp, float t) { float T = (m_t > 0.0f) ? (float)(System.Math.IEEERemainder(t, m_t) - m_t / 2) : 0.0f; float w = m_w[0] + m_w[1] * T + m_w[2] * T * T; float h = m_h[0] + m_h[1] * T + m_h[2] * T * T; if (w > 0 && h > 0) { float rx = m_rx[0] + m_rx[1] * T + m_rx[2] * T * T; float ry = m_ry[0] + m_ry[1] * T + m_ry[2] * T * T; float rz = m_rz[0] + m_rz[1] * T + m_rz[2] * T * T; Video.MODELVIEW_PushMatrix(); { float y0 = (m_fl & Solid.B_EDGE) != 0 ? 0 : -h / 2; float y1 = (m_fl & Solid.B_EDGE) != 0 ? h : +h / 2; Video.MODELVIEW_Rotate(ry, 0.0f, 1.0f, 0.0f); Video.MODELVIEW_Rotate(rx, 1.0f, 0.0f, 0.0f); Video.MODELVIEW_Translate(0.0f, 0.0f, -m_d); if ((m_fl & Solid.B_FLAT) != 0) { Video.MODELVIEW_Rotate(-rx - 90.0f, 1.0f, 0.0f, 0.0f); Video.MODELVIEW_Rotate(-ry, 0.0f, 0.0f, 1.0f); } if ((m_fl & Solid.B_EDGE) != 0) { Video.MODELVIEW_Rotate(-rx, 1.0f, 0.0f, 0.0f); } Video.MODELVIEW_Rotate(rz, 0.0f, 0.0f, 1.0f); mp = fp.m_mv[m_mi].sol_draw_mtrl(mp); Video.Begin(Video.TRIANGLE_FAN); { Video.TexCoord2(0.0f, 0.0f); Video.Vertex2(-w / 2, y0); Video.TexCoord2(1.0f, 0.0f); Video.Vertex2(+w / 2, y0); Video.TexCoord2(1.0f, 1.0f); Video.Vertex2(+w / 2, y1); Video.TexCoord2(0.0f, 1.0f); Video.Vertex2(-w / 2, y1); } Video.End(); } Video.MODELVIEW_PopMatrix(); } return(mp); }
void fp_bv_i_ol_draw(s_file fp) { //fp.bv[i].ol = Video.GenLists(1); //Video.NewList(fp.bv[i].ol, Video.COMPILE); { s_mtrl mp = s_mtrl.default_mtrl; mp = fp.sol_draw_body(this, mp, Solid.M_OPAQUE, 0); mp = fp.sol_draw_body(this, mp, Solid.M_OPAQUE, Solid.M_DECAL); mp = s_mtrl.default_mtrl.sol_draw_mtrl(mp); } //Video.EndList(); }
public static float sol_test_edge(float dt, float[] T, s_ball up, s_file fp, s_edge ep, float[] o, float[] w) { float[] q = new float[3]; float[] u = new float[3]; Vec3.v_cpy(q, fp.m_vv[ep.m_vi].m_p); Vec3.v_sub(u, fp.m_vv[ep.m_vj].m_p, fp.m_vv[ep.m_vi].m_p); return(v_edge(T, o, q, u, w, up.m_p, up.m_v, up.m_r)); }
void sol_shad_geom(s_file fp, s_geom gp, int mi) { if (gp.m_mi == mi) { float[] vi = fp.m_vv[gp.m_vi].m_p; float[] vj = fp.m_vv[gp.m_vj].m_p; float[] vk = fp.m_vv[gp.m_vk].m_p; Video.TexCoord2(vi[0], vi[2]); Video.Vertex3(vi); Video.TexCoord2(vj[0], vj[2]); Video.Vertex3(vj); Video.TexCoord2(vk[0], vk[2]); Video.Vertex3(vk); } }
/* * Compute the states of all switches after DT seconds have passed. */ public static void sol_swch_step(s_file fp, float dt) { int xi; for (xi = 0; xi < fp.m_xc; xi++) { s_swch xp = fp.m_xv[xi]; //volatile float t = xp.m_t; if (t < xp.m_t0) { xp.m_t = (t += dt); if (t >= xp.m_t0) { int pi = xp.m_pi; int pj = xp.m_pi; do /* Tortoise and hare cycle traverser. */ { fp.m_pv[pi].m_f = xp.m_f0; fp.m_pv[pj].m_f = xp.m_f0; cmd.type = cmd_type.CMD_PATH_FLAG; cmd.pathflag.pi = pi; cmd.pathflag.f = fp.m_pv[pi].m_f; sol_cmd_enq(cmd); pi = fp.m_pv[pi].m_pi; pj = fp.m_pv[pj].m_pi; pj = fp.m_pv[pj].m_pi; }while (pi != pj); xp.m_f = xp.m_f0; cmd.type = cmd_type.CMD_SWCH_TOGGLE; cmd.swchtoggle.xi = xi; sol_cmd_enq(cmd); } } } }
public void item_draw(s_item hp, float r) { float[] c = new float[3]; s_file fp = null; switch (hp.m_t) { case Solid.ITEM_COIN: fp = item_coin_file; break; case Solid.ITEM_GROW: fp = item_grow_file; break; case Solid.ITEM_SHRINK: fp = item_shrink_file; break; } item_color(hp, c); Video.Color(c); fp.sol_draw(0, 1); }
public void item_free() { if (item_coin_file != null) { item_coin_file.sol_free_gl(); item_coin_file = null; } if (item_grow_file != null) { item_grow_file.sol_free_gl(); item_grow_file = null; } if (item_shrink_file != null) { item_shrink_file.sol_free_gl(); item_shrink_file = null; } }
void fp_bv_i_sl_draw(s_file fp) { int on = fp.sol_enum_body(this, Solid.M_OPAQUE); int rn = fp.sol_enum_body(this, Solid.M_REFLECTIVE); int dn = fp.sol_enum_body(this, Solid.M_DECAL); if (on != 0) { sol_shad_body(fp, Solid.M_OPAQUE, 0); } if (rn != 0) { sol_shad_body(fp, Solid.M_REFLECTIVE, 0); } if (dn != 0) { sol_shad_body(fp, Solid.M_OPAQUE, Solid.M_DECAL); } }
public void sol_draw_list_tl(s_file fp) { if (draw_tl) { float[] p = new float[3]; solid_phys.sol_body_p(p, fp, this); Video.MODELVIEW_PushMatrix(); { /* Translate a moving body. */ Video.MODELVIEW_Translate(p[0], p[1], p[2]); /* Draw the body. */ fp_bv_i_tl_draw(fp); } Video.MODELVIEW_PopMatrix(); } }
public static int ball_opts(s_file fp, ref float alpha) { int flags = F_DEPTHTEST; int di; // MY for (di = 0; di < fp.m_dc; ++di) { string k = fp.Get_av(fp.m_dv[di].m_ai); string v = fp.Get_av(fp.m_dv[di].m_aj); if (string.Equals(k, "drawback")) { flags = SET(flags, int.Parse(v, System.Globalization.CultureInfo.InvariantCulture), F_DRAWBACK); } if (string.Equals(k, "depthmask")) { flags = SET(flags, int.Parse(v, System.Globalization.CultureInfo.InvariantCulture), F_DEPTHMASK); } if (string.Equals(k, "depthtest")) { flags = SET(flags, int.Parse(v, System.Globalization.CultureInfo.InvariantCulture), F_DEPTHTEST); } if (string.Equals(k, "alphatest")) { if (v != null) { string[] parts = v.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); if (parts != null && parts.Length > 0) { alpha = (float)double.Parse(parts[0], System.Globalization.CultureInfo.InvariantCulture); } } } } return(flags); }
/* * Compute the positions of all bodies after DT seconds have passed. */ public static void sol_body_step(s_file fp, float dt) { int i; for (i = 0; i < fp.m_bc; i++) { s_body bp = fp.m_bv[i];// + i; if (bp.m_pi >= 0) { s_path pp = fp.m_pv[bp.m_pi]; if (pp.m_f != 0) { //volatile float t = bp.m_t; bp.m_t = (t += dt); if (t >= pp.m_t) { bp.m_t = 0; bp.m_pi = pp.m_pi; cmd.type = cmd_type.CMD_BODY_TIME; cmd.bodytime.bi = i; cmd.bodytime.t = bp.m_t; sol_cmd_enq(cmd); cmd.type = cmd_type.CMD_BODY_PATH; cmd.bodypath.bi = i; cmd.bodypath.pi = bp.m_pi; sol_cmd_enq(cmd); } } } } }
/* * Test if the ball UI is inside a jump. Return 1 if yes and fill P * with the destination position, return 0 if not, and return 2 if the * ball is on the border of a jump. */ public static int sol_jump_test(s_file fp, float[] p, int ui) { float[] ball_p = fp.m_uv[ui].m_p; float ball_r = fp.m_uv[ui].m_r; int ji; float l; int res = 0; for (ji = 0; ji < fp.m_jc; ji++) { float[] r = new float[3]; r[0] = ball_p[0] - fp.m_jv[ji].m_p[0]; r[1] = ball_p[2] - fp.m_jv[ji].m_p[2]; r[2] = 0; l = Vec3.v_len(r) - fp.m_jv[ji].m_r; if (l < 0 && ball_p[1] > fp.m_jv[ji].m_p[1] && ball_p[1] < fp.m_jv[ji].m_p[1] + Config.JUMP_HEIGHT / 2) { if (l < -ball_r) { p[0] = fp.m_jv[ji].m_q[0] + (ball_p[0] - fp.m_jv[ji].m_p[0]); p[1] = fp.m_jv[ji].m_q[1] + (ball_p[1] - fp.m_jv[ji].m_p[1]); p[2] = fp.m_jv[ji].m_q[2] + (ball_p[2] - fp.m_jv[ji].m_p[2]); return(1); } else { res = 2; } } } return(res); }