Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Drawing lanes - tricky question concerning rotation and placement

Author
Message
Daryn Alsup
18
Years of Service
User Offline
Joined: 5th Jul 2008
Location: In your head... dun dun DUN!!!!!!!!
Posted: 6th Jan 2013 22:00 Edited at: 6th Jan 2013 23:30
So I have this bit of code you'll see below all media free for you to run. There's a function in it that either creates 2 - 4 - or 6 lane roads (no model yet for the roads) but I've come into a bit of a road block (HA HA! A PUN rofrofrof *smack desk* HA HA poo)

Say you click on any location on that map... because I haven't figured out how to rotate the start point, the roads can only be correctly drawn at a 45 degree angle.

Think of it like this... you have a piece of yarn wrapped around a tack board. That yarn can be pulled and stretched to any other tack. Now say you have three base tacks and three end tacks, each with yarn going straight to the correct tack at each end. You can't rotate the yarn anymore around a single point, but rather, now you have to rotate both the end tacks and start tacks... what in the code below are lane start and end points.

How do I rotate the points I am drawing from.... in.... this.... code (click and drag to draw roads... you will see the lanes - if you want to change the amount of lanes, there is a function called "dragtransport" - change the number or lanes to either 1, 2, 3... meaning 2, 4, 6:


EDIT - YOU NEED IAN'S MATRIX UTILITIES PLUG INs

Illustration:

I see a lil' byte, its 1/4th a dword, Double float, Double float - but it doesnt beat a Global. Very very frightning, integers dividing me! Look a constant oh a constant. Oh-oh I just want the byte!
Phaelax
DBPro Master
23
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 6th Jan 2013 23:27
Check out my snippet from this post:

http://forum.thegamecreators.com/?m=forum_view&t=202512&b=1

See if that helps you work it out. If not then I'll help ya out.

"You're not going crazy. You're going sane in a crazy world!" ~Tick
Daryn Alsup
18
Years of Service
User Offline
Joined: 5th Jul 2008
Location: In your head... dun dun DUN!!!!!!!!
Posted: 6th Jan 2013 23:34
I think I've got it - a bit different from yours but I think I got it...

I am already calculating the center point at the end and start of the lines (the middle line start end point) I can use curve and wrapvalues to determine the angle based on the 3d mouse, then rotate based on it's movement. I will post the code. Let me try it out.

I see a lil' byte, its 1/4th a dword, Double float, Double float - but it doesnt beat a Global. Very very frightning, integers dividing me! Look a constant oh a constant. Oh-oh I just want the byte!
Daryn Alsup
18
Years of Service
User Offline
Joined: 5th Jul 2008
Location: In your head... dun dun DUN!!!!!!!!
Posted: 7th Jan 2013 02:09 Edited at: 7th Jan 2013 03:25
okay so here's what I did - and I need a little bit of help.

I used the mid points at the end of each segement as the center... then made vectors and using curve, newxvalue/y/z, and a wrap value, got the points for each lane to orbit around the center point... but now I need to appropriately rotate the end points and start points for each lane according to the mouse... IE, if you move your mouse left it rotates left... I need to figure out how the mousemoveX/Y commands can be used in this command...

anglestep#=WrapValue(anglestep#+(((((((((MOUSE CODE)))))))))

new code is:



I see a lil' byte, its 1/4th a dword, Double float, Double float - but it doesnt beat a Global. Very very frightning, integers dividing me! Look a constant oh a constant. Oh-oh I just want the byte!
Daryn Alsup
18
Years of Service
User Offline
Joined: 5th Jul 2008
Location: In your head... dun dun DUN!!!!!!!!
Posted: 7th Jan 2013 07:54
Here it is! note that I didn't write the code for additional lanes (only north and south / east and west / one lane roads work) but this is perfect!



I see a lil' byte, its 1/4th a dword, Double float, Double float - but it doesnt beat a Global. Very very frightning, integers dividing me! Look a constant oh a constant. Oh-oh I just want the byte!
Phaelax
DBPro Master
23
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 8th Jan 2013 17:34
Glad you got it figured out. Looks interesting so far

"You're not going crazy. You're going sane in a crazy world!" ~Tick
Daryn Alsup
18
Years of Service
User Offline
Joined: 5th Jul 2008
Location: In your head... dun dun DUN!!!!!!!!
Posted: 9th Jan 2013 01:30
A step up from this for a second, just for thinking sake - Say I do this for models I lay... like roads... if I wanted to curve them, what would be the best method. Should I stop the segment at a point, create an angled object and then continue drawing the object until I reach the next curve point?

(Imagine dominoes you curve in an arch... there are gaps in the curves that are triangular in nature. Do I create an object to place in the gaps as I draw, or is there a better way to curve them than this?)

I see a lil' byte, its 1/4th a dword, Double float, Double float - but it doesnt beat a Global. Very very frightning, integers dividing me! Look a constant oh a constant. Oh-oh I just want the byte!
Phaelax
DBPro Master
23
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 9th Jan 2013 03:55 Edited at: 9th Jan 2013 03:58
If you plan on turning this into a 3D model with curved corners you would want to determine the angle of the curve you want first. Next, determine how many additional polys you want the corner to use.

The first image you have the two lines making a right angle. Then you have the curved road you'd rather have. The green dots represent how many segments that curve is broken down to. The more segments, the smoother than curve (but the greater number of polys).

The second image is what your 3D road might look like once it's formed.




"You're not going crazy. You're going sane in a crazy world!" ~Tick
Daryn Alsup
18
Years of Service
User Offline
Joined: 5th Jul 2008
Location: In your head... dun dun DUN!!!!!!!!
Posted: 9th Jan 2013 04:19 Edited at: 9th Jan 2013 08:08
So let me ask you this - I have a plane that is 8X8, if I draw from one location to another it's a straight line. But if I have a key pressed, then the hypothetical code would take into account the red dots in your images above, and based on the angle, add more segments.

Using this method, I calculate an X and Z (y for 2d) point for the start and end points, as well as an intersection point. (The upper left red dot in your images) Then using math I don't know YET, I calculate the angle of the bend based on the distance, and thus the segments... do I understand correctly

I don't need to raycast the intersect point, just get the start and end points position and determine when they meet.


I see a lil' byte, its 1/4th a dword, Double float, Double float - but it doesnt beat a Global. Very very frightning, integers dividing me! Look a constant oh a constant. Oh-oh I just want the byte!
Daryn Alsup
18
Years of Service
User Offline
Joined: 5th Jul 2008
Location: In your head... dun dun DUN!!!!!!!!
Posted: 9th Jan 2013 09:33
here is what I have thus far - a project is included with all the prerequisites. You can see that I am very close. Basically what this does is calculates the small green lines in the image above and divides it into segments appropriately... it also recognizes when you've drawn a straight line of objects. A sample object is included, though it's the wrong scale... I haven't worked out a proper scale ratio from Sketch Up to DBPro yet... seeing as the plane in this project is 5280 units (a mile) and these are generic units, my initial scaling was.... incorrect.

I see a lil' byte, its 1/4th a dword, Double float, Double float - but it doesnt beat a Global. Very very frightning, integers dividing me! Look a constant oh a constant. Oh-oh I just want the byte!
Daryn Alsup
18
Years of Service
User Offline
Joined: 5th Jul 2008
Location: In your head... dun dun DUN!!!!!!!!
Posted: 10th Jan 2013 10:52
Okay I need a little help with determining the location of points for the curve. Basically as the project above shows, segments of the line are broken up into distances. If you are drawing a line from 0,0,0 to 5,0,5, that is 5 segments of equal length (the segment size inc or dec depending on the location of the end point) - but as for the actual location of the object, or its rotation / angle, I am confused.

I see a lil' byte, its 1/4th a dword, Double float, Double float - but it doesnt beat a Global. Very very frightning, integers dividing me! Look a constant oh a constant. Oh-oh I just want the byte!
Daryn Alsup
18
Years of Service
User Offline
Joined: 5th Jul 2008
Location: In your head... dun dun DUN!!!!!!!!
Posted: 17th Jan 2013 10:45
**Light Bump**

I see a lil' byte, its 1/4th a dword, Double float, Double float - but it doesnt beat a Global. Very very frightning, integers dividing me! Look a constant oh a constant. Oh-oh I just want the byte!
Phaelax
DBPro Master
23
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 17th Jan 2013 12:36 Edited at: 17th Jan 2013 12:59
I'm trying to work it out.

In the attached pic, you could find a circle's center point using point A and C and simply trace along the circle's curve. Drawing a circle using a specified amount of dots is simple. But if line AB is a different length than line BC, then you can't use a circle and must have an arc matching an elliptical shape instead. Drawing an ellipse I'm not so sure about, that's where I'm stuck.






I have code which draws an ellipse, but not in a simple method that would allow me to control the number of points.

The white curve would form a circle, but note how it doesn't meet one of the end points? It's because the line segments are different lengths. The blue curve is elliptical.

Look at this code to better understand the illustration.



Btw, have you seen this race track editor?
http://forum.thegamecreators.com/?m=forum_view&t=200791&b=8&p=0

"You're not going crazy. You're going sane in a crazy world!" ~Tick

Login to post a reply

Server time is: 2026-07-07 05:16:17
Your offset time is: 2026-07-07 05:16:17