2D drawing functions vs. 3D billboards

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.
Isometric God
Posts: 69
Joined: Sun Oct 12, 2003 3:42 pm
Location: Germany

2D drawing functions vs. 3D billboards

Post by Isometric God »

I'm planning to do a HUD for my little shooter game which you can find here : http://www.eve-corp.com/Raptor :lol: and I was wondering whether to use the 2D drawing functions offered by the driver interface or the scene-managers billboard functions.

Also, I was wondering about generals pros & cons of the 2D drawing functions. :?:
thx in advance
[dx/x]=HUNT3R
Posts: 271
Joined: Sat Aug 23, 2003 5:52 pm
Location: Hurricane Central, Florida

Post by [dx/x]=HUNT3R »

I'm currently using the 2D drawing functions to do my HUD and everything works fine. Except for some reason one time my crosshair had little specks around it and I could not make them go away. I decreased the size of the crosshair jpeg and they're not there anymore.
t
Posts: 43
Joined: Sun Nov 02, 2003 2:59 am
Location: Australia

Post by t »

I had the same problem with my crosshair. reducing the size of the bitmap helped. (sounds like a bug to me)

Also, does anyone know how to get the 2d screen co-ordinate of a 3d position?

I want my crosshair to be like

Code: Select all

      y
       |
  ----+---z
       |
       
ship ------------- crosshair 
in 3d, but to be drawn with 2d functions so that it is always visible.
(or using a billboard that remains visible, if possible)
Isometric God
Posts: 69
Joined: Sun Oct 12, 2003 3:42 pm
Location: Germany

Post by Isometric God »

the specks around the crosshair seem to be a result of bi-linear filtering. Turn it off, and the specks will disappear.

Concerning the coordination translation : There is a function pair which is able to convert screen coordinates to world coordinates and vice versa. I just forgot the name, sorry :roll:
Maybe it's somewhere in the camera classes ...
[dx/x]=HUNT3R
Posts: 271
Joined: Sat Aug 23, 2003 5:52 pm
Location: Hurricane Central, Florida

Post by [dx/x]=HUNT3R »

I don't think mine were from bilinear filtering, the specks were inside the transparent area of my crosshair which was black in the crosshair jpeg. No matter how many times I went back and blacked out my crosshair pic, they were still there in the same places each time I ran the game. I tested it on a bunch of computers too with all different kinds of video cards and had the same results each time. The only fix was to make the crosshair pic smaller for some reason. Strangely enough, this is the only pic thats had this problem in my game as I have loaded many others into the game without any problem. Like the cockpit, which covers the whole screen and has blacked out windows.
saigumi
Posts: 921
Joined: Fri Aug 22, 2003 11:31 am
Location: St. Louis, MO USA
Contact:

Post by saigumi »

This one?

Code: Select all

virtual core::position2d<s32> irr::scene::ISceneCollisionManager::getScreenCoordinatesFrom3DPosition  (  core::vector3df    pos,  
  ICameraSceneNode *    camera = 0 
 )  [pure virtual] 
 
   Calculates 2d screen position from a 3d position. 

Parameters: 
pos:  3D position in world space to be transformed into 2d.  
camera:  Camera to be used. If null, the currently active camera is used.  

Returns: 
Returns the 2d screen coordinates which a object in the 3d world would have if it would be rendered to the screen. If the 3d position is behind the camera, it is set to (-10000,-10000). In most cases you can ignore this fact, because if you use this method for drawing a decorator over a 3d object, it will be clipped by the screen borders 

Crud, how do I do this again?
t
Posts: 43
Joined: Sun Nov 02, 2003 2:59 am
Location: Australia

Post by t »

Thanks for that! :)

As for my crosshair pixel problem, my problem was the same as [dx/x]=HUNT3R's.
Isometric God
Posts: 69
Joined: Sun Oct 12, 2003 3:42 pm
Location: Germany

Post by Isometric God »

the 2D drawing function seem to lack the alpha-blending feature somehow. Is that possible ? I tried to load a 32bit un-compressed TGA, but it wont show up if I set the "useAlphaFromFile" bool to true.

And makeColorKeyTexture(..) doesn't do anything but convert my transparent color ( pink ) into pure black. Doesn't make much sense for me. Anybody has an idea ?
Guest

Post by Guest »

Perhaps the speckles were generated during jpeg-compression. Very fine structures like Lines or Text will receive some noise at higher compression rates. Maybe that is the Problem. Try to Load the crosshair as BMP.
t
Posts: 43
Joined: Sun Nov 02, 2003 2:59 am
Location: Australia

Post by t »

Guest, good point. I had the same thought, but the same problem occured using .bmp files.
Isometric God
Posts: 69
Joined: Sun Oct 12, 2003 3:42 pm
Location: Germany

Post by Isometric God »

I'm quite sure that the specks show up due to bilinear filtering. I don't know the exact source of the problem though...
[dx/x]=HUNT3R
Posts: 271
Joined: Sat Aug 23, 2003 5:52 pm
Location: Hurricane Central, Florida

Post by [dx/x]=HUNT3R »

Anonymous wrote:Try to Load the crosshair as BMP.
I already had with the same results. It's strange that my 2D cockpit picture that covers most of the screen does not suffer from the same problems.
t
Posts: 43
Joined: Sun Nov 02, 2003 2:59 am
Location: Australia

Post by t »

[dx/x] where in your source bitmap is the picture? in mine it was at the left edge... maybe that's the problem? what happens if it is moved to the right of the bitmap away from any borders
[dx/x]=HUNT3R
Posts: 271
Joined: Sat Aug 23, 2003 5:52 pm
Location: Hurricane Central, Florida

Post by [dx/x]=HUNT3R »

my bitmap was right in the center.
squonk
Posts: 1
Joined: Thu Nov 20, 2003 11:21 pm

Post by squonk »

@IsoGod regarding your color keyin problem:
Do you use the DirectX driver? Afaik that's the way the ColorKey function works in DX. At least the DX9 SDK mentions this. Don't know about DX8 or OpenGl. So if Irrlicht just uses the DX function that would explain why the color keying function does... er... what it does ;)
Btw, I'm not sure if the function affects the alpha channel in any way (given the selected display mode supports an alpha channel)

squonk
Post Reply