Fix tile rendering
This commit is contained in:
+9
-15
@@ -8,7 +8,7 @@ tToRender :: Tile -> [(Point3,Point3)]
|
||||
tToRender t = polyToTris $ zip ps3 coords3
|
||||
where
|
||||
ps = _tilePoly t
|
||||
coords = map (calcTexCoord (_tileCenter t) (_tileX t) (_tileY t)) ps
|
||||
coords = map (calcTexCoord (_tileZero t) (_tileX t)) ps
|
||||
ps3 = map (addToV2 0) ps
|
||||
coords3 = map (addToV2 (_tileZ t)) coords
|
||||
|
||||
@@ -21,29 +21,23 @@ mkTrip z (x,y) = (x,y,z)
|
||||
calcTexCoord
|
||||
:: Point2 -- ^ tile (0,0)
|
||||
-> Point2 -- ^ tile (1,0)
|
||||
-> Point2 -- ^ tile (0,1)
|
||||
-> Point2 -- ^ world point
|
||||
-> Point2
|
||||
calcTexCoord cen x' y' p = V2
|
||||
( magV (projV (p -.- cen) x) / magV x )
|
||||
( magV (projV (p -.- cen) y) / magV y )
|
||||
calcTexCoord c p x = V2 (0.02 * dotV (p -.- c) xdir) (0.02 * dotV (p -.- c) ydir)
|
||||
where
|
||||
x = x' -.- cen
|
||||
y = y' -.- cen
|
||||
xdir = x -.- c
|
||||
ydir = vNormal xdir
|
||||
|
||||
oTile
|
||||
makeTileFromPoly
|
||||
:: [Point2]
|
||||
-> Float
|
||||
-> Tile
|
||||
oTile poly z = Tile
|
||||
makeTileFromPoly poly z = Tile
|
||||
{ _tilePoly = poly
|
||||
, _tileCenter = c
|
||||
, _tileX = x
|
||||
, _tileY = y
|
||||
, _tileZero = c
|
||||
--, _tileXY = c +.+ xdir +.+ vNormal xdir
|
||||
, _tileX = c +.+ (normalizeV $ (poly !! 1) -.- c)
|
||||
, _tileZ = z
|
||||
}
|
||||
where
|
||||
c = head poly
|
||||
xdir = 50 *.* normalizeV (poly !! 1 -.- c)
|
||||
x = c +.+ xdir
|
||||
y = c +.+ vNormal xdir
|
||||
|
||||
Reference in New Issue
Block a user