Replacing RootNode

Hey there monkeys.

This is a question out of curiosity, since i kinda found an answer of Normen from some years ago. (: There he said:

You replace the whole rootNode, simpleApplication only updates the preset rootNode, just attach your fakeRootNode to that instead of removing the rootNode.

But in fact. Thats exactly what i want to do: I want to replace the whole rootNode, since this would save my much time of work and effort.:P
I would really love to replace the damned rootNode. ;)
Why or why not shall not be a question here since i could do it in different ways but dont really like to. ( More work is always nasty. )

Anyone of you has an idea wether i can work around this little problem?
( I bet Normen answers first and sais "No": :D )

With warm regards,

You can easily do that, the question is why would you? As said you have to manage calling updateLogicalState() and updateGeometricState() on that node yourself and just attaching another node to the rootNode works just as well. What kind of work would it save you? I think it would only produce more work for you. I am sure e.g. mythruna just uses the default rootNode as well, theres no reason to replace it even for large projects, maybe you should rethink whatever strategy makes you think replacing it is a good idea.

The reason is, that i build a new rootNode from XML with different setups. Those are controlled by CustomControls and those are used to build a treeconstruct above the rootNode.

I know its wierd. But it works surprisingly well and fast. :smiley:

I managed to build the whole routine for creation and stuff and didnt think much about what i did… So i ran into a little problem here… Which is easily solved by replacing the rootNode.

It would be faster to implement than changing my code. Im a lazy one, thats all.

As i said: i could easily recode that but it would need more time. :wink:

Why so much frustration with the rootNode :)? Can’t just you attach your built root nodes from your xml files to the original root node one?

Yeah, still no reason to replace the rootNode… Just attach two nodes if you need a parent node ^^

I made a quick workaround for it.

Making both possible: Leave my actual code unaltered thus let the rootNode untouched.

I wrote a little Editor for 3D worlds since i dont feel confident with the sceneViewer thingy from JMP and it works like a charm now. JMECanvas are funny to use. ^^

Why didn’t you improve the editor in the SDK instead? Or make your own editor plugin for it?

Because i dont know how to be honest.

And my needs are pretty special in this case. I implement most of my gameLogic via PythonScripts which work similar to customControls. Not everyone needs that so it would be some kind of overhead.

But i rly need that little feature and i like it pretty much. ( Who dosnt love to change GameLogics while the Game is running? :smiley: )

Maybe I will have a look how to improve the SDK but for now im satisfied with what i’ve done. ( 3-4hours of work where at least 1 hour was elarning jmeCanvas. )

1 Like

You’d have to extend Application instead of SimpleApplication if you want to do it properly. rootNode is created in SimpleApplication, not Application. Just look at how viewport, rendermanager and rootnode etc. is set up in SimpleApplication and copy that, but use viewport.addScene(weirdXMLNode) instead of rootNode etc. I just made an offscreen renderer setup just like that, its not hard.

I (also) think this is a very strange approach tho. It seems like a very convoluted and hard way of doing something easy.

As i said: I made a workaround about it. I just changed two references and changed one if… It was ready. Im doing some testing atm but i think I’m fine with that solution.

Thanks, anyway (:

@KuroSei said:
Because i dont know how to be honest.

+1 just for the honesty :)

I tried making a small viewer application in NetBeans Platform (as a sworn Eclipse user). I was able to get a scene canvas on there easily enough but that was about as far as I got. The whole system, and RCP is the same way, is pretty complex to get started doing anything in so I decided to mothball it until I had a few days to devote to it.

If there is a general interest in the features i’d like to have i could work me into it, but i guess too few ppl really need built-in script support.

The Tree-Aspect is pretty neat to have though. I really enjoy working with contextmenus to add and edit things in the scenegraph just by using a very clear tree-structure.

@KuroSei said:
but i guess too few ppl really need built-in script support.

With JSR-223, I think it's really easy to add scripting support for a variety of languages. So I think it's just that for the people who would want scripting, they just integrate it themselves (4 or 5 lines of code). For the people who don't know how to integrate it easily, they would probably have trouble getting scripts to work anyway.

I didnt mean the access to scripts.

I meant, that scripts can be assigned to Entites directly in the editor. It makes life much easier for me since i have a nice framework and all i need to do from now is to add .py files and models :wink:


Im well aware i could have done that by userdata… ^^