Ejemplo n.º 1
0
    void onMove(int dx, int dy)    
    {
        get_scene()->cam()->move(math::vec3(dx * 0.03,dy * 0.05,0));
        auto p = get_scene()->cam()->pos();

        PRINT(p.x,":",p.y,":",p.z);
    };
Ejemplo n.º 2
0
	void on_frame(unsigned int dt)
	{
        get_scene().process(dt);
        get_scene().draw();

	    m_ui.process(dt);
        m_ui.draw();

	    static unsigned int fps_counter=0;
	    static unsigned int fps_update_timer=0;

	    ++fps_counter;

	    fps_update_timer+=dt;
	    if(fps_update_timer>1000)
	    {
            char name[255];
            sprintf(name,"npl2 %d fps",fps_counter);
            set_title(name);

            //nya_log::log()<<name<<"\n";

            fps_update_timer%=1000;
            fps_counter=0;
	    }
	}
Ejemplo n.º 3
0
void Viewport::unhandled_input(const InputEvent& p_event) {

	ERR_FAIL_COND(!is_inside_scene());

	get_scene()->_call_input_pause(unhandled_input_group,"_unhandled_input",p_event);
	//call_group(GROUP_CALL_REVERSE|GROUP_CALL_REALTIME|GROUP_CALL_MULIILEVEL,"unhandled_input","_unhandled_input",ev);
	if (!get_scene()->input_handled && p_event.type==InputEvent::KEY) {
		get_scene()->_call_input_pause(unhandled_key_input_group,"_unhandled_key_input",p_event);
		//call_group(GROUP_CALL_REVERSE|GROUP_CALL_REALTIME|GROUP_CALL_MULIILEVEL,"unhandled_key_input","_unhandled_key_input",ev);
	}
}
Ejemplo n.º 4
0
void RayCast2D::set_cast_to(const Vector2& p_point) {

	cast_to=p_point;
	if (is_inside_scene() && get_scene()->is_editor_hint())
		update();

}
Ejemplo n.º 5
0
	void on_free() 
    {
        nya_log::log()<<"on_free\n";
        
        get_scene().release();
        m_ui.release();
    }
Ejemplo n.º 6
0
void Spatial::_propagate_transform_changed(Spatial *p_origin) {

	if (!is_inside_scene()) {
		return;
	}

//	if (data.dirty&DIRTY_GLOBAL)
//		return; //already dirty

	data.children_lock++;
		
	for (List<Spatial*>::Element *E=data.children.front();E;E=E->next()) {
	
		if (E->get()->data.toplevel_active)
			continue; //don't propagate to a toplevel
		E->get()->_propagate_transform_changed(p_origin);
	}
	

	if (!data.ignore_notification && !xform_change.in_list()) {

		get_scene()->xform_change_list.add(&xform_change);

	}
	data.dirty|=DIRTY_GLOBAL;

	data.children_lock--;
}
Ejemplo n.º 7
0
bool Camera::_get(const StringName& p_name,Variant &r_ret) const {

	if (p_name=="projection") {
		r_ret= mode;
	} else if (p_name=="fov" || p_name=="fovy" || p_name=="fovx")
		r_ret= fov;
	else if (p_name=="size" || p_name=="sizex" || p_name=="sizey")
		r_ret= size;
	else if (p_name=="near")
		r_ret= near;
	else if (p_name=="far")
		r_ret= far;
	else if (p_name=="keep_aspect")
		r_ret= int(keep_aspect);
	else if (p_name=="current") {

		if (is_inside_scene() && get_scene()->is_editor_hint()) {
			r_ret=current;
		} else {
			r_ret=is_current();
		}
	} else if (p_name=="visible_layers") {
		r_ret=get_visible_layers();
	} else if (p_name=="environment") {
		r_ret=get_environment();
	} else
		return false;

	return true;
}
        bool osg_visualization_t::run()
        {
            PRX_ASSERT(initialized);

            //    bool init = false;
            sys_clock_t timer;
            // Listens for updates to rigid body configurations.
            osg_scene = dynamic_cast<osg_scene_t*>(get_scene());

            while( ros::ok() && !viewer.done() )
            {
                //        ros::getGlobalCallbackQueue()->callAvailable();
                ros::getGlobalCallbackQueue()->callAvailable(ros::WallDuration(0.001));
                update_configurations(*listener, *osg_scene);

                for (unsigned i = 0; i <window_screenshot_queue.size(); i++)
                {
                    viewer.take_screenshot(window_screenshot_queue[i].first, window_screenshot_queue[i].second );
                }
                viewer.frame();
                
                window_screenshot_queue.clear();

                //        if(!init || timer.measure() > 5)
                //        {
                //            comm->poll_topics();
                //            timer.reset();
                //            init = true;
                //        }
            }
            return true;
        }
