how do i get the vertex color of an imported .obj

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
AndreL
Posts: 7
Joined: Sun Aug 12, 2012 4:16 pm

how do i get the vertex color of an imported .obj

Post by AndreL »

Hi,

i'm having problems finding out the color of the vertices in my mesh, is that info in the MeshBuffer?

Code: Select all

 
            irr::scene::IMeshBuffer* mb=mesh->getMeshBuffer(i); 
            video::S3DVertex* vertices = (video::S3DVertex*)mb->getVertices();
 
the video::S3DVertex* vertices have the vertices right position, but now how do i find the colors?
CuteAlien
Admin
Posts: 9933
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: how do i get the vertex color of an imported .obj

Post by CuteAlien »

IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
AndreL
Posts: 7
Joined: Sun Aug 12, 2012 4:16 pm

Re: how do i get the vertex color of an imported .obj

Post by AndreL »

I'm really new at this and stuck at this point, could you please show me an example, how do i get access to the mesh vertex color?
CuteAlien
Admin
Posts: 9933
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: how do i get the vertex color of an imported .obj

Post by CuteAlien »

You already got the pointer to vertices above - so you can just loop over them and get the color.
Something like:

Code: Select all

 
irr::scene::IMeshBuffer* mb=mesh->getMeshBuffer(i); 
if (  mb->getVertexType () == EVT_STANDARD )
{
    video::S3DVertex* vertices = (video::S3DVertex*)mb->getVertices();
    for ( u32 v=0; v < mb->getVertexCount (); ++v )
    {
         video::SColor myCol = vertices[v].Color;
    }
}
 
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
AndreL
Posts: 7
Joined: Sun Aug 12, 2012 4:16 pm

Re: how do i get the vertex color of an imported .obj

Post by AndreL »

Thanks CuteAlien, however, myCol is returning all white for all vertices.
CuteAlien
Admin
Posts: 9933
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: how do i get the vertex color of an imported .obj

Post by CuteAlien »

I don't know anything about your .obj file ... maybe they are white?
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
AndreL
Posts: 7
Joined: Sun Aug 12, 2012 4:16 pm

Re: how do i get the vertex color of an imported .obj

Post by AndreL »

it's just a plane exported in maya, with a texture file, just red. 4 vertices, 6 indexes.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Re: how do i get the vertex color of an imported .obj

Post by hybrid »

.obj does not support vertex color IIRC.
mongoose7
Posts: 1227
Joined: Wed Apr 06, 2011 12:13 pm

Re: how do i get the vertex color of an imported .obj

Post by mongoose7 »

Kd?

Anyway, he's exported with a texture and expects the vertices to have the colour of the texture. The vertices are white, the texture is read. Enough said.
MTLZ
Posts: 11
Joined: Wed Apr 25, 2012 1:39 pm
Location: Paris, France
Contact:

Re: how do i get the vertex color of an imported .obj

Post by MTLZ »

Sorry to bring back this thread but I have exactly the same problem.
I'm looking for a mesh format that support materials and vertex colors. I though "obj" was the one but there is no vertex color.
Can anyone advice me which format Irrlicht can import with materials and vertex color ?

Thanks.
MTLZ
== Invisible Spirit - http://www.is06.com ==
chronologicaldot
Competition winner
Posts: 699
Joined: Mon Sep 10, 2012 8:51 am

Re: how do i get the vertex color of an imported .obj

Post by chronologicaldot »

Besides its native format? hm... Try b3d... I think...
Post Reply