2 questions :) (white color ? and... origin unwanted change)

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
Lideln
Posts: 79
Joined: Sat Jun 24, 2006 11:35 am
Location: Paris, France

2 questions :) (white color ? and... origin unwanted change)

Post by Lideln »

Hi all !

Here I am with 2 new noob questions :lol:

1) The first one (the simplest I guess) :
I can't get many colours work....
When I write :

Code: Select all

const SColor COLOR_BOUNDING_BOX = SColor(255, 255, 255, 255);
I hope to get a white color, but no, I get red (or green, dont remember)...
The same happens if I try

Code: Select all

const SColor COLOR_BOUNDING_BOX = SColor(255, 255, 0, 255);
I get red as well...
Did I do something wrong ?

2) The second question (more difficult maybe)
I use the CQuadTreeSceneNode (picked here http://irrlicht.sourceforge.net/phpBB2/ ... hp?t=13500 thanks to bitplane), but when I put the first and the 42nd node on the map, (Im currently working on a simple level editor for my future game) it changes the origin of my whole world to the place where I put the node !! :shock:
(then everything is shifted, for example if I try to draw the bounding box of a node... the drawed box is shifted by a distance that equals the position of the "new" origin, substracted by the "normal" origin (0,0,0) )

Please, if someone knows what can be the cause of that thing, I would really appreciate any help :)


Thanks , and good evening !
--
Lideln, France
Lideln
Posts: 79
Joined: Sat Jun 24, 2006 11:35 am
Location: Paris, France

Post by Lideln »

PS :

after some tests, I can tell you that my second issue (the unwanted origin change) is not caused by the QuadTree itself, I have the same origin change when I put nodes using addMeshSceneNode

Is it something well known and normal, or am I doing something terribly wrong ? :)
--
Lideln, France
bitplane
Admin
Posts: 3204
Joined: Mon Mar 28, 2005 3:45 am
Location: England
Contact:

Post by bitplane »

you should be thanking prosoft for the quad tree node, not me :)
how are you setting that colour? you need to create a material, set solid rendering, turn lighting off, set the material's diffuse with the colour, set the material and ETS_WORLD transformation in the driver, and then draw the bounding box.
secondly.. the 1st and 42nd nodes you say? :shock: this sounds very strange, does it happen when creating another type of node (cube or billboard), or when using a different mesh loader? the only things i can think of- you're doing something terribly wrong, or a badly formed mesh (or loader bug) is causing memory corruption.
if it only happens with a certain mesh, can you upload it somewhere please?
Submit bugs/patches to the tracker!
Need help right now? Visit the chat room
Lideln
Posts: 79
Joined: Sat Jun 24, 2006 11:35 am
Location: Paris, France

Post by Lideln »

Hi Bitplane ! :)

(I thank you to having told me about that QuadTree node :) But I have still quesitons about it, I'll tell you about that later if you do accept )

1) For the color, I use :

Code: Select all

const SColor COLOR_AXIS_X = SColor(255, 255, 0, 0);
const SColor COLOR_AXIS_Y = SColor(255, 0, 255, 0);
const SColor COLOR_AXIS_Z = SColor(255, 0, 0, 255);
const SColor COLOR_BOUNDING_BOX = SColor(255, 255, 255, 255);


void CInGameScreen::preEnvDrawScreen()
{
        // Defines
	hotp->driver->draw3DLine(vector3df(0, 0, 0), vector3df(AXIS_LENGTH, 0, 0), COLOR_AXIS_X);
	hotp->driver->draw3DLine(vector3df(0, 0, 0), vector3df(0, AXIS_LENGTH, 0), COLOR_AXIS_Y);
	hotp->driver->draw3DLine(vector3df(0, 0, 0), vector3df(0, 0, AXIS_LENGTH), COLOR_AXIS_Z);
	
        // In ctor()
        material.Lighting = false;
        material.DiffuseColor = video::SColor( 255, 255, 255, 255 );

        //
        // All that follows is in a post world-rendering function (called after scene->drawAll();)
        //
        // Pitga is a pointer to the selected object (a tree or an experience shrine atm)
        // In fact, I put objects on the map with left click, and select an object with right click

        // Here I draw the origin (thats why I can see that the origin changed)
	hotp->driver->draw3DLine(vector3df(0, 0, 0), vector3df(AXIS_LENGTH, 0, 0), COLOR_AXIS_X);
	hotp->driver->draw3DLine(vector3df(0, 0, 0), vector3df(0, AXIS_LENGTH, 0), COLOR_AXIS_Y);
	hotp->driver->draw3DLine(vector3df(0, 0, 0), vector3df(0, 0, AXIS_LENGTH), COLOR_AXIS_Z);
	// Here I draw the base square of the selected object (to show that it is selected). This is here that I can also see the origin change, and that the white colour does not work
	if (ptiga != NULL)
	{
		vector3df _edges[8];
		core::aabbox3d<f32> bb = ptiga->getBoundingBox();
		vector3df pos = ptiga->getAbsolutePosition();
		bb.getEdges(&_edges[0]);
		vector3df elevation = vector3df(0, 0.1, 0);
		for (int i = 0; i < 8; ++i)
			_edges[i] += pos + elevation;
		hotp->driver->draw3DLine(_edges[0], _edges[2], COLOR_BOUNDING_BOX);
		hotp->driver->draw3DLine(_edges[2], _edges[6], COLOR_BOUNDING_BOX);
		hotp->driver->draw3DLine(_edges[6], _edges[4], COLOR_BOUNDING_BOX);
		hotp->driver->draw3DLine(_edges[4], _edges[0], COLOR_BOUNDING_BOX);
        }
}

