Jump to content


Photo

creating model from paths


  • Please log in to reply
11 replies to this topic

#1 fel666

fel666

    GMC Member

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

Posted 27 February 2012 - 03:14 PM

so, here is the problem: i am creating a tron light-cycle game where you can turn smoothly and go up and down on slopes. the bikes are meant to create a trail behind them and the way i am doing this is with paths, one for the x,y axis and one for the z axis. now, i need to make it create a smooth model of the line from the paths every step. it needs to be a perfectly smooth and lag free method since there are going to be 4 to 6 bikes on the world. please post an example code.

p.s.
i also need to know how to efficiently check if an object is colliding with a path. the way i'm doing it now is by creating a sprites via a surface and assigning it to an object, its all very slow.
______________________________________________________________
Ball HEad Runnout: download

Edited by fel666, 27 February 2012 - 05:39 PM.

  • 0

#2 fel666

fel666

    GMC Member

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

Posted 01 March 2012 - 04:27 PM

BUMP :sweat:
  • 0

#3 eafg2

eafg2

    GMC Member

  • GMC Member
  • 166 posts

Posted 01 March 2012 - 05:09 PM

Depending on what you mean with "smooth" but I remember a tutorial that reminds about your "problem"
http://gmc.yoyogames...88&hl=road&st=0
and a fast method is a hard one since you need to check every step where the new segment is supose to be at the same time check where the old one was drawn.
However give this a try and see how it goes with your game, you probely need to change a lot from this but it should give you a start.
  • 0

#4 fel666

fel666

    GMC Member

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

Posted 02 March 2012 - 07:59 PM

thnks ::lmao:: its exactly what i needed
  • 0

#5 fel666

fel666

    GMC Member

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

Posted 02 March 2012 - 08:10 PM

erm... im still fairly new with vertexes and i barely managed to get a straight wall. what i ultimatly want to achive is more of a concave shapy thing. could you help me with making this plz?
  • 0

#6 fel666

fel666

    GMC Member

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

Posted 07 March 2012 - 06:21 PM

i made it draw all the segments of my wall every step and recalculate it. but it became really laggy :sad: but it worked :thumbsup: .so now, im using a simmilar technic, but since its updating every time, i add a the last bit of the trail only by using models:
x1=path_get_x(p_xy,0.9);
y1=path_get_y(p_xy,0.9);
x2=path_get_x(p_xy,1);
y2=path_get_y(p_xy,1);
z1=path_get_y(p_z,0.9);
z2=path_get_y(p_xy,1);
d3d_model_wall(wallmod,x1,y1,z1,x2,y2,z2,1,1);

here is my path creating code:
if point_distance_3d(x,y,z,xprevious,yprevious,zprevious)>=0.5
{
path_add_point(p_xy,x,y,0);
path_add_point(p_xy,x,y,0);
path_add_point(p_z,path_get_length+1,z,0);
}
and here is how i draw it:
d3d_model_draw(wallmod,0,0,0,background_get_texture(tex_1));

so the problem is; its not showing up,all the rest is (the world and bike)!!!! there is no wall whatsoever!!!!!

Edited by fel666, 07 March 2012 - 06:26 PM.

  • 0

#7 fel666

fel666

    GMC Member

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

Posted 10 March 2012 - 04:13 PM

so, any answers?

Edited by fel666, 14 March 2012 - 04:24 PM.

  • 0

#8 fel666

fel666

    GMC Member

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

Posted 14 March 2012 - 04:23 PM

BUMP
  • 0

#9 The Scorpion

The Scorpion

    GMC Member

  • GMC Member
  • 421 posts
  • Version:GM8

Posted 14 March 2012 - 10:11 PM

i made it draw all the segments of my wall every step and recalculate it. but it became really laggy :sad: but it worked :thumbsup: .so now, im using a simmilar technic, but since its updating every time, i add a the last bit of the trail only by using models:

x1=path_get_x(p_xy,0.9);
y1=path_get_y(p_xy,0.9);
x2=path_get_x(p_xy,1);
y2=path_get_y(p_xy,1);
z1=path_get_y(p_z,0.9);
z2=path_get_y(p_xy,1);
d3d_model_wall(wallmod,x1,y1,z1,x2,y2,z2,1,1);

