Creating a "glowing" sphere

What a world of difference the billboard + glowmap makes. Never would have considered the effect it would have on the horizon line… VERY nice indeed!!

1 Like

@pspeed
Ok, i have tryed it now. I use a quad, filled with a textured material. The texture is only a circle with a white solar flare. In the middle i render a sphere. It looks so:

Looks not so bad for the first try :wink:
But there is a big problem, and i don’t know how to solve it:
If i move, the billboard effect works right but the positioning is incorrect:

Don’t know if there is a easy and fast way to fix this, or if i should calculate the position from my quad in my simpleUpdate method (if so, i hate it =) ).
I have no idea how to fix this without heavy calculation…

2 Likes

Add them both to a single Node and move the Node.

1 Like

@t0neg0d
no thats not the problem. The problem its this:

I look at my sphere (picture 1 above). When i then move my flyCam on the x-axis, everything is ok. But if i move on the z-axis (moving around the sphere) strange effects like in picture nr. 2 happens. its a problem with the positioning.

1 Like

You can try it yourself, use a simple blue quad and a simple yellow sphere to test is:

[java]
Node n = new Node(“test”);

    Quad quad = new Quad(10, 10);
    Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
    mat.setColor("Color", ColorRGBA.Blue);
    Geometry geo = new Geometry("quad", quad);
    geo.setMaterial(mat);
    geo.setLocalTranslation(-5f, -5f, 0f);
    
    
    BillboardControl bill = new BillboardControl();
    bill.setAlignment(BillboardControl.Alignment.Screen);
    geo.addControl(bill);
    
    
    
    Sphere sp = new Sphere(64, 64, 3f);
    Material mat2 = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
    mat2.setColor("Color", ColorRGBA.Yellow);
    Geometry spgeo = new Geometry("sun", sp);
    spgeo.setMaterial(mat2);
    
    n.attachChild(geo);
    n.attachChild(spgeo);
    rootNode.attachChild(n);

[/java]

1 Like

Your quad and sphere are at 2 different locations.

Add both to a Node without setting the local translation of either, then move the node where you want it. This will fix the problem.

They both should be center-out built meshes… if one is not then use Geometry.center();

1 Like

@t0neg0d
yes you are right, but i need to move my quad cause the zero center position of a quad is at the bottom left, the zero center position of a sphere is in the middle of it. i need a way to set the center of a quad to its middle, then everything would be fine. looking for it…

edit:
i use this to test:

[java]
Node n = new Node(“test”);

    Quad quad = new Quad(10, 10);
    Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
    mat.setColor("Color", ColorRGBA.Blue);
    Geometry geo = new Geometry("quad", quad);
    geo.setMaterial(mat);
    geo.center();
    
    
    
    BillboardControl bill = new BillboardControl();
    bill.setAlignment(BillboardControl.Alignment.Screen);
    geo.addControl(bill);
    
    
    
    Sphere sp = new Sphere(64, 64, 3f);
    Material mat2 = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
    mat2.setColor("Color", ColorRGBA.Yellow);
    Geometry spgeo = new Geometry("sun", sp);
    spgeo.setMaterial(mat2);
    
    n.attachChild(geo);
    n.attachChild(spgeo);
    rootNode.attachChild(n);

[/java]

no luck with it (i use geo.center(); for my quad)

1 Like

https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:scenegraph_for_dummies

Put the billboard on the node. Offset the quad however you like.

1 Like

@pspeed
thanks, i have seen the scene graph for dummies and i have read the whole tutorials about jmonkey (all beginner tutorials, really i have read them!). But you know, there is so much new to learn an my brain needs some time and practice to burn the information deep enough into it :wink:

Back to my problem: I don’t understand what you mean with “Put the billboard on the node”. I cant attach the billboard to the node, i can only attach the spatial which uses the billboard to my node. Or i’m missing a method of my billboard?

Edit:
I’m so an idiot! :facepalm:
I forget that i can add a control to my node instead to my quad. That was what you mean. It’s really late here in germany and i need to go to sleep. To much information for one day :mrgreen:
I’m really a troll. SRY :troll:

Here is a working example for all other newbs :wink:
[java]
Node n = new Node(“test”);

    Quad quad = new Quad(10, 10);
    Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
    mat.setColor("Color", ColorRGBA.Blue);
    Geometry geo = new Geometry("quad", quad);
    geo.setMaterial(mat);
    geo.center();     
    
    
    
    
    BillboardControl bill = new BillboardControl();
    bill.setAlignment(BillboardControl.Alignment.Screen);
    n.addControl(bill);
    
    
    
    
    
    Sphere sp = new Sphere(64, 64, 3f);
    Material mat2 = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
    mat2.setColor("Color", ColorRGBA.Yellow);
    Geometry spgeo = new Geometry("sun", sp);
    spgeo.setMaterial(mat2);
    
    
    n.attachChild(geo);
    n.attachChild(spgeo);
    rootNode.attachChild(n);

[/java]

2 Likes

Node is a spatial.

to be painfully specific:
You have a node.
This node has two children.
One child is a sphere or whatever.
The other child is a quad or whatever.

Put the billboard control on the node.

1 Like

@pspeed
Yes yes, i understand :wink:
My problem was really that i forget about the fact, that every node or geometry extends a spatial and so its possible to add a control to a node. For the next time i will notice this.
Thank you and t0neg0d for all your help. Now i will try to make the effect look smoother and better. Will show my experience here for all other users which are tying to do the same like me.

By the way: This forum needs a thank you smilie…

2 Likes

The translation of your quad must be rotated along with the quad. In your example, the quad is rotated around it !

Just add you biilboard control to the node “n”, and voila…

PS. : Oops, not seen the 4th page, sorry for being late !

1 Like

Hey ho, i have a little problem here and i’m really to stupid to get it to work.
I have created a new scene file (j3o) which contains a particle effect. Now i want to add this particle to my scene. Like this:

Spatial sp = assetManager.loadModel(“Effects/SunFire.j3o”);
rootNode.attachChild(sp);

But i can’t see anything :smiley:
If i add a point light to my scene, i also don’t see my particle effect.
I have also tryed to use a ParticleEmitter but it has no method to add a spatial to it (the setSpatial method is empty and cant be used).
In the video from normen he use his j3o particle effect not in code, only in the scene editor, but i want to add it manually trough code.
The documentation don’t tell me anything about using a j3o file as particleemitter. Any ideas or hints for me?
Thanks :wink:

Edit:
Have fund my problem. There was everything fine in my code, the problem was that my particle effect was corrupt. :wink:

1 Like