2021-07-03 05:07:57 +01:00
<!DOCTYPE HTML>
< html >
< head >
< meta http-equiv = "Content-Type" content = "text/html;charset=US-ASCII" >
2021-12-11 11:10:58 +00:00
< meta name = "generator" content = "ZealOS V1.07" >
2021-07-03 05:07:57 +01:00
< style type = "text/css" >
2021-10-08 07:06:11 +01:00
body {background-color:#1f1f1f;}
.cF0{color:#e3e3e3;background-color:#1f1f1f;}
.cF1{color:#4f84a6;background-color:#1f1f1f;}
.cF2{color:#73a255;background-color:#1f1f1f;}
.cF3{color:#297582;background-color:#1f1f1f;}
.cF4{color:#b34f4b;background-color:#1f1f1f;}
.cF5{color:#8a52c3;background-color:#1f1f1f;}
.cF6{color:#b7822f;background-color:#1f1f1f;}
.cF7{color:#444444;background-color:#1f1f1f;}
.cF8{color:#6d6d6d;background-color:#1f1f1f;}
.cF9{color:#94bfde;background-color:#1f1f1f;}
.cFA{color:#a1ce97;background-color:#1f1f1f;}
.cFB{color:#6db4be;background-color:#1f1f1f;}
.cFC{color:#e88e88;background-color:#1f1f1f;}
.cFD{color:#ca94e8;background-color:#1f1f1f;}
.cFE{color:#d4b475;background-color:#1f1f1f;}
.cFF{color:#1f1f1f;background-color:#1f1f1f;}
2021-07-03 05:07:57 +01:00
< / style >
< / head >
< body >
2021-07-05 01:12:38 +01:00
< pre style = "font-family:monospace;font-size:12pt" >
2021-07-03 05:07:57 +01:00
< 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 >
2021-07-04 23:11:34 +01:00
< a name = "l4" > < / a > #< / span > < span class = cF1 > define< / span > < span class = cF0 > TRIS_NUM < / span > < span class = cFE > 1024< / span > < span class = cF0 >
2021-07-03 05:07:57 +01:00
< a name = "l5" > < / a >
< a name = "l6" > < / a > < / span > < span class = cF1 > class< / span > < span class = cF0 > Ball
< a name = "l7" > < / a > {
2021-07-04 23:11:34 +01:00
< 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];
2021-07-03 05:07:57 +01:00
< 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 > {
2021-07-04 23:11:34 +01:00
< 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 > ;
2021-07-03 05:07:57 +01:00
< 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 > {
2021-07-04 23:11:34 +01:00
< 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 > ;
2021-07-03 05:07:57 +01:00
< 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 > {
2021-07-04 23:11:34 +01:00
< 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 > ;
2021-07-03 05:07:57 +01:00
< 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 > {
2021-07-04 23:11:34 +01:00
< a name = "l38" > < / a > < / span > < span class = cF9 > I64< / span > < span class = cF0 > i;
2021-07-03 05:07:57 +01:00
< a name = "l39" > < / a >
2021-07-04 23:11:34 +01:00
< 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;
2021-07-03 05:07:57 +01:00
< a name = "l47" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l48" > < / a > < / span > < span class = cF1 > return< / span > < span class = cF0 > i;
2021-07-03 05:07:57 +01:00
< 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 > {
2021-07-04 23:11:34 +01:00
< a name = "l53" > < / a > < / span > < span class = cF9 > I64< / span > < span class = cF0 > res = b-> tri_count++;
2021-07-03 05:07:57 +01:00
< a name = "l54" > < / a >
2021-07-04 23:11:34 +01:00
< 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;
2021-07-03 05:07:57 +01:00
< a name = "l59" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l60" > < / a > < / span > < span class = cF1 > return< / span > < span class = cF0 > res;
2021-07-03 05:07:57 +01:00
< 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 > {
2021-12-11 11:10:58 +00:00
< a name = "l65" > < / a > < / span > < span class = cF2 > //See < / span > < a href = "https://zeal-operating-system.github.io/ZealOS/System/Gr/GrSpritePlot.ZC.html#l1" > < span class = cF4 > ::/System/Gr/GrSpritePlot.ZC< / span > < / a > < span class = cF2 > for how CSprite are stored.< / span > < span class = cF0 >
2021-07-04 23:11:34 +01:00
< 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 > ;
2021-07-03 05:07:57 +01:00
< a name = "l78" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l79" > < / a > < / span > < span class = cF1 > return< / span > < span class = cF0 > res;
2021-07-03 05:07:57 +01:00
< 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 > {
2021-07-04 23:11:34 +01:00
< 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;
2021-07-03 05:07:57 +01:00
< a name = "l88" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l89" > < / a > BDInit(& bd1);
2021-07-03 05:07:57 +01:00
< a name = "l90" > < / a >
2021-07-04 23:11:34 +01:00
< 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);
2021-07-03 05:07:57 +01:00
< a name = "l97" > < / a >
2021-07-04 23:11:34 +01:00
< 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 > ;
2021-07-03 05:07:57 +01:00
< a name = "l101" > < / a >
2021-07-04 23:11:34 +01:00
< 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 > }
2021-07-03 05:07:57 +01:00
< a name = "l124" > < / a >
2021-07-04 23:11:34 +01:00
< 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 >
2021-07-03 05:07:57 +01:00
< a name = "l137" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l138" > < / a > < / span > < span class = cF1 > return< / span > < span class = cF0 > res;
2021-07-03 05:07:57 +01:00
< a name = "l139" > < / a > }
< / span > < / pre > < / body >
< / html >