예제 #1
0
        private void AddVertexGraph(VertexGraph graph)
        {
            Individual = graph.Vertices.Select(vertex =>
            {
                var mass = 10000;
                var motionState = new DefaultMotionState();
                var collisionShape = new BoxShape(1);

                var info = new RigidBodyConstructionInfo(mass, motionState, collisionShape);
                var rigidBody = new VertexBoundRigidBody(vertex, info);

                return rigidBody;
            }).ToList();

            foreach (var body in Individual)
            {
                // Select the 3 nearest vertices, excluding this one
                var nearest = Individual.OrderBy(a => a.Binding.DistanceTo(body.Binding))
                                         .Where(a => a != body)
                                         .Take(3);
                foreach (var other in nearest)
                {
                    // TODO: What are these matrices supposed to be?
                    var frameInA = body.MotionState.WorldTransform;
                    var frameInB = other.MotionState.WorldTransform;

                    // TODO: How do you specify the spring's springiness?
                    var constraint = new Generic6DofSpringConstraint(body, other, frameInA, frameInB, true);

                    // TODO: Now how do I apply this to the bodies?
                    body.AddConstraintRef(constraint);
                    other.AddConstraintRef(constraint);
                }
            }
        }
예제 #2
0
        public override Individual FromBinary(Stream stream)
        {
            var graph = new VertexGraph();

            using (stream)
            {
                var reader = new BinaryReader(stream);

                for (int i = 0; i < VertexCount; i++)
                {
                    var vertex = new Vertex(ReadNormalLong(reader), ReadNormalLong(reader), ReadNormalLong(reader), Max);
                    graph.Vertices.Add(vertex);
                }

                var individual = new SkyscraperIndividual(graph);

                return individual;
            }
        }
예제 #3
0
파일: Individual.cs 프로젝트: kylc/seve
 /// <summary>
 /// Creates a random individual to be used in the initial population.
 /// </summary>
 public Individual()
 {
     Graph = new VertexGraph();
 }
예제 #4
0
 public SkyscraperIndividual(VertexGraph graph)
 {
     Graph = graph;
 }
예제 #5
0
파일: VertexGraph.cs 프로젝트: kylc/seve
        public VertexGraph Copy()
        {
            VertexGraph graph = new VertexGraph();

            foreach (var vertex in Vertices)
            {
                graph.Vertices.Add(vertex.Copy());
            }

            return graph;
        }
예제 #6
0
 public DefaultRigidBodyWorld(VertexGraph initialState)
 {
     AddVertexGraph(initialState);
 }