[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[palito-dev] primitive alright!
From: |
Michael Devey |
Subject: |
[palito-dev] primitive alright! |
Date: |
Sat, 27 Sep 2003 22:28:07 +1000 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.3) Gecko/20030319 Debian/1.3-3 |
yikes!
Have you ever seen anything as ugly as my additions to flush code? I
don't ever remember it being that hideous! Anyway I shall attempt to
make ammends, given time. Here's a start.
Looks like I'm over trying to get lower levels to do arcs for us, so
lets go mad with trig functions and waste our time drawing them with
lines ... :/
I think you can add this blindly but I would appreciate someone who
knows what they're doing to add flush_lod to the vertices calculation.
Oh, would it be nicer to define a constant such that its (SEGMENTS+1) /
(2pi) ?
(paranoid about clean :)
myke
kill that code it's embarrassing!
*flush.h
void flush2d_semicircle(float x, float y, float r, float startR, float
sweepR);
void flush2d_closedsemicircle(float x, float y, float r, float startR,
float sweepR);
void flush2d_xsemicircle(int closed, float x, float y, float r, float
startR, float sweepR);
*toodee.c
//-----------------------------------------------------------------------------
#define MAGICMYKE_PACMAN 2
#define MAGICMYKE_GHOST 0
#define MAGICMYKE_21_div_2pi 3.342253805
/*
* Draw a closed/notclosed Circular Arc out of lines given:
* centre x y, radius r, starting angle (radians) startR,
* and arc length (radians) sweepR.
*/
//---
void flush2d_semicircle(float x, float y, float r, float startR, float
sweepR)
{
flush2d_xsemicircle( MAGICMYKE_GHOST, x, y, r, startR, sweepR);
}
//---
void flush2d_closedsemicircle(float x, float y, float r, float startR,
float sweepR)
{
flush2d_xsemicircle( MAGICMYKE_PACMAN, x, y, r, startR, sweepR);
}
//---
void flush2d_xsemicircle(int closed, float x, float y, float r, float
startR, float sweepR)
{
// int vertices = 21 /* 20 lines at 2pi */
/*
(vertices-1) line segments, must change for zoom/speed!!!
flush_lod will do this yes???? FEED ME!!!!
growing arcs is a little jerky but you'll survive :)
( or just swap it back to 21 :} )
*/
int vertices = (int)(sweepR*MAGICMYKE_21_div_2pi);
float v[2], v1[2] = { x, y }, v2[2] = { r, 0 };
float radius;
int *ip, i;
if(!dynbuf((void **) &ipoints, &isize,
(vertices+closed)*sizeof(int)*2))
return;
ip = ipoints;
sweepR /= vertices-1;
afim2_mult_vector2(v, sp, v1);
matrix2_mult_vector2(v1, sp, v2);
startR += atan2 (v1[1], v1[0]);
radius = sqrt(v1[0]*v1[0] + v1[1]*v1[1]);
for(i = 0; i < vertices; i++, startR += sweepR){
*ip = (int) ( v[0] + radius * cos(startR) ); ip++;
*ip = (int) ( v[1] + radius * sin(startR) ); ip++;
}
if(closed){
*ip = (int) v[0]; ip++;
*ip = (int) v[1]; ip++;
*ip = *ipoints;
*(ip+1) = *(ipoints+1);
}
flush_polyline(ipoints, vertices+closed);
}
//-----------------------------------------------------------------------------
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [palito-dev] primitive alright!,
Michael Devey <=