void update_random_value(int type,int type_num,int motion_type)
{
    float random_walk_value = 0.1;
    float random_rotate_value = 0.025;
    switch(motion_type)
    {
    case 0:
        update_values(0,-random_walk_value,0,-random_walk_value,type,type_num);
        break;
    case 1:
        update_values(0,random_walk_value,0,random_walk_value,type,type_num);
        break;
    case 2:
        update_values(-random_walk_value,0,-random_walk_value,0,type,type_num);
        break;
    case 3:
        update_values(random_walk_value,0,random_walk_value,0,type,type_num);
        break;
    case 4:
        rotate_object(-atan(random_rotate_value),-1,type,type_num);
        break;
    case 5:
        rotate_object(atan(random_rotate_value),1,type,type_num);
        break;
    }
    glutPostRedisplay();
}
示例#2
0
bool map_object::rotate_object_sticky_cardinal(int rot){
	bool intercardinals = false;
	vector<int> sticky_angles;
	sticky_angles.push_back(0);
	if(intercardinals)
		sticky_angles.push_back(45);
	sticky_angles.push_back(90);
	if(intercardinals)
		sticky_angles.push_back(135);
	sticky_angles.push_back(180);
	if(intercardinals)
		sticky_angles.push_back(225);
	sticky_angles.push_back(270);

	int newrot = rot;

	for(vector<int>::iterator itr = sticky_angles.begin(); itr!=sticky_angles.end(); itr++){
		if(rot >= (*itr)-15 && rot <= (*itr)+15){
			newrot = *itr;
		}
	}

	rotate_object(newrot);

	return true;
}
示例#3
0
static void rotate_robot(double heading)
{
    if(!isnan(heading))
    {
        printf("%s: rotating at angle %f\n", __func__, heading);
        rotate_object(heading);
    }
}
示例#4
0
bool map_object::rotate_object_by(int rot){
	if(actual_rotation == 0){actual_rotation = rotations[0];}
	actual_rotation = actual_rotation+rot;

	while(actual_rotation < 0){actual_rotation += 360;}
	while(actual_rotation > 360){actual_rotation -= 360;}

	rotate_object(actual_rotation);
	return true;
}
示例#5
0
文件: STARS.C 项目: sickill/canvator
int main()
{
   clock_t t;
   long fr;

   for (int k=0; k<64000; k++) back[k] = back[k] / 7;

   srand(666);
   if (!add_stars()) { printf("err\n"); exit(1); }

	open_vid();
//   set_mode(0x13);
//   for (int i=0; i<256; i++) set_col(i, i/12, i/8, i/4);

   translate_object(stars, 0.0, 0.0, 2.0);

   fr = 0;
   t = clock();
	while (!ptc_console_key(console))
   {
//      memfill_d((long)screen, 16000, 0);
//      memcopy_d((long)back, (long)screen, 16000);
	memcpy(screen, back, 64000);
//      memset(screen, 0, 64000);
      rotate_object_local(stars);
      cast_object(stars);
      vis_object(stars);
      render_object(stars);
      alfa();
//      memcpy((char *)0xA0000, old_screen, 64000);
//      memcopy_d((long)old_screen, 0xA0000, 16000);
	show(old_screen);

      rotate_object(stars, 9, 9, 9);
      fr++;
   }
   t = clock() - t;
//   getch();

	close_vid();
//   set_mode(3);
   printf("f/s = %f\n", ((float)fr * CLOCKS_PER_SEC / (float)t));
   return 0;
}
示例#6
0
int ObjectChangeRotation()
{
	return rotate_object(vobjptridx(Cur_object_index), p, b, h);
}
void handle_keyboard_keys(unsigned char key ,int x ,int y)
{
    if(key == 27 || key == 'q')
    {
        save_world();
        exit(0);
    }
    if(key == 'z')
    {
        random_walk_mode = random_walk_mode?0:1;
    }
    if(key == 't')
    {
        light_transport_mode = light_transport_mode?0:1;
        update_timer = light_transport_mode?200:10;
    }
    if(key == 'g')
    {
        gaze_cursor_mode = gaze_cursor_mode?0:1;
    }
    if(key == 'p')
    {
        //Enter/Exit Play Game Mode
    }
    if(key == 'r')
    {
        rotate_object(-atan(rotat_val),-1,select_type,select_number);
    }
    if(key == 'l')
    {
        rotate_object(atan(rotat_val),1,select_type,select_number);
    }
    if(key == 'f')
    {
        trans_val += 0.2;
        rotat_val += 0.1;
    }
    if(key == 's')
    {
        trans_val -= 0.2;
        if(trans_val < 0.0)
            trans_val = 0.2;
        rotat_val -= 0.1;
        if(rotat_val < 0.0)
            rotat_val = 0.1;
    }
    if(key == 'b')
    {
        //Insert Block
    }
    if(key == 'm')
    {
        //Insert Mirror
    }
    if(key == 'o')
    {
        //Insert Projector
    }
    if(key == 'c')
    {
        if(select_type == PROJECTOR)
        {
            if(select_number == num_projectors-1 || num_projectors == 0)
            {
                select_number = 0;
                select_type = BLOCK;
            }
            else
                select_number++;
        }
        else if(select_type == BLOCK)
        {
            if(select_number == num_blocks-1 || num_blocks == 0)
            {
                select_number = 0;
                select_type = MIRROR;
            }
            else
                select_number++;
        }
        else
        {
            if(select_number == num_mirrors-1 || num_mirrors == 0)
            {
                select_number = 0;
                select_type = PROJECTOR;
            }
            else
                select_number++;
        }
    }
}
示例#8
0
int ObjectIncreaseHeadingBig()	{return rotate_object(Cur_object_index, 0, 0, (ROTATION_UNIT*4));}
示例#9
0
int ObjectIncreasePitchBig()		{return rotate_object(Cur_object_index, (ROTATION_UNIT*4), 0, 0);}
示例#10
0
int ObjectDecreaseBankBig()		{return rotate_object(Cur_object_index, 0, -(ROTATION_UNIT*4), 0);}
示例#11
0
int ObjectDecreaseHeading()	{return rotate_object(Cur_object_index, 0, 0, -ROTATION_UNIT);}
示例#12
0
int ObjectIncreasePitch()		{return rotate_object(Cur_object_index, ROTATION_UNIT, 0, 0);}
示例#13
0
int ObjectIncreaseBank()		{return rotate_object(Cur_object_index, 0, ROTATION_UNIT, 0);}