507 lines
54 KiB
Plaintext
507 lines
54 KiB
Plaintext
|
<!DOCTYPE html>
|
||
|
<html lang="en">
|
||
|
<head>
|
||
|
<meta charset="UTF-8">
|
||
|
<meta name="generator" content="TempleOS V5.03">
|
||
|
<meta name="viewport" content="width=device-width">
|
||
|
<link rel="stylesheet" href="/style/templeos.css">
|
||
|
<script src="/script/templeos.js"></script>
|
||
|
<style type="text/css">
|
||
|
.cF0{color:#000000;background-color:#ffffff;}
|
||
|
.cF1{color:#0000aa;background-color:#ffffff;}
|
||
|
.cF2{color:#00aa00;background-color:#ffffff;}
|
||
|
.cF3{color:#00aaaa;background-color:#ffffff;}
|
||
|
.cF4{color:#aa0000;background-color:#ffffff;}
|
||
|
.cF5{color:#aa00aa;background-color:#ffffff;}
|
||
|
.cF6{color:#aa5500;background-color:#ffffff;}
|
||
|
.cF7{color:#aaaaaa;background-color:#ffffff;}
|
||
|
.cF8{color:#555555;background-color:#ffffff;}
|
||
|
.cF9{color:#5555ff;background-color:#ffffff;}
|
||
|
.cFA{color:#55ff55;background-color:#ffffff;}
|
||
|
.cFB{color:#55ffff;background-color:#ffffff;}
|
||
|
.cFC{color:#ff5555;background-color:#ffffff;}
|
||
|
.cFD{color:#ff55ff;background-color:#ffffff;}
|
||
|
.cFE{color:#ffff55;background-color:#ffffff;}
|
||
|
.cFF{color:#ffffff;background-color:#ffffff;}
|
||
|
</style>
|
||
|
</head>
|
||
|
<body>
|
||
|
<pre id="content">
|
||
|
<a name="l1"></a><span class=cF0>#</span><span class=cF1>help_index</span><span class=cF0> </span><span class=cF6>"Graphics/Sprite;Sprites"</span><span class=cF0>
|
||
|
<a name="l2"></a></span><span class=cF2>/*</span><span class=cF4>
|
||
|
<a name="l3"></a></span><a href="/Wb/Adam/Gr/Gr.HH.HTML#l157"><span class=cF4>CSprite</span></a><span class=cF2>s are stored as a sequence of var</span><span class=cF0>
|
||
|
<a name="l4"></a></span><span class=cF2>length operations with a 1-byte </span><a href="/Wb/Adam/Gr/Gr.HH.HTML#l128"><span class=cF4>type</span></a><span class=cF2> leading</span><span class=cF0>
|
||
|
<a name="l5"></a></span><span class=cF2>each operation. They are stored, one after another,</span><span class=cF0>
|
||
|
<a name="l6"></a></span><span class=cF2>in a chunk of memory terminated by a </span><a href="/Wb/Adam/Gr/Gr.HH.HTML#l120"><span class=cF4>zero</span></a><span class=cF2>.</span><span class=cF4>
|
||
|
<a name="l7"></a></span><a href="/Wb/Adam/Gr/GrSpritePlot.HC.HTML#l18"><span class=cF4>Sprite3</span></a><span class=cF2>() shows how the </span><a href="/Wb/Adam/Gr/Gr.HH.HTML#l157"><span class=cF4>CSprite</span></a><span class=cF2> unions are used.</span><span class=cF0>
|
||
|
<a name="l8"></a></span><span class=cF4>
|
||
|
<a name="l9"></a></span><a href="/Wb/Adam/Gr/SpriteNew.HC.HTML#l44"><span class=cF4>SpriteElemSize</span></a><span class=cF2>() will return the size of a single</span><span class=cF0>
|
||
|
<a name="l10"></a></span><span class=cF2>element, while </span><a href="/Wb/Adam/Gr/SpriteNew.HC.HTML#l80"><span class=cF4>SpriteSize</span></a><span class=cF2>() will return the size</span><span class=cF0>
|
||
|
<a name="l11"></a></span><span class=cF2>of an entire list. Look at </span><a href="/Wb/Adam/Gr/SpriteNew.HC.HTML#l6"><span class=cF4>sprite_elem_base_sizes</span></a><span class=cF2>.</span><span class=cF0>
|
||
|
<a name="l12"></a>
|
||
|
<a name="l13"></a></span><span class=cF2>See </span><span class=cF9><u>::/Apps/GrModels</u></span><span class=cF2> for an example of</span><span class=cF0>
|
||
|
<a name="l14"></a></span><span class=cF2>making CSprite by hand. It uses </span><a href="/Wb/Adam/Gr/Gr.HH.HTML#l144"><span class=cF4>SPT_MESH</span></a><span class=cF2>,</span><span class=cF0>
|
||
|
<a name="l15"></a></span><span class=cF2>one of the most complicated.</span><span class=cF0>
|
||
|
<a name="l16"></a></span><span class=cF2>*/</span><span class=cF0>
|
||
|
<a name="l17"></a>
|
||
|
<a name="l18"></a></span><span class=cF1>public</span><span class=cF0> </span><span class=cF1>U0</span><span class=cF0> </span><span class=cF5>Sprite3</span><span class=cF0>(</span><span class=cF9>CDC</span><span class=cF0> *dc=</span><span class=cFB>gr</span><span class=cF0>.dc,</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,</span><span class=cF1>U8</span><span class=cF0> *elems,
|
||
|
<a name="l19"></a> </span><span class=cF1>Bool</span><span class=cF0> just_one_elem=</span><span class=cF3>FALSE</span><span class=cF0>)
|
||
|
<a name="l20"></a>{</span><span class=cF2>//Plot a sprite into a CDC.</span><span class=cF0>
|
||
|
<a name="l21"></a> </span><span class=cF9>CSprite</span><span class=cF0> *tmpg=elems-</span><span class=cF1>offset</span><span class=cF0>(</span><span class=cF9>CSprite</span><span class=cF0>.</span><span class=cF1>start</span><span class=cF0>);
|
||
|
<a name="l22"></a> </span><span class=cF9>I64</span><span class=cF0> i,j,k,x1,y1,z1,x2,y2,
|
||
|
<a name="l23"></a> *old_r,*r2,old_flags=dc->flags,old_pen_width=dc->thick;
|
||
|
<a name="l24"></a> </span><span class=cF9>I32</span><span class=cF0> *ptr;
|
||
|
<a name="l25"></a> </span><span class=cF9>CColorROPU32</span><span class=cF0> old_color=dc->color;
|
||
|
<a name="l26"></a> </span><span class=cF9>CDC</span><span class=cF0> *img;
|
||
|
<a name="l27"></a> </span><span class=cF9>CD3I32</span><span class=cF0> *p,*p2;
|
||
|
<a name="l28"></a> </span><span class=cF9>CGrSym</span><span class=cF0> old_sym;
|
||
|
<a name="l29"></a> </span><span class=cF5>MemCpy</span><span class=cF0>(&old_sym,&dc->sym,</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF9>CGrSym</span><span class=cF7>)</span><span class=cF0>);
|
||
|
<a name="l30"></a> </span><span class=cF1>if</span><span class=cF0> (dc->flags & </span><span class=cF3>DCF_LOCATE_NEAREST</span><span class=cF0>)
|
||
|
<a name="l31"></a> dc->nearest_dist=</span><span class=cF3>I64_MAX</span><span class=cF0>;
|
||
|
<a name="l32"></a> </span><span class=cF1>while</span><span class=cF0> (tmpg->type&</span><span class=cF3>SPG_TYPE_MASK</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l33"></a> </span><span class=cF1>switch</span><span class=cF0> (tmpg->type&</span><span class=cF3>SPG_TYPE_MASK</span><span class=cF0>) {
|
||
|
<a name="l34"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SPT_COLOR</span><span class=cF0>:
|
||
|
<a name="l35"></a> dc->color=dc->color&~(</span><span class=cF3>COLORROP_COLORS_MASK</span><span class=cF0>|</span><span class=cF3>ROPF_DITHER</span><span class=cF0>)|tmpg->c.color;
|
||
|
<a name="l36"></a> </span><span class=cF1>break</span><span class=cF0>;
|
||
|
<a name="l37"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SPT_DITHER_COLOR</span><span class=cF0>:
|
||
|
<a name="l38"></a> dc->color=dc->color&~</span><span class=cF3>COLORROP_COLORS_MASK</span><span class=cF0>|
|
||
|
<a name="l39"></a> tmpg->d.dither_color.u8[0]|
|
||
|
<a name="l40"></a> tmpg->d.dither_color.u8[1]<<</span><span class=cF3>COLORROP_BITS</span><span class=cF0>|</span><span class=cF3>ROPF_DITHER</span><span class=cF0>;
|
||
|
<a name="l41"></a> </span><span class=cF1>break</span><span class=cF0>;
|
||
|
<a name="l42"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SPT_THICK</span><span class=cF0>:
|
||
|
<a name="l43"></a> dc->thick=tmpg->t.thick;
|
||
|
<a name="l44"></a> </span><span class=cF5>DCThickScale</span><span class=cF0>(dc);
|
||
|
<a name="l45"></a> </span><span class=cF1>break</span><span class=cF0>;
|
||
|
<a name="l46"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SPT_TRANSFORM_ON</span><span class=cF0>:
|
||
|
<a name="l47"></a> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF7>(</span><span class=cF0>dc->flags&</span><span class=cF3>DCF_TRANSFORMATION</span><span class=cF7>)</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l48"></a> x-=dc->x;
|
||
|
<a name="l49"></a> y-=dc->y;
|
||
|
<a name="l50"></a> z-=dc->z;
|
||
|
<a name="l51"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l52"></a> dc->flags|=</span><span class=cF3>DCF_TRANSFORMATION</span><span class=cF0>;
|
||
|
<a name="l53"></a> </span><span class=cF1>break</span><span class=cF0>;
|
||
|
<a name="l54"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SPT_TRANSFORM_OFF</span><span class=cF0>:
|
||
|
<a name="l55"></a> </span><span class=cF1>if</span><span class=cF0> (dc->flags&</span><span class=cF3>DCF_TRANSFORMATION</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l56"></a> x+=dc->x;
|
||
|
<a name="l57"></a> y+=dc->y;
|
||
|
<a name="l58"></a> z+=dc->z;
|
||
|
<a name="l59"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l60"></a> dc->flags&=~</span><span class=cF3>DCF_TRANSFORMATION</span><span class=cF0>;
|
||
|
<a name="l61"></a> </span><span class=cF1>break</span><span class=cF0>;
|
||
|
<a name="l62"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SPT_PT</span><span class=cF0>:
|
||
|
<a name="l63"></a> </span><span class=cF5>GrPlot3</span><span class=cF0>(dc,tmpg->p.x1+x,tmpg->p.y1+y,z);
|
||
|
<a name="l64"></a> </span><span class=cF1>break</span><span class=cF0>;
|
||
|
<a name="l65"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SPT_TEXT</span><span class=cF0>:
|
||
|
<a name="l66"></a> </span><span class=cF5>GrPrint3</span><span class=cF0>(dc,tmpg->ps.x1+x,tmpg->ps.y1+y,z,</span><span class=cF6>"%s"</span><span class=cF0>,tmpg->ps.st);
|
||
|
<a name="l67"></a> </span><span class=cF1>break</span><span class=cF0>;
|
||
|
<a name="l68"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SPT_TEXT_BOX</span><span class=cF0>:
|
||
|
<a name="l69"></a> </span><span class=cF5>GrTextBox3</span><span class=cF0>(dc,tmpg->ps.x1+x,tmpg->ps.y1+y,z,tmpg->ps.st);
|
||
|
<a name="l70"></a> </span><span class=cF1>break</span><span class=cF0>;
|
||
|
<a name="l71"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SPT_TEXT_DIAMOND</span><span class=cF0>:
|
||
|
<a name="l72"></a> </span><span class=cF5>GrTextDiamond3</span><span class=cF0>(dc,tmpg->ps.x1+x,tmpg->ps.y1+y,z,tmpg->ps.st);
|
||
|
<a name="l73"></a> </span><span class=cF1>break</span><span class=cF0>;
|
||
|
<a name="l74"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SPT_FLOOD_FILL</span><span class=cF0>:
|
||
|
<a name="l75"></a> </span><span class=cF5>GrFloodFill3</span><span class=cF0>(dc,tmpg->p.x1+x,tmpg->p.y1+y,z,</span><span class=cF3>FALSE</span><span class=cF0>);
|
||
|
<a name="l76"></a> </span><span class=cF1>break</span><span class=cF0>;
|
||
|
<a name="l77"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SPT_FLOOD_FILL_NOT</span><span class=cF0>:
|
||
|
<a name="l78"></a> i=dc->color;
|
||
|
<a name="l79"></a> dc->color=dc->color.c0;
|
||
|
<a name="l80"></a> </span><span class=cF5>GrFloodFill3</span><span class=cF0>(dc,tmpg->p.x1+x,tmpg->p.y1+y,z,</span><span class=cF3>TRUE</span><span class=cF0>);
|
||
|
<a name="l81"></a> dc->color=i;
|
||
|
<a name="l82"></a> </span><span class=cF1>break</span><span class=cF0>;
|
||
|
<a name="l83"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SPT_SHIFT</span><span class=cF0>:
|
||
|
<a name="l84"></a> x+=tmpg->p.x1;
|
||
|
<a name="l85"></a> y+=tmpg->p.y1;
|
||
|
<a name="l86"></a> </span><span class=cF1>break</span><span class=cF0>;
|
||
|
<a name="l87"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SPT_LINE</span><span class=cF0>:
|
||
|
<a name="l88"></a> </span><span class=cF5>GrLine3</span><span class=cF0>(dc,tmpg->pp.x1+x,tmpg->pp.y1+y,z,
|
||
|
<a name="l89"></a> tmpg->pp.x2+x,tmpg->pp.y2+y,z);
|
||
|
<a name="l90"></a> </span><span class=cF1>break</span><span class=cF0>;
|
||
|
<a name="l91"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SPT_ARROW</span><span class=cF0>:
|
||
|
<a name="l92"></a> </span><span class=cF5>GrArrow3</span><span class=cF0>(dc,tmpg->pp.x1+x,tmpg->pp.y1+y,z,
|
||
|
<a name="l93"></a> tmpg->pp.x2+x,tmpg->pp.y2+y,z);
|
||
|
<a name="l94"></a> </span><span class=cF1>break</span><span class=cF0>;
|
||
|
<a name="l95"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SPT_PLANAR_SYMMETRY</span><span class=cF0>:
|
||
|
<a name="l96"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>DCSymmetry3Set</span><span class=cF7>(</span><span class=cF0>dc,tmpg->pp.x1+x,tmpg->pp.y1+y,z,
|
||
|
<a name="l97"></a> tmpg->pp.x2+x,tmpg->pp.y2+y,z,
|
||
|
<a name="l98"></a> tmpg->pp.x2+x,tmpg->pp.y2+y,z+1</span><span class=cF7>)</span><span class=cF0>)
|
||
|
<a name="l99"></a> dc->flags|=</span><span class=cF3>DCF_SYMMETRY</span><span class=cF0>;
|
||
|
<a name="l100"></a> </span><span class=cF1>else</span><span class=cF0>
|
||
|
<a name="l101"></a> dc->flags&=~</span><span class=cF3>DCF_SYMMETRY</span><span class=cF0>;
|
||
|
<a name="l102"></a> </span><span class=cF1>break</span><span class=cF0>;
|
||
|
<a name="l103"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SPT_BITMAP</span><span class=cF0>:
|
||
|
<a name="l104"></a> img=</span><span class=cF5>CAlloc</span><span class=cF0>(</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF9>CDC</span><span class=cF7>)</span><span class=cF0>);
|
||
|
<a name="l105"></a> img->width=tmpg->pwhu.width;
|
||
|
<a name="l106"></a> img->width_internal=(tmpg->pwhu.width+7)&~7;
|
||
|
<a name="l107"></a> img->height=tmpg->pwhu.height;
|
||
|
<a name="l108"></a> img->body=&tmpg->pwhu.u;
|
||
|
<a name="l109"></a> img->dc_signature=</span><span class=cF3>DCS_SIGNATURE_VAL</span><span class=cF0>;
|
||
|
<a name="l110"></a> </span><span class=cF5>GrBlot3</span><span class=cF0>(dc,tmpg->pwhu.x1+x,tmpg->pwhu.y1+y,z,img);
|
||
|
<a name="l111"></a> </span><span class=cF5>Free</span><span class=cF0>(img);
|
||
|
<a name="l112"></a> </span><span class=cF1>break</span><span class=cF0>;
|
||
|
<a name="l113"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SPT_RECT</span><span class=cF0>:
|
||
|
<a name="l114"></a> </span><span class=cF5>GrRect3</span><span class=cF0>(dc,tmpg->pp.x1+x,tmpg->pp.y1+y,z,
|
||
|
<a name="l115"></a> tmpg->pp.x2-tmpg->pp.x1,tmpg->pp.y2-tmpg->pp.y1);
|
||
|
<a name="l116"></a> </span><span class=cF1>break</span><span class=cF0>;
|
||
|
<a name="l117"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SPT_ROTATED_RECT</span><span class=cF0>:
|
||
|
<a name="l118"></a> x1=tmpg->ppa.x1+x;
|
||
|
<a name="l119"></a> y1=tmpg->ppa.y1+y;
|
||
|
<a name="l120"></a> z1=z;
|
||
|
<a name="l121"></a> </span><span class=cF5>Mat4x4MulXYZ</span><span class=cF0>(dc->r,&x1,&y1,&z1);
|
||
|
<a name="l122"></a> old_r=dc->r;
|
||
|
<a name="l123"></a> dc->flags|=</span><span class=cF3>DCF_TRANSFORMATION</span><span class=cF0>;
|
||
|
<a name="l124"></a> r2=</span><span class=cF5>Mat4x4IdentNew</span><span class=cF0>;
|
||
|
<a name="l125"></a> </span><span class=cF5>Mat4x4RotZ</span><span class=cF0>(r2,-tmpg->ppa.angle);
|
||
|
<a name="l126"></a> </span><span class=cF5>Mat4x4TranslationEqu</span><span class=cF0>(r2,x1,y1,z1);
|
||
|
<a name="l127"></a> </span><span class=cF5>DCMat4x4Set</span><span class=cF0>(dc,</span><span class=cF5>Mat4x4MulMat4x4New</span><span class=cF7>(</span><span class=cF0>old_r,r2</span><span class=cF7>)</span><span class=cF0>);
|
||
|
<a name="l128"></a> </span><span class=cF5>GrRect3</span><span class=cF0>(dc,0,0,0,
|
||
|
<a name="l129"></a> tmpg->ppa.x2-tmpg->ppa.x1,tmpg->ppa.y2-tmpg->ppa.y1);
|
||
|
<a name="l130"></a> </span><span class=cF5>Free</span><span class=cF0>(dc->r);
|
||
|
<a name="l131"></a> </span><span class=cF5>Free</span><span class=cF0>(r2);
|
||
|
<a name="l132"></a> </span><span class=cF5>DCMat4x4Set</span><span class=cF0>(dc,old_r);
|
||
|
<a name="l133"></a> dc->flags=dc->flags&~</span><span class=cF3>DCF_TRANSFORMATION</span><span class=cF0>|old_flags;
|
||
|
<a name="l134"></a> </span><span class=cF1>break</span><span class=cF0>;
|
||
|
<a name="l135"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SPT_CIRCLE</span><span class=cF0>:
|
||
|
<a name="l136"></a> </span><span class=cF5>GrCircle3</span><span class=cF0>(dc,tmpg->pr.x1+x,tmpg->pr.y1+y,z,tmpg->pr.radius);
|
||
|
<a name="l137"></a> </span><span class=cF1>break</span><span class=cF0>;
|
||
|
<a name="l138"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SPT_ELLIPSE</span><span class=cF0>:
|
||
|
<a name="l139"></a> </span><span class=cF5>GrEllipse3</span><span class=cF0>(dc,tmpg->pwha.x1+x,tmpg->pwha.y1+y,z,tmpg->pwha.width,
|
||
|
<a name="l140"></a> tmpg->pwha.height,tmpg->pwha.angle);
|
||
|
<a name="l141"></a> </span><span class=cF1>break</span><span class=cF0>;
|
||
|
<a name="l142"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SPT_POLYGON</span><span class=cF0>:
|
||
|
<a name="l143"></a> </span><span class=cF5>GrRegPoly3</span><span class=cF0>(dc,tmpg->pwhas.x1+x,tmpg->pwhas.y1+y,z,tmpg->pwhas.width,
|
||
|
<a name="l144"></a> tmpg->pwhas.height,tmpg->pwhas.sides,tmpg->pwhas.angle);
|
||
|
<a name="l145"></a> </span><span class=cF1>break</span><span class=cF0>;
|
||
|
<a name="l146"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SPT_POLYLINE</span><span class=cF0>:
|
||
|
<a name="l147"></a> ptr=&tmpg->nu.u;
|
||
|
<a name="l148"></a> x1=ptr[0];
|
||
|
<a name="l149"></a> y1=ptr[1];
|
||
|
<a name="l150"></a> </span><span class=cF1>for</span><span class=cF0> (i=1;i<tmpg->nu.num;i++) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l151"></a> x2=ptr[i<<1];
|
||
|
<a name="l152"></a> y2=ptr[i<<1+1];
|
||
|
<a name="l153"></a> </span><span class=cF5>GrLine3</span><span class=cF0>(dc,x1+x,y1+y,z,x2+x,y2+y,z);
|
||
|
<a name="l154"></a> x1=x2;y1=y2;
|
||
|
<a name="l155"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l156"></a> </span><span class=cF1>break</span><span class=cF0>;
|
||
|
<a name="l157"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SPT_POLYPT</span><span class=cF0>:
|
||
|
<a name="l158"></a> x1=tmpg->npu.x;
|
||
|
<a name="l159"></a> y1=tmpg->npu.y;
|
||
|
<a name="l160"></a> ptr=&tmpg->npu.u;
|
||
|
<a name="l161"></a> k=tmpg->npu.num*3;
|
||
|
<a name="l162"></a> </span><span class=cF5>GrPlot3</span><span class=cF0>(dc,x1+x,y1+y,z);
|
||
|
<a name="l163"></a> </span><span class=cF1>for</span><span class=cF0> (i=0;i<k;i+=3) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l164"></a> j=</span><span class=cF5>BFieldExtU32</span><span class=cF0>(ptr,i,3);
|
||
|
<a name="l165"></a> x1+=</span><span class=cFB>gr_x_offsets</span><span class=cF0>[j];
|
||
|
<a name="l166"></a> y1+=</span><span class=cFB>gr_y_offsets</span><span class=cF0>[j];
|
||
|
<a name="l167"></a> </span><span class=cF5>GrPlot3</span><span class=cF0>(dc,x1+x,y1+y,z);
|
||
|
<a name="l168"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l169"></a> </span><span class=cF1>break</span><span class=cF0>;
|
||
|
<a name="l170"></a> </span><span class=cF1>start</span><span class=cF0>:
|
||
|
<a name="l171"></a> p2=p=</span><span class=cF5>MAlloc</span><span class=cF0>(tmpg->nu.num*</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF9>CD3I32</span><span class=cF7>)</span><span class=cF0>);
|
||
|
<a name="l172"></a> </span><span class=cF5>MemCpy</span><span class=cF0>(p,&tmpg->nu.u,tmpg->nu.num*</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF9>CD3I32</span><span class=cF7>)</span><span class=cF0>);
|
||
|
<a name="l173"></a> </span><span class=cF1>for</span><span class=cF0> (i=0;i<tmpg->nu.num;i++,p2++) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l174"></a> p2->x+=x;
|
||
|
<a name="l175"></a> p2->y+=y;
|
||
|
<a name="l176"></a> p2->z+=z;
|
||
|
<a name="l177"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l178"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SPT_BSPLINE2</span><span class=cF0>:
|
||
|
<a name="l179"></a> </span><span class=cF5>Gr2BSpline3</span><span class=cF0>(dc,p,tmpg->nu.num,</span><span class=cF3>FALSE</span><span class=cF0>);
|
||
|
<a name="l180"></a> </span><span class=cF1>break</span><span class=cF0>;
|
||
|
<a name="l181"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SPT_BSPLINE3</span><span class=cF0>:
|
||
|
<a name="l182"></a> </span><span class=cF5>Gr3BSpline3</span><span class=cF0>(dc,p,tmpg->nu.num,</span><span class=cF3>FALSE</span><span class=cF0>);
|
||
|
<a name="l183"></a> </span><span class=cF1>break</span><span class=cF0>;
|
||
|
<a name="l184"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SPT_BSPLINE2_CLOSED</span><span class=cF0>:
|
||
|
<a name="l185"></a> </span><span class=cF5>Gr2BSpline3</span><span class=cF0>(dc,p,tmpg->nu.num,</span><span class=cF3>TRUE</span><span class=cF0>);
|
||
|
<a name="l186"></a> </span><span class=cF1>break</span><span class=cF0>;
|
||
|
<a name="l187"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SPT_BSPLINE3_CLOSED</span><span class=cF0>:
|
||
|
<a name="l188"></a> </span><span class=cF5>Gr3BSpline3</span><span class=cF0>(dc,p,tmpg->nu.num,</span><span class=cF3>TRUE</span><span class=cF0>);
|
||
|
<a name="l189"></a> </span><span class=cF1>break</span><span class=cF0>;
|
||
|
<a name="l190"></a> </span><span class=cF1>end</span><span class=cF0>:
|
||
|
<a name="l191"></a> </span><span class=cF5>Free</span><span class=cF0>(p);
|
||
|
<a name="l192"></a> </span><span class=cF1>break</span><span class=cF0>;
|
||
|
<a name="l193"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SPT_MESH</span><span class=cF0>:
|
||
|
<a name="l194"></a> p2=p=</span><span class=cF5>MAlloc</span><span class=cF0>(tmpg->mu.vertex_cnt*</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF9>CD3I32</span><span class=cF7>)</span><span class=cF0>);
|
||
|
<a name="l195"></a> </span><span class=cF5>MemCpy</span><span class=cF0>(p,&tmpg->mu.u,tmpg->mu.vertex_cnt*</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF9>CD3I32</span><span class=cF7>)</span><span class=cF0>);
|
||
|
<a name="l196"></a> </span><span class=cF1>for</span><span class=cF0> (i=0;i<tmpg->mu.vertex_cnt;i++,p2++) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l197"></a> p2->x+=x;
|
||
|
<a name="l198"></a> p2->y+=y;
|
||
|
<a name="l199"></a> p2->z+=z;
|
||
|
<a name="l200"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l201"></a> </span><span class=cF5>Gr3Mesh</span><span class=cF0>(dc,tmpg->mu.vertex_cnt,p,tmpg->mu.tri_cnt,
|
||
|
<a name="l202"></a> </span><span class=cF7>(</span><span class=cF0>&tmpg->mu.u</span><span class=cF7>)(</span><span class=cF1>U8</span><span class=cF0> *</span><span class=cF7>)</span><span class=cF0>+</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF9>CD3I32</span><span class=cF7>)</span><span class=cF0>*tmpg->mu.vertex_cnt);
|
||
|
<a name="l203"></a> </span><span class=cF5>Free</span><span class=cF0>(p);
|
||
|
<a name="l204"></a> </span><span class=cF1>break</span><span class=cF0>;
|
||
|
<a name="l205"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SPT_SHIFTABLE_MESH</span><span class=cF0>:
|
||
|
<a name="l206"></a> </span><span class=cF1>if</span><span class=cF0> (dc->flags&</span><span class=cF3>DCF_TRANSFORMATION</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l207"></a> dc->x+=tmpg->pmu.x;
|
||
|
<a name="l208"></a> dc->y+=tmpg->pmu.y;
|
||
|
<a name="l209"></a> dc->z+=tmpg->pmu.z;
|
||
|
<a name="l210"></a> x1=x;
|
||
|
<a name="l211"></a> y1=y;
|
||
|
<a name="l212"></a> z1=z;
|
||
|
<a name="l213"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l214"></a> x1=tmpg->pmu.x+x;
|
||
|
<a name="l215"></a> y1=tmpg->pmu.y+y;
|
||
|
<a name="l216"></a> z1=tmpg->pmu.z+z;
|
||
|
<a name="l217"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l218"></a> p2=p=</span><span class=cF5>MAlloc</span><span class=cF0>(tmpg->pmu.vertex_cnt*</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF9>CD3I32</span><span class=cF7>)</span><span class=cF0>);
|
||
|
<a name="l219"></a> </span><span class=cF5>MemCpy</span><span class=cF0>(p,&tmpg->pmu.u,tmpg->pmu.vertex_cnt*</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF9>CD3I32</span><span class=cF7>)</span><span class=cF0>);
|
||
|
<a name="l220"></a> </span><span class=cF1>for</span><span class=cF0> (i=0;i<tmpg->pmu.vertex_cnt;i++,p2++) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l221"></a> p2->x+=x1;
|
||
|
<a name="l222"></a> p2->y+=y1;
|
||
|
<a name="l223"></a> p2->z+=z1;
|
||
|
<a name="l224"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l225"></a> </span><span class=cF5>Gr3Mesh</span><span class=cF0>(dc,tmpg->pmu.vertex_cnt,p,tmpg->pmu.tri_cnt,
|
||
|
<a name="l226"></a> </span><span class=cF7>(</span><span class=cF0>&tmpg->pmu.u</span><span class=cF7>)(</span><span class=cF1>U8</span><span class=cF0> *</span><span class=cF7>)</span><span class=cF0>+</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF9>CD3I32</span><span class=cF7>)</span><span class=cF0>*tmpg->pmu.vertex_cnt);
|
||
|
<a name="l227"></a> </span><span class=cF5>Free</span><span class=cF0>(p);
|
||
|
<a name="l228"></a> </span><span class=cF1>if</span><span class=cF0> (dc->flags&</span><span class=cF3>DCF_TRANSFORMATION</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l229"></a> dc->x-=tmpg->pmu.x;
|
||
|
<a name="l230"></a> dc->y-=tmpg->pmu.y;
|
||
|
<a name="l231"></a> dc->z-=tmpg->pmu.z;
|
||
|
<a name="l232"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l233"></a> </span><span class=cF1>break</span><span class=cF0>;
|
||
|
<a name="l234"></a> }
|
||
|
<a name="l235"></a> </span><span class=cF1>if</span><span class=cF0> (just_one_elem) </span><span class=cF1>break</span><span class=cF0>;
|
||
|
<a name="l236"></a> tmpg(</span><span class=cF1>U8</span><span class=cF0> *)+=</span><span class=cF5>SpriteElemSize</span><span class=cF0>(tmpg);
|
||
|
<a name="l237"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l238"></a> </span><span class=cF5>MemCpy</span><span class=cF0>(&dc->sym,&old_sym,</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF9>CGrSym</span><span class=cF7>)</span><span class=cF0>);
|
||
|
<a name="l239"></a> dc->color=old_color;
|
||
|
<a name="l240"></a> dc->thick=old_pen_width;
|
||
|
<a name="l241"></a> dc->flags=dc->flags&~(</span><span class=cF3>DCF_SYMMETRY</span><span class=cF0>|</span><span class=cF3>DCF_TRANSFORMATION</span><span class=cF0>) |
|
||
|
<a name="l242"></a> old_flags&(</span><span class=cF3>DCF_SYMMETRY</span><span class=cF0>|</span><span class=cF3>DCF_TRANSFORMATION</span><span class=cF0>);
|
||
|
<a name="l243"></a>}
|
||
|
<a name="l244"></a>
|
||
|
<a name="l245"></a></span><span class=cF1>public</span><span class=cF0> </span><span class=cF1>U0</span><span class=cF0> </span><span class=cF5>Sprite3B</span><span class=cF0>(</span><span class=cF9>CDC</span><span class=cF0> *dc=</span><span class=cFB>gr</span><span class=cF0>.dc,</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,</span><span class=cF1>U8</span><span class=cF0> *elems)
|
||
|
<a name="l246"></a>{</span><span class=cF2>//Plot a sprite into a CDC, post transform xyz translation.</span><span class=cF0>
|
||
|
<a name="l247"></a> </span><span class=cF9>I64</span><span class=cF0> old_x=dc->x,old_y=dc->y,old_z=dc->z,
|
||
|
<a name="l248"></a> old_flags=dc->flags&</span><span class=cF3>DCF_TRANSFORMATION</span><span class=cF0>;
|
||
|
<a name="l249"></a> dc->x=x; dc->y=y; dc->z=z;
|
||
|
<a name="l250"></a> dc->flags|=</span><span class=cF3>DCF_TRANSFORMATION</span><span class=cF0>;
|
||
|
<a name="l251"></a> </span><span class=cF5>Sprite3</span><span class=cF0>(dc,0,0,0,elems);
|
||
|
<a name="l252"></a> dc->x=old_x; dc->y=old_y; dc->z=old_z;
|
||
|
<a name="l253"></a> dc->flags=dc->flags&~</span><span class=cF3>DCF_TRANSFORMATION</span><span class=cF0>|old_flags;
|
||
|
<a name="l254"></a>}
|
||
|
<a name="l255"></a>
|
||
|
<a name="l256"></a></span><span class=cF1>public</span><span class=cF0> </span><span class=cF1>U0</span><span class=cF0> </span><span class=cF5>Sprite3Mat4x4B</span><span class=cF0>(</span><span class=cF9>CDC</span><span class=cF0> *dc=</span><span class=cFB>gr</span><span class=cF0>.dc,</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,</span><span class=cF1>U8</span><span class=cF0> *elems,</span><span class=cF9>I64</span><span class=cF0> *m)
|
||
|
<a name="l257"></a>{</span><span class=cF2>//Plot rotated by matrix.</span><span class=cF0>
|
||
|
<a name="l258"></a> </span><span class=cF9>I64</span><span class=cF0> r[16],*old_r=dc->r,new_m[16],
|
||
|
<a name="l259"></a> old_flags=dc->flags&</span><span class=cF3>DCF_TRANSFORMATION</span><span class=cF0>;
|
||
|
<a name="l260"></a> </span><span class=cF5>MemCpy</span><span class=cF0>(new_m,m,16*</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF9>I64</span><span class=cF7>)</span><span class=cF0>);
|
||
|
<a name="l261"></a> dc->flags|=</span><span class=cF3>DCF_TRANSFORMATION</span><span class=cF0>;
|
||
|
<a name="l262"></a> </span><span class=cF5>Mat4x4TranslationAdd</span><span class=cF0>(new_m,x,y,z);
|
||
|
<a name="l263"></a> dc->r=</span><span class=cF5>Mat4x4MulMat4x4Equ</span><span class=cF0>(r,old_r,new_m);
|
||
|
<a name="l264"></a> </span><span class=cF5>Sprite3</span><span class=cF0>(dc,0,0,0,elems);
|
||
|
<a name="l265"></a> dc->r=old_r;
|
||
|
<a name="l266"></a> dc->flags=dc->flags&~</span><span class=cF3>DCF_TRANSFORMATION</span><span class=cF0>|old_flags;
|
||
|
<a name="l267"></a>}
|
||
|
<a name="l268"></a>
|
||
|
<a name="l269"></a></span><span class=cF1>public</span><span class=cF0> </span><span class=cF1>U0</span><span class=cF0> </span><span class=cF5>Sprite3XB</span><span class=cF0>(</span><span class=cF9>CDC</span><span class=cF0> *dc=</span><span class=cFB>gr</span><span class=cF0>.dc,</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,</span><span class=cF1>U8</span><span class=cF0> *elems,</span><span class=cF1>F64</span><span class=cF0> phi=0)
|
||
|
<a name="l270"></a>{</span><span class=cF2>//Plot rotated around X axis.</span><span class=cF0>
|
||
|
<a name="l271"></a> </span><span class=cF9>I64</span><span class=cF0> r[16];
|
||
|
<a name="l272"></a> </span><span class=cF5>Mat4x4IdentEqu</span><span class=cF0>(r);
|
||
|
<a name="l273"></a> </span><span class=cF5>Mat4x4RotX</span><span class=cF0>(r,phi);
|
||
|
<a name="l274"></a> </span><span class=cF5>Sprite3Mat4x4B</span><span class=cF0>(dc,x,y,z,elems,r);
|
||
|
<a name="l275"></a>}
|
||
|
<a name="l276"></a>
|
||
|
<a name="l277"></a></span><span class=cF1>public</span><span class=cF0> </span><span class=cF1>U0</span><span class=cF0> </span><span class=cF5>Sprite3YB</span><span class=cF0>(</span><span class=cF9>CDC</span><span class=cF0> *dc=</span><span class=cFB>gr</span><span class=cF0>.dc,</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,</span><span class=cF1>U8</span><span class=cF0> *elems,</span><span class=cF1>F64</span><span class=cF0> omega=0)
|
||
|
<a name="l278"></a>{</span><span class=cF2>//Plot rotated around Y axis.</span><span class=cF0>
|
||
|
<a name="l279"></a> </span><span class=cF9>I64</span><span class=cF0> r[16];
|
||
|
<a name="l280"></a> </span><span class=cF5>Mat4x4IdentEqu</span><span class=cF0>(r);
|
||
|
<a name="l281"></a> </span><span class=cF5>Mat4x4RotY</span><span class=cF0>(r,omega);
|
||
|
<a name="l282"></a> </span><span class=cF5>Sprite3Mat4x4B</span><span class=cF0>(dc,x,y,z,elems,r);
|
||
|
<a name="l283"></a>}
|
||
|
<a name="l284"></a>
|
||
|
<a name="l285"></a></span><span class=cF1>public</span><span class=cF0> </span><span class=cF1>U0</span><span class=cF0> </span><span class=cF5>Sprite3ZB</span><span class=cF0>(</span><span class=cF9>CDC</span><span class=cF0> *dc=</span><span class=cFB>gr</span><span class=cF0>.dc,</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,</span><span class=cF1>U8</span><span class=cF0> *elems,</span><span class=cF1>F64</span><span class=cF0> theta=0)
|
||
|
<a name="l286"></a>{</span><span class=cF2>//Plot rotated around Z axis.</span><span class=cF0>
|
||
|
<a name="l287"></a> </span><span class=cF9>I64</span><span class=cF0> r[16];
|
||
|
<a name="l288"></a> </span><span class=cF5>Mat4x4IdentEqu</span><span class=cF0>(r);
|
||
|
<a name="l289"></a> </span><span class=cF5>Mat4x4RotZ</span><span class=cF0>(r,theta);
|
||
|
<a name="l290"></a> </span><span class=cF5>Sprite3Mat4x4B</span><span class=cF0>(dc,x,y,z,elems,r);
|
||
|
<a name="l291"></a>}
|
||
|
<a name="l292"></a>
|
||
|
<a name="l293"></a></span><span class=cF1>public</span><span class=cF0> </span><span class=cF1>U0</span><span class=cF0> </span><span class=cF5>SpriteExtents</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> *elems,</span><span class=cF9>I64</span><span class=cF0> *min_x=</span><span class=cF3>NULL</span><span class=cF0>,</span><span class=cF9>I64</span><span class=cF0> *max_x=</span><span class=cF3>NULL</span><span class=cF0>,
|
||
|
<a name="l294"></a> </span><span class=cF9>I64</span><span class=cF0> *min_y=</span><span class=cF3>NULL</span><span class=cF0>,</span><span class=cF9>I64</span><span class=cF0> *max_y=</span><span class=cF3>NULL</span><span class=cF0>)
|
||
|
<a name="l295"></a>{</span><span class=cF2>//Ignores flood fills.</span><span class=cF0>
|
||
|
<a name="l296"></a> </span><span class=cF9>CDC</span><span class=cF0> *dc=</span><span class=cF5>DCNew</span><span class=cF0>(</span><span class=cF3>I32_MAX</span><span class=cF0>,</span><span class=cF3>I32_MAX</span><span class=cF0>,</span><span class=cF5>Fs</span><span class=cF0>,</span><span class=cF3>TRUE</span><span class=cF0>);
|
||
|
<a name="l297"></a> </span><span class=cF5>DCExtentsInit</span><span class=cF0>(dc);
|
||
|
<a name="l298"></a> </span><span class=cF5>Sprite3</span><span class=cF0>(dc,</span><span class=cF3>I32_MAX</span><span class=cF0>/2,</span><span class=cF3>I32_MAX</span><span class=cF0>/2,</span><span class=cF3>I32_MAX</span><span class=cF0>/2,elems);
|
||
|
<a name="l299"></a> </span><span class=cF1>if</span><span class=cF0> (dc->min_x<=dc->max_x) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l300"></a> dc->min_x-=</span><span class=cF3>I32_MAX</span><span class=cF0>/2;
|
||
|
<a name="l301"></a> dc->max_x-=</span><span class=cF3>I32_MAX</span><span class=cF0>/2;
|
||
|
<a name="l302"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l303"></a> </span><span class=cF1>if</span><span class=cF0> (dc->min_y<=dc->max_y) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l304"></a> dc->min_y-=</span><span class=cF3>I32_MAX</span><span class=cF0>/2;
|
||
|
<a name="l305"></a> dc->max_y-=</span><span class=cF3>I32_MAX</span><span class=cF0>/2;
|
||
|
<a name="l306"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l307"></a> </span><span class=cF1>if</span><span class=cF0> (min_x) *min_x=dc->min_x;
|
||
|
<a name="l308"></a> </span><span class=cF1>if</span><span class=cF0> (max_x) *max_x=dc->max_x;
|
||
|
<a name="l309"></a> </span><span class=cF1>if</span><span class=cF0> (min_y) *min_y=dc->min_y;
|
||
|
<a name="l310"></a> </span><span class=cF1>if</span><span class=cF0> (max_y) *max_y=dc->max_y;
|
||
|
<a name="l311"></a> </span><span class=cF5>DCDel</span><span class=cF0>(dc);
|
||
|
<a name="l312"></a>}
|
||
|
<a name="l313"></a>
|
||
|
<a name="l314"></a></span><span class=cF1>public</span><span class=cF0> </span><span class=cF9>CDC</span><span class=cF0> *</span><span class=cF5>Sprite2DC</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> *elems)
|
||
|
<a name="l315"></a>{</span><span class=cF2>//Convert sprite to device context.</span><span class=cF0>
|
||
|
<a name="l316"></a> </span><span class=cF9>CDC</span><span class=cF0> *res;
|
||
|
<a name="l317"></a> </span><span class=cF9>I64</span><span class=cF0> min_x,max_x,min_y,max_y;
|
||
|
<a name="l318"></a> </span><span class=cF5>SpriteExtents</span><span class=cF0>(elems,&min_x,&max_x,&min_y,&max_y);
|
||
|
<a name="l319"></a> res=</span><span class=cF5>DCNew</span><span class=cF0>(max_x-min_x+1,max_y-min_y+1);
|
||
|
<a name="l320"></a> </span><span class=cF5>Sprite3</span><span class=cF0>(res,-min_x,-min_y,0,elems);
|
||
|
<a name="l321"></a> </span><span class=cF1>return</span><span class=cF0> res;
|
||
|
<a name="l322"></a>}
|
||
|
<a name="l323"></a>
|
||
|
<a name="l324"></a></span><span class=cF1>public</span><span class=cF0> </span><span class=cF1>U8</span><span class=cF0> *</span><span class=cF5>SpriteInterpolate</span><span class=cF0>(</span><span class=cF1>F64</span><span class=cF0> t,</span><span class=cF1>U8</span><span class=cF0> *elems0,</span><span class=cF1>U8</span><span class=cF0> *elems1)
|
||
|
<a name="l325"></a>{</span><span class=cF2>//The two CSprite should be ident except for points shifted around.</span><span class=cF0>
|
||
|
<a name="l326"></a></span><span class=cF2>//t ranges from 0.0 to 1.0.</span><span class=cF0>
|
||
|
<a name="l327"></a> </span><span class=cF9>I64</span><span class=cF0> i,t1=</span><span class=cF3>GR_SCALE</span><span class=cF0>*t,t0=</span><span class=cF3>GR_SCALE</span><span class=cF0>-t1;
|
||
|
<a name="l328"></a> </span><span class=cF9>I32</span><span class=cF0> *ptr0,*ptr1,*ptrr;
|
||
|
<a name="l329"></a> </span><span class=cF9>CD3I32</span><span class=cF0> *p0,*p1,*pr;
|
||
|
<a name="l330"></a> </span><span class=cF1>U8</span><span class=cF0> *res;
|
||
|
<a name="l331"></a> </span><span class=cF9>CSprite</span><span class=cF0> *tmpg0=elems0-</span><span class=cF1>offset</span><span class=cF0>(</span><span class=cF9>CSprite</span><span class=cF0>.</span><span class=cF1>start</span><span class=cF0>),
|
||
|
<a name="l332"></a> *tmpg1=elems1-</span><span class=cF1>offset</span><span class=cF0>(</span><span class=cF9>CSprite</span><span class=cF0>.</span><span class=cF1>start</span><span class=cF0>),*tmpgr;
|
||
|
<a name="l333"></a> </span><span class=cF1>if</span><span class=cF0> (t<0.5) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l334"></a> i=</span><span class=cF5>SpriteSize</span><span class=cF0>(elems0),
|
||
|
<a name="l335"></a> res=</span><span class=cF5>MAlloc</span><span class=cF0>(i);
|
||
|
<a name="l336"></a> </span><span class=cF5>MemCpy</span><span class=cF0>(res,elems0,i);
|
||
|
<a name="l337"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l338"></a> i=</span><span class=cF5>SpriteSize</span><span class=cF0>(elems1),
|
||
|
<a name="l339"></a> res=</span><span class=cF5>MAlloc</span><span class=cF0>(i);
|
||
|
<a name="l340"></a> </span><span class=cF5>MemCpy</span><span class=cF0>(res,elems1,i);
|
||
|
<a name="l341"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l342"></a> tmpgr=res-</span><span class=cF1>offset</span><span class=cF0>(</span><span class=cF9>CSprite</span><span class=cF0>.</span><span class=cF1>start</span><span class=cF0>);
|
||
|
<a name="l343"></a> </span><span class=cF1>while</span><span class=cF0> (tmpg0->type&</span><span class=cF3>SPG_TYPE_MASK</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l344"></a> </span><span class=cF1>if</span><span class=cF0> (tmpg0->type&</span><span class=cF3>SPG_TYPE_MASK</span><span class=cF0>!=tmpg1->type&</span><span class=cF3>SPG_TYPE_MASK</span><span class=cF0>)
|
||
|
<a name="l345"></a> </span><span class=cF5>throw</span><span class=cF0>(</span><span class=cF6>'Graphics'</span><span class=cF0>);
|
||
|
<a name="l346"></a> </span><span class=cF1>switch</span><span class=cF0> (tmpg0->type&</span><span class=cF3>SPG_TYPE_MASK</span><span class=cF0>) {
|
||
|
<a name="l347"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SPT_ROTATED_RECT</span><span class=cF0>:
|
||
|
<a name="l348"></a> tmpgr->ppa.angle=(tmpg0->ppa.angle*t0+tmpg1->ppa.angle*t1)/</span><span class=cF3>GR_SCALE</span><span class=cF0>;
|
||
|
<a name="l349"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SPT_RECT</span><span class=cF0>:
|
||
|
<a name="l350"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SPT_LINE</span><span class=cF0>:
|
||
|
<a name="l351"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SPT_ARROW</span><span class=cF0>:
|
||
|
<a name="l352"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SPT_PLANAR_SYMMETRY</span><span class=cF0>:
|
||
|
<a name="l353"></a> tmpgr->pp.x2=(tmpg0->pp.x2*t0+tmpg1->pp.x2*t1)>>32;
|
||
|
<a name="l354"></a> tmpgr->pp.y2=(tmpg0->pp.y2*t0+tmpg1->pp.y2*t1)>>32;
|
||
|
<a name="l355"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SPT_TEXT</span><span class=cF0>:
|
||
|
<a name="l356"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SPT_TEXT_BOX</span><span class=cF0>:
|
||
|
<a name="l357"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SPT_TEXT_DIAMOND</span><span class=cF0>:
|
||
|
<a name="l358"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SPT_PT</span><span class=cF0>:
|
||
|
<a name="l359"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SPT_FLOOD_FILL</span><span class=cF0>:
|
||
|
<a name="l360"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SPT_FLOOD_FILL_NOT</span><span class=cF0>:
|
||
|
<a name="l361"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SPT_SHIFT</span><span class=cF0>:
|
||
|
<a name="l362"></a> tmpgr->p.x1=(tmpg0->p.x1*t0+tmpg1->p.x1*t1)>>32;
|
||
|
<a name="l363"></a> tmpgr->p.y1=(tmpg0->p.y1*t0+tmpg1->p.y1*t1)>>32;
|
||
|
<a name="l364"></a> </span><span class=cF1>break</span><span class=cF0>;
|
||
|
<a name="l365"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SPT_CIRCLE</span><span class=cF0>:
|
||
|
<a name="l366"></a> tmpgr->pr.radius=(tmpg0->pr.radius*t0+tmpg1->pr.radius*t1)>>32;
|
||
|
<a name="l367"></a> tmpgr->pr.x1=(tmpg0->pr.x1*t0+tmpg1->pr.x1*t1)>>32;
|
||
|
<a name="l368"></a> tmpgr->pr.y1=(tmpg0->pr.y1*t0+tmpg1->pr.y1*t1)>>32;
|
||
|
<a name="l369"></a> </span><span class=cF1>break</span><span class=cF0>;
|
||
|
<a name="l370"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SPT_ELLIPSE</span><span class=cF0>:
|
||
|
<a name="l371"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SPT_POLYGON</span><span class=cF0>:
|
||
|
<a name="l372"></a> tmpgr->pwha.x1=(tmpg0->pwha.x1*t0+tmpg1->pwha.x1*t1)>>32;
|
||
|
<a name="l373"></a> tmpgr->pwha.y1=(tmpg0->pwha.y1*t0+tmpg1->pwha.y1*t1)>>32;
|
||
|
<a name="l374"></a> tmpgr->pwha.width =(tmpg0->pwha.width *t0+tmpg1->pwha.width*t1)>>32;
|
||
|
<a name="l375"></a> tmpgr->pwha.height=(tmpg0->pwha.height*t0+tmpg1->pwha.height*t1)>>32;
|
||
|
<a name="l376"></a> </span><span class=cF1>break</span><span class=cF0>;
|
||
|
<a name="l377"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SPT_BITMAP</span><span class=cF0>:
|
||
|
<a name="l378"></a> tmpgr->pwhu.x1=(tmpg0->pwhu.x1*t0+tmpg1->pwhu.x1*t1)>>32;
|
||
|
<a name="l379"></a> tmpgr->pwhu.y1=(tmpg0->pwhu.y1*t0+tmpg1->pwhu.y1*t1)>>32;
|
||
|
<a name="l380"></a> </span><span class=cF1>break</span><span class=cF0>;
|
||
|
<a name="l381"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SPT_POLYLINE</span><span class=cF0>:
|
||
|
<a name="l382"></a> ptr0=&tmpg0->nu.u;
|
||
|
<a name="l383"></a> ptr1=&tmpg1->nu.u;
|
||
|
<a name="l384"></a> ptrr=&tmpgr->nu.u;
|
||
|
<a name="l385"></a> </span><span class=cF1>for</span><span class=cF0> (i=0;i<tmpg0->nu.num;i++) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l386"></a> ptrr[i<<1]=(ptr0[i<<1]*t0+ptr1[i<<1]*t1)>>32;
|
||
|
<a name="l387"></a> ptrr[i<<1+1]=(ptr0[i<<1+1]*t0+ptr1[i<<1+1]*t1)>>32;
|
||
|
<a name="l388"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l389"></a> </span><span class=cF1>break</span><span class=cF0>;
|
||
|
<a name="l390"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SPT_POLYPT</span><span class=cF0>:
|
||
|
<a name="l391"></a> tmpgr->npu.x=(tmpg0->npu.x*t0+tmpg1->npu.x*t1)>>32;
|
||
|
<a name="l392"></a> tmpgr->npu.y=(tmpg0->npu.y*t0+tmpg1->npu.y*t1)>>32;
|
||
|
<a name="l393"></a> </span><span class=cF1>break</span><span class=cF0>;
|
||
|
<a name="l394"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SPT_BSPLINE2</span><span class=cF0>:
|
||
|
<a name="l395"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SPT_BSPLINE3</span><span class=cF0>:
|
||
|
<a name="l396"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SPT_BSPLINE2_CLOSED</span><span class=cF0>:
|
||
|
<a name="l397"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SPT_BSPLINE3_CLOSED</span><span class=cF0>:
|
||
|
<a name="l398"></a> p0=&tmpg0->nu.u;
|
||
|
<a name="l399"></a> p1=&tmpg1->nu.u;
|
||
|
<a name="l400"></a> pr=&tmpgr->nu.u;
|
||
|
<a name="l401"></a> </span><span class=cF1>for</span><span class=cF0> (i=0;i<tmpg0->nu.num;i++) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l402"></a> pr[i].x=(p0[i].x*t0+p1[i].x*t1)>>32;
|
||
|
<a name="l403"></a> pr[i].y=(p0[i].y*t0+p1[i].y*t1)>>32;
|
||
|
<a name="l404"></a> pr[i].z=(p0[i].z*t0+p1[i].z*t1)>>32;
|
||
|
<a name="l405"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l406"></a> </span><span class=cF1>break</span><span class=cF0>;
|
||
|
<a name="l407"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SPT_MESH</span><span class=cF0>:
|
||
|
<a name="l408"></a> p0=&tmpg0->mu.u;
|
||
|
<a name="l409"></a> p1=&tmpg1->mu.u;
|
||
|
<a name="l410"></a> pr=&tmpgr->mu.u;
|
||
|
<a name="l411"></a> </span><span class=cF1>for</span><span class=cF0> (i=0;i<tmpg0->mu.vertex_cnt;i++) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l412"></a> pr[i].x=(p0[i].x*t0+p1[i].x*t1)>>32;
|
||
|
<a name="l413"></a> pr[i].y=(p0[i].y*t0+p1[i].y*t1)>>32;
|
||
|
<a name="l414"></a> pr[i].z=(p0[i].z*t0+p1[i].z*t1)>>32;
|
||
|
<a name="l415"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l416"></a> </span><span class=cF1>break</span><span class=cF0>;
|
||
|
<a name="l417"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SPT_SHIFTABLE_MESH</span><span class=cF0>:
|
||
|
<a name="l418"></a> p0=&tmpg0->pmu.u;
|
||
|
<a name="l419"></a> p1=&tmpg1->pmu.u;
|
||
|
<a name="l420"></a> pr=&tmpgr->pmu.u;
|
||
|
<a name="l421"></a> </span><span class=cF1>for</span><span class=cF0> (i=0;i<tmpg0->pmu.vertex_cnt;i++) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l422"></a> pr[i].x=(p0[i].x*t0+p1[i].x*t1)>>32;
|
||
|
<a name="l423"></a> pr[i].y=(p0[i].y*t0+p1[i].y*t1)>>32;
|
||
|
<a name="l424"></a> pr[i].z=(p0[i].z*t0+p1[i].z*t1)>>32;
|
||
|
<a name="l425"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l426"></a> </span><span class=cF1>break</span><span class=cF0>;
|
||
|
<a name="l427"></a> }
|
||
|
<a name="l428"></a> tmpg0(</span><span class=cF1>U8</span><span class=cF0> *)+=</span><span class=cF5>SpriteElemSize</span><span class=cF0>(tmpg0);
|
||
|
<a name="l429"></a> tmpg1(</span><span class=cF1>U8</span><span class=cF0> *)+=</span><span class=cF5>SpriteElemSize</span><span class=cF0>(tmpg1);
|
||
|
<a name="l430"></a> tmpgr(</span><span class=cF1>U8</span><span class=cF0> *)+=</span><span class=cF5>SpriteElemSize</span><span class=cF0>(tmpgr);
|
||
|
<a name="l431"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l432"></a> </span><span class=cF1>return</span><span class=cF0> res;
|
||
|
<a name="l433"></a>}
|
||
|
<a name="l434"></a>
|
||
|
<a name="l435"></a>#</span><span class=cF1>help_index</span><span class=cF0> </span><span class=cF6>"Graphics/Sprite;DolDoc/Output;StdOut/DolDoc"</span><span class=cF0>
|
||
|
<a name="l436"></a></span><span class=cF1>public</span><span class=cF0> </span><span class=cF9>CDocEntry</span><span class=cF0> *</span><span class=cF5>DocSprite</span><span class=cF0>(</span><span class=cF9>CDoc</span><span class=cF0> *doc=</span><span class=cF3>NULL</span><span class=cF0>,</span><span class=cF1>U8</span><span class=cF0> *elems,</span><span class=cF1>U8</span><span class=cF0> *fmt=</span><span class=cF3>NULL</span><span class=cF0>)
|
||
|
<a name="l437"></a>{</span><span class=cF2>//Put a sprite into a document. You can, optionally, supply a fmt string</span><span class=cF0>
|
||
|
<a name="l438"></a></span><span class=cF2>//for </span><a href="/Wb/Doc/DolDocOverview.DD.HTML#l1"><span class=cF4>DolDoc</span></a><span class=cF2> cmd with a %d for the bin_num.</span><span class=cF0>
|
||
|
<a name="l439"></a> </span><span class=cF9>I64</span><span class=cF0> size;
|
||
|
<a name="l440"></a> </span><span class=cF1>U8</span><span class=cF0> *st;
|
||
|
<a name="l441"></a> </span><span class=cF1>Bool</span><span class=cF0> unlock;
|
||
|
<a name="l442"></a> </span><span class=cF9>CDocEntry</span><span class=cF0> *doc_e;
|
||
|
<a name="l443"></a> </span><span class=cF9>CDocBin</span><span class=cF0> *tmpb;
|
||
|
<a name="l444"></a> </span><span class=cF1>if</span><span class=cF0> (!doc && !</span><span class=cF7>(</span><span class=cF0>doc=</span><span class=cF5>DocPut</span><span class=cF7>)</span><span class=cF0>) </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>NULL</span><span class=cF0>;
|
||
|
<a name="l445"></a> unlock=</span><span class=cF5>DocLock</span><span class=cF0>(doc);
|
||
|
<a name="l446"></a> size=</span><span class=cF5>SpriteSize</span><span class=cF0>(elems);
|
||
|
<a name="l447"></a> tmpb=</span><span class=cF5>CAlloc</span><span class=cF0>(</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF9>CDocBin</span><span class=cF7>)</span><span class=cF0>,doc->mem_task);
|
||
|
<a name="l448"></a> tmpb->size=size;
|
||
|
<a name="l449"></a> tmpb->data=</span><span class=cF5>MAlloc</span><span class=cF0>(size,doc->mem_task);
|
||
|
<a name="l450"></a> </span><span class=cF5>MemCpy</span><span class=cF0>(tmpb->data,elems,size);
|
||
|
<a name="l451"></a> tmpb->num=doc->cur_bin_num;
|
||
|
<a name="l452"></a> tmpb->use_cnt=1;
|
||
|
<a name="l453"></a> </span><span class=cF5>QueIns</span><span class=cF0>(tmpb,doc->bin_head.last);
|
||
|
<a name="l454"></a> </span><span class=cF1>if</span><span class=cF0> (fmt)
|
||
|
<a name="l455"></a> st=</span><span class=cF5>MStrPrint</span><span class=cF0>(fmt,doc->cur_bin_num++);
|
||
|
<a name="l456"></a> </span><span class=cF1>else</span><span class=cF0>
|
||
|
<a name="l457"></a> st=</span><span class=cF5>MStrPrint</span><span class=cF0>(</span><span class=cF6>"$SP,\"\",BI=%d$"</span><span class=cF0>,doc->cur_bin_num++);
|
||
|
<a name="l458"></a> doc_e=</span><span class=cF5>DocPrint</span><span class=cF0>(doc,</span><span class=cF6>"%s"</span><span class=cF0>,st);
|
||
|
<a name="l459"></a> </span><span class=cF5>Free</span><span class=cF0>(st);
|
||
|
<a name="l460"></a> doc_e->bin_data=tmpb;
|
||
|
<a name="l461"></a> </span><span class=cF1>if</span><span class=cF0> (doc_e && doc_e->de_flags&</span><span class=cF3>DOCEF_TAG</span><span class=cF0> && doc_e->tag && *doc_e->tag)
|
||
|
<a name="l462"></a> tmpb->tag=</span><span class=cF5>StrNew</span><span class=cF0>(doc_e->tag,doc->mem_task);
|
||
|
<a name="l463"></a> </span><span class=cF1>if</span><span class=cF0> (unlock)
|
||
|
<a name="l464"></a> </span><span class=cF5>DocUnlock</span><span class=cF0>(doc);
|
||
|
<a name="l465"></a> </span><span class=cF1>return</span><span class=cF0> doc_e;
|
||
|
<a name="l466"></a>}
|
||
|
<a name="l467"></a>
|
||
|
<a name="l468"></a></span><span class=cF1>public</span><span class=cF0> </span><span class=cF9>CDocEntry</span><span class=cF0> *</span><span class=cF5>Sprite</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> *elems,</span><span class=cF1>U8</span><span class=cF0> *fmt=</span><span class=cF3>NULL</span><span class=cF0>)
|
||
|
<a name="l469"></a>{</span><span class=cF2>//Put sprite to the command-line, </span><a href="/Wb/Adam/DolDoc/DocDblBuf.HC.HTML#l2"><span class=cF4>DocPut</span></a><span class=cF2>.</span><span class=cF0>
|
||
|
<a name="l470"></a></span><span class=cF2>//If you set fmt, then include dollars ("$SP ...$") and leave %d for num.</span><span class=cF0>
|
||
|
<a name="l471"></a> </span><span class=cF9>CDoc</span><span class=cF0> *doc;
|
||
|
<a name="l472"></a> </span><span class=cF1>if</span><span class=cF0> (doc=</span><span class=cF5>DocPut</span><span class=cF0>)
|
||
|
<a name="l473"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF5>DocSprite</span><span class=cF0>(doc,elems,fmt);
|
||
|
<a name="l474"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>NULL</span><span class=cF0>;
|
||
|
<a name="l475"></a>}
|
||
|
</span></pre></body>
|
||
|
</html>
|