mirror of
https://github.com/Zeal-Operating-System/ZealOS.git
synced 2024-12-30 17:26:31 +00:00
168 lines
15 KiB
HTML
Executable file
168 lines
15 KiB
HTML
Executable file
<!DOCTYPE HTML>
|
|
<html>
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/html;charset=US-ASCII">
|
|
<meta name="generator" content="ZealOS V0.15">
|
|
<style type="text/css">
|
|
body {background-color:#fef1f0;}
|
|
.cF0{color:#000000;background-color:#fef1f0;}
|
|
.cF1{color:#0148a4;background-color:#fef1f0;}
|
|
.cF2{color:#3b7901;background-color:#fef1f0;}
|
|
.cF3{color:#057c7e;background-color:#fef1f0;}
|
|
.cF4{color:#bb2020;background-color:#fef1f0;}
|
|
.cF5{color:#9e42ae;background-color:#fef1f0;}
|
|
.cF6{color:#b57901;background-color:#fef1f0;}
|
|
.cF7{color:#b2b6af;background-color:#fef1f0;}
|
|
.cF8{color:#555753;background-color:#fef1f0;}
|
|
.cF9{color:#678fbb;background-color:#fef1f0;}
|
|
.cFA{color:#82bc49;background-color:#fef1f0;}
|
|
.cFB{color:#0097a2;background-color:#fef1f0;}
|
|
.cFC{color:#e26a6a;background-color:#fef1f0;}
|
|
.cFD{color:#c671bc;background-color:#fef1f0;}
|
|
.cFE{color:#c7ab00;background-color:#fef1f0;}
|
|
.cFF{color:#fef1f0;background-color:#fef1f0;}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<pre style="font-family:monospace;font-size:12pt">
|
|
<a name="l1"></a><span class=cF2>//Makes a mesh ball.</span><span class=cF0>
|
|
<a name="l2"></a>
|
|
<a name="l3"></a>#</span><span class=cF1>define</span><span class=cF0> VERTICES_NUM </span><span class=cFE>1024</span><span class=cF0>
|
|
<a name="l4"></a>#</span><span class=cF1>define</span><span class=cF0> TRIS_NUM </span><span class=cFE>1024</span><span class=cF0>
|
|
<a name="l5"></a>
|
|
<a name="l6"></a></span><span class=cF1>class</span><span class=cF0> Ball
|
|
<a name="l7"></a>{
|
|
<a name="l8"></a> </span><span class=cF9>I32</span><span class=cF0> vertex_count;
|
|
<a name="l9"></a> </span><span class=cF9>I32</span><span class=cF0> tri_count;
|
|
<a name="l10"></a> </span><span class=cF9>CD3I32</span><span class=cF0> v[VERTICES_NUM];
|
|
<a name="l11"></a> </span><span class=cF9>CMeshTri</span><span class=cF0> t[TRIS_NUM];
|
|
<a name="l12"></a>
|
|
<a name="l13"></a>} *b;
|
|
<a name="l14"></a>
|
|
<a name="l15"></a></span><span class=cF1>class</span><span class=cF0> BallDefineStruct
|
|
<a name="l16"></a>{
|
|
<a name="l17"></a> </span><span class=cF1>F64</span><span class=cF0> radius format </span><span class=cF6>"$DA-TRM,A=\"Radius :%8.3f\"$\n"</span><span class=cF0>;
|
|
<a name="l18"></a> </span><span class=cF9>I64</span><span class=cF0> n_longitude format </span><span class=cF6>"$DA-TRM,A=\"Longitude Faces:%5d\"$\n"</span><span class=cF0>;
|
|
<a name="l19"></a> </span><span class=cF9>I64</span><span class=cF0> n_lattitude format </span><span class=cF6>"$DA-TRM,A=\"Lattitude Rings:%5d\"$\n"</span><span class=cF0>;
|
|
<a name="l20"></a>};
|
|
<a name="l21"></a>
|
|
<a name="l22"></a></span><span class=cF1>U0</span><span class=cF0> BDInit(BallDefineStruct *bd)
|
|
<a name="l23"></a>{
|
|
<a name="l24"></a> </span><span class=cF5>MemSet</span><span class=cF0>(bd, </span><span class=cFE>0</span><span class=cF0>, </span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF0>BallDefineStruct</span><span class=cF7>)</span><span class=cF0>);
|
|
<a name="l25"></a> bd->n_longitude = </span><span class=cFE>16</span><span class=cF0>;
|
|
<a name="l26"></a> bd->n_lattitude = </span><span class=cFE>8</span><span class=cF0>;
|
|
<a name="l27"></a> bd->radius = </span><span class=cFE>20</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0>;
|
|
<a name="l28"></a>}
|
|
<a name="l29"></a>
|
|
<a name="l30"></a></span><span class=cF1>U0</span><span class=cF0> BDCorrect(BallDefineStruct *bd)
|
|
<a name="l31"></a>{
|
|
<a name="l32"></a> bd->n_longitude = (bd->n_longitude + </span><span class=cFE>1</span><span class=cF0>) / </span><span class=cFE>2</span><span class=cF0>;
|
|
<a name="l33"></a> bd->n_lattitude = (bd->n_lattitude + </span><span class=cFE>1</span><span class=cF0>) / </span><span class=cFE>2</span><span class=cF0>;
|
|
<a name="l34"></a>}
|
|
<a name="l35"></a>
|
|
<a name="l36"></a></span><span class=cF9>I64</span><span class=cF0> AddVertex(BallDefineStruct *, </span><span class=cF9>I64</span><span class=cF0> x, </span><span class=cF9>I64</span><span class=cF0> y, </span><span class=cF9>I64</span><span class=cF0> z)
|
|
<a name="l37"></a>{
|
|
<a name="l38"></a> </span><span class=cF9>I64</span><span class=cF0> i;
|
|
<a name="l39"></a>
|
|
<a name="l40"></a> </span><span class=cF1>for</span><span class=cF0> (i = </span><span class=cFE>0</span><span class=cF0>; i < b->vertex_count; i++)
|
|
<a name="l41"></a> </span><span class=cF1>if</span><span class=cF0> (b->v[i].x == x && b->v[i].y == y && b->v[i].z == z)
|
|
<a name="l42"></a> </span><span class=cF1>return</span><span class=cF0> i;
|
|
<a name="l43"></a> i = b->vertex_count++;
|
|
<a name="l44"></a> b->v[i].x = x;
|
|
<a name="l45"></a> b->v[i].y = y;
|
|
<a name="l46"></a> b->v[i].z = z;
|
|
<a name="l47"></a>
|
|
<a name="l48"></a> </span><span class=cF1>return</span><span class=cF0> i;
|
|
<a name="l49"></a>}
|
|
<a name="l50"></a>
|
|
<a name="l51"></a></span><span class=cF9>I64</span><span class=cF0> AddTri(BallDefineStruct *, </span><span class=cF9>I64</span><span class=cF0> c, </span><span class=cF9>I64</span><span class=cF0> n0, </span><span class=cF9>I64</span><span class=cF0> n1, </span><span class=cF9>I64</span><span class=cF0> n2)
|
|
<a name="l52"></a>{
|
|
<a name="l53"></a> </span><span class=cF9>I64</span><span class=cF0> res = b->tri_count++;
|
|
<a name="l54"></a>
|
|
<a name="l55"></a> b->t[res].color = c;
|
|
<a name="l56"></a> b->t[res].nums[</span><span class=cFE>0</span><span class=cF0>] = n0;
|
|
<a name="l57"></a> b->t[res].nums[</span><span class=cFE>1</span><span class=cF0>] = n1;
|
|
<a name="l58"></a> b->t[res].nums[</span><span class=cFE>2</span><span class=cF0>] = n2;
|
|
<a name="l59"></a>
|
|
<a name="l60"></a> </span><span class=cF1>return</span><span class=cF0> res;
|
|
<a name="l61"></a>}
|
|
<a name="l62"></a>
|
|
<a name="l63"></a></span><span class=cF1>U8</span><span class=cF0> *Ball2CSprite()
|
|
<a name="l64"></a>{
|
|
<a name="l65"></a></span><span class=cF2>//See </span><a href="https://zeal-operating-system.github.io/ZealOS/System/Gr/GrSpritePlot.CC.html#l1"><span class=cF4>::/System/Gr/GrSpritePlot.CC</span></a><span class=cF2> for how CSprite are stored.</span><span class=cF0>
|
|
<a name="l66"></a> </span><span class=cF1>U8</span><span class=cF0> *res = </span><span class=cF5>MAlloc</span><span class=cF0>(</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF9>CSpriteMeshU8s</span><span class=cF7>)</span><span class=cF0> +
|
|
<a name="l67"></a> b->vertex_count * </span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF9>CD3I32</span><span class=cF7>)</span><span class=cF0> +
|
|
<a name="l68"></a> b->tri_count * </span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF9>CMeshTri</span><span class=cF7>)</span><span class=cF0> + </span><span class=cFB>sprite_elem_base_sizes</span><span class=cF0>[</span><span class=cF3>SPT_END</span><span class=cF0>]),
|
|
<a name="l69"></a> *dst = res;
|
|
<a name="l70"></a> *dst++ = </span><span class=cF3>SPT_MESH</span><span class=cF0>;
|
|
<a name="l71"></a> *dst(</span><span class=cF9>I32</span><span class=cF0> *)++ = b->vertex_count;
|
|
<a name="l72"></a> *dst(</span><span class=cF9>I32</span><span class=cF0> *)++ = b->tri_count;
|
|
<a name="l73"></a> </span><span class=cF5>MemCopy</span><span class=cF0>(dst, &b->v, b->vertex_count * </span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF9>CD3I32</span><span class=cF7>)</span><span class=cF0>);
|
|
<a name="l74"></a> dst += b->vertex_count * </span><span class=cF1>sizeof</span><span class=cF0>(</span><span class=cF9>CD3I32</span><span class=cF0>);
|
|
<a name="l75"></a> </span><span class=cF5>MemCopy</span><span class=cF0>(dst, &b->t, b->tri_count * </span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF9>CMeshTri</span><span class=cF7>)</span><span class=cF0>);
|
|
<a name="l76"></a> dst += b->tri_count * </span><span class=cF1>sizeof</span><span class=cF0>(</span><span class=cF9>CMeshTri</span><span class=cF0>);
|
|
<a name="l77"></a> *dst++ = </span><span class=cF3>SPT_END</span><span class=cF0>;
|
|
<a name="l78"></a>
|
|
<a name="l79"></a> </span><span class=cF1>return</span><span class=cF0> res;
|
|
<a name="l80"></a>}
|
|
<a name="l81"></a>
|
|
<a name="l82"></a></span><span class=cF1>public</span><span class=cF0> </span><span class=cF1>U8</span><span class=cF0> *BallGen()
|
|
<a name="l83"></a>{
|
|
<a name="l84"></a> </span><span class=cF1>U8</span><span class=cF0> *res;
|
|
<a name="l85"></a> </span><span class=cF9>I64</span><span class=cF0> i, j, n, m, c, p1, p2, p3, p4;
|
|
<a name="l86"></a> BallDefineStruct bd1, bd2;
|
|
<a name="l87"></a> </span><span class=cF1>F64</span><span class=cF0> r, r1, r2, z1, z2, d_a1, d_a2;
|
|
<a name="l88"></a>
|
|
<a name="l89"></a> BDInit(&bd1);
|
|
<a name="l90"></a>
|
|
<a name="l91"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF3>TRUE</span><span class=cF0>)
|
|
<a name="l92"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l93"></a> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF5>DocForm</span><span class=cF7>(</span><span class=cF0>&bd1</span><span class=cF7>)</span><span class=cF0>)
|
|
<a name="l94"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>NULL</span><span class=cF0>;
|
|
<a name="l95"></a> </span><span class=cF5>MemCopy</span><span class=cF0>(&bd2, &bd1, </span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF0>BallDefineStruct</span><span class=cF7>)</span><span class=cF0>);
|
|
<a name="l96"></a> BDCorrect(&bd2);
|
|
<a name="l97"></a>
|
|
<a name="l98"></a> c = </span><span class=cF5>PopUpColorLighting</span><span class=cF0>;
|
|
<a name="l99"></a> </span><span class=cF1>if</span><span class=cF0> (c < </span><span class=cFE>0</span><span class=cF0>)
|
|
<a name="l100"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>NULL</span><span class=cF0>;
|
|
<a name="l101"></a>
|
|
<a name="l102"></a> b = </span><span class=cF5>CAlloc</span><span class=cF0>(</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF0>Ball</span><span class=cF7>)</span><span class=cF0>);
|
|
<a name="l103"></a> r = bd2.radius;
|
|
<a name="l104"></a> n = bd2.n_lattitude;
|
|
<a name="l105"></a> m = bd2.n_longitude;
|
|
<a name="l106"></a> d_a1 = </span><span class=cFE>2</span><span class=cF0> * </span><span class=cF3>pi</span><span class=cF0> / n / </span><span class=cFE>4</span><span class=cF0>;
|
|
<a name="l107"></a> d_a2 = </span><span class=cFE>2</span><span class=cF0> * </span><span class=cF3>pi</span><span class=cF0> / m / </span><span class=cFE>2</span><span class=cF0>;
|
|
<a name="l108"></a> </span><span class=cF1>for</span><span class=cF0> (j = -n; j < n; j++)
|
|
<a name="l109"></a> {
|
|
<a name="l110"></a> r1 = r * </span><span class=cF5>Cos</span><span class=cF0>( j *d_a1);
|
|
<a name="l111"></a> r2 = r * </span><span class=cF5>Cos</span><span class=cF0>(</span><span class=cF7>(</span><span class=cF0>j+</span><span class=cFE>1</span><span class=cF7>)</span><span class=cF0>*d_a1);
|
|
<a name="l112"></a> z1 = r * </span><span class=cF5>Sin</span><span class=cF0>( j *d_a1);
|
|
<a name="l113"></a> z2 = r * </span><span class=cF5>Sin</span><span class=cF0>(</span><span class=cF7>(</span><span class=cF0>j+</span><span class=cFE>1</span><span class=cF7>)</span><span class=cF0>*d_a1);
|
|
<a name="l114"></a> </span><span class=cF1>for</span><span class=cF0> (i = </span><span class=cFE>0</span><span class=cF0>; i < m; i++)
|
|
<a name="l115"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l116"></a> p1 = AddVertex(&bd2, r1 * </span><span class=cF5>Cos</span><span class=cF7>(</span><span class=cF0>(</span><span class=cFE>2</span><span class=cF0> * i + j) * d_a2</span><span class=cF7>)</span><span class=cF0>, r1 * </span><span class=cF5>Sin</span><span class=cF7>(</span><span class=cF0>(</span><span class=cFE>2</span><span class=cF0> * i + j) * d_a2</span><span class=cF7>)</span><span class=cF0>, z1);
|
|
<a name="l117"></a> p2 = AddVertex(&bd2, r1 * </span><span class=cF5>Cos</span><span class=cF7>(</span><span class=cF0>(</span><span class=cFE>2</span><span class=cF0> * i + </span><span class=cFE>2</span><span class=cF0> +j) * d_a2</span><span class=cF7>)</span><span class=cF0>, r1 * </span><span class=cF5>Sin</span><span class=cF7>(</span><span class=cF0>(</span><span class=cFE>2</span><span class=cF0> * i + </span><span class=cFE>2</span><span class=cF0> + j) * d_a2</span><span class=cF7>)</span><span class=cF0>, z1);
|
|
<a name="l118"></a> p3 = AddVertex(&bd2, r2 * </span><span class=cF5>Cos</span><span class=cF7>(</span><span class=cF0>(</span><span class=cFE>2</span><span class=cF0> * i + </span><span class=cFE>1</span><span class=cF0> +j) * d_a2</span><span class=cF7>)</span><span class=cF0>, r2 * </span><span class=cF5>Sin</span><span class=cF7>(</span><span class=cF0>(</span><span class=cFE>2</span><span class=cF0> * i + </span><span class=cFE>1</span><span class=cF0> + j) * d_a2</span><span class=cF7>)</span><span class=cF0>, z2);
|
|
<a name="l119"></a> p4 = AddVertex(&bd2, r2 * </span><span class=cF5>Cos</span><span class=cF7>(</span><span class=cF0>(</span><span class=cFE>2</span><span class=cF0> * i + </span><span class=cFE>3</span><span class=cF0> +j) * d_a2</span><span class=cF7>)</span><span class=cF0>, r2 * </span><span class=cF5>Sin</span><span class=cF7>(</span><span class=cF0>(</span><span class=cFE>2</span><span class=cF0> * i + </span><span class=cFE>3</span><span class=cF0> + j) * d_a2</span><span class=cF7>)</span><span class=cF0>, z2);
|
|
<a name="l120"></a> AddTri(&bd2, c, p1, p2, p3);
|
|
<a name="l121"></a> AddTri(&bd2, c, p3, p2, p4);
|
|
<a name="l122"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l123"></a> }
|
|
<a name="l124"></a>
|
|
<a name="l125"></a> res = Ball2CSprite;
|
|
<a name="l126"></a> </span><span class=cF6>"%h7c"</span><span class=cF0>, </span><span class=cF6>'\n'</span><span class=cF0>;
|
|
<a name="l127"></a> </span><span class=cF5>Sprite</span><span class=cF0>(res, </span><span class=cF6>"\t\t$SP,\"<1>\",BI=%d$"</span><span class=cF0>);
|
|
<a name="l128"></a> </span><span class=cF6>"%h7c"</span><span class=cF0>, </span><span class=cF6>'\n'</span><span class=cF0>;
|
|
<a name="l129"></a> </span><span class=cF6>"Vertices:%d\n"</span><span class=cF0>, b->vertex_count;
|
|
<a name="l130"></a> </span><span class=cF5>Free</span><span class=cF0>(b);
|
|
<a name="l131"></a> </span><span class=cF6>"Do another"</span><span class=cF0>;
|
|
<a name="l132"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>YorN</span><span class=cF0>)
|
|
<a name="l133"></a> </span><span class=cF5>Free</span><span class=cF0>(res);
|
|
<a name="l134"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l135"></a> </span><span class=cF1>break</span><span class=cF0>;
|
|
<a name="l136"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l137"></a>
|
|
<a name="l138"></a> </span><span class=cF1>return</span><span class=cF0> res;
|
|
<a name="l139"></a>}
|
|
</span></pre></body>
|
|
</html>
|