Jump to content


Photo

Curved 3D line using x and y points


  • Please log in to reply
5 replies to this topic

#1 95jonpet

95jonpet

    GMC Member

  • GMC Member
  • 76 posts
  • Version:GM:Studio

Posted 30 June 2012 - 09:58 PM

Hello!

I am making a 3D game, and I need to make 3D walls in a seamless fashion using X and Y coordinates as well as a direction and a width + height of the wall.
I know about finding a straight line between to points and making walls from a 3D model, but is there a way to make it curved and not very jagged like a stair?

The coordinates are a set of data from various arrays, so atleast 2 are needed in order for this to work, the line should pass through all coordinates and still be 3-dimensional. This means that each coordinate should probably mark a turning point for the long wall/curve.

I greatly appreciate help with this.

Edited by 95jonpet, 30 June 2012 - 10:02 PM.

  • 0

#2 1101

1101

    GMC Member

  • New Member
  • 460 posts

Posted 01 July 2012 - 05:36 AM

I'm not quite entirely sure what you're asking for but here is one way of drawing curved lines in 3D:

d3d_primitive_begin(pr_linestrip);
var i,ii,iii;
i = 0; ii = 0; iii = 0;
d3d_vertex_color(i,ii,iii,c_teal,1);
repeat(100)
{
    i += 1;
    ii += 2*i;
    iii += i*i;
    d3d_vertex_color(i,ii,iii,c_teal,1);
}
d3d_primitive_end();

Here the rates at which i,ii, and iii change in the repeat loop determine how the line curves, the values I used are just an example. The only other way I can think of would be to plot a line in 2D and then project it into 3D but it wouldn't really be a 3D curve just a 2D one in 3D space.

Edited by 1101, 01 July 2012 - 05:37 AM.

  • 0

#3 95jonpet

95jonpet

    GMC Member

  • GMC Member
  • 76 posts
  • Version:GM:Studio

Posted 01 July 2012 - 06:20 AM

It doesn't really need to be 3D, it can be 2D and then projected in 3D, so that it has a width and a height. This is because the z coordinate doesn't change. However, I need it to be quite fast, but this should be faster than dealing with tons of models all the time. How is this projection done?

Also, how to I change the width and height of the wall with your code?

Edited by 95jonpet, 01 July 2012 - 06:32 AM.

  • 0

#4 1101

1101

    GMC Member

  • New Member
  • 460 posts

Posted 01 July 2012 - 06:32 AM

It doesn't really need to be 3D, it can be 2D and then projected in 3D, so that it has a width and a height. How is that done?


Are you asking how to make curved walls?

Something like this?:
Spoiler


If that's the case the easiest way is to use d3d_draw_block and use rectangles to approximate the shape of the curve.

Edited by 1101, 01 July 2012 - 06:33 AM.

  • 0

#5 95jonpet

95jonpet

    GMC Member

  • GMC Member
  • 76 posts
  • Version:GM:Studio

Posted 01 July 2012 - 06:35 AM

Are you asking how to make curved walls?

If that's the case the easiest way is to use d3d_draw_block and use rectangles to approximate the shape of the curve.


Yea, it should look a bit like that.
The script that you gave me is great and does what I want, but the line is in 2D and not 3D. Hence the function should be similar but a bit morphed so that the line appears in 3D.

Edited by 95jonpet, 01 July 2012 - 06:43 AM.

  • 0

#6 95jonpet

95jonpet

    GMC Member

  • GMC Member
  • 76 posts
  • Version:GM:Studio

Posted 01 July 2012 - 07:28 AM

This is my current code that uses models, how can I change it to use d3d_blocks? I cannot get the directions to work.

for (i=0; i<placedwalls; i+=1) {
	d3d_transform_set_identity()
	d3d_transform_add_rotation_x(-90)
	d3d_transform_add_rotation_z(walldir[i]-90)
	d3d_transform_add_translation(wallx[i],wally[i],19.5)
	d3d_model_draw(model.wall1,0,0,0,background_get_texture(tex_wall1))
	d3d_transform_set_identity()
}
The current code works like a charm.
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users