Casting or assignment problem... Very confused

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
LittleGiant
Posts: 15
Joined: Wed Jun 02, 2004 1:53 am

Casting or assignment problem... Very confused

Post by LittleGiant »

Code: Select all

vector2df vPos;
vPos.X = (f32)(event.MouseInput.X - 400);
vPos.Y = (f32)(event.MouseInput.Y - 300);
Is there any reason that this code would not work as expect, i get values in vector that make no sense. I've tried a bunch of permutations and different casts.

PS - the values in the event are reasonable, not a case of them being undefined or some such.

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

Post by vitek »

Depends on what you are trying to get. If you want the mouse position subtract (400, 300) and then casted to a float, then that is what you're going to get. Most likely that is not what you want. Maybe you want the mouse position as a fraction of the screen size or something like that?
LittleGiant
Posts: 15
Joined: Wed Jun 02, 2004 1:53 am

Post by LittleGiant »

I'm simply looking for the position of the mouse around an origin of the center of the screen.

i've trouble shot this more and it seems like there is only an issue when i try to assign these values to members of a struct, defined in the class i'm working in...

Still confused but this seems to suggest this is more a general c++ error then an error in my use of Irrlitch.

Sorry about this.

-Chris
LittleGiant
arras
Posts: 1622
Joined: Mon Apr 05, 2004 8:35 am
Location: Slovakia
Contact:

Post by arras »

I'm simply looking for the position of the mouse around an origin of the center of the screen.
Your code work fine for me if screen size is 800 x 600. Check if event.MouseInput.X and Y are returning correct walues. Also in case you don't know, origin of screen is in upper left corner of your monitor.
Post Reply