My VertexDeclaration does not have OGRE::VES_DEFFUSE[Solved]

Anything and everything that's related to OGRE or the wider graphics field that doesn't fit into the other forums.
Post Reply
alisebti
Gnoblar
Posts: 9
Joined: Tue Dec 09, 2014 12:19 pm

My VertexDeclaration does not have OGRE::VES_DEFFUSE[Solved]

Post by alisebti »

I have loaded an entity in my Ogre program. Then list Elements in vertexDeclaration like below.

Ogre::VertexDeclaration::VertexElementList lst = vertex_data->vertexDeclaration->getElements();

In the list i have seen VES_POSITION and VES_NORMAL only. Therefor when i run below code,

const Ogre::VertexElement* posElem = vertex_data->vertexDeclaration->findElementBySemantic(Ogre::VES_DIFFUSE);

posElem is contained nothing or null. How to access this kind of element that is not exist? is it possible?
Last edited by alisebti on Sat Dec 27, 2014 1:41 pm, edited 1 time in total.
User avatar
Kojack
OGRE Moderator
OGRE Moderator
Posts: 7157
Joined: Sun Jan 25, 2004 7:35 am
Location: Brisbane, Australia
x 534

Re: My VertexDeclaration does not have OGRE::VES_DEFFUSE ele

Post by Kojack »

Grab OgreMeshy. If you load your mesh into it, it will give you the vertex declaration for all submeshes and vertex buffers. That will let you check if the mesh actually has diffuse, and where it's located.
alisebti
Gnoblar
Posts: 9
Joined: Tue Dec 09, 2014 12:19 pm

Re: My VertexDeclaration does not have OGRE::VES_DEFFUSE ele

Post by alisebti »

I have added material like below to my entity. This time model loaded successfully with material and diffuse property. but the problem persists. This means that VertexDeclaration does not contain an element with VES_DEFFUSE semantic (only VES_POSITION and VES_NORMAL). Also i loaded some another models, but none of them had such an element with VES_DEFFUSE semantic.
material base_mesh
{

technique
{
pass
{
lighting on
ambient 0.3 0.3 0.3 1
diffuse 0.1 0.7 0.2 1
emissive 0 0 0 1


}
}
}
User avatar
Kojack
OGRE Moderator
OGRE Moderator
Posts: 7157
Joined: Sun Jan 25, 2004 7:35 am
Location: Brisbane, Australia
x 534

Re: My VertexDeclaration does not have OGRE::VES_DEFFUSE ele

Post by Kojack »

VES_DIFFUSE is optional. If it wasn't exported with it, then it won't be there, no matter what material is used. There's no easy way to guess what diffuse values would be, that's the job of the artist/modeller program.

I just did a quick check (using OgreMeshy as I mentioned above), the only Ogre sample mesh that has a diffuse element in it's vertices is spine.mesh.
It has normals in source 0, diffuse and texture coords in source 1, blend indices and weights in source 2 and position in source 3.
alisebti
Gnoblar
Posts: 9
Joined: Tue Dec 09, 2014 12:19 pm

Re: My VertexDeclaration does not have OGRE::VES_DEFFUSE[Sol

Post by alisebti »

many thanks.
I convert my mesh file with OgreXmlConverter to xml file. Then edit xml file and add colour_diffuse tag to each vertex tag like below:

<vertex>
<position y="2.779611" x="0.272802" z="0.245147"/>
<normal y="-0.291635" x="0.955870" z="0.034669"/>
<colour_diffuse value="1 1 1 1" /></vertex>
<vertex>

Then convert back to mesh file.Now in VertexDeclaration we have VES_DEFFUSE semantic element.
Post Reply