more fun & play

This commit is contained in:
nek0 2018-05-18 07:56:11 +02:00
parent e793085399
commit e5eaaa4b49
2 changed files with 16 additions and 9 deletions

View file

@ -67,7 +67,10 @@ load = do
, "uniform mat4 mvp;" , "uniform mat4 mvp;"
, "varying vec2 f_texcoord;" , "varying vec2 f_texcoord;"
, "void main(void) {" , "void main(void) {"
, " float zoom = 1.0;"
, " gl_Position = mvp * vec4(coord3d, 1.0);" , " gl_Position = mvp * vec4(coord3d, 1.0);"
-- , " gl_Position.z = 0.0;"
-- , " gl_Position.w += 10.0;"
, " f_texcoord = texcoord;" , " f_texcoord = texcoord;"
, "}" , "}"
] ]
@ -91,7 +94,7 @@ load = do
y <- randomRIO (-50, 50) y <- randomRIO (-50, 50)
z <- randomRIO (-50, 50) z <- randomRIO (-50, 50)
return (V3 x y z) return (V3 x y z)
) [0..2000] ) [0..2222]
poss2 <- mapM (\_ -> do poss2 <- mapM (\_ -> do
x <- randomRIO (-100, 100) x <- randomRIO (-100, 100)
@ -120,7 +123,7 @@ load = do
{ ships = shipList { ships = shipList
, planet = planet , planet = planet
, oplanets = otherPlanets , oplanets = otherPlanets
, proj = perspective (pi/2) (1600 / 900) 1 (-1) , proj = infinitePerspective (pi/2) (1600 / 900) 1
, camera = Camera , camera = Camera
{ cameraFocus = V3 0 0 0 { cameraFocus = V3 0 0 0
, cameraRot = Euler 0 0 0 , cameraRot = Euler 0 0 0
@ -163,24 +166,25 @@ initPhysicsObjects poss poss2 = do
-- fx <- randomRIO (-1000, 1000) -- fx <- randomRIO (-1000, 1000)
-- fy <- randomRIO (-1000, 1000) -- fy <- randomRIO (-1000, 1000)
-- fz <- randomRIO (-1000, 1000) -- fz <- randomRIO (-1000, 1000)
let m = 100
smallBallMotionState <- newDefaultMotionState (Quaternion 1 (V3 0 0 0)) smallBallMotionState <- newDefaultMotionState (Quaternion 1 (V3 0 0 0))
(fmap realToFrac pos) (fmap realToFrac pos)
localInertia <- calculateLocalInertia smallBall 1 (V3 0 0 0) localInertia <- calculateLocalInertia smallBall m (V3 0 0 0)
smallBallBody <- newRigidBody 1 smallBallMotionState 0.9 0.5 smallBall localInertia smallBallBody <- newRigidBody m smallBallMotionState 0.9 0.5 smallBall localInertia
-- applyCentralForce smallBallBody (V3 fx fy fz) -- applyCentralForce smallBallBody (V3 fx fy fz)
return $ PhysBody smallBall smallBallMotionState smallBallBody 1 return $ PhysBody smallBall smallBallMotionState smallBallBody m
) poss ) poss
bigBallsPOs <- mapM (\pos -> do bigBallsPOs <- mapM (\pos -> do
let m = 1000000 let m = 1000000
fx <- randomRIO (-1000, 1000) -- fx <- randomRIO (-1000, 1000)
fy <- randomRIO (-1000, 1000) -- fy <- randomRIO (-1000, 1000)
fz <- randomRIO (-1000, 1000) -- fz <- randomRIO (-1000, 1000)
bigBallMotionState <- newDefaultMotionState (Quaternion 1 (V3 0 0 0)) bigBallMotionState <- newDefaultMotionState (Quaternion 1 (V3 0 0 0))
(fmap realToFrac pos) (fmap realToFrac pos)
localInertia <- calculateLocalInertia bigBall m (V3 0 0 0) localInertia <- calculateLocalInertia bigBall m (V3 0 0 0)
bigBallBody <- newRigidBody m bigBallMotionState 0.9 0.5 bigBall localInertia bigBallBody <- newRigidBody m bigBallMotionState 0.9 0.5 bigBall localInertia
applyCentralForce bigBallBody (V3 fx fy fz) -- applyCentralForce bigBallBody (V3 fx fy fz)
return $ PhysBody bigBall bigBallMotionState bigBallBody m return $ PhysBody bigBall bigBallMotionState bigBallBody m
) poss2 ) poss2
@ -195,4 +199,5 @@ initPhysicsObjects poss poss2 = do
{ poBigBall = bigBallPO { poBigBall = bigBallPO
, poSmallBalls = smallBallPOs , poSmallBalls = smallBallPOs
, poBigBalls = bigBallsPOs , poBigBalls = bigBallsPOs
-- , poBigBalls = []
} }

View file

@ -136,6 +136,7 @@ draw = do
GL.viewport $= (GL.Position 0 0, GL.Size 1600 900) GL.viewport $= (GL.Position 0 0, GL.Size 1600 900)
StateData{..} <- getAffection StateData{..} <- getAffection
drawThings program (planet : ships) drawThings program (planet : ships)
-- drawThings program (ships)
drawThings program2 oplanets drawThings program2 oplanets
where where
drawThings prog ts = do drawThings prog ts = do
@ -204,6 +205,7 @@ handleKey code
ud <- getAffection ud <- getAffection
let ind = focusIndex ud let ind = focusIndex ud
ps = planet ud : oplanets ud ps = planet ud : oplanets ud
-- ps = oplanets ud
if ind + 1 < length ps if ind + 1 < length ps
then putAffection ud then putAffection ud
{ focusIndex = ind + 1 { focusIndex = ind + 1