[Solved] Plastic cube

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
Grz-
Posts: 62
Joined: Wed Dec 26, 2007 1:06 pm

[Solved] Plastic cube

Post by Grz- »

Hello,

i want to try to acheive this kind of plastic rendering in my game for cubes&characters but i don't know where to start:

http://www.iikgames.com/bouncyqubes/images/image07.jpg

I tried a toon shader and also many different light settings but that doesn't look like the same, i also tried flat shading but for some reason i can't get this smooth plastic/marshmallow feeling, this look simple but i can't get the same rendering, any hint on how that was done please?
Last edited by Grz- on Wed Oct 14, 2009 12:17 pm, edited 1 time in total.
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

The 'marshmallow' look happens because the cubes aren't actually cubes. They bulge at the sides a bit, which makes them seem squished a little. Instead of using cubes, use a modelled mesh object with the correct shape.

Travis
Grz-
Posts: 62
Joined: Wed Dec 26, 2007 1:06 pm

Post by Grz- »

Thank. Do the blob use this 'technic' too? So it's just some high poly models with lighting?
Beroc
Posts: 18
Joined: Fri Sep 28, 2007 3:25 pm

Post by Beroc »

none of those models look particularly "high" poly. I would say anywhere between 100 and 500 polygons per model at the highest and you could achieve the same result. look for a toon shader tutorial to get the look you are going for.
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

It looks to me like all of this could easily be done with 2d sprites, possibly rendered from 3d objects. Even if they are 3d, I don't think the models have to be exceptionally high quality to get what you see in that image.

Travis
jpoag
Posts: 25
Joined: Mon Aug 10, 2009 1:00 am

Post by jpoag »

Is that dEvil Dice?

Looks like the old playstation game minus the numbers. If that's the case then the cubes rotate about their corners (and need to be 3d models).
-James
Grz-
Posts: 62
Joined: Wed Dec 26, 2007 1:06 pm

Post by Grz- »

Nop, it's a remake of Q*Bert without the pyramid level style: http://www.iikgames.com/bouncyqubes/

Well i know that theses was not particularly high poly but by looking at the blob shape/ligthing, it seem to be pretty smooth, anyway i will try to make the same kind of mesh and render it with a toon shader, thank.

PS: Looking at the system requirement, it seem this game don't use any shaders, it would be better if i can avoid using shaders too... i don't think toon shader is necessary...
DavidJE13
Posts: 165
Joined: Tue Jan 09, 2007 7:17 pm

Post by DavidJE13 »

looks like ~80 triangles per block (10 per corner) would be easily enough to match this game (you can see it's fairly low poly). Even less if you don't include the cube bases & other faces you never see.
You don't need to use any special toon stuff - this thing's just using textures with 1 light square and the rest slightly darker. There's not even any lighting.
Grz-
Posts: 62
Joined: Wed Dec 26, 2007 1:06 pm

Post by Grz- »

I tried to make a cube mesh that have round edge and exported it to .obj but now edge are shown by blacks line in irrlicht:

Image

it look like that in Blender:

Image

I used only material color with shadeless option.

Here is the code i use to add the mesh:

Code: Select all

            node = smgr->addMeshSceneNode(qbe);
            node->setScale(core::vector3df(5.0f,5.0f,5.0f));
            node->setPosition(core::vector3df(xOffset,yOffset,zOffset));
            node->setRotation(core::vector3df(0.0f,45.0f,0.0f));
            node->setMaterialFlag(video::EMF_WIREFRAME,false);
            node->setMaterialFlag(video::EMF_LIGHTING,false);
The mesh can be downloaded here:

.obj
.mtl
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

Looks like you had a problem exporting your mesh to me. You could use the 09.MeshViewer example to look at it, or you could use the following code...

Code: Select all

#include <irrlicht.h>
using namespace irr;

#ifdef _IRR_WINDOWS_
#  pragma comment(lib, "Irrlicht.lib")
#endif

int main()
{
  IrrlichtDevice *device = createDevice(video::EDT_OPENGL);
  if (!device)
    return 1;

  video::IVideoDriver* driver = device->getVideoDriver();
  scene::ISceneManager* smgr = device->getSceneManager();

  // get a camera
  scene::ISceneNode* camera = smgr->addCameraSceneNodeFPS();

  const core::vector3df pos(1020.f, 0.f, 1020.f);
  camera->setPosition(pos);

  // get some background
	smgr->addSkyBoxSceneNode(
    driver->getTexture("../../media/irrlicht2_up.jpg"),
	  driver->getTexture("../../media/irrlicht2_dn.jpg"),
	  driver->getTexture("../../media/irrlicht2_lf.jpg"),
	  driver->getTexture("../../media/irrlicht2_rt.jpg"),
	  driver->getTexture("../../media/irrlicht2_ft.jpg"),
	  driver->getTexture("../../media/irrlicht2_bk.jpg"));

  scene::IAnimatedMesh* mesh = smgr->getMesh("../../media/qbe.obj");

  scene::ISceneNode* node = smgr->addMeshSceneNode(mesh->getMesh(0));
  node->setMaterialFlag(video::EMF_LIGHTING, false);
  node->setMaterialFlag(video::EMF_WIREFRAME, true);
  //node->setMaterialFlag(video::EMF_BACK_FACE_CULLING, false);

  const core::vector3df scl (1000.f, 1000.f, 1000.f);
  node->setScale(scl);

  while(device->run()) 
  { 
    if (driver->beginScene(true, true, video::SColor(0,200,200,200))) 
    { 
      smgr->drawAll(); 

      driver->endScene(); 
    } 
  } 

  device->drop();

  return 0;
}
As you can see, some of the faces along the edges are flipped. If you leave backface culling on, they will not be rendered. If you fix your mesh, or disable backface culling, then the cube will appear as intended.

Travis
Grz-
Posts: 62
Joined: Wed Dec 26, 2007 1:06 pm

Post by Grz- »

Great, i fixed the mesh and added some nice materials/lights settings and it's close that i wanted, thank you all. :)

Image
Virion
Competition winner
Posts: 2148
Joined: Mon Dec 18, 2006 5:04 am

Post by Virion »

hey that's looking great 8) good luck
Eigen
Competition winner
Posts: 375
Joined: Fri Jan 27, 2006 2:01 pm
Location: Estonia
Contact:

Post by Eigen »

Q*Bert remake? :D
Post Reply