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 » Sat Jan 12, 2019 10:27 pm

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?
0 x

xrgo
OGRE Expert User
OGRE Expert User
Posts: 1038
Joined: Sat Jul 06, 2013 10:59 pm
Location: Chile
x 68

Re: how to get Item from SceneNode

Post by xrgo » Sat Jan 12, 2019 11:29 pm

Not really sure, but iirc...:

Code: Select all

static_cast<Ogre::Item*>( node->getAttachedObject(0) )
0 x

srd
Gnoblar
Posts: 21
Joined: Sun Jan 14, 2018 6:12 am

Re: how to get Item from SceneNode

Post by srd » Sun Jan 13, 2019 12:17 am

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.
0 x

xrgo
OGRE Expert User
OGRE Expert User
Posts: 1038
Joined: Sat Jul 06, 2013 10:59 pm
Location: Chile
x 68

Re: how to get Item from SceneNode

Post by xrgo » Sun Jan 13, 2019 12:20 am

no, you don't have to do anything, once attached you can do item stuff while its attached
0 x

srd
Gnoblar
Posts: 21
Joined: Sun Jan 14, 2018 6:12 am

Re: how to get Item from SceneNode

Post by srd » Sun Jan 13, 2019 12:21 am

Ah, ok, thanks.
0 x

Post Reply