Пример #1
0
        private void SecondPass(State state)
        {
            int set         = 0;
            int index       = 0;
            var lookupShape = default(Shape <TNode, TPosition, TKey>);

            var shape = default(Shape <TNode, TPosition, TKey>);
            var node  = default(TNode);
            var tesselationSurroundEnumerable = default(IEnumerable <TPosition>);
            var tesselationSurroundEnumerator = default(IEnumerator <TPosition>);
            var neighbor = default(TPosition);

            for (int shapeIndex = state.Shapes.Count - 1; shapeIndex >= 0; shapeIndex--)
            {
                shape = state.Shapes[shapeIndex];
                for (int nodeIndex = shape.Nodes.Count - 1; nodeIndex >= 0; nodeIndex--)
                {
                    set   = 0;
                    index = 0;
                    node  = shape.Nodes[nodeIndex];

                    tesselationSurroundEnumerable = Tesselation.Surround(node.Point);
                    tesselationSurroundEnumerator = tesselationSurroundEnumerable.GetEnumerator();
                    while (tesselationSurroundEnumerator.MoveNext())
                    {
                        neighbor = tesselationSurroundEnumerator.Current;
                        if (Tesselation.Valid(neighbor))
                        {
                            lookupShape = state.GetShape(neighbor);
                        }
                        else
                        {
                            lookupShape = null;
                        }
                        set *= 2;
                        if (lookupShape != shape)
                        {
                            set++;
                        }
                        node[index++] = lookupShape != null ? lookupShape.Area : null;
                    }
                    tesselationSurroundEnumerator.Dispose();

                    if (CollisionGenerator.OuterNode(set))
                    {
                        shape.AddOuterNode(node);
                    }
                }
            }
        }
Пример #2
0
        /// <summary>
        /// The main entry point of the application.
        /// </summary>
        /// <param name="args"></param>
        static void Main(string[] args)
        {
            // Instantiate Generator & Exporter
            collisionExporter  = new CollisionExporter();
            collisionGenerator = new CollisionGenerator();

            // Check Arguments
            VerifyArguments(args);

            // Check if it is a CL or OBJ File for Exporting/Importing
            if (CollisionGenerator.Properties.FilePath != null)
            {
                if (CollisionGenerator.Properties.FilePath.EndsWith(".cl"))
                {
                    action = 2;
                }
                else if (CollisionGenerator.Properties.FilePath.EndsWith(".obj"))
                {
                    action = 1;
                }
            }

            // Switch all of the available action states..
            switch (action)
            {
            case 1:
                collisionGenerator.LoadObjFile();
                collisionGenerator.GenerateCollision();
                collisionGenerator.WriteFile();
                break;

            case 2:
                collisionExporter.ReadColliison(CollisionGenerator.Properties.FilePath);
                collisionExporter.WriteCollision(CollisionGenerator.Properties.FilePath + ".obj");
                break;

            default:
                ShowHelp();
                break;
            }
        }
Пример #3
0
 init()
 {
     CG = new CollisionGenerator(this);
     Body b1 = new Body(this);
     b1.addEffect(CG);
 }