I wasn’t sure where to put this, because I’m not sure if it’s an IDE issue, or a doc/tutorial issue.
I typed “rootNode.clone();”
and the IDE asked if I wanted to give it a return value, which I did, and I got
Spatial rootNode2 = rootNode.clone();
I then went to check out what the type of “rootNode” is and it’s “Type Node.” I then went to the tutorials to see what the differences specifically are between a “Spacial” and a “Node” are, and found this link, which says
You never create a Spatial with Spatial s = new Spatial();! A Spatial is an abstract concept, like a mammal (there is no actual creature called “mammal” walking around here). You create either a com.jme3.scene.Node or com.jme3.scene.Geometry instance.
Note the Spatial s = new Spatial(); is “strike-through” but It didn’t copy over, and I don’t know how to do it on this forum :(.
Anyways, I’m not sure what the rules are, so I wanted to bring up this issue just in case the IDE is not supposed to do that, and just want to make sure that we should be using “Node” which I’m going to do anyways.
Maybe it will be better for you to go and learn some Java concepts and OOP concepts first and only then return to JME.
Regarding your question, it’s absolutely OK to use variable of Spatial type where you don’t need to know if you are working with Geometry or Node. And it’s NOT OK to try to create new instance of Spatial - you have to use it’s subtypes when it comes to real creation of objects.
Yeah, sorry, they aren’t exactly the same, I was just making sure that this is okay.
As for concepts and JME, I’ve been working with JME for a couple of years now on and off.
It’s just that I’ve been curious about this issue for a bit, and why we would set it up in this way, so I got confused about it I guess. I’m reading up something now that I found so hopefully that explains it better…
Well, if the Fruit is an Apple then you can do it with a cast. If it’s not an Apple then it doesn’t make sense… as what would you clone from an Orange to turn it into an Apple? clone() creates a copy… and a copy of an Orange is not an Apple no matter how many ways you slice it.
Spatial is an abstract class. It can never exist on its own so it must be really something else. Geometry, Node, etc… Either one of those will have vastly different internal needs than the other.