here is my path creating code:
if point_distance_3d(x,y,z,xprevious,yprevious,zprevious)>=0.5
{
path_add_point(p_xy,x,y,0);
path_add_point(p_xy,x,y,0);
path_add_point(p_z,path_get_length+1,z,0);
}
and here is how i draw it:
d3d_model_draw(wallmod,0,0,0,background_get_texture(tex_1));

so the problem is; its not showing up,all the rest is (the world and bike)!!!! there is no wall whatsoever!!!!!


Are you updating your path ?

If I were you I would use arrays !!!
e.g

// init ! (in create event)
for (i=1;i<40;i+=1) // 40 is trail length (modify it as you wish)
{posX[i]=x
posY[i]=y
posZ[i]=z}

// update trail ( in step event)

for (i=1;i<40 -1  ;i+=1)
{posX[i]=posX[i+1];
posY[i]=posY[i+1];
posZ[i]=posZ[i+1];
}
posX[40]=x; posY[40]=y; posZ[i]=z;



// draw the trail (in draw event)
// I would normally go for primitives! I 'm being lazy, and you said you don't get it! so :p
for (i=1;i<40 -1  ;i+=1)
d3d_draw_wall(posX[i],posY[i],posZ[i],posX[i+1],posY[i+1],posZ[i+1],TEX,1,1);

I did NOT test this code! So test it and correct it if there are minor errors! If you need any help to polish it , just ask :thumbsup:
  • 0

#10 fel666

fel666

    GMC Member

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

Posted 15 March 2012 - 04:30 PM


i made it draw all the segments of my wall every step and recalculate it. but it became really laggy :sad: but it worked :thumbsup: .so now, im using a simmilar technic, but since its updating every time, i add a the last bit of the trail only by using models:

x1=path_get_x(p_xy,0.9);
y1=path_get_y(p_xy,0.9);
x2=path_get_x(p_xy,1);
y2=path_get_y(p_xy,1);
z1=path_get_y(p_z,0.9);
z2=path_get_y(p_xy,1);
d3d_model_wall(wallmod,x1,y1,z1,x2,y2,z2,1,1);

here is my path creating code:
if point_distance_3d(x,y,z,xprevious,yprevious,zprevious)>=0.5
{
path_add_point(p_xy,x,y,0);
path_add_point(p_xy,x,y,0);
path_add_point(p_z,path_get_length+1,z,0);
}
and here is how i draw it:
d3d_model_draw(wallmod,0,0,0,background_get_texture(tex_1));

so the problem is; its not showing up,all the rest is (the world and bike)!!!! there is no wall whatsoever!!!!!


Are you updating your path ?

If I were you I would use arrays !!!
e.g

// init ! (in create event)
for (i=1;i<40;i+=1) // 40 is trail length (modify it as you wish)
{posX[i]=x
posY[i]=y
posZ[i]=z}

// update trail ( in step event)

for (i=1;i<40 -1  ;i+=1)
{posX[i]=posX[i+1];
posY[i]=posY[i+1];
posZ[i]=posZ[i+1];
}
posX[40]=x; posY[40]=y; posZ[i]=z;



// draw the trail (in draw event)
// I would normally go for primitives! I 'm being lazy, and you said you don't get it! so :p
for (i=1;i<40 -1  ;i+=1)
d3d_draw_wall(posX[i],posY[i],posZ[i],posX[i+1],posY[i+1],posZ[i+1],TEX,1,1);

I did NOT test this code! So test it and correct it if there are minor errors! If you need any help to polish it , just ask :thumbsup:


thanks, but...
i tested it and it didnt work :confused: . so i checked the code and noticed there where a few problems;
firstly, the trail would apear flat since the difference in z every sttep is small. i fixed it by adding 15 to the x2 value in draw_wall.
secondly, 40 is too small, i made it to 400. you couldnt see it befor.

i tried it again, but it still didnt work, just like befor. :sad:

so, still looking for anwsers...

Edited by fel666, 15 March 2012 - 04:31 PM.

  • 0

#11 fel666

fel666

    GMC Member

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

Posted 30 March 2012 - 12:15 PM

BUMP

Edited by fel666, 31 March 2012 - 09:27 AM.

  • 0

#12 fel666

fel666

    GMC Member

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

Posted 29 April 2012 - 05:41 PM

re: BUMP

ps: is this against the rules?

[edit]: oh, and vertexes are fine now, im amazed by how long this has been here and noone found a solution! :mellow:

Edited by fel666, 29 April 2012 - 05:47 PM.

  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users