Răsfoiți Sursa

missing navmesh demo and small fixes

Juan Linietsky 11 ani în urmă
părinte
comite
e709468bb1

+ 9 - 0
demos/3d/navmesh/engine.cfg

@@ -0,0 +1,9 @@
+[application]
+
+name="Navmesh Demo"
+main_scene="res://navmesh.scn"
+icon="res://icon.png"
+
+[rasterizer]
+
+shadow_filter=3

+ 110 - 0
demos/3d/navmesh/navmesh.gd

@@ -0,0 +1,110 @@
+
+extends Navigation
+
+# member variables here, example:
+# var a=2
+# var b="textvar"
+
+const SPEED=4.0
+
+var camrot=0.0
+
+var begin=Vector3()
+var end=Vector3()
+var m = FixedMaterial.new()
+
+var path=[]
+
+func _process(delta):
+
+
+	if (path.size()>1):
+	
+		var to_walk = delta*SPEED
+		var to_watch = Vector3(0,1,0)
+		while(to_walk>0 and path.size()>=2):
+			var pfrom = path[path.size()-1]
+			var pto = path[path.size()-2]
+			to_watch = (pto - pfrom).normalized()
+			var d = pfrom.distance_to(pto)
+			if (d<=to_walk):
+				path.remove(path.size()-1)
+				to_walk-=d
+			else:
+				path[path.size()-1] = pfrom.linear_interpolate(pto,to_walk/d)
+				to_walk=0
+				
+		var atpos = path[path.size()-1]
+		var atdir = to_watch
+		atdir.y=0
+		
+		var t = Transform()
+		t.origin=atpos
+		t=t.looking_at(atpos+atdir,Vector3(0,1,0))
+		get_node("robot_base").set_transform(t)
+		
+		if (path.size()<2):
+			path=[]
+			set_process(false)
+				
+	else:
+		set_process(false)
+
+var draw_path=false
+
+func _update_path():
+
+	var p = get_simple_path(begin,end,true)
+	path=Array(p) # Vector3array to complex to use, convert to regular array
+	path.invert()
+	set_process(true)
+
+	if (draw_path):
+		var im = get_node("draw")
+		im.set_material_override(m)
+		im.clear()
+		im.begin(Mesh.PRIMITIVE_POINTS,null)
+		im.add_vertex(begin)
+		im.add_vertex(end)
+		im.end()
+		im.begin(Mesh.PRIMITIVE_LINE_STRIP,null)
+		for x in p:
+			im.add_vertex(x)
+		im.end()
+
+func _input(ev):
+
+	if (ev.type==InputEvent.MOUSE_BUTTON and ev.button_index==BUTTON_LEFT and ev.pressed):
+                
+		var from = get_node("cambase/Camera").project_position(ev.pos)
+		var to = from+get_node("cambase/Camera").project_ray_normal(ev.pos)*100
+		var p = get_closest_point_to_segment(from,to)
+	
+		begin=get_closest_point(get_node("robot_base").get_translation())
+		end=p
+
+		_update_path()
+		
+	if (ev.type==InputEvent.MOUSE_MOTION):
+		if (ev.button_mask&BUTTON_MASK_MIDDLE):
+			
+			camrot+=ev.relative_x*0.005
+			get_node("cambase").set_rotation(Vector3(0,camrot,0))
+			print("camrot ", camrot)
+
+		
+
+func _ready():
+	# Initalization here
+	set_process_input(true)
+	m.set_line_width(3)
+	m.set_point_size(3)
+	m.set_fixed_flag(FixedMaterial.FLAG_USE_POINT_SIZE,true)
+	m.set_flag(Material.FLAG_UNSHADED,true)
+	#begin = get_closest_point(get_node("start").get_translation())
+	#end = get_closest_point(get_node("end").get_translation())
+	#call_deferred("_update_path")
+
+	pass
+
+

BIN
demos/3d/navmesh/navmesh.scn


BIN
demos/3d/navmesh/particle.png


+ 4 - 1
drivers/theoraplayer/SCsub

@@ -67,10 +67,13 @@ if env["platform"] == "iphone":
 
 
 env_theora = env.Clone()
 env_theora = env.Clone()
 
 
