So the assetmanager.loadModel returns a Spatial instance, but in this case we are converting the Spatial to a Node. Spatials can either be in form of a com.jme3.scene.Node or a com.jme3.scene.Geometry. This provides a more in-depth overview of Geometry vs Node: https://docs.jmonkeyengine.org/advanced/spatial.html
I’m not sure if he meant what it does, e.g. pspeed’s answer, or if he meant why cast it to a node (I was typing out a reply along the lines of yours).
I know the basic java concepts but sometimes it’s hard to remember it all when I don’t practice all the time. You are right, I guess this thread is myself seeking knowledge on what (Node) means, why is it there and what purpose does it serve. I am currently reading the link sent in by yourself so hopefully it explains it all to me.
By the way I am really thankful for the help you all give. It really makes life easier when I am trying to apply the basic concepts I learnt into something more practical.
…you should read more about casting. Java is not a dynamically typed language so you can only call things on the class you have.
Spatial model = assetManager.loadModel(…);
I can only treat it like a spatial. I cannot call node-specific methods on it even if it IS a node. If I want to treat it like a Node (call node-specific methods) then I need to cast it to a node.
Polymorphism, casting, etc… are kind of fundamental to object oriented languages. You should spend extra time reading and wrapping your head around these ideas.
I have read a good amount into Polymorphism. I just have never used casting up until now. Ill read more in-depth into it. I feel like that might be a good idea. I just found that reading all of the information without putting it into practical use slowed my learning process a lot. I need to actually do things with what I learn in order for it to make sense and sink in.
Thanks for your explanation of casting. At least now I know where to start !!
Well thank you for been in a good mood !! Learning how to make interesting applications like games is something I’ve always wanted to do and people willing to help you is always great to see.
I think there should be a disclaimer that pops up in the sdk install process that states in flashing red letters … “WARNING!! DO NOT INSTALL THIS UNLESS YOU HAVE PASSED JAVA 101! DOING SO OTHERWISE WILL MELT YOUR BRAIN!”
EDIT: Or better yet force a java 101 small quiz that has to be passed before it lets you install
Thats a little bit harsh. There are links above the logo. They are all probably fundamental reading, especially scenegraph. I find the best way to learn is through practical tutorials too. It doesnt stick if i dont have a use for it. Its a long road but determination is the key
You assume that basic java 101 concepts of polymorphysm are already know … which this post clearly shows that some people don’t even know basic java concepts and they jump into java game development. Mind boggling really.
I think somewhere I have a quote that compares learning to program Java and learning game development to be similar to learning to ride a bike and learning to shave with a straight razor. Something you really don’t want to do at the same time.