Explorar o código

-fix sound room params (was not working)
-fixes to DAE exporter
-ios fixes (video)

Juan Linietsky %!s(int64=11) %!d(string=hai) anos
pai
achega
d70e16f72f

+ 3 - 0
platform/iphone/app_delegate.mm

@@ -286,6 +286,9 @@ static int frame_count = 0;
 	if (OS::get_singleton()->get_main_loop())
 		OS::get_singleton()->get_main_loop()->notification(MainLoop::NOTIFICATION_WM_FOCUS_IN);
 	[view_controller.view startAnimation]; // FIXME: resume seems to be recommended elsewhere
+	if (OSIPhone::get_singleton()->native_video_is_playing()) {
+		OSIPhone::get_singleton()->native_video_unpause();
+	};
 }
 
 - (void)accelerometer:(UIAccelerometer*)accelerometer didAccelerate:(UIAcceleration*)acceleration {

+ 1 - 0
platform/iphone/detect.py

@@ -81,6 +81,7 @@ def configure(env):
 							#'-framework', 'AdSupport',
 							'-framework', 'MediaPlayer',
 							'-framework', 'AVFoundation',
+							'-framework', 'CoreMedia',
 							])
 
 	if env['game_center'] == 'yes':

+ 36 - 2
platform/iphone/gl_view.mm

@@ -52,6 +52,7 @@ static GLView* _instance = NULL;
 static bool video_found_error = false;
 static bool video_playing = false;
 static float video_previous_volume = 0.0f;