-env_theora.Append(CPPFLAGS=["-D_YUV_C", "-D__THEORA", "-D_LIB"])
+env_theora.Append(CPPFLAGS=["-D_YUV_C", "-D_LIB", "-D__THEORA"])
 
 
 if env["platform"] == "iphone":
 if env["platform"] == "iphone":
 	env_theora.Append(CPPFLAGS=["-D__AVFOUNDATION"])
 	env_theora.Append(CPPFLAGS=["-D__AVFOUNDATION"])
+else:
+	pass
+	#env_theora.Append(CPPFLAGS=["-D__FFMPEG"])
 
 
 if env["platform"] == "android":
 if env["platform"] == "android":
 	env_theora.Append(CPPFLAGS=["-D_ANDROID"])
 	env_theora.Append(CPPFLAGS=["-D_ANDROID"])

+ 2 - 0
drivers/theoraplayer/src/AVFoundation/TheoraVideoClip_AVFoundation.mm

@@ -271,6 +271,8 @@ void TheoraVideoClip_AVFoundation::load(TheoraDataSource* source)
 	AVAssetTrack *videoTrack = [tracks objectAtIndex:0];
 	AVAssetTrack *videoTrack = [tracks objectAtIndex:0];
 
 
 	NSArray* audioTracks = [asset tracksWithMediaType:AVMediaTypeAudio];
 	NSArray* audioTracks = [asset tracksWithMediaType:AVMediaTypeAudio];
+	if (audio_track >= audioTracks.count)
+		audio_track = 0;
 	AVAssetTrack *audioTrack = audioTracks.count > 0 ? [audioTracks objectAtIndex:audio_track] : NULL;
 	AVAssetTrack *audioTrack = audioTracks.count > 0 ? [audioTracks objectAtIndex:audio_track] : NULL;
 	printf("*********** using audio track %i\n", audio_track);
 	printf("*********** using audio track %i\n", audio_track);
 	
 	

+ 26 - 7
drivers/theoraplayer/video_stream_theoraplayer.cpp

