Fade In/Out player tranlation

In the simpleUpdate, when player’s local position’s Y value goes under a certain(goes deep into the water) position, player re spawns to a certain location. Things are pretty straight forward up to this point.



But, Now I want a fade in, fade out the screen while character re spawns to the start location, this sudden translation looks odd.



my current code is somthing like that,

if Y < -24 then relocate player to new V3f(A, B, C)



but, how do i implement a smooth fadeIn fadeOut in this code? Just writting fadeFilter.fadeOut(), results in fading out, after ,the player re spawned.



I am using the fade filter to fadeIn and fadeOut.

Create a quad and add it to the GUI layer (so it draws overtop of everything else). Have that quad be the size of the screen. Then, have it fade into a black color (fully transparent to fully opaque) during the player’s transition.

Look at the TestColoredTexture.java test case. It creates a quad and renders it on the GUI queue so it will appear above the scene underneath. It changes the color of the texture in the simpleUpdate() method; there you can just supply a solid texture and change its color.

mhhhh the fade filter should work, could you show your code?

nehon said:mhhhh the fade filter should work, could you show your code?


[java]
if(node_player_control.getPhysicsLocation().getY() < - 28)
{
fadeFilter.fadeOut();
if(dice_count == 0) node_player_control.setPhysicsLocation(new Vector3f(0, -5, 0));
}
[/java]

I was testing if at least the fadeOut works.

Sploreg said:
Create a quad and add it to the GUI layer (so it draws overtop of everything else). Have that quad be the size of the screen. Then, have it fade into a black color (fully transparent to fully opaque) during the player's transition.


Well, Yeh, But the problem is the transition is to abrupt, node_location A goes to node_location B. How do I so something between this?

ok i get it.

The fade as a default length of 1 second. fadeFilter.fadeOut(); call just starts the fade out, it does not play it completely and then resume the execution of the code.



So what you need is to change the location of your player ONCE the fade out is finished.



For that you need to be notified when the filter animation is done.

What you need is to combine it with a cinematic event. (you can look at testCenematic for an example)



you can make a cinematic even RespawnEvent that extends AbstractCinematicEvent.

(pseudo code)



public class RespawnEvent extends AbstractCinematicEvent{

FadeFilter filter;



public RespawnEvent (FadeFilter filter,float duration ){

super(duration);

this.filter=filter;

this.filter.setDuration(duration);

}



@Override

public void onPlay() {

fade.fadeOut();

}



@Override

public void onUpdate(float tpf) {

}



@Override

public void onStop() {

… your respawn code here …

if(dice_count == 0) node_player_control.setPhysicsLocation(new Vector3f(0, -5, 0));

fade.fadeIn();

}



@Override

public void onPause() {

}

}



in your simple init create a cinematic and attach it to the appstateManager

add the event to it at the 0 timestamp.



then to call the event you just have to do :



if(node_player_control.getPhysicsLocation().getY() < - 28)

{

respawnCinematic.play();

}