Ejemplo n.º 9
0
void ProjectManager::_open_project() {


	if (selected=="") {
		return;
	}

	String path = EditorSettings::get_singleton()->get("projects/"+selected);
	print_line("OPENING: "+path+" ("+selected+")");

	List<String> args;


	args.push_back("-path");
	args.push_back(path);

	args.push_back("-editor");

	if (selected_main!="") {
		args.push_back(selected_main);
	}

	String exec = OS::get_singleton()->get_executable_path();

	OS::ProcessID pid=0;
	Error err = OS::get_singleton()->execute(exec,args,false,&pid);
	ERR_FAIL_COND(err);

	get_scene()->quit();

}
Ejemplo n.º 10
0
void ProjectManager::_open_project_confirm() {

	for (Map<String,String>::Element *E=selected_list.front(); E; E=E->next()) {
		const String &selected = E->key();
		String path = EditorSettings::get_singleton()->get("projects/"+selected);
		print_line("OPENING: "+path+" ("+selected+")");

		List<String> args;

		args.push_back("-path");
		args.push_back(path);

		args.push_back("-editor");

		const String &selected_main = E->get();
		if (selected_main!="") {
			args.push_back(selected_main);
		}

		String exec = OS::get_singleton()->get_executable_path();

		OS::ProcessID pid=0;
		Error err = OS::get_singleton()->execute(exec,args,false,&pid);
		ERR_FAIL_COND(err);
	}

	get_scene()->quit();
}
Ejemplo n.º 11
0
void Spatial::_notify_dirty() {

	if (!data.ignore_notification && !xform_change.in_list()) {

		get_scene()->xform_change_list.add(&xform_change);
	}
}
void CollisionPolygonEditor::_notification(int p_what) {

    switch(p_what) {

    case NOTIFICATION_READY: {

        button_create->set_icon( get_icon("Edit","EditorIcons"));
        button_edit->set_icon( get_icon("MovePoint","EditorIcons"));
        button_edit->set_pressed(true);
        get_scene()->connect("node_removed",this,"_node_removed");


    }
    break;
    case NOTIFICATION_PROCESS: {

        if (node->get_depth() != prev_depth) {
            _polygon_draw();
            prev_depth=node->get_depth();
        }

    }
    break;
    }

}
Ejemplo n.º 13
0
void Camera2D::make_current() {

	if (!is_inside_scene()) {
		current=true;
	} else {
		get_scene()->call_group(SceneMainLoop::GROUP_CALL_REALTIME,group_name,"_make_current",this);
	}
}
Ejemplo n.º 14
0
Archivo: main.c Proyecto: sbran/42
void		treat_image(t_param *param, char *file)
{
  int ret;

  ret = get_scene(param, file);
  if (ret == -1)
    exit(0);
  rempli_img(param);
}
Ejemplo n.º 15
0
void RayCast2D::set_enabled(bool p_enabled) {

	enabled=p_enabled;
	if (is_inside_scene() && !get_scene()->is_editor_hint())
		set_fixed_process(p_enabled);
	if (!p_enabled)
		collided=false;

}
Ejemplo n.º 16
0
void ReferenceFrame::_notification(int p_what) {

	if (p_what==NOTIFICATION_DRAW) {

		if (!is_inside_scene())
			return;
		if (get_scene()->is_editor_hint())
			draw_style_box(get_stylebox("border"),Rect2(Point2(),get_size())) ;
	}
}
Ejemplo n.º 17
0
    void on_mouse_move(int x,int y)
    {
        //nya_log::log()<<"mmove "<<x<<" "<<y<<"\n";

        if(m_mouse_drag.left)
        {
            get_scene().get_camera().add_rot(((x-m_mouse_drag.last_x)*180.0f)/200.0f,
                                             -((y-m_mouse_drag.last_y)*180.0f)/200.0f);
        }
        else if(m_mouse_drag.right)
        {
            get_scene().get_camera().add_pos((x-m_mouse_drag.last_x)/20.0f,(y-m_mouse_drag.last_y)/20.0f);
        }
        else
            m_ui.mouse_move(x,y);

        m_mouse_drag.last_x=x;
        m_mouse_drag.last_y=y;
    }
