Page 1 of 1

Check if 2D points are clockwise or counterclockwise...

Posted: Fri Sep 12, 2008 9:57 pm
by Michael Vogel
Thanks to eddy I was able to put a map into my small 3D sport program:(demo at http://mr.vogel.googlepages.com/ForerunnerMap.zip)

This is done with the following code lines...

Code: Select all

;***Google Maps***
	;GoogleMapsAvailable=0
	If GoogleMapsAvailable
		If Start3D()
			TransformSprite3D(#GoogleMapSprite,Polygon(0),Polygon(1),Polygon(6),Polygon(7),Polygon(4),Polygon(5),Polygon(2),Polygon(3))
			DisplaySprite3D(#GoogleMapSprite,0,0,255)
			Stop3D()
		EndIf
	EndIf

	windc=StartDrawing(ScreenOutput())

	;***Google Maps***
	Box(Polygon(0),Polygon(1),6,6,#Yellow)
	Box(Polygon(2),Polygon(3),6,6,#Green)
	Box(Polygon(4),Polygon(5),6,6,#Red)
	Box(Polygon(6),Polygon(7),6,6,#Blue)

	:
	:

	If GoogleMapsAvailable=0
		SelectObject_(windc,winbrush)
		Polygon_(windc,@Polygon(),4)
	EndIf

My problem is, to recognize, if the map can be displayed or not. It will be seen, if the corners are in clockwise order (yellow, blue, red green corners). Nothing will be displayed, if the corners are seen like yellow- green - red - blue, but how to check this easily and fast?

Posted: Fri Sep 12, 2008 10:26 pm
by tinman

Posted: Fri Sep 12, 2008 10:37 pm
by Michael Vogel
Thanks, will have a look at that tomorrow morning

Posted: Sat Sep 13, 2008 11:48 am
by Michael Vogel
Done!
Thanks once again, it was just easy - only two lines (three points) of the rectangle have to be checked, works simple and fast :)

Code: Select all

Crossproduct=(Polygon(6)-Polygon(0))*(Polygon(3)-Polygon(1))-(Polygon(7)-Polygon(1))*(Polygon(2)-Polygon(0))
My "demo" (3D viewer and reporting is fully functional) has been updated and can be downloaded here

Just decompress all files to the same directory, start the Forerunner.exe and press enter for displaying the selected sport track. If you press 'K' while viewing, the "upper side" of the ground plate will change from a single color to a bitmap (will be a downloaded google map in the future) and vice versa, the "backplane" stays colored.

The quality of the map is not perfect, some distorting effects can be seen while rotating the graphic (using the cursor keys or dragging the track with the mouse).

Michael

Posted: Sat Sep 13, 2008 9:30 pm
by Comtois
Michael Vogel wrote:
My "demo" (3D viewer and reporting is fully functional) has been updated and can be downloaded here

Michael
it crash when i press 'view' button
AppName: forerunner map.exe AppVer: 0.0.0.0 ModName: forerunner map.exe
ModVer: 0.0.0.0 Offset: 00016684

Posted: Sat Sep 13, 2008 11:12 pm
by r_hyde
same here - crash when I press 'View' button, just after screen init.

Posted: Sun Sep 14, 2008 9:09 am
by Michael Vogel
Thanks, r_hyde and Comtois for your informations, the program works fine here (but checked only on two notebooks) - I think, the problem is related to the graphic card...

So please try one of the following things :roll: :
  • Set the FineLine value in the forerunner.ini to 0 (Disable Antialiazing)
    Set the DirectMemory value in the forerunner.ini to 0 (uses 'normal' plot command instead of PokeB for drawi8ng commands)
    Try the'older version without the Sprite3D (so there is also no map :( )
This tests would give me an indication where to search for the problem - the source code has already more than 7500 lines, so i don't want to post it :wink:

Thanks for your help,
Michael