@@ -122,6 +122,7 @@ class AudioStreamInput : public AudioStreamResampled {
 	int rb_power;
 	int rb_power;
 	int total_wrote;
 	int total_wrote;
 	bool playing;
 	bool playing;
+	bool paused;
 
 
 public:
 public:
 
 
@@ -133,6 +134,7 @@ public:
 		AudioServer::get_singleton()->stream_set_active(stream_rid,true);
 		AudioServer::get_singleton()->stream_set_active(stream_rid,true);
 		AudioServer::get_singleton()->stream_set_volume_scale(stream_rid,1);
 		AudioServer::get_singleton()->stream_set_volume_scale(stream_rid,1);
 		playing = true;
 		playing = true;
+		paused = false;
 	};
 	};
 	virtual void stop() {
 	virtual void stop() {
 
 
@@ -146,8 +148,8 @@ public:
 
 
 	virtual bool is_playing() const { return true; };
 	virtual bool is_playing() const { return true; };
 
 
-	virtual void set_paused(bool p_paused) {};
-	virtual bool is_paused(bool p_paused) const { return false; };
+	virtual void set_paused(bool p_paused) { paused = p_paused; };
+	virtual bool is_paused(bool p_paused) const { return paused; };
 
 
 	virtual void set_loop(bool p_enable) {};
 	virtual void set_loop(bool p_enable) {};
 	virtual bool has_loop() const { return false; };
 	virtual bool has_loop() const { return false; };
@@ -209,6 +211,7 @@ public:
 	AudioStreamInput(int p_channels, int p_freq) {
 	AudioStreamInput(int p_channels, int p_freq) {
 
 
 		playing = false;
 		playing = false;
+		paused = true;
 		channels = p_channels;
 		channels = p_channels;
 		freq = p_freq;
 		freq = p_freq;
 		total_wrote = 0;
 		total_wrote = 0;
@@ -285,12 +288,12 @@ void VideoStreamTheoraplayer::stop() {
 		clip->stop();
 		clip->stop();
 		clip->seek(0);
 		clip->seek(0);
 	};
 	};
+	started = true;
 };
 };
 
 
 void VideoStreamTheoraplayer::play() {
 void VideoStreamTheoraplayer::play() {
-
-	playing = true;
-	started = true;
+	if (clip)
+		playing = true;
 };
 };
 
 
 bool VideoStreamTheoraplayer::is_playing() const {
 bool VideoStreamTheoraplayer::is_playing() const {
@@ -300,7 +303,13 @@ bool VideoStreamTheoraplayer::is_playing() const {
 
 
 void VideoStreamTheoraplayer::set_paused(bool p_paused) {
 void VideoStreamTheoraplayer::set_paused(bool p_paused) {
 
 
-	playing = false;
+	paused = p_paused;
+	if (paused) {
+		clip->pause();
+	} else {
+		if (clip && playing && !started)
+			clip->play();
+	}
 };
 };
 
 
 bool VideoStreamTheoraplayer::is_paused(bool p_paused) const {
 bool VideoStreamTheoraplayer::is_paused(bool p_paused) const {
@@ -355,6 +364,9 @@ int VideoStreamTheoraplayer::get_pending_frame_count() const {
 
 
 void VideoStreamTheoraplayer::pop_frame(Ref<ImageTexture> p_tex) {
 void VideoStreamTheoraplayer::pop_frame(Ref<ImageTexture> p_tex) {
 
 
+	if (!clip)
+		return;
+
 	TheoraVideoFrame* f = clip->getNextFrame();
 	TheoraVideoFrame* f = clip->getNextFrame();
 	if (!f) {
 	if (!f) {
 		return;
 		return;
@@ -374,7 +386,7 @@ void VideoStreamTheoraplayer::pop_frame(Ref<ImageTexture> p_tex) {
 	{
 	{
 		DVector<uint8_t>::Write wr = data.write();
 		DVector<uint8_t>::Write wr = data.write();
 		uint8_t* ptr = wr.ptr();
 		uint8_t* ptr = wr.ptr();
-		memcpy(ptr, f->getBuffer(), imgsize);
+		copymem(ptr, f->getBuffer(), imgsize);
 	}
 	}
     /*
     /*
     for (int i=0; i<h; i++) {
     for (int i=0; i<h; i++) {
@@ -416,6 +428,12 @@ void VideoStreamTheoraplayer::update(float p_time) {
 	if (!mgr)
 	if (!mgr)
 		return;
 		return;
 
 
+	if (!clip)
+		return;
+
+	if (!playing || paused)
+		return;
+
 	//printf("video update!\n");
 	//printf("video update!\n");
 	if (started) {
 	if (started) {
 		if (clip->getNumReadyFrames() < 2) {
 		if (clip->getNumReadyFrames() < 2) {
@@ -499,6 +517,7 @@ VideoStreamTheoraplayer::VideoStreamTheoraplayer() {
 	clip = NULL;
 	clip = NULL;
 	started = false;
 	started = false;
 	playing = false;
 	playing = false;
+	paused = false;
 	loop = false;
 	loop = false;
 	audio_track=0;
 	audio_track=0;
 };
 };

+ 1 - 0
drivers/theoraplayer/video_stream_theoraplayer.h

@@ -17,6 +17,7 @@ class VideoStreamTheoraplayer : public VideoStream {
 	bool started;
 	bool started;
 	bool playing;
 	bool playing;
 	bool loop;
 	bool loop;
+	bool paused;
 
 
 	int audio_track;
 	int audio_track;
 
 

+ 2 - 0
modules/gdscript/gd_script.cpp

@@ -2464,6 +2464,8 @@ void GDScriptLanguage::get_reserved_words(List<String> *p_words) const  {
 		"assert",
 		"assert",
 		"yield",
 		"yield",
 		"static",
 		"static",
+		"float",
+		"int",
 	0};
 	0};
 
 
 
 

+ 1 - 1
platform/windows/os_windows.cpp

@@ -1494,7 +1494,7 @@ OS::Date OS_Windows::get_date() const {
 OS::Time OS_Windows::get_time() const {
 OS::Time OS_Windows::get_time() const {
 
 
 	SYSTEMTIME systemtime;
 	SYSTEMTIME systemtime;
-	GetSystemTime(&systemtime);
+	GetLocalTime(&systemtime);
 
 
 	Time time;
 	Time time;
 	time.hour=systemtime.wHour;
 	time.hour=systemtime.wHour;