2) For the origin change when I place an object...
I tried with another object (the experience shrine), using the addOctTreeSceneNode() function, and the same thing happened.

When I use the QuadTree instead, there are two behaviours :
If I use the "startAdding" and "endAdding" functions everytime I add an object, the origin change happens VERY OFTEN. If I do not use these functions, it does happen like I told in my previous post.
Strange, he ?

I also remarked another thing (just right now, because Im doing tests while writing this answer) : I have 3 objects types in my editor atm :
a ridiculous tree with "transparent" textures (that do not work lol), a less ridiculous tree, that I use for my tests, and an experience shrine (that does not draw its selection square... Strange !).
When I add the FIRST instance of each kind, it changes the origin to the position of that new node. Then its not doing this when I add the first object in the world, but the first of each type.

Maybe is my "origin drawing" code not good ? I hope no. But if it is good, then where is the error ?

If you need the project I can upload it somwhere, with the sources, and you will just have to compile.
If not, I hope that what I told in this answer will let you understand why it is doing this origin change... :cry:

For the white color (that is drawed as Red instead), I do not care a lot, but the origin change is more... huuu... "bad" for me ("problematic" ?)

Thank you a lot, and do not hesitate if you need the whole project.
--
Lideln, France
Lideln
Posts: 79
Joined: Sat Jun 24, 2006 11:35 am
Location: Paris, France

Post by Lideln »

PS :

I forgot two small things :

1) When I use the addMeshSceneNode or the addOctTreeSceneNode, the origin change happens (even with the Quadtree as I said earlier)

2) Something weird :
I draw the FPS in the window titlebar (like in some tuts), but you know that when you launch the engine, it takes 1 or 2 seconds before computing the first FPS (I think its quite normal... :) )
You know what ? Please, guess :lol:
....
If I add a node during this small time, the origin change DO NOT HAPPEN (but when I add another type of object later, it happens again of course :) )

Isn't that weird ? :shock:
--
Lideln, France
Lideln
Posts: 79
Joined: Sat Jun 24, 2006 11:35 am
Location: Paris, France

Post by Lideln »

I know, I know, it has just been one day but...

up ! :D
--
Lideln, France
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

it takes 1 or 2 seconds before computing the first FPS
That's normal. Have a look at CFPSCounter::registerFrame(). Basically the fps counter gives the average FPS over a two second period. Until two seconds have elapsed, there isn't enough data to do the average.

Travis
Lideln
Posts: 79
Joined: Sat Jun 24, 2006 11:35 am
Location: Paris, France

Post by Lideln »

Hi Vitek,

Thanks for the answer :
That's normal. Have a look at CFPSCounter::registerFrame().
But as I wrote :
it takes 1 or 2 seconds before computing the first FPS (I think its quite normal... Smile )
I know this is normal. What I find abnormal are the 2 questions I asked, and thats what I was praying to get answers for :)

Thanks anyway :)
--
Lideln, France
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

I think the problem is that you aren't setting the world transform when you draw your origin indicator lines. When you render something, you need to make sure that the matarials and the matrices have been setup so the objects render in the right place.

Simply putting driver->setTransform(video::ETS_WORLD, core::matrix4()) before you draw any lines will do what you want.

Travis
Lideln
Posts: 79
Joined: Sat Jun 24, 2006 11:35 am
Location: Paris, France

Post by Lideln »

Thank you Travis for this answer !

I'll try to have a look at it when I'm back home this evening.
I'll keep you informed, thanks again :)

Lideln
--
Lideln, France
Lideln
Posts: 79
Joined: Sat Jun 24, 2006 11:35 am
Location: Paris, France

Post by Lideln »

Hi Vitek !

Indeed, it was the problem ! Calling the "setTransform" function before drawing my origin or my bounding box solves the issue, it is now nice :D

Thanks again ! :)

Lideln

PS : I have still the issue with the white colour.
I have :

Code: Select all

const SColor COLOR_BOUNDING_BOX = SColor(255, 255, 255, 255);
hotp->driver->draw3DLine(_edges[0], _edges[2], COLOR_BOUNDING_BOX);
It sometimes draws it in grey, but most of time it draws it in orange. And for the experience shrine mesh, it is invisible.... :shock:
Why is it so random ???
--
Lideln, France
Post Reply