Dynamic object creation

what im trying to figure out is how to dynamically name objects. what im looking to do down the road is dynamically create and store in a file the items and then create them off of the file.

something like this. non working code but hopefully conveys what i trying to do.


for(int i=1; i<=20; i++);


Box box = new Box(Vector3f.ZERO, i, 1, 1);

Geometry geom = new Geometry("Box", i);


Material mat = new Material(assetManager, "Common/MatDefs/Misc/SolidColor.j3md");

mat.setColor("m_Color", ColorRGBA.Blue);





mhhh…I don’t get it. You want to know how to dynamically name your geom?

what about geom = new Geometry(“Box”+i, i);

you’ll have Box0,Box1,…

But is that really your issue?

that helped. what im trying to do is create a way to add blocks into a world from a file or db and dynamically create the blocks ala minecraft or mythruna… ofcourse its a dumbed down version. but just learning java and using this as a way to learn. if im going about this the wrong way please let me know

[java]int x = 0;

for(int i=1; i<=20; i++)


Box box = new Box(new Vector3f(x,1,1) , 1, 1, 1);

Geometry blocks = new Geometry("Box"+i, box);

x = x + 3;

Material mats = new Material(assetManager, "Common/MatDefs/Misc/SolidColor.j3md");

mats.setColor("m_Color", ColorRGBA.Blue);




nevermind, long day. please move to right forum or delete/