Jump to content


Photo

Homeworld style Ion Cannon?


  • Please log in to reply
5 replies to this topic

#1 sharpe_alex10@yahoo.com

sharpe_alex10@yahoo.com

    GMC Member

  • New Member
  • 76 posts

Posted 20 February 2012 - 10:35 PM

Homeworld is an old RTS game. It had Ion Cannon Frigates that I am trying to replicate, and I am almost done.

As the description mentioned I have all the coding I need for the ships functions: quaternions, textures, ray casting for collision checking, I even have the beam being drawn in the right direction the ship is facing. I just need to get the beam, drawn in the form of a 2d sprite with no rotation except the rotation of the ship right now, to face the camera so that the beam looks like a beam and not a flat sprite. (rotation around the x axis)


camera variables:
x,y,z -> global.fromx,global.fromy,global.fromz


Draw event code I have now for the replicated frigate:

//turn off lighting and culling for the sprite drawing
d3d_set_lighting(false);
d3d_set_culling(false);

if (firing)
{
d3d_transform_set_identity();
d3d_add_rotation_quaternion(Qw,Qx,Qy,Qz);//point in the same direction as the quaternion



//d3d_transform_add_rotation_x(beam rotation script goes here returning the right value);



d3d_transform_add_translation(x+FVx*10,y+FVy*10,z+FVz*10)//move the start of the beam to the front of the ship
draw_sprite_ext(tex_IonCannonBeam,0,0,0,beam_distance,.05,0,c_white,1);// draw the actual beam
d3d_transform_set_identity();
}

d3d_set_lighting(true);
d3d_set_culling(true);
if (point_distance3d(x, y, z, global.fromx, global.fromy, global.fromz) < visible_range)
{
d3d_add_rotation_quaternion(Qw,Qx,Qy,Qz);
d3d_transform_add_translation(x,y,z);
d3d_model_draw(global.TS_IonCannonFrig_model,0,0,0,global.tex_ship_tex);
d3d_transform_set_identity();
}




I don't know the math I would need to find the value and I have looked everywhere.

EXAMPLE IMAGE:
http://media.photobucket.com/image/ion%20cannon%20homeworld/DrunkenGrognard/homeworld-1.jpg
Posted Image

Edited by sharpe_alex10@yahoo.com, 20 February 2012 - 10:38 PM.

  • 0

#2 hit172

hit172

    GMC Member

  • New Member
  • 189 posts
  • Version:GM8

Posted 21 February 2012 - 12:00 AM

Homeworld is an old RTS game. It had Ion Cannon Frigates that I am trying to replicate, and I am almost done.

As the description mentioned I have all the coding I need for the ships functions: quaternions, textures, ray casting for collision checking, I even have the beam being drawn in the right direction the ship is facing. I just need to get the beam, drawn in the form of a 2d sprite with no rotation except the rotation of the ship right now, to face the camera so that the beam looks like a beam and not a flat sprite. (rotation around the x axis)


camera variables:
x,y,z -> global.fromx,global.fromy,global.fromz


Draw event code I have now for the replicated frigate:


//turn off lighting and culling for the sprite drawing
d3d_set_lighting(false);
d3d_set_culling(false);

if (firing)
{
d3d_transform_set_identity();
d3d_add_rotation_quaternion(Qw,Qx,Qy,Qz);//point in the same direction as the quaternion



//d3d_transform_add_rotation_x(beam rotation script goes here returning the right value);



d3d_transform_add_translation(x+FVx*10,y+FVy*10,z+FVz*10)//move the start of the beam to the front of the ship
draw_sprite_ext(tex_IonCannonBeam,0,0,0,beam_distance,.05,0,c_white,1);// draw the actual beam
d3d_transform_set_identity();
}

d3d_set_lighting(true);
d3d_set_culling(true);
if (point_distance3d(x, y, z, global.fromx, global.fromy, global.fromz) < visible_range)
{
d3d_add_rotation_quaternion(Qw,Qx,Qy,Qz);
d3d_transform_add_translation(x,y,z);
d3d_model_draw(global.TS_IonCannonFrig_model,0,0,0,global.tex_ship_tex);
d3d_transform_set_identity();
}




I don't know the math I would need to find the value and I have looked everywhere.

EXAMPLE IMAGE:
http://media.photobucket.com/image/ion%20cannon%20homeworld/DrunkenGrognard/homeworld-1.jpg
Posted Image


Try making a second sprite that is a round sprite that looks like it is facing the camera and draw it where the camera collides with the laser beam.
  • 0

#3 sharpe_alex10@yahoo.com

sharpe_alex10@yahoo.com

    GMC Member

  • New Member
  • 76 posts

Posted 21 February 2012 - 12:19 AM


Homeworld is an old RTS game. It had Ion Cannon Frigates that I am trying to replicate, and I am almost done.

As the description mentioned I have all the coding I need for the ships functions: quaternions, textures, ray casting for collision checking, I even have the beam being drawn in the right direction the ship is facing. I just need to get the beam, drawn in the form of a 2d sprite with no rotation except the rotation of the ship right now, to face the camera so that the beam looks like a beam and not a flat sprite. (rotation around the x axis)


camera variables:
x,y,z -> global.fromx,global.fromy,global.fromz


