Пример #1
0
/* main program */
int main(void)
{
   int c;

   if (allegro_init() != 0)
      return 1;
   install_keyboard();
   install_mouse();
   install_timer();

   if (set_gfx_mode(GFX_AUTODETECT, 640, 480, 0, 0) != 0) {
      if (set_gfx_mode(GFX_SAFE, 640, 480, 0, 0) != 0) {
	 set_gfx_mode(GFX_TEXT, 0, 0, 0, 0);
	 allegro_message("Unable to set any graphic mode\n%s\n",
			 allegro_error);
	 return 1;
      }
   }

   set_palette(desktop_palette);

   input_nodes();
   calc_tangents();

   curviness = ftofix(0.25);
   show_tangents = FALSE;
   show_control_points = FALSE;

   draw_splines();

   for (;;) {
      if (keypressed()) {
	 c = readkey() >> 8;
	 if (c == KEY_ESC)
	    break;
	 else if (c == KEY_UP) {
	    curviness += ftofix(0.05);
	    draw_splines();
	 }
	 else if (c == KEY_DOWN) {
	    curviness -= ftofix(0.05);
	    draw_splines();
	 }
	 else if (c == KEY_SPACE) {
	    walk();
	    draw_splines();
	 }
	 else if (c == KEY_T) {
	    show_tangents = !show_tangents;
	    draw_splines();
	 }
	 else if (c == KEY_C) {
	    show_control_points = !show_control_points;
	    draw_splines();
	 }
      }
   }

   return 0;
}
Пример #2
0
void worm::shootrope() 
{
	ropex=x;
	ropey=y-4000; 
	ropexspd=fixtof(fixsin(ftofix(aim/1000.)))*3500*dir;
	ropeyspd=fixtof(fixcos(ftofix(aim/1000.)))*3500;
	rope_length=*game->ROPE_LENGHT;
	ropestate=1;
};
Пример #3
0
static void osc_dsp(t_osc *x, t_signal **sp)
{
	post("samplerate %f",sp[0]->s_sr);
    x->x_conv = ftofix(1000.)/sp[0]->s_sr;
     post("conf %d",x->x_conv);
    x->x_conv = mult(x->x_conv + 500,ftofix(0.001));
     post("conf %d",x->x_conv);
    dsp_add(osc_perform, 4, x, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n);
}
Пример #4
0
    /* "set" message to specify thresholds and dead times */
