-fix sound room params (was not working)

-fixes to DAE exporter
-ios fixes (video)
This commit is contained in:
Juan Linietsky 2014-11-26 14:24:13 -03:00
parent e709468bb1
commit d70e16f72f
7 changed files with 68 additions and 6 deletions

View file

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

View file

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

View file

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

View file

@ -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.x = ev.mouse_button.global_x = p_x;
ev.mouse_button.y = ev.mouse_button.global_y = p_y; 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.button_index = BUTTON_LEFT;
ev.mouse_button.doubleclick = p_doubleclick; ev.mouse_button.doubleclick = p_doubleclick;
ev.mouse_button.pressed = p_pressed; 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 _play_video(String p_path, float p_volume, String p_audio_track, String p_subtitle_track);
extern bool _is_video_playing(); extern bool _is_video_playing();
extern void _pause_video(); extern void _pause_video();
extern void _unpause_video();
extern void _stop_video(); extern void _stop_video();
Error OSIPhone::native_video_play(String p_path, float p_volume, String p_audio_track, String p_subtitle_track) { 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(); _pause_video();
} }
void OSIPhone::native_video_unpause() {
_unpause_video();
};
void OSIPhone::native_video_stop() { void OSIPhone::native_video_stop() {
if (native_video_is_playing()) if (native_video_is_playing())
_stop_video(); _stop_video();

View file

@ -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 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 bool native_video_is_playing() const;
virtual void native_video_pause(); virtual void native_video_pause();
virtual void native_video_unpause();
virtual void native_video_stop(); virtual void native_video_stop();
OSIPhone(int width, int height); OSIPhone(int width, int height);

View file

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

View file

@ -863,6 +863,20 @@ class DaeExporter:
if (node.parent.type=="ARMATURE"): if (node.parent.type=="ARMATURE"):
armature=node.parent 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) meshdata = self.export_mesh(node,armature)
close_controller=False 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)): 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 pass #all good you pass with flying colors for morphs inside of action
else: else:
#print("fail "+str((node in self.armature_for_morph)))
continue 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)): 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"] target = self.mesh_cache[node.data]["morph_id"]
@ -1453,7 +1468,7 @@ class DaeExporter:
allowed_skeletons.append(y) allowed_skeletons.append(y)
y.animation_data.action=x; y.animation_data.action=x;
print("allowed skeletons "+str(allowed_skeletons))
print(str(x)) print(str(x))
@ -1563,6 +1578,7 @@ class DaeExporter:
def save(operator, context, def save(operator, context,
filepath="", filepath="",
use_selection=False, use_selection=False,