LoadingGameState w/ picture

Is there anything like a LoadingGameState with a picture on top of the progress bar? If there is, I couldnt find it. If there isnt, and I write it, is there ANY chance it might get into jme?(that would make me feel good.  :))



                                  -Gibi :evil:


If you want to add the capability to the current LoadingGameState and then post the changes I'd be happy to check them in for you.  Just make sure it continues to work as is now as well.

I'll try. It might be useful for something like having a company logo while loading.



                          -Gibi }:-@

Hows this going Gibi? I'm interested in using it.

Not very well I'm afraid. But, it will be done someday. (if someone doesnt beat me to it). And now that you reminded me, ill go work on it. (The slowness is due to the fact that I'm still a total n00b. :()

Actually, I've already done it.



I put a little more functionality in than originally planned and its great.

I've taken the LoadingGameState and added a textured quad to apply a texture to and the quad fades out along with the rest of the text. In addition to this, I have also added another constructor witch allows you to supply the current game state as a lead in, so this can also be used as a transition state, from the lead in to the destination state, all with fades.



So if you're in your menu state and the user clicks play, it will fade to the transition state, disable the menu state, load the new game state and then fade into it, cleaning up after itself like it originally did.



I didn't change or modify any of the original functionality, it all works the same.

If you want it I'll post it.

If you post it soon I'll try to get it checked in.  Otherwise perhaps one of the other devs would be kind enough to do this.

I'm in the process commenting right now, and double testing, just to make sure! I'll post it asap

I actually re-wrote and renamed it (TransitionGameState) as it now extends from LoadingGameState.

This turned out to be cleaner and only required minimal changes to LoadingGameState as follows…



LoadingGamesState needs these changes:

  1. rootNode and color now protected (instead of private)
  2. alphaState made into a protected class variable for my use
  3. thats it!



    This has been tested and I havn't had any trouble with it, so anyone that finds a bug gets a cookie.



import static src.Main.GAME;

import java.net.URL;

import com.jme.image.Texture;
import com.jme.math.Vector3f;
import com.jme.renderer.Renderer;
import com.jme.scene.shape.Quad;
import com.jme.scene.state.TextureState;
import com.jme.system.DisplaySystem;
import com.jme.util.TextureManager;
import com.jmex.game.state.GameState;
import com.jmex.scene.TimedLifeController;

/**
 * TransitionGameState
 *
 * The transition game state provides additional functionality to
 * LoadingGameState. A background image is now shown during the loading phase of
 * LoadingGameState. In addition, if a lead in game state is provided, the
 * transition state will fade frame the previous game state into the loading
 * state and then fade away. The lead in game state will be deactivated once the
 * transition is complete, but not removed from the game state manager.
 *
 *
 * @author Andrew Carter
 */
public class TransitionGameState extends LoadingGameState {

   /** Background image will be on this */
   protected Quad background;

   /**
    * Constructs a new Transition state without fading from the previous game
    * state. Essentially the LoadingGameState but with a background image.
    *
    * @param imagePath
    *

Aw… :x Someone beat me to it. But thats great, cuz now i can just use yours and not use mine. Rme! (Rule of Minimal Effort) :)  :smiley:



                -Gibi :evil:


Okay, had to make a few changes to it but it's now checked in.  I haven't had a chance to test it, so if there's a problem let me know.

Thanks, thats awesome!

What were the changes that it needed (other than the obvious disclaimer at the top)?

A bit of code formatting (the majority of which was likely because copying from a post here), there were a couple references to external dependencies (like a GAME class), and moving it to the right package.



Great work though!

Perfect!



I'm really lovin' this StandardGame (GAME was a static reference to it). Keep it up.



@darkfrog: Off topic but quick: I think you should throw a flag in StandardGame so we can turn off the FPS node, I would like that.

Yeah, actually I've been meaning to do that just never got around to it.  I need to push it into DebugGameState instead but I just never sat down and did it.

Here's a threading question for you.



I'm my current application, when transitioning from my menu state to the loading state, I invoke a new thread to do the loading, so the other thread can continue and update the fade controller. As you can see in the example usage above, I tried upping the thread priority of the loading thread. This was because I noticed a large increase in loading time when using the transition state, my guess is its competing with to rendering thread. I'm not too familiar with threading and yields and all that, but is there a way to have the rendering thread back off (not completely) enough to give most computing power to the loading thread, but stil update the progress bar?



In short, how can we speed this up?

I'm a HUGE advocate of vsync as it seems to give much better machine performance and reduce screen tearing.



That should help somewhat. It is often a better idea to reduce the priority of your loading thread if you've got anything going on in your graphical thread so it doesn't cause the rendering to suffer, so your best option here is limiting the number of updates per second your OpenGL thread is doing if it maintains a higher priority.  By default if the update thread is hitting as fast as it can you'll get almost no time to anything else and just simply wastes machine performance.

The loading thread is what needs to work faster. While in the loading state the renderer has almost nothing to do accept update the progress bar. Whats the safest way you recommend the limit the render thread while loading during this state?



I know that this shouldn't be done for dynamic loading during gameplay, but this situation I think would call for a temp slow down of rendering, for performance of other threads.

Like I said, using vsync will seriously help you out there.

So should I be enabling vsynch?



I'll try it. Can you explain to me in further detail what this does and how it will help?