summaryrefslogtreecommitdiff
path: root/src/graphyx/Graphyx.scala
blob: 01caea8f4f670ef70385bb39bbb94ce2ae98e6c8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/*
 * Graphyx
 * copyright (c) 2009 Jakob Odersky
 * made available under the MIT License
*/

package graphyx

import graphyx.actors._
import graphyx.graphics._
import graphyx.tests._
import sims.geometry._
import sims.dynamics._

object Graphyx{
  
  val tests: List[graphyx.tests.Test] = List(
    CompositeShape,
    Joints1,
    Joints2,
    Spring,
    Atom,
    Chain,
    Wave,
    Stacking,
    BallStack,
    Cup,
    Net,
    Friction,
    Friction2,
    Restitution,
    RagdollTest,
    Carriage,
    General1,
    General2,
    EmptyTest
  )
  
  private var _test: graphyx.tests.Test = tests(0)
  def test = _test
  def test_=(t: graphyx.tests.Test) = {
    t.world.time = 0
    t.world.clear()
    t.init()
    physicsActor ! SetWorld(t.world)
    _test = t
  }
  
  val physicsActor = new PhysicsActor
  val guiActor = new GUIActor
  
  def main(args: Array[String]): Unit = {
    test.init()
    physicsActor.world = test.world 
    guiActor.start()
    physicsActor.start()
  }
  
  def exit() = {
    guiActor.container.exitGUI
    guiActor ! Exit
    physicsActor ! Exit
  }
}