Example #1
0
//----------------------------------------------------------------------------------------------------------------------
//   INIT
//----------------------------------------------------------------------------------------------------------------------
void cListViewComputers::init ()
{
	assert ( 0 < iQtyColumns );
	set_view ( LVS_REPORT ); // LVS_REPORT
	// INSERT COLUMNS
	// AT LEAST ONE MUST BE INSERTED FOR THE CONTROL TO BE VISIBLE

	LVCOLUMN lc;

    memset ( &lc, 0, sizeof(lc) ); 
	lc.mask= LVCF_TEXT | LVCF_WIDTH | LVCF_SUBITEM;    // Type of mask
	lc.pszText = L"ComputerX name";                     // First Header
	lc.cx = 150;

	SendMessage ( hwnd, LVM_INSERTCOLUMN, 0, (LPARAM) &lc );

	if ( 2 <= iQtyColumns )
	{
		lc.pszText = L"IP address";
		SendMessage ( hwnd, LVM_INSERTCOLUMN, 1, (LPARAM) &lc );
	}

	if ( 3 <= iQtyColumns )
	{
		lc.pszText = L"Status";
		lc.cx = 250;
		SendMessage ( hwnd, LVM_INSERTCOLUMN, 2, (LPARAM) &lc );
	}

	insert_image_lists ( hwnd );
	set_view ( LVS_REPORT ); // LVS_REPORT
	set_view ( LVS_ICON ); // LVS_REPORT
	ShowWindow ( hwnd, SW_NORMAL );
}
Example #2
0
bool file_location_go(struct file_location *loc)
{
	struct window *w = window;
	struct view *v = window_open_buffer(w, loc->filename, true, NULL);
	bool ok = true;

	if (!v) {
		// failed to open file. error message should be visible
		return false;
	}
	if (w->view != v) {
		set_view(v);
		// force centering view to the cursor because file changed
		v->force_center = true;
	}
	if (loc->pattern != NULL) {
		bool err = false;
		search_tag(loc->pattern, &err);
		ok = !err;
	} else if (loc->line > 0) {
		move_to_line(v, loc->line);
		if (loc->column > 0) {
			move_to_column(v, loc->column);
		}
	}
	return ok;
}
Example #3
0
bool file_location_return(struct file_location *loc)
{
	struct window *w = window;
	struct buffer *b = find_buffer_by_id(loc->buffer_id);
	struct view *v;

	if (b != NULL) {
		v = window_get_view(w, b);
	} else {
		if (loc->filename == NULL) {
			// Can't restore closed buffer which had no filename.
			// Try again.
			return false;
		}
		v = window_open_buffer(w, loc->filename, true, NULL);
	}
	if (v == NULL) {
		// Open failed. Don't try again.
		return true;
	}
	set_view(v);
	move_to_line(v, loc->line);
	move_to_column(v, loc->column);
	return true;
}
Example #4
0
Camera::Camera(int view_mat_location, int proj_mat_location) {
	this->view_mat_location = view_mat_location;
	this->proj_mat_location = proj_mat_location;
	cam_pos = vec3 (0.0f, 0.0f, 5.0f);
	near = 0.1f; // clipping plane
	far = 100.0f; // clipping plane
	fovy = 67.0f; // 67 degrees
	// aspect ratio
	aspect = (float)g_gl_width / (float)g_gl_height;
	proj_mat = perspective (fovy, aspect, near, far);
	cam_speed = 5.0f; // 1 unit per second
	cam_heading_speed = 100.0f; // 30 degrees per second
	cam_heading = 0.0f; // y-rotation in degrees
	T = translate (
		identity_mat4 (), vec3 (-cam_pos.v[0], -cam_pos.v[1], -cam_pos.v[2])
	);
	create_versor (quaternion, -cam_heading, 0.0f, 1.0f, 0.0f);
	// convert the quaternion to a rotation matrix (just an array of 16 floats)
	quat_to_mat4 (R.m, quaternion);
	// combine the inverse rotation and transformation to make a view matrix
	view_mat = R * T;

	fwd = FORWARD;
	rgt = RIGHT;
	up = UP;

	set_view();
	set_proj();

	reset_control();
}
void PlayerInterface::spawnPlayer( unsigned short player_index, const iXY &location )
{
    if ( player_index < max_players )
    {
        SDL_mutexP(mutex);
        if ( player_lists[player_index].getStatus() != _player_state_free )
        {
            UnitInterface::spawnPlayerUnits( location,
                                             player_index,
                                             player_lists[ player_index ].unit_config
                                           );
            
            iXY world_loc;
            MapInterface::mapXYtoPointXY( location, &world_loc );
            if ( getLocalPlayerIndex() == player_index )
            {
                WorldViewInterface::setCameraPosition( world_loc );
            }
            else
            {
                SystemSetPlayerView set_view(world_loc.x, world_loc.y);
                NetworkServer::sendMessage(player_index, &set_view, sizeof(SystemSetPlayerView));
            }
        } // ** if _player_state_active
        SDL_mutexV(mutex);
    }
}
static void
gtk_source_gutter_set_property (GObject       *object,
                                guint          prop_id,
                                const GValue  *value,
                                GParamSpec    *pspec)
{
	GtkSourceGutter *self = GTK_SOURCE_GUTTER (object);

	switch (prop_id)
	{
		case PROP_VIEW:
			set_view (self, GTK_SOURCE_VIEW (g_value_get_object (value)));
			break;
		case PROP_WINDOW_TYPE:
			self->priv->window_type = g_value_get_enum (value);
			break;
		case PROP_XPAD:
			set_xpad (self, g_value_get_int (value), TRUE);
			break;
		case PROP_YPAD:
			set_ypad (self, g_value_get_int (value), TRUE);
			break;
		default:
			G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
			break;
	}
}
Example #7
0
void
cmd_compat(const char *buf)
{
	const char *s;

	if (strcasecmp(buf, "help") == 0) {
		show_help();
		need_update = 1;
		return;
	}
	if (strcasecmp(buf, "quit") == 0 || strcasecmp(buf, "q") == 0) {
		gotsig_close = 1;
		return;
	}
	if (strcasecmp(buf, "stop") == 0) {
		paused = 1;
		gotsig_alarm = 1;
		return;
	}
	if (strncasecmp(buf, "start", 5) == 0) {
		paused = 0;
		gotsig_alarm = 1;
		cmd_delay(buf + 5);
		return;
	}

	for (s = buf; *s && strchr("0123456789+-.eE", *s) != NULL; s++)
		;
	if (*s) {
		if (set_view(buf))
			error("Invalid/ambiguous view: %s", buf);
	} else
		cmd_delay(buf);
}
Example #8
0
int main(int argc,char *argv[])
{
	gtk_init(&argc,&argv);
	system("./get_pass");
	system("./initial.sh");
	FILE *fp=fopen("log.txt","r");
	int i;
	fscanf(fp,"%d",&no_of_services);
	no_of_services=no_of_services-SYSTEM_SERVICES;
	service_info service[no_of_services];
	GtkBuilder *builder;
	builder=gtk_builder_new();
	gtk_builder_add_from_file(builder,"drama.glade",NULL);
	GObject *box,*window1;
	box=gtk_builder_get_object(builder,"box2");
	window1=gtk_builder_get_object(builder,"applicationwindow1");
	for(i=0;i<no_of_services;i++)
	{
		fscanf(fp,"%s %d %d %d %d %d %d %d",service[i].service_name,&service[i].runlevel[0],&service[i].runlevel[1],&service[i].runlevel[2],&service[i].runlevel[3],&service[i].runlevel[4],&service[i].runlevel[5],&service[i].runlevel[6]);
		set_view(&service[i],box);
	}
	fclose(fp);
	
	g_signal_connect (window1, "destroy", G_CALLBACK (final_change), &service[0]);
	gtk_widget_show_all(GTK_WIDGET(box));
	gtk_main();
}
		TITANIUM_PROPERTY_SETTER(Animation, view)
		{
			TITANIUM_ASSERT(argument.IsObject());
			const auto object = static_cast<JSObject>(argument);
			set_view(object.GetPrivate<Titanium::UI::View>());
			return true;
		}