Draw event code I have now for the replicated frigate:


//turn off lighting and culling for the sprite drawing
d3d_set_lighting(false);
d3d_set_culling(false);

if (firing)
{
d3d_transform_set_identity();
d3d_add_rotation_quaternion(Qw,Qx,Qy,Qz);//point in the same direction as the quaternion



//d3d_transform_add_rotation_x(beam rotation script goes here returning the right value);



d3d_transform_add_translation(x+FVx*10,y+FVy*10,z+FVz*10)//move the start of the beam to the front of the ship
draw_sprite_ext(tex_IonCannonBeam,0,0,0,beam_distance,.05,0,c_white,1);// draw the actual beam
d3d_transform_set_identity();
}

d3d_set_lighting(true);
d3d_set_culling(true);
if (point_distance3d(x, y, z, global.fromx, global.fromy, global.fromz) < visible_range)
{
d3d_add_rotation_quaternion(Qw,Qx,Qy,Qz);
d3d_transform_add_translation(x,y,z);
d3d_model_draw(global.TS_IonCannonFrig_model,0,0,0,global.tex_ship_tex);
d3d_transform_set_identity();
}




I don't know the math I would need to find the value and I have looked everywhere.

EXAMPLE IMAGE:
http://media.photobucket.com/image/ion%20cannon%20homeworld/DrunkenGrognard/homeworld-1.jpg
Posted Image


Try making a second sprite that is a round sprite that looks like it is facing the camera and draw it where the camera collides with the laser beam.


That would not work because the entire beam is one large 2d sprite/line drawn in 3d space. You cant place a round sprite over it. I am not just trying to cover the ends of the line, I am trying to rotate the line.
  • 0

#4 hit172

hit172

    GMC Member

  • New Member
  • 189 posts
  • Version:GM8

Posted 21 February 2012 - 01:46 AM



Homeworld is an old RTS game. It had Ion Cannon Frigates that I am trying to replicate, and I am almost done.

As the description mentioned I have all the coding I need for the ships functions: quaternions, textures, ray casting for collision checking, I even have the beam being drawn in the right direction the ship is facing. I just need to get the beam, drawn in the form of a 2d sprite with no rotation except the rotation of the ship right now, to face the camera so that the beam looks like a beam and not a flat sprite. (rotation around the x axis)


camera variables:
x,y,z -> global.fromx,global.fromy,global.fromz


Draw event code I have now for the replicated frigate:


//turn off lighting and culling for the sprite drawing
d3d_set_lighting(false);
d3d_set_culling(false);

if (firing)
{
d3d_transform_set_identity();
d3d_add_rotation_quaternion(Qw,Qx,Qy,Qz);//point in the same direction as the quaternion



//d3d_transform_add_rotation_x(beam rotation script goes here returning the right value);



d3d_transform_add_translation(x+FVx*10,y+FVy*10,z+FVz*10)//move the start of the beam to the front of the ship
draw_sprite_ext(tex_IonCannonBeam,0,0,0,beam_distance,.05,0,c_white,1);// draw the actual beam
d3d_transform_set_identity();
}

d3d_set_lighting(true);
d3d_set_culling(true);
if (point_distance3d(x, y, z, global.fromx, global.fromy, global.fromz) < visible_range)
{
d3d_add_rotation_quaternion(Qw,Qx,Qy,Qz);
d3d_transform_add_translation(x,y,z);
d3d_model_draw(global.TS_IonCannonFrig_model,0,0,0,global.tex_ship_tex);
d3d_transform_set_identity();
}




I don't know the math I would need to find the value and I have looked everywhere.

EXAMPLE IMAGE:
http://media.photobucket.com/image/ion%20cannon%20homeworld/DrunkenGrognard/homeworld-1.jpg
Posted Image


Try making a second sprite that is a round sprite that looks like it is facing the camera and draw it where the camera collides with the laser beam.


That would not work because the entire beam is one large 2d sprite/line drawn in 3d space. You cant place a round sprite over it. I am not just trying to cover the ends of the line, I am trying to rotate the line.

You might need to find a way to make the ion cannon out of 3d models so that you can view it from any angle. I would suggest having a series of semi transparent cylinders that start as blue and almost completely transparent on the outside and as you move inwards, it gets whiter and more opaque.
  • 0

#5 Gamer3D

Gamer3D

    Human* me = this;

  • GMC Member
  • 1589 posts
  • Version:GM8.1

Posted 21 February 2012 - 10:08 PM

My example (Rather old, still applies)

Use a cross product to find a vector perpendicular to a look vector and the laser's direction. Normalize it, then use that as an offset from the endpoints of the laser.
  • 2

#6 sharpe_alex10@yahoo.com

sharpe_alex10@yahoo.com

    GMC Member

  • New Member
  • 76 posts

Posted 25 February 2012 - 04:35 AM

My example (Rather old, still applies)

Use a cross product to find a vector perpendicular to a look vector and the laser's direction. Normalize it, then use that as an offset from the endpoints of the laser.



THIS IS WHAT IM LOOKING FOR! Thanks! I can now continue working on my game. This problem has had me stumped for months. Once more thanks!

If you want you can go in the credits of my game... Just PM me.
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users