static void threshold_tilde_set(t_threshold_tilde *x,
    t_floatarg hithresh, t_floatarg hideadtime,
    t_floatarg lothresh, t_floatarg lodeadtime)
{
    if (lothresh > hithresh)
    	lothresh = hithresh;
    x->x_hithresh = ftofix(hithresh);
    x->x_hideadtime = hideadtime;
    x->x_lothresh = ftofix(lothresh);
    x->x_lodeadtime = lodeadtime;
}
Пример #5
0
void AGENT::draw_selected(DISPLAY* display)
{
	int drawX = display->toScreenX((int) x);
	int drawY = display->toScreenY((int) y);
	circle(display->buffer, drawX, drawY, unitData->radius * 4 / (build_data ? 2 : 5), makecol(164, 24, 24)); // select circle
	arc(display->buffer, drawX, drawY, 0, ftofix((float) health / unitData->maxHealth * 255), unitData->radius * 4 / (build_data ? 2 : 5), makecol(28, 47, 226)); // health bar
}
Пример #6
0
static void *sfread_new(t_floatarg chan,t_floatarg skip)
{
#ifdef ROCKBOX
    (void) skip;
#endif
    t_sfread *x = (t_sfread *)pd_new(sfread_class);
    t_int c = chan;

    x->x_glist = (t_glist*) canvas_getcurrent();

    if (c<1 || c > MAX_CHANS) c = 1;
    inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("ft1"));
    inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("ft2"));


    x->x_fd = -1;
    x->x_mapaddr = NULL;

    x->x_size = 0;
    x->x_loop = 0;
    x->x_channels = c;
    x->x_mapaddr=NULL;
    x->x_pos = 0;
    x->x_skip = 0;
    x->x_speed = ftofix(1.0);
    x->x_play = 0;

    while (c--) {
	 outlet_new(&x->x_obj, gensym("signal"));
    }

     x->x_bangout = outlet_new(&x->x_obj, &s_float);

    return (x);
}
int build_preheat_curve(int curve)
{
//points
    curve_ctrl_pt[curve][1][0]=0;
    curve_ctrl_pt[curve][1][1]=255-28;//point 1 en 0 0

    curve_ctrl_pt[curve][2][0]=40;
    curve_ctrl_pt[curve][2][1]=255-86;//point 1 en 0 0
    curve_ctrl_pt[curve][3][0]=102;
    curve_ctrl_pt[curve][3][1]=255-163;//point 1 en 0 0
    curve_ctrl_pt[curve][4][0]=187;
    curve_ctrl_pt[curve][4][1]=255-235;//point 1 en 0 0

    curve_ctrl_pt[curve][5][0]=255;
    curve_ctrl_pt[curve][5][1]=0;//point 5 en 255 255

    the_curve_spline_level[curve]=176;
    index_curve_spline_level=178;
    curve_spline_level=(((float)index_curve_spline_level)/127)-1;
    curve_node_count=6;
    curve_curviness = ftofix(curve_spline_level);
    curve_calc_tangents();
    curve_draw_splines();
//write_curve(); //fait planter si debordement de memoire
    view_curve_after_draw();
    return(0);
}
Пример #8
0
static void tabwrite_float(t_tabwrite *x, t_float f)
{
#ifdef ROCKBOX
    int vecsize;
#else
    int i, vecsize;
#endif
    t_garray *a;
    t_sample *vec;

    if (!(a = (t_garray *)pd_findbyclass(x->x_arrayname, garray_class)))
    	pd_error(x, "%s: no such array", x->x_arrayname->s_name);
    else if (!garray_getfloatarray(a, &vecsize, &vec))
    	pd_error(x, "%s: bad template for tabwrite", x->x_arrayname->s_name);
    else
    {
    	int n = x->x_ft1;
    	double timesince = clock_gettimesince(x->x_updtime);
    	if (n < 0) n = 0;
    	else if (n >= vecsize) n = vecsize-1;
    	vec[n] = ftofix(f);
    	if (timesince > 1000)
    	{
    	    tabwrite_tick(x);
    	}
    	else
    	{
    	    if (x->x_set == 0)
    	    {
    	    	clock_delay(x->x_clock, 1000 - timesince);
    	    	x->x_set = 1;
    	    }
    	}
    }
}
Пример #9
0
static void *sigenv_new(t_floatarg fnpoints, t_floatarg fperiod)
{
    int npoints = fnpoints;
    int period = fperiod;
    t_sigenv *x;
    t_sample *buf;
    int i;

    if (npoints < 1) npoints = 1024;
    if (period < 1) period = npoints/2;
    if (period < npoints / MAXOVERLAP + 1)
        period = npoints / MAXOVERLAP + 1;
    if (!(buf = getbytes(sizeof(t_sample) * (npoints + MAXVSTAKEN))))
    {
        error("env: couldn't allocate buffer");
        return (0);
    }
    x = (t_sigenv *)pd_new(sigenv_class);
    x->x_buf = buf;
    x->x_npoints = npoints;
    x->x_phase = 0;
    x->x_period = period;
    for (i = 0; i < MAXOVERLAP; i++) x->x_sumbuf[i] = 0;
    for (i = 0; i < npoints; i++)
        buf[i] = ftofix((1. - cos((2 * 3.14159 * i) / npoints))/npoints);
    for (; i < npoints+MAXVSTAKEN; i++) buf[i] = 0;
    x->x_clock = clock_new(x, (t_method)sigenv_tick);
    x->x_outlet = outlet_new(&x->x_obj, gensym("float"));
    x->x_f = 0;
    return (x);
}
Пример #10
0
static t_int *sigvd_perform(t_int *w)
{
     t_sample *in = (t_sample *)(w[1]);
     t_sample *out = (t_sample *)(w[2]);
     t_delwritectl *ctl = (t_delwritectl *)(w[3]);
#ifndef ROCKBOX
     t_sigvd *x = (t_sigvd *)(w[4]);
#endif
     int n = (int)(w[5]);
 
     int nsamps = ctl->c_n;
     int fn = n;
     t_sample limit = nsamps - n - 1;
     t_sample *vp = ctl->c_vec, *bp, *wp = vp + ctl->c_phase;
#ifndef ROCKBOX
     t_sample zerodel = x->x_zerodel;
#endif
     while (n--)
     {
       t_time delsamps =  ((long long) mult((*in++),ftofix(44.1)));//- itofix(zerodel);
	int index = fixtoi(delsamps);
	t_sample frac;
	//	post("%d: index %d f %lld",index,findex,*in);

	frac = delsamps - itofix(index);
        index+=fn;
     	if (index < 1 ) index += nsamps ;
     	if (index > limit) index-= nsamps;
     	bp = wp - index;
     	if (bp < vp + 2) bp += nsamps;
     	*out++ = bp[-1] + mult(frac,bp[-1]-bp[0]);
        wp++;
     }
     return (w+6);
}
Пример #11
0
static void vline_tilde_float(t_vline *x, t_float f)
{
    t_time timenow = clock_gettimesince(x->x_referencetime);
    t_sample inlet1 = (x->x_inlet1 < 0 ? 0 : (t_sample)x->x_inlet1);
    t_sample inlet2 = (t_sample) x->x_inlet2;
    t_time starttime = timenow + inlet2;
    t_vseg *s1, *s2, *deletefrom = 0,
    	*snew = (t_vseg *)t_getbytes(sizeof(*snew));
    if (PD_BADFLOAT(f))
	f = 0;

    	/* negative delay input means stop and jump immediately to new value */
    if (inlet2 < 0)
    {
    	vline_tilde_stop(x);
	x->x_value = ftofix(f);
	return;
    }
    	/* check if we supplant the first item in the list.  We supplant
	an item by having an earlier starttime, or an equal starttime unless
	the equal one was instantaneous and the new one isn't (in which case
	we'll do a jump-and-slide starting at that time.) */
    if (!x->x_list || x->x_list->s_starttime > starttime ||
    	(x->x_list->s_starttime == starttime &&
	    (x->x_list->s_targettime > x->x_list->s_starttime || inlet1 <= 0)))
    {
    	deletefrom = x->x_list;
	x->x_list = snew;
    }
    else
    {
    	for (s1 = x->x_list; (s2 = s1->s_next); s1 = s2)
	{
    	    if (s2->s_starttime > starttime ||
    		(s2->s_starttime == starttime &&
		    (s2->s_targettime > s2->s_starttime || inlet1 <= 0)))
	    {
    		deletefrom = s2;
		s1->s_next = snew;
		goto didit;
	    }
	}
	s1->s_next = snew;
	deletefrom = 0;
    didit: ;
    }
    while (deletefrom)
    {
    	s1 = deletefrom->s_next;
	t_freebytes(deletefrom, sizeof(*deletefrom));
	deletefrom = s1;
    }
    snew->s_next = 0;
    snew->s_target = f;
    snew->s_starttime = starttime;
    snew->s_targettime = starttime + inlet1;
    x->x_inlet1 = x->x_inlet2 = 0;
}
Пример #12
0
static void sigbp_docoef(t_sigbp *x, t_floatarg f, t_floatarg q)
{
    float r, oneminusr, omega;
    if (f < 0.001) f = 10;
    if (q < 0) q = 0;
    x->x_freq = f;
    x->x_q = q;
    omega = f * (2.0f * 3.14159f) / x->x_sr;
    if (q < 0.001) oneminusr = 1.0f;
    else oneminusr = omega/q;
    if (oneminusr > 1.0f) oneminusr = 1.0f;
    r = 1.0f - oneminusr;
    x->x_ctl->c_coef1 = ftofix(2.0f * sigbp_qcos(omega) * r);
    x->x_ctl->c_coef2 = ftofix(- r * r);
    x->x_ctl->c_gain = ftofix(2 * oneminusr * (oneminusr + r * omega));
    /* post("r %f, omega %f, coef1 %f, coef2 %f",
    	r, omega, x->x_ctl->c_coef1, x->x_ctl->c_coef2); */
}
Пример #13
0
static void pd_floatforsignal(t_pd *x, t_float f)
{
    int offset = (*x)->c_floatsignalin;
    if (offset > 0)
    	*(t_sample *)(((char *)x) + offset) = ftofix(f);
    else
    	pd_error(x, "%s: float unexpected for signal input",
	    (*x)->c_name->s_name);
}
Пример #14
0
static void siglop_ft1(t_siglop *x, t_floatarg f)
{
     t_float coeff;
    if (f < 0.001) f = 10;
    x->x_hz = f;
    coeff = f * (2 * 3.14159) / x->x_sr;
    if (coeff > 1) coeff = 1;
    x->x_ctl->c_coef = ftofix(coeff);
}
Пример #15
0
static void *osc_new(t_floatarg f)
{
    t_osc *x = (t_osc *)pd_new(osc_class);
    x->x_f = ftofix(f);
    outlet_new(&x->x_obj, gensym("signal"));
    inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("ft1"));
    x->x_phase = 0;
    x->x_conv = 0;
    return (x);
}
Пример #16
0
/* get_camera_matrix: 
 *  Constructs a camera matrix for translating world-space objects into
 *  a normalised view space, ready for the perspective projection. The
 *  x, y, and z parameters specify the camera position, xfront, yfront,
 *  and zfront is an 'in front' vector specifying which way the camera
 *  is facing (this can be any length: normalisation is not required),
 *  and xup, yup, and zup is the 'up' direction vector. Up is really only
 *  a 1.5d vector, since the front vector only leaves one degree of freedom
 *  for which way up to put the image, but it is simplest to specify it
 *  as a full 3d direction even though a lot of the information in it is
 *  discarded. The fov parameter specifies the field of view (ie. width
 *  of the camera focus) in fixed point, 256 degrees to the circle format.
 *  For typical projections, a field of view in the region 32-48 will work
 *  well. Finally, the aspect ratio is used to scale the Y dimensions of
 *  the image relative to the X axis, so you can use it to correct for
 *  the proportions of the output image (set it to 1 for no scaling).
 */