Ejemplo n.º 18
0
void Viewport::update_worlds() {

	if (!is_inside_scene())
		return;

	Rect2 xformed_rect = (global_canvas_transform * canvas_transform).affine_inverse().xform(get_visible_rect());
	find_world_2d()->_update_viewport(this,xformed_rect);
	find_world_2d()->_update();

	find_world()->_update(get_scene()->get_frame());
}
Ejemplo n.º 19
0
void	draw_staff_roll( void )
{
	long	sx, sw,sh;
	long	x, y;
	long	i;

	if( get_scene() == SCENE_N_ENDING_END ){
		draw_the_end();
		return;
	}

	sx = 0;
	sw = SCREEN_WIDTH;
	sh = SCREEN_HEIGHT;

	x = (sw - (staff_roll_interval_width * staff_roll_max_len)) / 2;
	x += sx;
	y = 0;

	for( i = 0; i < LOOP_MAX_1000; i++ ){
		if( g_str_staff_roll[i] == NULL )
			break;
		if( g_str_staff_roll[i][0] == '\0' )
			break;

		y = (i * staff_roll_interval_height) - staff_roll_y;

		if( y < 0 )
			continue;
		if( y >= sh )
			continue;

		draw_staff_roll_line( x, y, g_str_staff_roll[i] );
	}

	if( (y <= (sh / 2)) && (get_scene() != SCENE_N_ENDING_END) ){
		if( !g_flg_gui ){
			change_scene( SCENE_N_ENDING_END );
		}
	}
}
Ejemplo n.º 20
0
void TouchScreenButton::_notification(int p_what) {

	switch(p_what) {

		case NOTIFICATION_DRAW: {

			if (!is_inside_scene())
				return;
			if (!get_scene()->is_editor_hint() && !OS::get_singleton()->has_touchscreen_ui_hint() && visibility==VISIBILITY_TOUCHSCREEN_ONLY)
				return;

			if (finger_pressed!=-1) {

				if (texture_pressed.is_valid())
					draw_texture(texture_pressed,Point2());
				else if (texture.is_valid())
					draw_texture(texture,Point2());

			} else {
				if (texture.is_valid())
					draw_texture(texture,Point2());
			}

		} break;
		case NOTIFICATION_ENTER_SCENE: {

			if (!get_scene()->is_editor_hint() && !OS::get_singleton()->has_touchscreen_ui_hint() && visibility==VISIBILITY_TOUCHSCREEN_ONLY)
				return;
			update();

			if (!get_scene()->is_editor_hint())
				set_process_input(true);

			if (action.operator String()!="" && InputMap::get_singleton()->has_action(action)) {
				action_id=InputMap::get_singleton()->get_action_id(action);
			} else {
				action_id=-1;
			}
		} break;
	}
}
Ejemplo n.º 21
0
void InterpolatedCamera::set_interpolation_enabled(bool p_enable) {

	if (enabled==p_enable)
		return;
	enabled=p_enable;
	if (p_enable) {
		if (is_inside_scene() && get_scene()->is_editor_hint())
			return;
		set_process(true);
	} else
		set_process(false);
}
Ejemplo n.º 22
0
void Light::_update_visibility() {

	if (!is_inside_scene())
		return;


bool editor_ok=true;

#ifdef TOOLS_ENABLED
	if (editor_only) {
		if (!get_scene()->is_editor_hint()) {
			editor_ok=false;
		} else {
			editor_ok = (get_scene()->get_edited_scene_root() && (this==get_scene()->get_edited_scene_root() || get_owner()==get_scene()->get_edited_scene_root()));
		}
	}
#endif

	VS::get_singleton()->instance_light_set_enabled(get_instance(),is_visible() && enabled && editor_ok);
	_change_notify("geometry/visible");

}
Ejemplo n.º 23
0
void Camera2D::_update_scroll() {


	if (!is_inside_scene())
		return;

	if (get_scene()->is_editor_hint()) {
		update(); //will just be drawn
		return;
	}

	if (current) {
		Matrix32 xform = get_camera_transform();

		RID vp =  viewport->get_viewport();
		if (viewport) {
		       viewport->set_canvas_transform( xform );
		}
		get_scene()->call_group(SceneMainLoop::GROUP_CALL_REALTIME,group_name,"_camera_moved",xform);
	};

}
Ejemplo n.º 24
0
void VideoPlayer::_notification(int p_notification) {

	switch (p_notification) {

		case NOTIFICATION_ENTER_SCENE: {

			//set_idle_process(false); //don't annoy
			if (stream.is_valid() && autoplay && !get_scene()->is_editor_hint())
				play();
		} break;

		case NOTIFICATION_PROCESS: {

			if (stream.is_null())
				return;
			if (paused)
				return;

			while (stream->get_pending_frame_count()) {

				Image img = stream->pop_frame();
				if (texture->get_width() == 0) {
					texture->create(img.get_width(),img.get_height(),img.get_format(),Texture::FLAG_VIDEO_SURFACE|Texture::FLAG_FILTER);
					update();
					minimum_size_changed();
				} else {

					if (stream->get_pending_frame_count() == 0)
						texture->set_data(img);
				};
			};

		} break;

		case NOTIFICATION_DRAW: {

			if (texture.is_null())
				return;
			if (texture->get_width() == 0)
				return;

			Size2 s=expand?get_size():texture->get_size();
			RID ci = get_canvas_item();
			printf("drawing with size %f, %f\n", s.x, s.y);
			draw_texture_rect(texture,Rect2(Point2(),s),false);

		} break;
	};

};
Ejemplo n.º 25
0
void InterpolatedCamera::_notification(int p_what) {

	switch(p_what) {
		case NOTIFICATION_ENTER_SCENE: {

			if (get_scene()->is_editor_hint() && enabled)
				set_fixed_process(false);

		} break;
		case NOTIFICATION_PROCESS: {

			if (!enabled)
				break;
			if (has_node(target)) {

				Spatial *node = get_node(target)->cast_to<Spatial>();
				if (!node)
					break;

				float delta = speed*get_process_delta_time();
				Transform target_xform = node->get_global_transform();
				Transform local_transform = get_transform();
				local_transform = local_transform.interpolate_with(target_xform,delta);
				set_global_transform(local_transform);

				if (node->cast_to<Camera>()) {
					Camera *cam = node->cast_to<Camera>();
					if (cam->get_projection()==get_projection())  {

						float new_near = Math::lerp(get_znear(),cam->get_znear(),delta);
						float new_far = Math::lerp(get_zfar(),cam->get_zfar(),delta);

						if (cam->get_projection()==PROJECTION_ORTHOGONAL) {

							float size = Math::lerp(get_size(),cam->get_size(),delta);
							set_orthogonal(size,new_near,new_far);
						} else {

							float fov = Math::lerp(get_fov(),cam->get_fov(),delta);
							set_perspective(fov,new_near,new_far);
						}
					}
				}


			}

		} break;
	}
}
Ejemplo n.º 26
0
void AnimationPlayer::_notification(int p_what) {

    switch(p_what) {

    case NOTIFICATION_ENTER_SCENE: {

        if (!processing) {
            //make sure that a previous process state was not saved
            //only process if "processing" is set
            set_fixed_process(false);
            set_process(false);
        }
        //_set_process(false);
        clear_caches();
    }
    break;
    case NOTIFICATION_READY: {

        if (!get_scene()->is_editor_hint() && animation_set.has(autoplay)) {
            play(autoplay);
        }
    }
    break;
    case NOTIFICATION_PROCESS: {
        if (animation_process_mode==ANIMATION_PROCESS_FIXED)
            break;

        if (processing)
            _animation_process( get_process_delta_time() );
    }
    break;
    case NOTIFICATION_FIXED_PROCESS: {

        if (animation_process_mode==ANIMATION_PROCESS_IDLE)
            break;

        if (processing)
            _animation_process( get_fixed_process_delta_time() );
    }
    break;
    case NOTIFICATION_EXIT_SCENE: {

        stop_all();
        clear_caches();
    }
    break;
    }
}
Ejemplo n.º 27
0
void EventPlayer::_notification(int p_what) {

	switch(p_what) {

		case NOTIFICATION_ENTER_SCENE: {

			//set_idle_process(false); //don't annoy
			if (playback.is_valid() && autoplay && !get_scene()->is_editor_hint())
				play();
		} break;
		case NOTIFICATION_EXIT_SCENE: {

			stop(); //wathever it may be doing, stop
		} break;
	}
}
Ejemplo n.º 28
0
void Camera::clear_current() {

	current=false;
	if (!is_inside_scene())
		return;

	if (viewport_ptr) {
		if (viewport_ptr->get_camera()==this) {
			viewport_ptr->_set_camera(NULL);
			//a group is used beause this needs to be in order to be deterministic
			get_scene()->call_group(SceneMainLoop::GROUP_CALL_REALTIME,camera_group,"_camera_make_next_current",this);

		}
	}

}
Ejemplo n.º 29
0
gint	handle_map_draw( gpointer p )
{
	static long	flagDrawing = false;

	if( flagDrawing )
		return TRUE;
	flagDrawing = true;
	gui_begin();

	gJoystick.checkEvent();

	if( get_scene() == SCENE_N_LAST_BOSS ){
		if( !gPcgDun.drawLastBoss() ){
			gui_end();
			flagDrawing = false;
			return TRUE;
		}
	} else if( chk_scene_group( SCENE_GROUP_N_TITLE ) ){
		gPcgDun.drawTitle();
	} else if( chk_scene_group( SCENE_GROUP_N_ENDING ) ){
		gPcgDun.drawEnding();
	} else if( chk_scene_group( SCENE_GROUP_N_GAME_OVER ) ){
		gPcgDun.drawGameOver();
#if	0
	} else if( chk_scene_group( SCENE_GROUP_N_SEL_GRAPH ) ){
		if( gSelMbrGraph != NULL )
			gSelMbrGraph->redraw();
#endif
	} else {
		gui_end();
		flagDrawing = false;
		return TRUE;
	}

	GtkWidget *drawingArea = (GtkWidget *)p;
	GdkRectangle rect;
	rect.x = 0;
	rect.y = 0;
	rect.width = drawingArea->allocation.width;
	rect.height = drawingArea->allocation.height;
	gtk_widget_draw( GTK_WIDGET( drawingArea ), &rect );

	gui_end();
	flagDrawing = false;
	return TRUE;
}
Ejemplo n.º 30
0
void Node::set_name(const String& p_name) {
	
	String name=p_name.replace(":","").replace("/","").replace("@","");

	ERR_FAIL_COND(name=="");
	data.name=XL_MESSAGE(name);
	
	if (data.parent) {
		
		data.parent->_validate_child_name(this);
	}

	if (is_inside_scene()) {

		emit_signal("renamed");
		get_scene()->tree_changed();
	}
}