Very basic jME question :S

@garnaout said:
I am not sure what she's trying to accomplish but for me I have a Visualizer class that extends SimpleApplication and an Animation class that takes care of the animation and adapters that use these two classes. I dont have a game though, I am animating a trace file for my simulator so for me I need one visualizer that is contained in an adapter (I have MANY adapters). I don't think her design is necessarily flawed, I know mine is not. But in my case I don't want to have the main class that extends simpleApplication (Visualizer) call the other class from it but vice versa.


The big difference here is that you seem to know what you're doing. Homsi OTOH... not so much. Not trying to be disrespectful but previous threads indicated that.

I've been wrong before though...
1 Like

Well regardless the thread sleep thing worked!! Is there anyway to be able to tell when the app initiated without putting a random number in thread. Sleep()?

Poll for something. If it’s null then you know it’s not ready.



[java]while (getThatThing() == null)

wait()[/java]

2 Likes

His design is flawed ^^ Attaching things from any other but the render thread is simply wrong. And waiting or polling for the application to start is abysmal.

@normen said:
And waiting or polling for the application to start is abysmal.


I agree, but at this point...
@madjack said:
I agree, but at this point...

Yep, just enough rope should do.. ;)

Have you tried



[java]



game = new Game();

game.start();

game.enqueue(new Callable<Object>() {

Object whateverthemethodisiforget() {

Box b = new Box(Vector3f.ZERO, 1, 1, 1); // create cube shape at the origin

Geometry geom = new Geometry(“Box”, b); // create cube geometry from the shape

Material mat = new Material(game.getAssetManager(),

“Common/MatDefs/Misc/Unshaded.j3md”); // create a simple material

mat.setColor(“Color”, ColorRGBA.Blue); // set color of material to blue

geom.setMaterial(mat); // set the cube’s material

game.getRootNode().attachChild(geom);

return null;

}

}

[/java]

2 Likes

what’s so bad about doing:



[java]

while(visualizer.getAssetManager() == null)

{

// let it sleep for a short time

}

[/java]

@garnaout said:
what's so bad about doing:

[java]
while(visualizer.getAssetManager() == null)
{
// let it sleep for a short time
}
[/java]

If you do that it a) means that you want to do stuff with the application from another thread but the render thread and b) it means you don't know how to simply trigger something when simpleInit() is called, which gives you the exact moment the application is ready.
@garnaout said:
what's so bad about doing:

[java]
while(visualizer.getAssetManager() == null)
{
// let it sleep for a short time
}
[/java]


Everything. Pretty much any decent threading primer will go into why :)

noted. Thanks guys