PDA

View Full Version : LFS Polygon Draw (html+js)


denis-takumi
15th April 2011, 06:45
Use LFS Polygon Draw to identify new areas (streets) without the use of nodes on opened track like FEX FEY (LFS Z30)
used jsDraw2D - http://jsdraw2d.jsfiction.com/
use FireFox =)

exsamle (http://denisbatya.narod.ru/)

C++ code to find point in polygon

x,y - curent pozition

polyX[] - array of X polygon points
polyY[] - array of Y polygon points

polySides - count of points

bool Check_Pos(int polySides,int polyX[],int polyY[],float x,float y)
{

int i, j=polySides-1 ;
bool oddNodes=false ;

for (i=0; i<polySides; i++)
{
if (polyY[i]<y && polyY[j]>=y
|| polyY[j]<y && polyY[i]>=y)
{
if (polyX[i]+(y-polyY[i])/(polyY[j]-polyY[i])*(polyX[j]-polyX[i])<x)
{
oddNodes=!oddNodes;
}
}
j=i;
}
return oddNodes;
}

PoVo
15th April 2011, 07:28
Great work! I'll use it :) Simple tool.

Only problem I have is I can't make the green point smaller.

It says the size is "1". I tried changing it to 0.2 and it doesn't work :shrug:

denis-takumi
15th April 2011, 08:24
i think.... just dont use this =)

skywatcher122
15th April 2011, 09:20
great tool however in 1 pixel means 65535 in the value?
can u make it zoom-able version? i can't see it very well (glasses)

denis-takumi
15th April 2011, 13:39
skywatcher122, use ctrl + mouse_scroll

denis-takumi
17th April 2011, 09:33
hmm, i found bug.. convert js_coordinates to game_coordinates.
fixed

skywatcher122
11th May 2011, 08:22
can u create a square tool like in paint so i can draw squares rather than polygon draw?

Thijs-boy
13th October 2011, 14:03
Sorry for Bump, but it doesn't work by me, and I have no idea to get work it.
If I draw an area, I get a different X and Y cordinates instead of what lfs gives.

And with that code, I get errors.

ARTlight
5th November 2011, 11:00
Coords of Polygon Draw = MCI Coords / 65536.
Coords of MCI = Polygon Draw Coords * 65536.
As far as I can remember now without looking into my code...
Could be 65536, could be 4096. Try for yourself :)

Ziroh
31st January 2012, 09:26
Sorry for bumping this up, but how do i use this tool?
I really can't understand it :x

Could anyone help me please?

cargame.nl
31st January 2012, 10:14
You can draw a polygon with it...

For example a rectangle. Just click four points on the track map in a clockwise direction and press 'fill polygon'.

Then it makes the area blue and it gives a set of coordinates which you then can use if a car is in that area or not depending on the info of a MCI InSim packet (and those coordinates are / 65536).

I just sound very wise now but I just figured that out today. :razz:

impresora
21st February 2012, 14:37
Ex: I used 18 points, now it gaveme:


202;364
210;390
222;429
238;446
259;439
276;418
288;382
282;355
300;349
303;381
294;422
269;446
242;466
231;460
209;441
193;400
187;363


Now how i work with this ?

impresora
8th March 2012, 12:34
Bump

MadCatX
8th March 2012, 15:16
And what is it you want to achieve? This tool only gives you coordinates of points on the track in a format that LFS understands. It's really up to you how you use this...