lasers generating in the wrong position

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
PWAUVAN
Posts: 8
Joined: Thu Mar 01, 2007 7:19 pm
Location: Milwaukee

lasers generating in the wrong position

Post by PWAUVAN »

Hey all,

I have this ship flying demo I am creating. I can move the ship and fly and swoop and whatever, but the issue is with the laser projectiles being fired. It seems to do fine when I am close to absolute (0,0,0), but the farther I fly away from that point the lasers don't appear on the ship anymore, they appear.
Here is the constructor for the Laser:

Code: Select all

//Ship is a ship which contains information about the ship as well as the ship' node
//CannonPosition is the position of the cannon firing the laser relative to the center of the ship
//TargetDirection is the direction the laser is being fired in
public Laser(Ship ship, Vector3D CannonPosition, Vector3D TargetDirection)
        {
            
            lasernode = new LaserBeamNode(null, ship.smgr, 200, "green.bmp");
            lasernode.StartPoint = ship.Node.Position + CannonPosition;
            //InitPosition is the original position of the laser, used to destroy a laser after it has gone a certain distance without colliding with something.
            InitPosition = ship.Node.AbsolutePosition + CannonPosition;
            lasernode.EndPoint = ship.Node.Position + CannonPosition + (TargetDirection * 100);
            lasernode.BeamColor = ship.LaserColor;
            lasernode.BeamScale = 1;
            direction = TargetDirection;//*/
        }

It flies in the correct direction after it is generated fine, the problem is that the further away the ship is from (0,0,0) absolute center, the farther away from the ship the node is generated.

NOTE: THis is in C# using Irrlicht.NET CP, but the code should be easy enough to read for all the c++ users out there. I read the c++ to get my ideas when using c#.


Thanks for the help
PWAUVAN (Programmer With An Unnecessarily Verbose Acronym Name
Midnight
Posts: 1772
Joined: Fri Jul 02, 2004 2:37 pm
Location: Wonderland

Post by Midnight »

I don't think the above code is causing the problem.

my first guess would be you need to update the matrix.

I'm not really about to start debugging.. provide more source maybe.
RapchikProgrammer
Posts: 279
Joined: Fri Dec 24, 2004 6:37 pm

Post by RapchikProgrammer »

How far off is the laser? Can u even see the laser? A screenshot might be helpful with some more code!
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Post by rogerborg »

Is CannonPosition being recalculated relative to ship.Node.Position? I.e. are you really starting at:

ship.Node.Position + ship.Node.Position + CannonPosition

Wait... what does your debugger tell you? ;)
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
PWAUVAN
Posts: 8
Joined: Thu Mar 01, 2007 7:19 pm
Location: Milwaukee

Post by PWAUVAN »

The problem with my debugger is I can only see what breakpoint I am at when the program is not in fullscreen mode, and for some reason, while Direct3D9 beats the pants off of OpenGL in fullscreen mode, it totally fails in Windowed mode. SO in order to use the debugger I have to have Irrlicht set to OpenGL instead of Direct#D9, and the projectiles seem to act even wierder in OpenGL for some inexplicable reason. I did find though that when I decided to fire a standard cube instead of a laser using that logic, the the cubes seemed to fire with no problems whatsoever, leading me to conclude that the problem lies not within my code, but within the laserbeam code I was using.
PWAUVAN (Programmer With An Unnecessarily Verbose Acronym Name
Post Reply