+static CMTime video_current_time;
 
 void _show_keyboard(String p_existing) {
 	keyboard_text = p_existing;
@@ -107,6 +108,8 @@ bool _play_video(String p_path, float p_volume, String p_audio_track, String p_s
 
 	_instance.avAsset = [AVAsset assetWithURL:[NSURL fileURLWithPath:file_path]];
 	_instance.avPlayerItem =[[AVPlayerItem alloc]initWithAsset:_instance.avAsset];
+	[_instance.avPlayerItem addObserver:_instance forKeyPath:@"status" options:0 context:nil];
+
     _instance.avPlayer = [[AVPlayer alloc]initWithPlayerItem:_instance.avPlayerItem];
     _instance.avPlayerLayer =[AVPlayerLayer playerLayerWithPlayer:_instance.avPlayer];
 
@@ -166,10 +169,18 @@ bool _is_video_playing() {
 
 void _pause_video() {
 	//[_instance.moviePlayerController pause];
+	video_current_time = _instance.avPlayer.currentTime;
 	[_instance.avPlayer pause];
 	video_playing = false;
 }
 
+void _unpause_video() {
+	[_instance.avPlayer play];
+	video_playing = true;
+
+	//video_current_time = kCMTimeZero;
+};
+
 void _stop_video() {
 	//[_instance.moviePlayerController stop];
 	//[_instance.moviePlayerController.view removeFromSuperview];
@@ -390,6 +401,11 @@ static void clear_touches() {
 	active = TRUE;
 	printf("start animation!\n");
 	animationTimer = [NSTimer scheduledTimerWithTimeInterval:animationInterval target:self selector:@selector(drawView) userInfo:nil repeats:YES];
+
+	if (video_playing)
+	{
+		_unpause_video();
+	}
 }
 
 - (void)stopAnimation
@@ -401,6 +417,11 @@ static void clear_touches() {
 	[animationTimer invalidate];
 	animationTimer = nil;
 	clear_touches();
+
+	if (video_playing)
+	{
+		// save position
+	}
 }
 
 - (void)setAnimationInterval:(NSTimeInterval)interval
@@ -439,9 +460,11 @@ static void clear_touches() {
 	glBindRenderbufferOES(GL_RENDERBUFFER_OES, viewRenderbuffer);
 	[context presentRenderbuffer:GL_RENDERBUFFER_OES];
 	
+#ifdef DEBUG_ENABLED
 	GLenum err = glGetError();
 	if(err)
 		NSLog(@"%x error", err);
+#endif
 }
 
 - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
@@ -589,11 +612,22 @@ static void clear_touches() {
 
 - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object
                         change:(NSDictionary *)change context:(void *)context {
-    if (object == _instance.avPlayer && [keyPath isEqualToString:@"status"]) {
-        if (_instance.avPlayer.status == AVPlayerStatusFailed) {
+
+	if (object == _instance.avPlayerItem && [keyPath isEqualToString:@"status"]) {
+        if (_instance.avPlayerItem.status == AVPlayerStatusFailed || _instance.avPlayer.status == AVPlayerStatusFailed) {
         	_stop_video();
             video_found_error = true;
         }
+
+        if(_instance.avPlayer.status == AVPlayerStatusReadyToPlay && 
+        	_instance.avPlayerItem.status == AVPlayerItemStatusReadyToPlay && 
+        	CMTIME_COMPARE_INLINE(video_current_time, ==, kCMTimeZero)) {
+
+        	//NSLog(@"time: %@", video_current_time);
+
+    		[_instance.avPlayer seekToTime:video_current_time];
+    		video_current_time = kCMTimeZero;
+		}
     }
 }
 

+ 7 - 0
platform/iphone/os_iphone.cpp

@@ -234,6 +234,7 @@ void OSIPhone::mouse_button(int p_idx, int p_x, int p_y, bool p_pressed, bool p_
 		ev.mouse_button.x = ev.mouse_button.global_x = p_x;
 		ev.mouse_button.y = ev.mouse_button.global_y = p_y;
 
+		input->set_mouse_pos(Point2(ev.mouse_motion.x,ev.mouse_motion.y));
 		ev.mouse_button.button_index = BUTTON_LEFT;
 		ev.mouse_button.doubleclick = p_doubleclick;
 		ev.mouse_button.pressed = p_pressed;
@@ -488,6 +489,7 @@ String OSIPhone::get_locale() const {
 extern bool _play_video(String p_path, float p_volume, String p_audio_track, String p_subtitle_track);
 extern bool _is_video_playing();
 extern void _pause_video();
+extern void _unpause_video();
 extern void _stop_video();
 
 Error OSIPhone::native_video_play(String p_path, float p_volume, String p_audio_track, String p_subtitle_track) {
@@ -505,6 +507,11 @@ void OSIPhone::native_video_pause() {
     	_pause_video();
 }
 
+void OSIPhone::native_video_unpause() {
+	_unpause_video();
+};
+
+
 void OSIPhone::native_video_stop() {
 	if (native_video_is_playing())
     	_stop_video();

+ 1 - 0
platform/iphone/os_iphone.h

@@ -187,6 +187,7 @@ public:
     virtual Error native_video_play(String p_path, float p_volume, String p_audio_track, String p_subtitle_track);
     virtual bool native_video_is_playing() const;
     virtual void native_video_pause();
+	virtual void native_video_unpause();
     virtual void native_video_stop();
 
 	OSIPhone(int width, int height);

+ 3 - 3
scene/audio/sound_room_params.cpp

@@ -54,7 +54,7 @@ void SoundRoomParams::_notification(int p_what) {
 
 
 		case NOTIFICATION_ENTER_TREE: {
-#if 0
+//#if 0
 			Node *n=this;
 			Room *room_instance=NULL;
 			while(n) {
@@ -74,11 +74,11 @@ void SoundRoomParams::_notification(int p_what) {
 			if (room_instance) {
 				room=room_instance->get_sound_room();
 			} else {
-				room=get_scene()->get_default_world()->get_sound_space();
+				room=get_viewport()->find_world()->get_sound_space();
 			}
 
 			_update_sound_room();
-#endif
+//#endif
 
 		} break;
 		case NOTIFICATION_EXIT_TREE: {

+ 17 - 1
tools/export/blender25/io_scene_dae/export_dae.py

@@ -863,6 +863,20 @@ class DaeExporter:
 			if (node.parent.type=="ARMATURE"):
 				armature=node.parent
 
+		if (node.data.shape_keys!=None):
+				sk = node.data.shape_keys
+				if (sk.animation_data):
+					print("HAS ANIM")
+					print("DRIVERS: "+str(len(sk.animation_data.drivers)))
+					for d in sk.animation_data.drivers:
+						if (d.driver):
+							for v in d.driver.variables:
+								for t in v.targets:
+									if (t.id!=None and t.id.name in self.scene.objects):
+										print("LINKING "+str(node)+" WITH "+str(t.id.name))
+										self.armature_for_morph[node]=self.scene.objects[t.id.name]
+
+
 		meshdata = self.export_mesh(node,armature)
 		close_controller=False
 
@@ -1339,6 +1353,7 @@ class DaeExporter:
 					if (node.type=="MESH" and node.data!=None and (node in self.armature_for_morph) and (self.armature_for_morph[node] in allowed)):
 						pass #all good you pass with flying colors for morphs inside of action
 					else:
+						#print("fail "+str((node in self.armature_for_morph)))
 						continue
 				if (node.type=="MESH" and node.data!=None and node.data.shape_keys!=None and (node.data in self.mesh_cache) and len(node.data.shape_keys.key_blocks)):
 					target = self.mesh_cache[node.data]["morph_id"]
@@ -1453,7 +1468,7 @@ class DaeExporter:
 									allowed_skeletons.append(y)
 						y.animation_data.action=x;
 
-
+				print("allowed skeletons "+str(allowed_skeletons))
 
 				print(str(x))
 
@@ -1563,6 +1578,7 @@ class DaeExporter:
 
 
 
+
 def save(operator, context,
 	filepath="",
 	use_selection=False,