Example #10
0
static void ui_do_fractal(int mode)
{
    int time, time1;
    if (mode < fastmode + 1)
	interruptiblemode = 1;
    else
	interruptiblemode = 0;
    if (tbreak)
	tl_reset_timer(maintimer);
    incalculation = 1;
    starttime1 = 0;
    endtime1 = 0;
    set_view(zcontext, &zcontext->s);
    waitcount = tl_lookup_timer(maintimer) / WAITTIME + 2;
    waitcount1 = tl_lookup_timer(maintimer) / WAITTIME1 + 1;
    do_fractal(zcontext, interruptiblemode);
    bbupdate();
    if (interruptiblemode) {
	bbupdate();
	time1 = time = tl_lookup_timer(maintimer);
	time -= endtime1 - starttime1;
	maxtime = time * 5;
	if (maxtime > 1000000 / 10)
	    maxtime = time * 3;
	if (maxtime < 1000000 / 30)
	    maxtime = 1000000 / 30;
	maxtime -= time1 - endtime1;
    }
    updatestatus();
}
void GameScene::update_camera(float dt)
{
    if (dt == 0)
    {
        return;
    }

    float panlerpratio = camera_pan_lerp_ratio_ * dt;
    float zoomlerpratio = camera_zoom_lerp_ratio_ * dt;

    camera_zoom_ = vector_LERP(camera_zoom_, camera_zoom_target_, zoomlerpratio);

    const sf::View& dft_view = default_view();
    float viewwidth = dft_view.GetRect().GetWidth() / camera_zoom_.x;
    float viewheight = dft_view.GetRect().GetHeight() / camera_zoom_.y;

    sf::FloatRect target(0,0,
        viewwidth, viewheight);

    sf::View new_view(target);

    sf::Vector2f new_pos = vector_LERP(camera_position_, camera_target_, panlerpratio);

    camera_position_ = new_pos;
    new_view.SetCenter(new_pos);
    set_view(new_view);
}
Example #12
0
void EvEve::init()
{
  if ( !list_copied && ala->browbase && copy_list_cb) {
    list_copied = 1;
    (copy_list_cb)( parent_ctx, ala);
    if ( !cdh_ObjidIsNull(view))
      set_view( view);
  }
}
Example #13
0
movable::movable()
{
    sc_x = 1; sc_y = 1; sc_z =1;

    pos_x = 0;
    pos_y = 0;
    pos_z = 0;

    set_view(0, 1, 0);

}
MemoryRenderWidgetHost::MemoryRenderWidgetHost(
        RenderViewHostDelegate *delegate,
        RenderWidgetHostView *wid,
        RenderProcessHost* host,
        int routing_id)
    : MemoryRenderHostImpl<RenderWidgetHost>(host, routing_id) {

    mWindow = static_cast<WindowImpl*>(delegate);
    mWidget = static_cast<RenderWidget*>(wid);

    set_view(wid);
}
Example #15
0
void EvEve::view_shift() 
{
  pwr_sClass_OpPlace *opp;
  pwr_tStatus sts;

  sts = gdh_ObjidToPointer( user, (pwr_tAddress *) &opp);
  if ( EVEN(sts)) return;

  if ( cdh_ObjidIsNull(ala->current_view)) {
    set_view( opp->AlarmViews[0]);
  }
  else {
    for ( unsigned int i = 0; i < sizeof(opp->AlarmViews)/sizeof(opp->AlarmViews[0]); i++) {
      if ( cdh_ObjidIsEqual( ala->current_view, opp->AlarmViews[i])) {
	if ( i == sizeof(opp->AlarmViews)/sizeof(opp->AlarmViews[0]) - 1)
	  set_view( pwr_cNObjid);
	else
	  set_view( opp->AlarmViews[i+1]);
	break;
      }	   
    }
  }
}
Example #16
0
void update(float dt) {
    // Update view
    pitch += 1.2f * dPitch * dt;
    yaw += 1.2f * dYaw * dt;

    set_view(pitch, yaw);

    // Set X/Z velocity depending on input
    velocity.x = velocity.z = 0.0f;

    if (keys[KEY_A] & 1) {
        velocity.x += 3.0f * cosf(M_PI - yaw);
        velocity.z += 3.0f * sinf(M_PI - yaw);
    }
    if (keys[KEY_W] & 1) {
        velocity.x += 3.0f * cosf(-M_PI / 2 - yaw);
        velocity.z += 3.0f * sinf(-M_PI / 2 - yaw);
    }
    if (keys[KEY_S] & 1) {
        velocity.x += 3.0f * cosf(M_PI / 2 - yaw);
        velocity.z += 3.0f * sinf(M_PI / 2 - yaw);
    }
    if (keys[KEY_D] & 1) {
        velocity.x += 3.0f * cosf(-yaw);
        velocity.z += 3.0f * sinf(-yaw);
    }

    // Simulate gravity
    velocity.y -= 20.0f * dt;

    // Handle block collision (head, lower body and feet)
    vec3 headPos = playerPos;
    vec3 lowerPos = playerPos;
    lowerPos.y -= 1.0f;
    vec3 footPos = playerPos;
    footPos.y -= 1.8f;

    handle_collision(headPos, &velocity);
    handle_collision(lowerPos, &velocity);
    handle_collision(footPos, &velocity);

    // Apply motion
    playerPos.x += velocity.x * dt;
    playerPos.y += velocity.y * dt;
    playerPos.z += velocity.z * dt;
}
Example #17
0
static void
gbp_spell_navigator_set_property (GObject      *object,
                                  guint         prop_id,
                                  const GValue *value,
                                  GParamSpec   *pspec)
{
  GbpSpellNavigator *self = GBP_SPELL_NAVIGATOR (object);

  switch (prop_id)
    {
    case PROP_VIEW:
      set_view (self, g_value_get_object (value));
      break;

    default:
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
    }
}
Example #18
0
void player::calc_view () {
    auto _map = this->_ent->_map;
    if (! _map)
        return;

    auto view_x = _map->view_x;
    auto view_y = _map->view_y;

    auto rel_x = this->_ent->x - view_x;
    auto page_w14 = (_map->page_w / 4) - (this->_ent->w / 2);
    auto page_w34 = ((_map->page_w * 3) /4) - (this->_ent->w / 2);
    if (rel_x < page_w14) {
        if (this->_ent->x < page_w14)
            view_x = 0;
        else
            view_x = this->_ent->x - page_w14;
    }
    else if (rel_x > page_w34) {
        view_x = this->_ent->x - page_w34;
    }

    auto rel_y = this->_ent->y - view_y;
    auto page_h14 = (_map->page_h / 4) - (this->_ent->h / 2);
    auto page_h34 = ((_map->page_h * 3) /4) - (this->_ent->h / 2);
    if (rel_y < page_h14) {
        if (this->_ent->y < page_h14)
            view_y = 0;
        else
            view_y = this->_ent->y - page_h14;
    }
    else if (rel_y > page_h34) {
        view_y = this->_ent->y - page_h34;
    }
    
    if ((view_y + _map->page_h) > _map->player_limit_y) {
        view_y = _map->player_limit_y - _map->page_h;
        if (view_y < 0)
            view_y = 0;
    }

    _map->set_view (view_x, view_y); 
}
Example #19
0
void Camera::update() {

	// update view matrix
	if (cam_moved) {
		quat_to_mat4 (R.m, quaternion);

		// checking for fp errors
		//	printf ("dot fwd . up %f\n", dot (fwd, up));
		//	printf ("dot rgt . up %f\n", dot (rgt, up));
		//	printf ("dot fwd . rgt\n %f", dot (fwd, rgt));

		cam_pos += vec3 (fwd) * -move.v[2];
		cam_pos += vec3 (up) * move.v[1];
		cam_pos += vec3 (rgt) * move.v[0];
		T = translate (identity_mat4 (), vec3 (cam_pos));

		view_mat = inverse (R) * inverse (T);
		set_view();
	}
}
// ******************************************************************
void GameManager::spawnPlayer( const PlayerID &player )
{
    sound->stopTankIdle();

    // ** Get a new spawn point and spawn the player **
    iXY spawn_point = MapInterface::getFreeSpawnPoint();
    PlayerInterface::spawnPlayer( player, spawn_point );

    //** Change the location of the view camera to the spawn point **
    iXY world_loc;
    MapInterface::mapXYtoPointXY( spawn_point, &world_loc );
    if ( PlayerInterface::getLocalPlayerIndex() == player.getIndex() ) {
        WorldViewInterface::setCameraPosition( world_loc );
    } else {
        SystemSetPlayerView set_view(world_loc.x, world_loc.y);
        SERVER->sendMessage(player, &set_view, sizeof(SystemSetPlayerView));
    }

    sound->playTankIdle();
}
Example #21
0
int main(int argc, char *argv[])
{
	gchar *message;

	config_file = g_strdup_printf("%s/.gtktermrc", getenv("HOME"));

	bindtextdomain(PACKAGE, LOCALEDIR);
	bind_textdomain_codeset(PACKAGE, "UTF-8");
	textdomain(PACKAGE);

	gtk_init(&argc, &argv);

	create_buffer();

	create_main_window();

	if(read_command_line(argc, argv) < 0)
	{
		delete_buffer();
		exit(1);
	}

	Config_port();

	message = get_port_string();
	Set_window_title(message);
	Set_status_message(message);
	g_free(message);

	add_shortcuts();

	set_view(ASCII_VIEW);

	gtk_main();

	delete_buffer();

	Close_port();

	return 0;
}
void Plugin::viewer_type_listener(const Glib::ustring &viewer_type,
                                  bool force_update)
{
  // Debug code
  //std::cout << "Plugin::viewer_type_listener called!" << std::endl;

  /* Setting viewer type, force_update allows resetting the view even when the
   * type is already correct */
  if (viewer_type == "curve")
  {
    if (force_update || !dynamic_cast<CurveView *>(view.get()))
      set_view(new CurveView(*this));
  }
  else if (viewer_type == "bar")
  {
    // It gets tricky here because them BarView can render 2 viewers.
    // Thus, we much also check the oriententation
    BarView *bar_view = dynamic_cast<BarView *>(view.get());
    if (force_update || !(bar_view && bar_view->is_horizontal()) )
      set_view(new BarView(*this));
  }
  else if (viewer_type == "vbar")
  {
    // Same situation as with "bar"
    BarView *bar_view = dynamic_cast<BarView *>(view.get());
    if (force_update || !(bar_view && !bar_view->is_horizontal()) )
      set_view(new BarView(*this, false));
  }
  else if (viewer_type == "text") {
    if (force_update || !dynamic_cast<TextView *>(view.get()))
      set_view(new TextView(*this));
  }
  else if (viewer_type == "flame") {
    if (force_update || !dynamic_cast<FlameView *>(view.get()))
      set_view(new FlameView(*this));
  }
  else if (viewer_type == "column") {
    if (force_update || !dynamic_cast<ColumnView *>(view.get()))
      set_view(new ColumnView(*this));
  }

  // Make sure the view sets the background
  background_color_listener(background_color);

  // Update recorded viewer type
  this->viewer_type = viewer_type;
}
static void
champlain_path_layer_dispose (GObject *object)
{
  ChamplainPathLayer *self = CHAMPLAIN_PATH_LAYER (object);
  ChamplainPathLayerPrivate *priv = self->priv;

  if (priv->nodes)
    champlain_path_layer_remove_all (CHAMPLAIN_PATH_LAYER (object));

  if (priv->view != NULL)
    set_view (CHAMPLAIN_LAYER (self), NULL);

  if (priv->right_canvas)
    {
      g_object_unref (priv->right_canvas);
      g_object_unref (priv->left_canvas);
      priv->right_canvas = NULL;
      priv->left_canvas = NULL;
    }

  g_clear_pointer (&priv->surface, cairo_surface_destroy);

  G_OBJECT_CLASS (champlain_path_layer_parent_class)->dispose (object);
}
Example #24
0
void
update_view (fractal_context * context)
{
    set_view (context, &context->s);
}
Example #25
0
void Level::load_level(string file)
{
    ifstream fin(file.c_str());

    cout << "Reading " << file << endl;
    
    literal(fin, "left");
    fin >> left;
    literal(fin, "bottom");
    fin >> bottom;
    literal(fin, "right");
    fin >> right;
    literal(fin, "top");
    fin >> top;

    vec p1pos, p2pos;
    literal(fin, "p1");
    fin >> p1pos.x >> p1pos.y;
    literal(fin, "p2");
    fin >> p2pos.x >> p2pos.y;

    num gravity;
    literal(fin, "gravity");
    fin >> gravity;

    literal(fin, "ropes");
    fin >> max_ropes;

    literal(fin, "gunspeed");
    fin >> fire_velocity;
    
    int boxes;
    literal(fin, "boxes");
    fin >> boxes;
    
    list<BoxDef> boxen;
    for (int i = 0; i < boxes; i++) {
        BoxDef bx;
        literal(fin, "box");
        fin >> bx.ll.x >> bx.ll.y >> bx.ur.x >> bx.ur.y;
        boxen.push_back(bx);
    }

    cout << "Building level\n";
    
    world = dWorldCreate();
    dWorldSetGravity(world, 0, -gravity, 0);
    collide_space = dSimpleSpaceCreate(0);
    contact_joints = dJointGroupCreate(0);
    
    manager = new ObjectManager;
    p1 = new Player(p1pos, Color(0,0,1));
    manager->add(p1);
    p2 = new Player(p2pos, Color(1,0,0));
    manager->add(p2);

    for (list<BoxDef>::iterator i = boxen.begin(); i != boxen.end(); ++i) {
        manager->add(new Wall(i->ll, i->ur));
    }

    set_view();

    player = P1_SCORE <= P2_SCORE ? p1 : p2;
    stepct_ = 5*int(1/STEP);
}
Example #26
0
void Simulation::command(int cmd)
{
	dMass mass;
	static int view;	// which view was set last
	static std::string input = "";	// input string ("" initially)
	//static dJointID tagging_joint = 0;            // joint that keeps one link static


	if (cmd >= 'A' && cmd <= 'B')
		cmd = cmd + 'a' - 'A';	// lower case
	if (mode == KeyMode) {
		switch (cmd) {
		case keyWriteFrame:
			mywriteframes ^= 1;
			break;
		case keyCreateMainBody:
			if (car->body_obj == 0) {
				car->createBody(center);
				objbin.Add(car->body_obj);
			};
			break;
			// switch mode to input
		case keyInputMode:
			mode = InputMode;
            std::cout << "input: ";
            std::cout.flush();
			break;
			// abandon ship
		case keyBreakWheel:
			car->breakWheel();
			break;
			// change speed
		case keyZeroSpeed:
			s_speed[0] = 0;
			s_speed[1] = 0;
			break;
		case keyRightSpeedIncrease:
			s_speed[1] += 0.1;
			break;
		case keyRightSpeedDecrease:
			s_speed[1] -= 0.1;
			break;
		case keyRightSpeedMax:
			s_speed[1] = max_speed;
			break;
		case keyRightSpeedMin:
			s_speed[1] = min_speed;
			break;
		case keyLeftSpeedIncrease:
			s_speed[0] += 0.1;
			break;
		case keyLeftSpeedDecrease:
			s_speed[0] -= 0.1;
			break;
		case keyLeftSpeedMax:
			s_speed[0] = max_speed;
			break;
		case keyLeftSpeedMin:
			s_speed[0] = min_speed;
			break;
		case keyBothSpeedIncrease:
			s_speed[0] += 0.1;
			s_speed[1] += 0.1;
			break;
		case keyBothSpeedDecrease:
			s_speed[0] -= 0.1;
			s_speed[1] -= 0.1;
			break;
		case keyBothSpeedMax:
			s_speed[0] = max_speed;
			s_speed[1] = max_speed;
			break;
		case keyBothSpeedMin:
			s_speed[0] = min_speed;
			s_speed[1] = min_speed;
			break;
			// do the twitch
		case keyTwitchToggle:
			twitch_flag = 1 - twitch_flag;
			break;
		case keyTwitchHertzHalf:
			twitch_hertz /= 2.0;
			break;
		case keyTwitchHertzDouble:
			twitch_hertz *= 2.0;
			break;
			// camera views change
		case keyAimCamera:
			aimCamera(camera_object);
			break;
		case keyLockCameraToVehicle: // only pos, not orientation so far
			lockCamera = 1 - lockCamera;
			float xyz[3], hpr[3];
			dsGetViewpoint(xyz, hpr);
			dBodyGetPosRelPoint(camera_object, xyz[0], xyz[1], xyz[2], cameraRelVec);	// returns point in body relative coordinates
			break;
		case keyIncreaseViewByTwoMod:
			view = (view + 2) % set_view(-1);
			set_view(view);
			break;
		case keyIncreaseViewByOneMod:
			view = (view + 1) % set_view(-1);
			set_view(view);
			break;
			// show speed and wanted speed (uncorrect when in twitch mode)
		case keyDisplayWheels:
			for (int i = 0 ; i  < 4 ; ++i)
				car->wheel_obj[i]->toggleDrawFlag();
		case keyPrintSprocketMass:
			car->getSprocketMass(&mass);
			printf("mass %3.3f %3.3f %3.3f %3.3f\n",
			       mass.mass, mass.I[0], mass.I[5],
			       mass.I[10]);
			break;
		case keyPrintManyVariables:
			printf
			    ("s_speed %3.3f | actual %3.3f | hertz %3.3f | time %3.3f | lv %d\n",
			     s_speed[0], car->getSprocketSpeed(),
			     twitch_hertz, dStopwatchTime(&timer), view);
			break;
		case keyEnterMovieMode:
			enterMovieMode();
			automat = new AutoEventFinish(simTime, event_time, m_myMachine, finish_time, m_exitMachine, camera_object);	// create automat
			break;
		};
		if (cmd >= '0' && cmd < ('0' + LINK_PARTS))
			Chain::showbit[cmd - '0'] =
			    1 - Chain::showbit[cmd - '0'];
		for (int i = 0; i < 2; ++i)
			s_speed[i] =
			    BRACKET(s_speed[i], min_speed, max_speed);
	} else if (mode == InputMode) {
		// switch mode to single key
		if (cmd == ' ') {
			mode = KeyMode;
			//process (input);
            std::istringstream s(input);
			int tagged_link;
			s >> tagged_link;
			/*
			   tagged_link = BRACKET(tagged_link, 0, chain_obj[0]->b_num - 1);
			   if (tagging_joint != 0) // delete old
			   dJointDestroy(tagging_joint);
			   tagging_joint = dJointCreateFixed(world, 0);
			   dJointAttach(tagging_joint, chain_obj[0]->body[tagged_link], 0);
			   dJointSetFixed(tagging_joint);
			 */
            std::cout << "\n";
			// reset input
			input = "";
		} else {
Example #27
0
void movable::init(float pos_x, float pos_y,float pos_z,
     float view_x, float view_y, float view_z)
{
   this->pos_x = pos_x; this->pos_y = pos_y; this->pos_z = pos_z;
   set_view(view_x, view_y, view_z);
}
Example #28
0
int
main(int argc, char *argv[])
{
	char errbuf[_POSIX2_LINE_MAX];
	extern char *optarg;
	extern int optind;
	double delay = 5;

	char *viewstr = NULL;

	gid_t gid;
	int countmax = 0;
	int maxlines = 0;

	int ch;

	ut = open(_PATH_UTMP, O_RDONLY);
	if (ut < 0) {
		warn("No utmp");
	}

	kd = kvm_openfiles(NULL, NULL, NULL, O_RDONLY, errbuf);

	gid = getgid();
	if (setresgid(gid, gid, gid) == -1)
		err(1, "setresgid");

	while ((ch = getopt(argc, argv, "BNabd:ins:w:")) != -1) {
		switch (ch) {
		case 'a':
			maxlines = -1;
			break;
		case 'B':
			averageonly = 1;
			if (countmax < 2)
				countmax = 2;
			/* FALLTHROUGH */
		case 'b':
			rawmode = 1;
			interactive = 0;
			break;
		case 'd':
			countmax = atoi(optarg);
			if (countmax < 0)
				countmax = 0;
			break;
		case 'i':
			interactive = 1;
			break;
		case 'N':
			nflag = 0;
			break;
		case 'n':
			/* this is a noop, -n is the default */
			nflag = 1;
			break;
		case 's':
			delay = atof(optarg);
			if (delay <= 0)
				delay = 5;
			break;
		case 'w':
			rawwidth = atoi(optarg);
			if (rawwidth < 1)
				rawwidth = DEFAULT_WIDTH;
			if (rawwidth >= MAX_LINE_BUF)
				rawwidth = MAX_LINE_BUF - 1;
			break;
		default:
			usage();
			/* NOTREACHED */
		}
	}

	if (kd == NULL)
		warnx("kvm_openfiles: %s", errbuf);

	argc -= optind;
	argv += optind;

	if (argc == 1) {
		double del = atof(argv[0]);
		if (del == 0)
			viewstr = argv[0];
		else
			delay = del;
	} else if (argc == 2) {
		viewstr = argv[0];
		delay = atof(argv[1]);
		if (delay <= 0)
			delay = 5;
	}

	udelay = (useconds_t)(delay * 1000000.0);
	if (udelay < 1)
		udelay = 1;

	naptime = (double)udelay / 1000000.0;

	gethostname(hostname, sizeof (hostname));
	gethz();

	initialize();

	set_order(NULL);
	if (viewstr && set_view(viewstr)) {
		fprintf(stderr, "Unknown/ambiguous view name: %s\n", viewstr);
		return 1;
	}

	if (check_termcap()) {
		rawmode = 1;
		interactive = 0;
	}

	setup_term(maxlines);

	if (rawmode && countmax == 0)
		countmax = 1;

	gotsig_alarm = 1;

	engine_loop(countmax);

	return 0;
}
Example #29
0
File: view.cpp Project: nobbk/copo
/// reset camera
void
view::reset_camera()	{
	cgv::math::linalg::fix_col_vec<float,4> target(0.0f);
	set_view(-45.0f, 45.0f, 50.0f, target);
}
Example #30
0
int load_game(char* s)
{
	int i, ver, vt_entries = MAX_VIEWTABLE;
	UINT8 t;
	SINT16 parm[7];
	char sig[8];
	char id[8];
	char description[256];
	FILE *f = fopen(s, "rb");

	if(!f)
		return err_BadFileOpen;

	read_bytes(f, sig, 8);
	if (strncmp (sig, strSig, 8)) {
		fclose(f);
		return err_BadFileOpen;
	}

	read_string (f, description);

	ver = read_uint8(f);
	if (ver == 0)
		vt_entries = 64;
	game.state = read_uint8(f);
	/* game.name - not saved */
	read_string(f, id);
	if(strcmp(id, game.id)) {
		fclose(f);
		return err_BadFileOpen;
	}
	/* game.crc - not saved */

	for (i = 0; i < MAX_FLAGS; i++)
		game.flags[i] = read_uint8(f);
	for (i = 0; i < MAX_VARS; i++)
		game.vars[i] = read_uint8(f);

	game.horizon = read_sint16(f);
	game.line_status = read_sint16(f);
	game.line_user_input = read_sint16(f);
	game.line_min_print = read_sint16(f);

	/* These are never saved */
	game.cursor_pos = 0;
	game.input_buffer[0] = 0;
	game.echo_buffer[0] = 0;
	game.keypress = 0;

	game.input_mode = read_sint16(f);
	game.lognum = read_sint16(f);

	game.player_control = read_sint16(f);
	game.quit_prog_now = read_sint16(f);
	game.status_line = read_sint16(f);
	game.clock_enabled = read_sint16(f);
	game.exit_all_logics = read_sint16(f);
	game.picture_shown = read_sint16(f);
	game.has_prompt = read_sint16(f);
	game.game_flags = read_sint16(f);
	game.input_enabled = !read_sint16(f);

	for (i = 0; i < _HEIGHT; i++)
		game.pri_table[i] = read_uint8(f);

	if(game.has_window)
		close_window();
	game.msg_box_ticks = 0;
	game.block.active = FALSE;
	/* game.window - fixed by close_window() */
	/* game.has_window - fixed by close_window() */

	game.gfx_mode = read_sint16(f);
	game.cursor_char = read_uint8(f);
	game.color_fg = read_sint16(f);
	game.color_bg = read_sint16(f);

	/* game.hires (#ifdef USE_HIRES) - rebuilt from image stack */
	/* game.sbuf - rebuilt from image stack */

	/* game.ego_words - fixed by clean_input */
	/* game.num_ego_words - fixed by clean_input */

	game.num_objects = read_sint16(f);
	for(i = 0; i < (SINT16)game.num_objects; i++)
		object_set_location(i, read_sint16(f));

	/* Those are not serialized */
	for (i = 0; i < MAX_DIRS; i++) {
		game.ev_keyp[i].occured = FALSE;
	}

	for (i = 0; i < MAX_STRINGS; i++)
		read_string (f, game.strings[i]);

	for (i = 0; i < MAX_DIRS; i++) {
		if(read_uint8(f) & RES_LOADED)
			agi_load_resource (rLOGIC, i);
		else
			agi_unload_resource (rLOGIC, i);
		game.logics[i].sIP = read_sint16(f);
		game.logics[i].cIP = read_sint16(f);
	}

	for (i = 0; i < MAX_DIRS; i++) {
		if(read_uint8(f) & RES_LOADED)
			agi_load_resource(rPICTURE, i);
		else
			agi_unload_resource(rPICTURE, i);
	}

	for (i = 0; i < MAX_DIRS; i++) {
		if(read_uint8(f) & RES_LOADED)
			agi_load_resource(rVIEW, i);
		else
			agi_unload_resource(rVIEW, i);
	}

	for(i = 0; i < MAX_DIRS; i++) {
		if(read_uint8(f) & RES_LOADED)
			agi_load_resource(rSOUND, i);
		else
			agi_unload_resource(rSOUND, i);
	}

	/* game.pictures - loaded above */
	/* game.logics - loaded above */
	/* game.views - loaded above */
	/* game.sounds - loaded above */

	for (i = 0; i < vt_entries; i++) {
		struct vt_entry* v = &game.view_table[i];

		v->step_time = read_uint8(f);
		v->step_time_count = read_uint8(f);
		v->entry = read_uint8(f);
		v->x_pos = read_sint16(f);
		v->y_pos = read_sint16(f);
		v->current_view = read_uint8(f);

		/* v->view_data - fixed below  */

		v->current_loop = read_uint8(f);
		v->num_loops = read_uint8(f);

		/* v->loop_data - fixed below  */

		v->current_cel = read_uint8(f);
		v->num_cels = read_uint8(f);

		/* v->cel_data - fixed below  */
		/* v->cel_data_2 - fixed below  */
		
		v->x_pos2 = read_sint16(f);
		v->y_pos2 = read_sint16(f);

		/* v->s - fixed below */

		v->x_size = read_sint16(f);
		v->y_size = read_sint16(f);
		v->step_size = read_uint8(f);
		v->cycle_time = read_uint8(f);
		v->cycle_time_count = read_uint8(f);
		v->direction = read_uint8(f);

		v->motion = read_uint8(f);
		v->cycle = read_uint8(f);
		v->priority = read_uint8(f);

		v->flags = read_uint16(f);
		
		v->parm1 = read_uint8(f);
		v->parm2 = read_uint8(f);
		v->parm3 = read_uint8(f);
		v->parm4 = read_uint8(f);
	}
	for (i = vt_entries; i < MAX_VIEWTABLE; i++) {
		memset (&game.view_table[i], 0, sizeof (struct vt_entry));
	}

	/* Fix some pointers in viewtable */

	for (i = 0; i < MAX_VIEWTABLE; i++) {
		struct vt_entry* v = &game.view_table[i];

		if(game.dir_view[v->current_view].offset == _EMPTY)
			continue;

		if(!(game.dir_view[v->current_view].flags & RES_LOADED))
			agi_load_resource(rVIEW, v->current_view);

		set_view(v, v->current_view); /* Fix v->view_data */
		set_loop(v, v->current_loop); /* Fix v->loop_data */
		set_cel(v, v->current_cel);   /* Fix v->cel_data */
		v->cel_data_2 = v->cel_data;
		v->s = NULL;		/* not sure if it is used... */
	}

	erase_both();

	/* Clear input line */
	clear_screen(0);
	write_status();

	/* Recreate background from saved image stack */
	clear_image_stack();
	while ((t = read_uint8(f)) != 0) {
		for (i = 0; i < 7; i++)
			parm[i] = read_sint16(f);
		replay_image_stack_call (t, parm[0], parm[1], parm[2],
			parm[3], parm[4], parm[5], parm[6]);
	}

	fclose(f);

	setflag(F_restore_just_ran, TRUE);

	game.has_prompt = 0;	/* force input line repaint if necessary*/
	clean_input();
	
	erase_both();
	blit_both();
	commit_both();
	show_pic();
	do_update();

	return err_OK;
}