From b3ff213b5012c8982afc547af5351d530a53b0a9 Mon Sep 17 00:00:00 2001 From: zzzzrrr Date: Tue, 1 Dec 2009 11:19:22 -0500 Subject: [PATCH] added test --- python/framework/polydecomp.pxi | 2 +- python/poly2tri.py | 25 ++++++++++++++++++++++++- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/python/framework/polydecomp.pxi b/python/framework/polydecomp.pxi index 3653b98..709d3d5 100644 --- a/python/framework/polydecomp.pxi +++ b/python/framework/polydecomp.pxi @@ -1,6 +1,6 @@ ## ## Ported from PolyDeomp by Mark Bayazit -## http://mnbayazit.com/406/credit +## http://mnbayazit.com/406/bayazit ## from sys import float_info diff --git a/python/poly2tri.py b/python/poly2tri.py index 3b56584..dc7c30d 100644 --- a/python/poly2tri.py +++ b/python/poly2tri.py @@ -22,6 +22,20 @@ class Poly2Tri(Game): [192.89701,377.80796],[177.18272,402.27225],[172.36129,413.87939],[169.14701,430.48653],[168.61129,458.52225], [168.61129,492.80796]] + test = [[235.04275999999999, 739.07534999999996], [218.13066000000001, 719.73902999999996], + [218.15215000000001, 709.96821], [218.17362, 700.19740000000002], [243.15215000000001, 685.27858000000003], + [268.13065, 670.35974999999996], [268.13065, 660.81429000000003], [268.13065, 651.26882999999998], + [314.55921999999998, 651.26882999999998], [360.98779000000002, 651.26882999999998], + [360.98683999999997, 666.44740000000002], [360.98046561000007, 669.27438118000009], + [360.96234088000011,672.68539864000013], [360.93345946999995, 676.58895225999993], + [360.89481504000003, 680.89354191999996], [360.84740125000002, 685.50766749999991], + [360.79221175999999, 690.33982888000003], [360.73024022999999, 695.29852593999999], + [360.66248032000004, 700.29225856000005], [360.58992569000003, 705.22952662000012], + [360.51357000000002, 710.01882999999998], [360.04131999999998, 738.41168000000005], + [310.51454999999999, 738.41168000000005], [260.98779999999999, 738.41168000000005], + [260.98779999999999, 748.41168000000005], [260.98779999999999, 758.41168000000005], + [256.47133000000002, 758.41168000000005], [251.95484999999999, 758.41168000000005]] + def __init__(self): super(Poly2Tri, self).__init__(*self.screen_size) @@ -50,13 +64,22 @@ class Poly2Tri(Game): dt = (self.time - t1) * 1000.0 print "time (ms) = %f , num polies = %d" % (dt, len(self.dude_poly)) + spam = [] + makeCCW(self.test) + clean = [] + for t in self.test: + x = round(t[0], 0) + y = round(t[1], 0) + clean.append([x,y]) + decompose_poly(clean, spam) + self.main_loop() def update(self): pass def render(self): - reset_zoom(2.1, (300, 450), self.screen_size) + reset_zoom(2.2, (300, 450), self.screen_size) red = 255, 0, 0 yellow = 255, 255, 0 green = 0, 255, 0