Jump to content


Photo

Draw_path Alternative


  • This topic is locked This topic is locked
4 replies to this topic

#1 icuurd12b42

icuurd12b42

    Self Formed Sentient

  • GMC Elder
  • 18181 posts
  • Version:GM:Studio

Posted 25 September 2007 - 05:09 AM

I have a map editor which allows to associate a path to an instance. I add path points on mouse click and I use draw_path (because the path is smooth) but the function will not draw any points beyond 30 or so.

Does anyone know how I can draw a smooth path as a work arround to this GM bug?

It has to work just like the real thing, draw the smooth path (fast) because the people using the path feature need to see if the smooth path will hit a wall in a curve.
  • 0

gmcbanner.pnggmcbanner_tools.png

ICU Live Tutoring Through Slack or Skype | My Tools Page follow.png

I FRANTICALLY MADE MY 18000 POST TOPIC BEFORE MIKE ANNOUNCED A DELAY...
Now I'm squirming not to hit that reply button


#2 ws25

ws25

    Gaming For Geeks

  • New Member
  • 724 posts

Posted 25 September 2007 - 05:24 AM

I have a map editor which allows to associate a path to an instance. I add path points on mouse click and I use draw_path (because the path is smooth) but the function will not draw any points beyond 30 or so.

Does anyone know how I can draw a smooth path as a work arround to this GM bug?

It has to work just like the real thing, draw the smooth path (fast) because the people using the path feature need to see if the smooth path will hit a wall in a curve.

<{POST_SNAPBACK}>


Congrats, you just gave me an idea for my script library (composited advanced drawing functions), to draw curves. I have to figure out how to do it though. If I find a way, I'll post the code.
  • 0

#3 Yourself

Yourself

    The Ultimate Pronoun

  • GMC Elder
  • 7352 posts
  • Version:Unknown

Posted 25 September 2007 - 05:28 AM

http://www.ultimatep...uff/coaster.gm6

I use an alternative method in that example. Look in the create event of the Train object at the very bottom.
  • 0

#4 icuurd12b42

icuurd12b42

    Self Formed Sentient

  • GMC Elder
  • 18181 posts
  • Version:GM:Studio

Posted 25 September 2007 - 06:42 AM

http://www.ultimatep...uff/coaster.gm6

I use an alternative method in that example.  Look in the create event of the Train object at the very bottom.

<{POST_SNAPBACK}>

Thank you!

I stripped out the model as I change the path too often to deal with that difficulty layer.
here's draw_pathall. Same arguments as draw_path
..sniped. see revision

Edited by icuurd12b42, 08 October 2013 - 05:00 AM.

  • 0

gmcbanner.pnggmcbanner_tools.png

ICU Live Tutoring Through Slack or Skype | My Tools Page follow.png

I FRANTICALLY MADE MY 18000 POST TOPIC BEFORE MIKE ANNOUNCED A DELAY...
Now I'm squirming not to hit that reply button


#5 icuurd12b42

icuurd12b42

    Self Formed Sentient

  • GMC Elder
  • 18181 posts
  • Version:GM:Studio

Posted 08 October 2013 - 04:56 AM

Studio still also clips the drawing if the lines is too long. also it does not does not respect the parameters
aka drawing a curve or a straight path will not draw at the same position, and the absolute makes it so path point 0 is the start of the drawing no matter what
That is it starts drawing at passed x,y no matter if path point 0 is 0,0 or any value. where at if path point 0 was -100,-100 it should start to draw at passed (x,y) + (-100,-100)


Revised version
//draw_path_all(argument0,argument1,argument2,argument3)
var dx = argument1*(argument3==0)
var dy = argument2*(argument3==0)
var ct = path_get_number(argument0)
if(ct<1) exit;
if(ct==1)
{
    draw_point(dx+path_get_point_x(argument0,0),dy+path_get_point_y(argument0,0));
    exit;
}    
if(path_get_kind(argument0))
{
    var ct = (path_get_precision(argument0)*path_get_precision(argument0)*ct)
    var fr = 1/ct;
    
    var xx1,yy1,xx2,yy2
    var frat = 0;
    repeat(ct)
    {
        xx1 = dx+path_get_x(argument0,frat);
        yy1 = dy+path_get_y(argument0,frat);
        xx2 = dx+path_get_x(argument0,frat+fr);
        yy2 = dy+path_get_y(argument0,frat+fr);
        
        draw_line(xx1,yy1,xx2,yy2)
        frat+=fr
    }
}
else
{
    var i = 0;
    var xx,yy,xx2,yy2;
    repeat(ct-1)
    {
        xx = dx+path_get_point_x(argument0,i);
        yy = dy+path_get_point_y(argument0,i);
        xx2 = dx+path_get_point_x(argument0,i+1);
        yy2 = dy+path_get_point_y(argument0,i+1);
        draw_line(xx,yy,xx2,yy2)
        i+=1;
    }
    if(path_get_closed(argument0))
    {
        xx = dx+path_get_point_x(argument0,i);
        yy = dy+path_get_point_y(argument0,i);
        xx2 = dx+path_get_point_x(argument0,0);
        yy2 = dy+path_get_point_y(argument0,0);
        draw_line(xx,yy,xx2,yy2)
    }
}


Edited by icuurd12b42, 08 October 2013 - 05:02 AM.

  • 1

gmcbanner.pnggmcbanner_tools.png

ICU Live Tutoring Through Slack or Skype | My Tools Page follow.png

I FRANTICALLY MADE MY 18000 POST TOPIC BEFORE MIKE ANNOUNCED A DELAY...
Now I'm squirming not to hit that reply button