Get lights

How do I get light infos from (Spatial) scene (where I have meshes, lights etc)?



I can print lights with

[java]

LightList ll=scene.getLocalLightList();

for(int q=0;q<ll.size();q++)

{

Light l=ll.get(q);

System.out.println("> "+l.getName());

}

[/java]



This gives Light where I can read name, color, etc but I need position and rotation infos too. But how, where?



And second question:

can I somehow print all objects in scene somehow? I tried

[java]

void ShowObjects(Spatial scene)

{

List<Spatial> ls = ((Node) scene).getChildren();

for (Spatial s : ls)

{

System.out.println("> " + s.getName());

ShowObjects(s);

}

}

[/java]

but this didnt work as I expected (ever-ending loop or so).

diesnt light have a getPosition()?



For the second,

you only want to o ShowObjects(s) if (s instanceof Node), else you would want to print the name. Your current code probably crashes as soon as the spatial is not castable to Node.

PointLight and SpotLight have getPosition(), Light does not. Cast it to the appropriate implementation.

@EmpirePhoenix:

thanks, got it to work. I though that Spatials are always Nodes (but they can be Geometries too, I see now).



@Sploreg:

thanks, casting to *Light was right cast (some reason I tried cast Light to Node/LightNode and got null).