Actually yes, try )
So Iâm curious to see what the output prints at line 3 8).
Press -79.69286
Press -79.75846
Press -79.89842
Press -79.96091
Press -79.54008
Press -79.116196
Press -78.74865
Press -78.36998
Press -77.95284
Press -77.48464
and so on
Yeah! My apologizes. The - confused me :D.
No problem, can you advise me how to make clones and placed them correctly in my âforâ?
to me it seems, thatâs youâre translating every sphere to the exast same location except the heightâŚ
I think so too, but cannot understand how to fix it
what you need to do is something like this:
[java]
Node grassContainer = new Node();
Node pivot // whatever pivot is
for (int i = 0; i<=tsize; i++){
if (terrain.getHeight(vector) > -80f && terrain.getHeight(vector) < -70f){
System.out.println("Press " + terrain.getHeight(vector));
Pivot = new Node() //or whatever this is
pivot.setLocalTranslation(terrain coordins+whatever y)
pivot.attachChild(new Geometry("y:"+i, new Sphere(50, 50, 5)));
pivot.setLocalTranslation(10,terrain.getHeight(vector),10);
pivot.setMaterial(mat);
grassContainer.attachChild(pivot)
}
}[/java]
dont copy and paste this is like pseudo typing
Did you mean to attach a pseudo grass clone to the pivot node? I canât remember, but I think geometry ( spatials ) has a method called âclone()â.
[java]
Geometry pseudoGrass = new Geometry(ây:â+i, new Sphere(50, 50, 5));
for(âŚ) {
âŚ
Geometry pseudoGrassClone = pseudoGrass.clone();
âŚ
}
[/java]
Edit: WOW! You guys were fast ;P.
basically you need to specify a translation/coordinates everytime you create a new geometry, and i do it by creating a blank node and attaching it to it and a parent container.
ryuu said:
what you need to do is something like this:
[java]
Node grassContainer = new Node();
Node pivot // whatever pivot is
for (int i = 0; i<=tsize; i++){
if (terrain.getHeight(vector) > -80f && terrain.getHeight(vector) < -70f){
System.out.println("Press " + terrain.getHeight(vector));
Pivot = new Node() //or whatever this is
pivot.setLocalTranslation(terrain coordins+whatever y)
pivot.attachChild(new Geometry("y:"+i, new Sphere(50, 50, 5)));
pivot.setLocalTranslation(10,terrain.getHeight(vector),10);
pivot.setMaterial(mat);
grassContainer.attachChild(pivot)
}
}[/java]
dont copy and paste this is like pseudo typing :P
No, still do not work (
I got your idea, but cannot figure out how to code
the key is the:
[java]pivot.setLocalTranslation(10, terrain.getHeight(vector), 10)[/java]
shouldnât that be:
[java]pivot.setLocalTranslation(vector.x, terrain.getHeight(vector), vector.z)[/java]
?
this correct, but pivot.setLocalTranslation(10, terrain.getHeight(vector), 10) - will reproduce a lot spheres as column, it is enough to see any result
wait are you not looping through vectors ? i.e.
[java]for(int x=0; x<100;x++){
for(int z=0; z<100;z++){
blah blah
}
}[/java]
No I am not, cause my âforâ is a simple test, it must reproduce a column of sphere
2dkot said:
this correct, but pivot.setLocalTranslation(10, terrain.getHeight(vector), 10) - will reproduce a lot spheres as column, it is enough to see any result
ok, I see.. another thought: you are attaching new spheres at the pivot's origin, then translate the pivot everytime to a new location. Try to translate the spheres themselves, an leave the pivot untranslated.
how can I do it?
[java]
for (int i = 0; i<=tsize; i++){
if (terrain.getHeight(vector) > -80f && terrain.getHeight(vector) < -70f){
System.out.println("Press " + terrain.getHeight(vector));
Geometry grass = new Geometry("y:"+i, new Sphere(50, 50, 5));
pivot.attachChild(grass);
grass.setLocalTranslation(10,terrain.getHeight(vector),10);
grass.setMaterial(mat);
}
}
[/java]
Are you attaching that âpivotContainerâ node or the âpivotâ nodes to the âterrainâ node or to the ârootNodeâ node?