[no bug] SColor not working..

You discovered a bug in the engine, and you are sure that it is not a problem of your code? Just post it in here. Please read the bug posting guidelines first.
Post Reply
flip
Posts: 5
Joined: Tue May 19, 2009 9:10 pm

[no bug] SColor not working..

Post by flip »

Code: Select all

#include <irrlicht.h>

using namespace irr;

using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;

#pragma comment(lib, "Irrlicht.lib")

int main()
{

   /* Bugfix: EDT_SOFTWARE2 is not defined in irrlicht 1.3, use
      EDT_SOFTWARE of EDT_OPENGL instead.

   IrrlichtDevice *device =
      createDevice( video::EDT_SOFTWARE2, dimension2d<s32>(640, 480), 16,
                    false, false, false, 0);
   */

   IrrlichtDevice *device =
	   createDevice( video::EDT_DIRECT3D9, dimension2d<s32>(640, 480), 32,
                    false, false, false, 0);


   device->setWindowCaption(L"Isometric Projection");

   IVideoDriver* driver = device->getVideoDriver();


   while(device->run())
   {
      /*
		Anything can be drawn between a beginScene() and an endScene()
		call. The beginScene clears the screen with a color and also
		the depth buffer if wanted. Then we let the Scene Manager and
		the GUI Environment draw their content. With the endScene()
		call everything is presented on the screen.
      */
      driver->beginScene(true, true, SColor(255,200,100,150));

      /**
       * we are not interested in this transform so let us set it to
       * identity
       */
      driver->setTransform(video::ETS_WORLD, core::matrix4());
      driver->setTransform(video::ETS_VIEW, core::matrix4());

      /**
       * first portion of transform - in matrix form
       * x' = (x - z)
       * y' = y + 0.5 * ( x + z )
       * this maps the z to the x and y axes in such a way that 
       * the result appears isometric. 
       */ 

      /* Bugfix: M is private member, to access values use simply
         projMatrix[index], not the projMatrix.M[index]

      matrix4 projMatrix;
      projMatrix.makeIdentity();
      projMatrix.M[0] = 1.0f;
      projMatrix.M[8] = -1.0f;
      projMatrix.M[1] = 0.5f;
      projMatrix.M[5] = 1.0f;
      projMatrix.M[9] = 0.5f;
      projMatrix.M[10] = 0.0;
      */

      matrix4 projMatrix;
      projMatrix.makeIdentity();
      projMatrix[0] = 1.0f;
      projMatrix[8] = -1.0f;
      projMatrix[1] = 0.5f;
      projMatrix[5] = 1.0f;
      projMatrix[9] = 0.5f;
      projMatrix[10] = 0.0;

      /**
       * second portion of transform -- scale to fit clipping
       * volume. If the scale is 1.0f then the unit vectors fit the
       * clipping volume. The volume is a cuboid, centered in the origin.
       * The scaling will determine the size of this volume which will
       * contain the portion of the world that we can see.
       */
      f32 scale = 4.0f;
      matrix4 clipMatrix;
      clipMatrix.buildProjectionMatrixOrthoLH(2 * scale, 2 * scale ,-1 * scale, 1 * scale);


      /**
       * concatentate transform - we multiply transforms together in
       * the opposite order to that which we would apply them to a
       * vector because of the law of associativity applies to
       * matrices, but not commutivity and NM != MN fun,
       * eh..matrices..gotta luv em..
       */
      projMatrix = clipMatrix * projMatrix;

      /**
       * ok we now have our projection matrix
       */
      driver->setTransform(video::ETS_PROJECTION, projMatrix);


      /**
       * draw unit x, y, and z vectors in our new space
       */

      // x axis is red
      driver->draw3DLine(vector3df(-1.0, 0.0, 0.0),
                         vector3df(1.0, 0.0, 0.0),
                         SColor(0,255,255,0));

      // y axis is green
      driver->draw3DLine(vector3df(0.0, -1.0, 0.0),
                         vector3df(0.0, 1.0, 0.0),
                         SColor(255,0,255,0));

      // z axis is blue
      driver->draw3DLine(vector3df(0.0, 0.0, -1.0),
                         vector3df(0.0, 0.0, 1.0),
                         SColor(200,255,0,255));



      /**
       * done
       */
      driver->endScene();
   }

   device->drop();

   return 0;
}

SColor doesn't color lines when calling "draw3DLine", is this bug or what is it?
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Just check the docs, you need to set a material and be careful with lighting.
Post Reply