Troubleshooting tutorials still

In hello picking the rootNode change block exercise is giving me trouble still. I had some help from a few people and it came to the decision of adding:

[java]

Geometry geom = rootNode.getChild(closest.getGeometry().getName());

//plus the material and geom.setMaterial blah

[/java]

Ut the main part was the geom section, that was, in theory supposed to make it so it gets the block and changes it not the root node, but when I type it in, it gives me an error that says:



Required: geometry

Found: spacial



I could be wrong but isnt geometry… A geometry, I don’t understand what’s going on here. Help. Would be appreciated!

Geometry extends spatial, you can cast the spatial to geometry.

How does one cast a spatial to a geometry, spatials are still fuzzy to me…

saturisk1 said:
How does one cast a spatial to a geometry, spatials are still fuzzy to me...

MUAAHuahauhAHUAA :D. Geometry extends Spatial, so :
[java]
Geometry myGeo = (Geometry) mySpatial;
[/java]
Sorry for my laugh, i didn't resist. It calls "POLYMORPHISM" ;).

So it would look like so:

[java] if (results.size() > 0){

// The closest collision point is what was truly hit:

// The closest collision point is what was truly hit:

CollisionResult closest = results.getClosestCollision();

// Let’s interact - we mark the hit with a red dot.

mark.setLocalTranslation(closest.getContactPoint());

rootNode.attachChild(mark);

Geometry geom = (Geometry) mySpacial;

<strong>Geometry geom = rootNode.getChild(closest.getGeometry().getName()); //find the geometry</strong>

Material m = new Material(assetManager, “Common/MatDefs/Misc/Unshaded.j3md”);

m.setColor(“Color”, ColorRGBA.randomColor());

geom.setMaterial(m); //set the material to the geometry[/java]

The mySpacial gives me an error ._. what the deuce, its a variable… and the bold is the trouble part, this is so simple. why can’t i get this one…?

Sorry my friend, it looks i didn’t explain to you what’s Spatial. Spatial is the super class of : geometries, nodes, and etc. That “getChild” method returns a Spatial instanced of Geometry. You must to cast it to geometry so:

[java]

Geometry geom = (Geometry)rootNode.getChild(closest.getGeometry().getName());

[/java]

Forget “mySpatial”. It was just a example ;).

OooOoOOooOh~ I get it now. Jeebus, thanks so much, very many regards!