I don't think you can use the material for coloring without texture and without lighting. With lighting you can set the emissive-color to guarantee a red color.
I think it should work by setting the color of the vertices directly, but I haven't tried and missing the time at the moment to write an example. Checkout S3DVertex - you can get that from the Meshbuffer, I'm sure you figure it out somehow :-)
CuteAlien wrote:Checkout S3DVertex - you can get that from the Meshbuffer, I'm sure you figure it out somehow :-)
No, I cannot get S3DVertex from meshbuffer because no documented method of IMeshBuffer returns S3DVertex or array thereof. What do I do with the void* returned by getVertices()? Static_cast it to S3DVertex? If there is only one S3DVertex that covers all vertex types then why doesn't IMeshBuffer::getVertices just return S3DVertex* in the first place?
edit: Oh yes, there's are also S3DVertex2TCoords and S3DVertexTangents, so:
switch(meshBuf->getVertexType()) {
case EVT_STANDARD: {
S3DVertex* begin=static_cast<S3DVertex*>(meshBuf->getVertices());
S3DVertex* end = begin + meshBuf->getVertexCount();
//... code
break;
}
case EVT_2TCOORDS: {
S3DVertex2TCoords* begin=static_cast<S3DVertex2TCoords*>(meshBuf->getVertices());
S3DVertex2TCoords* end = begin + meshBuf->getVertexCount();
//... exact same code
break;
}
case EVT_TANGENTS: {
S3DVertexTangents* begin=static_cast<S3DVertexTangents*>(meshBuf->getVertices());
S3DVertexTangents* end = begin + meshBuf->getVertexCount();
//... exact same code yet again
break;
}
}
... because I cannot KNOW that addCubeSceneNode returns a mesh with S3DVertex vertices. It is not documented.
Just... wonderful.
Last edited by Rulatir on Wed Nov 18, 2009 7:02 am, edited 1 time in total.
You can find out which type it has with getVertexType () and the clean solution is checking that and then casting to the corresponding type. But in the case of the cube it will be an video::S3DVertex unless you changed it yourself, so yes, you can static_cast to that.
CuteAlien wrote:You can find out which type it has with getVertexType () and the clean solution is checking that and then casting to the corresponding type.
Your response and my edit collided mid-air. Still, even if I know the vertex type for the "cube scene node", handling more general cases would require the nasty boilerplate :(
I just checked and I think in your case it might be possible to avoid the boilerplate code. All vertex types are derived from S3DVertex and you can get the size of the vertex-type with getVertexPitchFromType.
CuteAlien wrote:I just checked and I think in your case it might be possible to avoid the boilerplate code. All vertex types are derived from S3DVertex and you can get the size of the vertex-type with getVertexPitchFromType.
Btw, you can obtain the mesh manipulator using sceneManager->getMeshManipulator().
But I don't know why you want to go the vertex route, I think that you can just set diffuse color and specular color to black, enable lighting, and set emissive to the one that you need, this should satisfy all cases.