Coloured cubes

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
FyShu^
Posts: 6
Joined: Sun May 27, 2007 12:57 pm

Coloured cubes

Post by FyShu^ »

Hello!!
As you can see, I'm really new to Irrlicht, and fairly new to C++, in fact, yet not new to programming.

I'm trying to make a 3D Tetris game with irrlicht, something simple to start me off, ya know :)

So, for Tetris, obviously I need coloured blocks. I have my own funky beveled block I modelled (and phew was that hard ;)) which I loaded into irrlicht as a IAnimatedMesh (... lol, i don't even know why, I should be using IMesh really) and subsequently made a IAnimatedMeshSceneNode... Looks nice, even without lighting =]

As you would expect, it's just grey.
How can I make this IAnimatedMeshSceneNode take on another colour, like, red, cyan, and blue? I suspect that it's to do with Materials, but I can't see anywhere in the SMaterial struct any options for setting a colour, only everything to do with lighting.

Basically, if you don't use a texture, how do you define a plain colour?

Many thanks for your attention and I hope I didn't waste too much of your time ;p
Robert Y.
Posts: 212
Joined: Sun Jan 28, 2007 11:23 pm

Post by Robert Y. »

Welcome to Irrlicht, FyShu^ !

You can do that in two ways:

1. Use smgr->getMeshManipulator()->setVertexColors().

or

2. Create a simple texture for your model like this: http://www.megaupload.com/?d=8S32FZEB
FyShu^
Posts: 6
Joined: Sun May 27, 2007 12:57 pm

Post by FyShu^ »

Thank you for your reply

the weird thing is, my little block is an IAnimatedMesh.

setVertexColors() only accepts IMesh as an argument.

So how on earth do I load a model as an IMesh anyway, when getMesh() only ever returns IAnimatedMesh :P

and an IAnimatedMesh isn't even derived from an IMesh, so no luck there.
Dances
Posts: 454
Joined: Sat Jul 02, 2005 1:45 am
Location: Canada
Contact:

Post by Dances »

getMesh("filenamehere")->getMesh(0);
FyShu^
Posts: 6
Joined: Sun May 27, 2007 12:57 pm

Post by FyShu^ »

Ahhh Thank you, I understand now :)
Post Reply