void get_camera_matrix(MATRIX *m, fixed x, fixed y, fixed z, fixed xfront, fixed yfront, fixed zfront, fixed xup, fixed yup, fixed zup, fixed fov, fixed aspect)
{
   MATRIX_f camera;
   int i, j;
   ASSERT(m);

   get_camera_matrix_f(&camera,
		       fixtof(x), fixtof(y), fixtof(z), 
		       fixtof(xfront), fixtof(yfront), fixtof(zfront), 
		       fixtof(xup), fixtof(yup), fixtof(zup), 
		       fixtof(fov), fixtof(aspect));

   for (i=0; i<3; i++) {
      for (j=0; j<3; j++)
	 m->v[i][j] = ftofix(camera.v[i][j]);

      m->t[i] = ftofix(camera.t[i]);
   }
}
Пример #17
0
/* fsqrt:
 *  Fixed point square root routine for non-i386.
 */
fixed fsqrt(fixed x)
{
   if (x > 0)
      return ftofix(sqrt(fixtof(x)));

   if (x < 0)
      errno = EDOM;

   return 0;
}
Пример #18
0
/* fixsqrt:
 *  Fixed point square root routine for non-i386.
 */
fixed fixsqrt(fixed x)
{
   if (x > 0)
      return ftofix(sqrt(fixtof(x)));

   if (x < 0)
      *allegro_errno = EDOM;

   return 0;
}
Пример #19
0
void Menu::update(){
     poll_mouse();
     angle = atan2(mouse_y-cy,mouse_x-cx)*255.0/(2.0*3.14150926);
     masked_blit(bgd,image,0,0,x,y,width,height);
     populate();
     cy = 190 + 50*selectNum;
     //masked_blit(cursor,image,0,0,cx,cy,32,32);
     pivot_sprite(image,cursor,cx,cy,16,16,ftofix(angle));
     //angle++;
}
Пример #20
0
static void inlet_float(t_inlet *x, t_float f)
{
    if (x->i_symfrom == &s_float)
    	pd_vmess(x->i_dest, x->i_symto, "f", (t_floatarg)f);
    else if (x->i_symfrom == &s_signal)
    	x->i_un.iu_floatsignalvalue = ftofix(f);
    else if (!x->i_symfrom)
    	pd_float(x->i_dest, f);
    else inlet_wrong(x, &s_float);
}
Пример #21
0
alienrocket::alienrocket(){
    color = 0;
    x = 0;
    y = 0; 
    fired = false;
    hit = false;
    speed = 5;
    angle_stepsize = ftofix(3);
    angle = 0;
}
Пример #22
0
static t_int *clip_perform(t_int *w)
{
    t_clip *x = (t_clip *)(w[1]);
    t_sample *in = (t_sample *)(w[2]);
    t_sample *out = (t_sample *)(w[3]);
    int n = (int)(w[4]);
    t_sample lo;
    t_sample hi;
    lo = ftofix(x->x_lo);
    hi = ftofix(x->x_hi);

    while (n--)
    {
    	t_sample f = *in++;
	if (f < lo) f = lo;
	if (f > hi) f = hi;
    	*out++ = f;
    }
    return (w+5);
}
Пример #23
0
bool C4ValueProviderAction::Execute()
{
	// Object might have been removed
	if(!Object) return false;

	const C4Action& Action = Object->Action;
	C4PropList* pActionDef = Object->GetAction();

	// TODO: We could cache these...
	const StdMeshAnimation* animation = Action.Animation->GetAnimation();
	const int32_t length = pActionDef->GetPropertyInt(P_Length);
	const int32_t delay = pActionDef->GetPropertyInt(P_Delay);

	if (delay)
		Value = itofix(Action.Phase * delay + Action.PhaseDelay) * ftofix(animation->Length) / (delay * length);
	else
		Value = itofix(Action.Phase) * ftofix(animation->Length) / length;

	return true;
}
void AnimFrame::Draw(BITMAP* bmp, Vector pos, float scale, bool vertical_flip, float rotation, int alpha)
{
    BITMAP* graphic = (BITMAP*)global_datafile[graphic_id].dat;
    if (graphic == NULL) {
        erlog("Graphic ID out of bounds in frame draw", 3);
        return;
    }
    if (bmp == NULL) {
        erlog("Buffer out of bounds in frame draw", 3);
        return;
    }
    if (scale == 0.0 && vertical_flip == false && rotation == 0.0 && (alpha >= 256 || alpha < 0)) {
        draw_sprite(bmp, graphic, pos.XInt(), pos.YInt());
        return;
    }
    if (alpha >= 256 || alpha < 0) {
        if (vertical_flip == false) {
            rotate_scaled_sprite(bmp, graphic, pos.XInt(), pos.YInt(), fixmul(ftofix(rotation), radtofix_r), ftofix(scale));
            return;
        }
        rotate_scaled_sprite_v_flip(bmp, graphic, pos.XInt(), pos.YInt(), fixmul(ftofix(rotation), radtofix_r), ftofix(scale));
        return;
    }


    float fdiagonal = sqrt(static_cast<float>(graphic->w*graphic->w + graphic->h*graphic->h));
    int diagonal = static_cast<int>(fdiagonal + 1);
    BITMAP* temp_bmp = create_bitmap(diagonal, diagonal);

    if (vertical_flip == false) {
        rotate_scaled_sprite(temp_bmp, graphic, 0, 0, fixmul(ftofix(rotation), radtofix_r), ftofix(scale));
    }
    else {
        rotate_scaled_sprite_v_flip(temp_bmp, graphic, 0, 0, fixmul(ftofix(rotation), radtofix_r), ftofix(scale));
    }

    set_trans_blender(0, 0, 0, alpha);
    drawing_mode(DRAW_MODE_TRANS, 0, 0, 0);
    draw_trans_sprite(temp_bmp, bmp, pos.XInt(), pos.YInt());
    drawing_mode(DRAW_MODE_SOLID, 0, 0, 0);
}
Пример #25
0
int ShowSpline(int move_selected)
{

node_count=dock_moves_contains_steps[move_selected];
curviness = ftofix(spline_ratio[move_selected]);
calc_tangents();
if(GotoMoves[move_selected][actual_step_node]==0 || index_move_back==1)
{
draw_splines(move_selected);
}//l attribution des pas est fait dans drawsplines
return(0);
}
Пример #26
0
bool StdMeshUpdate::UpdateAnimationNode(StdMeshInstance* instance, const StdMesh& new_mesh, StdMeshInstance::AnimationNode* node) const
{
	switch (node->GetType())
	{
	case StdMeshInstance::AnimationNode::LeafNode:
		{
			// Find dead animation
			std::map<const StdMeshAnimation*, StdCopyStrBuf>::const_iterator iter = AnimationNames.find(node->Leaf.Animation);
			assert(iter != AnimationNames.end());

			// Update to new animation
			node->Leaf.Animation = new_mesh.GetSkeleton().GetAnimationByName(iter->second);
			if(!node->Leaf.Animation) return false;

			// Clamp provider value
			StdMeshInstance::ValueProvider* provider = node->GetPositionProvider();
			C4Real min = Fix0;
			C4Real max = ftofix(node->GetAnimation()->Length);
			provider->Value = BoundBy(provider->Value, min, max);
			return true;
		}
	case StdMeshInstance::AnimationNode::CustomNode:
		{
			// Update bone index by bone name
			StdCopyStrBuf bone_name = BoneNamesByIndex[node->Custom.BoneIndex];
			const StdMeshBone* bone = new_mesh.GetSkeleton().GetBoneByName(bone_name);
			if(!bone) return false;
			node->Custom.BoneIndex = bone->Index;
			return true;
		}
	case StdMeshInstance::AnimationNode::LinearInterpolationNode:
		{
			const bool left_result = UpdateAnimationNode(instance, new_mesh, node->GetLeftChild());
			const bool right_result = UpdateAnimationNode(instance, new_mesh, node->GetRightChild());

			// Remove this node completely
			if (!left_result && !right_result)
				return false;

			// Note that either of this also removes this node (and replaces by
			// the other child in the tree).
			if (!left_result)
				instance->StopAnimation(node->GetLeftChild());
			if (!right_result)
				instance->StopAnimation(node->GetRightChild());

			return true;
		}
	default:
		assert(false);
		return false;
	}
}
int SplineCurve()
{

    curve_node_count=6;
    curve_curviness = ftofix(curve_spline_level);
    curve_calc_tangents();
//allegro_gl_set_allegro_mode(); //melange gl et allegro screen
    curve_draw_splines();//l attribution des pas est fait dans drawsplines
//allegro_gl_unset_allegro_mode(); //melange gl et allegro screen
    view_curve_after_draw();
    return(0);
}
Пример #28
0
 Player::Player(int _bodyColor, int _faceColor, int _lengthX, int _lengthY, int _maxHealth): 
                                                 Object(_lengthX, _lengthY, 4),
                                                 C(bodyColor), C(faceColor),
                                                 dir(rand() % 4), C(maxHealth) {
     health = maxHealth;
     
     rectfill(sprites[0], 0, 0, lengthX, lengthY, bodyColor);
     rectfill(sprites[0], 7 * lengthX / 8, lengthY / 5,
                          lengthX, 4 * lengthY / 5,
                          faceColor);
     for(int i = 1; i < 4; i++)
         rotate_sprite(sprites[i], sprites[0], 0, 0, ftofix(i * 64));
 }
