how to get Item from SceneNode

Problems building or running the engine, queries about how to use features etc.
Post Reply
srd
Gnoblar
Posts: 21
Joined: Sun Jan 14, 2018 6:12 am

how to get Item from SceneNode

Post by srd »

Ogre Version: :2.1:
Operating System: :Linux:
Render System: :GL3+:

I have several items already created via createItem() followed by attachObject() to the SceneNode and I'm able to later find them via getSceneNode(id).

My problem is that I can't seem to get the Item from the SceneNode so that I can create a new HlmsUnlitDatablock and change the color of the mesh.

Does that sound like I'm trying to do it the right way? If so, what am I missing?
xrgo
OGRE Expert User
OGRE Expert User
Posts: 1148
Joined: Sat Jul 06, 2013 10:59 pm
Location: Chile
x 168

Re: how to get Item from SceneNode

Post by xrgo »

Not really sure, but iirc...:

Code: Select all

static_cast<Ogre::Item*>( node->getAttachedObject(0) )
srd
Gnoblar
Posts: 21
Joined: Sun Jan 14, 2018 6:12 am

Re: how to get Item from SceneNode

Post by srd »

Thanks for that.

Once I have the item, I think I should call setDatablock() with the new colors, and then call attachObject(item).
But my question is now, do I have to remove the previous object before attaching the new object with the updated HlmsUnlitDatablock?
detachObject() doesn't seem to remove it, but removeChild() possibly? Or should I just remove the entire node and create a new one?
Last edited by srd on Sun Jan 13, 2019 12:21 am, edited 1 time in total.
xrgo
OGRE Expert User
OGRE Expert User
Posts: 1148
Joined: Sat Jul 06, 2013 10:59 pm
Location: Chile
x 168

Re: how to get Item from SceneNode

Post by xrgo »

no, you don't have to do anything, once attached you can do item stuff while its attached
srd
Gnoblar
Posts: 21
Joined: Sun Jan 14, 2018 6:12 am

Re: how to get Item from SceneNode

Post by srd »

Ah, ok, thanks.
Post Reply