[2.1] Equivelant of setDatablock() for a submesh?
-
- Halfling
- Posts: 78
- Joined: Sun Jun 04, 2017 12:33 am
[2.1] Equivelant of setDatablock() for a submesh?
I have a VB with indexes which are not showing up and I'm wondering if it's because I don't have a material assigned.
How does one assign a material to a submesh. If it were an item, I'd call item->setDatablock(block), and this renders my model according to the macroblock I have.
But for a VB, all I see is setMaterial(), yet I'm avoiding this call because I was unable to get JSON support into Ogre using ogredeps, therefore, I'm creating macroblocks programmatically. So instead of an item, I have a submesh that I'm trying to assign a material to.
Thoughts?
How does one assign a material to a submesh. If it were an item, I'd call item->setDatablock(block), and this renders my model according to the macroblock I have.
But for a VB, all I see is setMaterial(), yet I'm avoiding this call because I was unable to get JSON support into Ogre using ogredeps, therefore, I'm creating macroblocks programmatically. So instead of an item, I have a submesh that I'm trying to assign a material to.
Thoughts?
Last edited by rrl on Fri Oct 20, 2017 2:29 am, edited 1 time in total.
-
- Bugbear
- Posts: 812
- Joined: Thu Dec 09, 2004 2:51 am
- x 42
Re: Equivelant of setDatablock() for a submesh?
subitem->setDatablock(block)
-
- Halfling
- Posts: 78
- Joined: Sun Jun 04, 2017 12:33 am
Re: Equivelant of setDatablock() for a submesh?
Sorry, I should have mentioned, this is for 2.1 (changed the title accordingly). I looked at the docs for Ogre::SubMesh and found no such call (for 2.1).
-
- OGRE Expert User
- Posts: 1148
- Joined: Sat Jul 06, 2013 10:59 pm
- Location: Chile
- x 168
Re: [2.1] Equivelant of setDatablock() for a submesh?
mesh/submesh can't have datablocks, they don't hold rendering information, just geometry, you have to use items..
whats a VB?
whats a VB?
-
- Halfling
- Posts: 78
- Joined: Sun Jun 04, 2017 12:33 am
Re: [2.1] Equivelant of setDatablock() for a submesh?
By VB, I meant vertex buffer. I've been learning to create vertex buffers in 2.1 by creating a mesh, then a submesh, then filled in the data and add index buffers. Problem is, my mesh is not showing up and I think I have it correct (I have it like the DynamicGeometry sample), and so I'm hoping it's because I don't have a material assigned. I'm trying to get it to show up as a wireframe.
Update: I think your reply may have helped. If I'm understanding this correctly, and I missed it in the samples, this somehow needs to translate to an item. So I'll go down that path.
Update: I think your reply may have helped. If I'm understanding this correctly, and I missed it in the samples, this somehow needs to translate to an item. So I'll go down that path.
-
- OGRE Expert User
- Posts: 1148
- Joined: Sat Jul 06, 2013 10:59 pm
- Location: Chile
- x 168
Re: [2.1] Equivelant of setDatablock() for a submesh?
oh rightrrl wrote:By VB, I meant vertex buffer.
yes! when creating an item you specify the mesh it will use, then you have to attach it to a scenenode, Items hold rendering information but no transform information, that's the sceneNode's job, you need it also so it can appear in the world space.rrl wrote:Update: I think your reply may have helped. If I'm understanding this correctly, and I missed it in the samples, this somehow needs to translate to an item. So I'll go down that path.
in code:
Code: Select all
Ogre::Item* myItem = mSceneManager->createItem( myMesh );
Ogre::SceneNode* myNode = mSceneManager->getRootSceneNode()->createChildSceneNode();
myNode->attachObject( myItem );
myItem->setDatablock( myDatablock );
- dark_sylinc
- OGRE Team Member
- Posts: 5296
- Joined: Sat Jul 21, 2007 4:55 pm
- Location: Buenos Aires, Argentina
- x 1278
- Contact:
Re: [2.1] Equivelant of setDatablock() for a submesh?
SubMeshes don't hold the pointer of the datablock, but rather the name of the datablock so that it's looked up on instantiation as a SubItem.
Thus you can do:
Thus you can do:
Code: Select all
const String *datablockName = datablock->getNameStr();
if( datablockName )
subMesh->setMaterialName( *datablockName );
else
{
//Datablock is not visible to HlmsManager (probably it was created in a special way by calling directly Hlms::createDatablock)
//You'll have to set the datablock by pointer once the subItem is instantiated, or make the datablock visible to the HlmsManager
}