Пример #29
0
static void sigbiquad_list(t_sigbiquad *x, t_symbol *s, int argc, t_atom *argv)
{
#ifdef ROCKBOX
    (void) s;
#endif

    float fb1 = atom_getfloatarg(0, argc, argv);
    float fb2 = atom_getfloatarg(1, argc, argv);
    float ff1 = atom_getfloatarg(2, argc, argv);
    float ff2 = atom_getfloatarg(3, argc, argv);
    float ff3 = atom_getfloatarg(4, argc, argv);
    float discriminant = fb1 * fb1 + 4 * fb2;

    t_biquadctl *c = x->x_ctl;
    if (discriminant < 0) /* imaginary roots -- resonant filter */
    {
    	    /* they're conjugates so we just check that the product
    	    is less than one */
    	if (fb2 >= -1.0f) goto stable;
    }
    else    /* real roots */
    {
    	    /* check that the parabola 1 - fb1 x - fb2 x^2 has a
    	    	vertex between -1 and 1, and that it's nonnegative
    	    	at both ends, which implies both roots are in [1-,1]. */
    	if (fb1 <= 2.0f && fb1 >= -2.0f &&
    	    1.0f - fb1 -fb2 >= 0 && 1.0f + fb1 - fb2 >= 0)
    	    	goto stable;
    }
    	/* if unstable, just bash to zero */
    fb1 = fb2 = ff1 = ff2 = ff3 = 0;
stable:
    c->c_fb1 = ftofix(fb1);
    c->c_fb2 = ftofix(fb2);
    c->c_ff1 = ftofix(ff1);
    c->c_ff2 = ftofix(ff2);
    c->c_ff3 = ftofix(ff3);
}
Пример #30
0
/* get_vector_rotation_matrix:
 *  Constructs a 3d transformation matrix, which will rotate points around
 *  the specified x,y,z vector by the specified angle (given in the Allegro 
 *  fixed point, 256 degrees to a circle format), in a clockwise direction.
 */
void get_vector_rotation_matrix(MATRIX *m, fixed x, fixed y, fixed z, fixed a)
{
   MATRIX_f rotation;
   int i, j;
   ASSERT(m);

   get_vector_rotation_matrix_f(&rotation, fixtof(x), fixtof(y), fixtof(z), fixtof(a));

   for (i=0; i<3; i++)
      for (j=0; j<3; j++)
	 m->v[i][j] = ftofix(rotation.v[i][j]);

   m->t[0] = m->t[1] = m->t[2] = 0;
}