Exemple #1
0
        /// <summary>
        /// Load content for the screen.
        /// </summary>
        /// <param name="GraphicInfo"></param>
        /// <param name="factory"></param>
        /// <param name="contentManager"></param>
        protected override void LoadContent(GraphicInfo GraphicInfo, GraphicFactory factory, IContentManager contentManager)
        {
            base.LoadContent(GraphicInfo, factory, contentManager);

            RegisterDebugDrawCommand rc = new RegisterDebugDrawCommand(ddrawer);

            CommandProcessor.getCommandProcessor().SendCommandAssyncronous(rc);
            dlines = new DebugLines();
            ddrawer.AddShape(dlines);

            Picking pick = new Picking(this, 2000);

            pick.OnPickedLeftButton += new OnPicked(pick_OnPickedLeftButton);

            {
                SimpleModel simpleModel = new SimpleModel(factory, "Model//block");
                simpleModel.SetTexture(factory.CreateTexture2DColor(1, 1, Color.White), TextureType.DIFFUSE);
                ///Physic info (position, rotation and scale are set here)
                BoxObject tmesh = new BoxObject(Vector3.Zero, 1, 1, 1, 10, new Vector3(1000, 1, 1000), Matrix.Identity, MaterialDescription.DefaultBepuMaterial());
                tmesh.isMotionLess = true;
                ///Forward Shader (look at this shader construction for more info)
                ForwardXNABasicShader shader = new ForwardXNABasicShader();
                ///Deferred material
                ForwardMaterial fmaterial = new ForwardMaterial(shader);
                ///The object itself
                IObject obj = new IObject(fmaterial, simpleModel, tmesh);
                ///Add to the world
                this.World.AddObject(obj);
            }

            wh = new WaypointHandler();
            wh.LoadConnectedWaypoints("waypoints.xml");
            start = wh.CurrentWaypointsCollection.GetWaypointsList()[0];

            {
                ///Procedural yellow diffuse texture
                SimpleModel sm = new SimpleModel(factory, "Model\\block");
                sm.SetTexture(factory.CreateTexture2DColor(1, 1, Color.Yellow), TextureType.DIFFUSE);
                ///physic Ghost object(no collision)
                GhostObject           pi  = new GhostObject(start.WorldPos, Matrix.Identity, new Vector3(5));
                ForwardXNABasicShader s   = new ForwardXNABasicShader();
                ForwardMaterial       mat = new ForwardMaterial(s);
                IObject obj4 = new IObject(mat, sm, pi);
                this.World.AddObject(obj4);
            }

            ///add a camera
            this.World.CameraManager.AddCamera(new CameraFirstPerson(GraphicInfo));

            {
                SimpleModel sm = new SimpleModel(factory, "Model\\block");
                sm.SetTexture(factory.CreateTexture2DColor(1, 1, Color.Blue), TextureType.DIFFUSE);
                GhostObject           pi  = new GhostObject(start.WorldPos, Matrix.Identity, new Vector3(5));
                ForwardXNABasicShader s   = new ForwardXNABasicShader();
                ForwardMaterial       mat = new ForwardMaterial(s);
                IObject obj4 = new IObject(mat, sm, pi);
                obj4.OnUpdate += new OnUpdate(obj4_OnUpdate);
                this.World.AddObject(obj4);
            }
        }
Exemple #2
0
    // public LightScript lightScript;

    //Start
    private void Start()
    {
        //zone1.SetActive(true);
        //zone2.SetActive(false);

        inUpDraft = false;
        audio     = FindObjectOfType <AudioManager>();

        creditsMenu = GameObject.Find("Credits Menu");
        creditsMenu.SetActive(false);

        //Calling Scripts
        debugLines         = GetComponent <DebugLines>();
        flyingStates       = GetComponent <FlyingStates>();
        playerCollider     = GetComponent <BoxCollider>();
        camFollow          = GetComponent <CamFollow>();
        input              = GetComponent <InputManager>();
        rotationController = GetComponent <RotationController>();
        animationScript    = GetComponent <AnimationScript>();
        loadLevel          = GetComponent <LoadLevel>();
        // lightScript.light.color = lightScript.Cavecolor;

        //boostLight.SetActive(false);
        //windStream.SetActive(false);
        flyingStates.WingStreamsOff();
        FindObjectOfType <AudioManager>().StopPlayingAudio("Boost");


        EndGameUI.SetActive(false);
    }
 public void AddDeformingForce(Vector3 point, float force)
 {
     DebugLines.DrawLine(transform.position, point, Color.green);
     for (int i = 0; i < mDisplacedVertices.Length; i++)
     {
         //DebugLines.DrawLine(point, transform.TransformPoint(mDisplacedVertices[i]), Color.blue);
         AddForceToVertex(i, point, force);
     }
 }
Exemple #4
0
        /// <summary>
        /// Load content for the screen.
        /// </summary>
        /// <param name="GraphicInfo"></param>
        /// <param name="factory"></param>
        /// <param name="contentManager"></param>
        protected override void LoadContent(PloobsEngine.Engine.GraphicInfo GraphicInfo, PloobsEngine.Engine.GraphicFactory factory, IContentManager contentManager)
        {
            ///must be called before all
            base.LoadContent(GraphicInfo, factory, contentManager);

            RegisterDebugDrawCommand rc = new RegisterDebugDrawCommand(ddrawer);

            CommandProcessor.getCommandProcessor().SendCommandAssyncronous(rc);

            ddrawer.AddShape(new DebugBox(new BoundingBox(new Vector3(-50), new Vector3(50)), Color.Red));

            DebugLine dl = new DebugLine(Vector3.Zero, new Vector3(1000, 1000, 1000), Color.Red);

            ddrawer.AddShape(dl);

            DebugLines dls = new DebugLines();

            ddrawer.AddShape(dls);

            dls.AddLine(Vector3.Zero, new Vector3(-1000, 1000, -1000), Color.Green);
            dls.AddLine(Vector3.Zero, new Vector3(-1000, 1000, 1000), Color.Pink);

            SimpleModel          simpleModel = new SimpleModel(factory, "Model//cenario");
            TriangleMeshObject   tmesh       = new TriangleMeshObject(simpleModel, Vector3.Zero, Matrix.Identity, Vector3.One, MaterialDescription.DefaultBepuMaterial());
            DeferredNormalShader shader      = new DeferredNormalShader();
            DeferredMaterial     fmaterial   = new DeferredMaterial(shader);
            IObject obj = new IObject(fmaterial, simpleModel, tmesh);

            this.World.AddObject(obj);

            ///Add some directional lights to completely iluminate the world
            #region Lights
            DirectionalLightPE ld1 = new DirectionalLightPE(Vector3.Left, Color.White);
            DirectionalLightPE ld2 = new DirectionalLightPE(Vector3.Right, Color.White);
            DirectionalLightPE ld3 = new DirectionalLightPE(Vector3.Backward, Color.White);
            DirectionalLightPE ld4 = new DirectionalLightPE(Vector3.Forward, Color.White);
            DirectionalLightPE ld5 = new DirectionalLightPE(Vector3.Down, Color.White);
            float li = 0.4f;
            ld1.LightIntensity = li;
            ld2.LightIntensity = li;
            ld3.LightIntensity = li;
            ld4.LightIntensity = li;
            ld5.LightIntensity = li;
            this.World.AddLight(ld1);
            this.World.AddLight(ld2);
            this.World.AddLight(ld3);
            this.World.AddLight(ld4);
            this.World.AddLight(ld5);
            #endregion

            ///Add a AA post effect
            this.RenderTechnic.AddPostEffect(new AntiAliasingPostEffect());

            ///add a camera
            this.World.CameraManager.AddCamera(new CameraFirstPerson(GraphicInfo));
        }
Exemple #5
0
        public BoobsEditor(CharaPoseController parent, GenericOCITarget target) : base(parent)
        {
            this._target = target;
            this._parent.onLateUpdate += this.LateUpdate;
            if (_debugLines == null)
            {
                _debugLines = new DebugLines();
                _debugLines.SetActive(false);
            }

            this._leftBoob  = this._target.ociChar.charInfo.human.body.bustDynamicBone_L;
            this._rightBoob = this._target.ociChar.charInfo.human.body.bustDynamicBone_R;

            DynamicBone_Ver02_LateUpdate_Patches.shouldExecuteLateUpdate += this.ShouldExecuteDynamicBoneLateUpdate;
            MethodInfo initTransforms     = typeof(DynamicBone_Ver02).GetMethod("InitTransforms", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy);
            MethodInfo updateDynamicBones = typeof(DynamicBone_Ver02).GetMethod("UpdateDynamicBones", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy);

            this._leftBoobInitTransforms      = (Action)Delegate.CreateDelegate(typeof(Action), this._leftBoob, initTransforms);
            this._leftBoobUpdateDynamicBones  = (Action <float>)Delegate.CreateDelegate(typeof(Action <float>), this._leftBoob, updateDynamicBones);
            this._rightBoobInitTransforms     = (Action)Delegate.CreateDelegate(typeof(Action), this._rightBoob, initTransforms);
            this._rightBoobUpdateDynamicBones = (Action <float>)Delegate.CreateDelegate(typeof(Action <float>), this._rightBoob, updateDynamicBones);

            this._dynamicBones = this._parent.GetComponentsInChildren <DynamicBone_Ver02>(true);

            foreach (KeyValuePair <DynamicBoneColliderBase, CollidersEditor> pair in CollidersEditor._loneColliders)
            {
                DynamicBoneCollider normalCollider = pair.Key as DynamicBoneCollider;
                if (normalCollider == null)
                {
                    continue;
                }
                HashSet <object> ignoredDynamicBones;
                if (pair.Value._dirtyColliders.TryGetValue(pair.Key, out CollidersEditor.ColliderDataBase data) == false || data.ignoredDynamicBones.TryGetValue(this._parent, out ignoredDynamicBones) == false)
                {
                    ignoredDynamicBones = null;
                }
                foreach (DynamicBone_Ver02 bone in this._dynamicBones)
                {
                    if (ignoredDynamicBones != null && ignoredDynamicBones.Contains(bone)) // Should be ignored
                    {
                        if (bone.Colliders.Contains(normalCollider))
                        {
                            bone.Colliders.Remove(normalCollider);
                        }
                    }
                    else
                    {
                        if (bone.Colliders.Contains(normalCollider) == false)
                        {
                            bone.Colliders.Add(normalCollider);
                        }
                    }
                }
            }
            this._incIndex = -3;
        }
Exemple #6
0
    private void RingDeformation()
    {
        var mouseRay = Camera.main.ScreenPointToRay(Input.mousePosition);
        //var mouseDir = mouseRay.origin + mouseRay.direction;
        var step = (Mathf.PI * 2) / 16;
        var dirs = new List <Ray>();

        for (float i = 0; i < Mathf.PI * 2; i += step)
        {
            var ray = mouseRay;
            ray.direction = mouseRay.direction + new Vector3(mouseRay.direction.x + Radius * Mathf.Cos(i), mouseRay.direction.y + Radius * Mathf.Sin(i));
            //ray.direction = new Vector3(mouseRay.direction.x + Radius * Mathf.Cos(i),
            //                            mouseRay.direction.y + Radius * Mathf.Sin(i));

            dirs.Add(ray);
        }

        var hits = new List <RaycastHit>();

        for (int i = 0; i < dirs.Count; i++)
        {
            var        r = dirs[i];
            RaycastHit hit;
            if (Physics.Raycast(r, out hit))
            {
                hits.Add(hit);
            }
        }

        for (int i = 0; i < hits.Count; i++)
        {
            var hit      = hits[i];
            var deformer = hit.collider.GetComponent <IDeformer>();
            if (deformer != null)
            {
                var point = hit.point;
                point += hit.normal * ForceOffset;

                // Force should be based on total number of hits, rather than the number of dirs.
                deformer.AddDeformingForce(point, Force);
            }
        }

        Debug.Log($"{mouseRay}");
        //var mouseInWorld = Camera.main.ScreenToWorldPoint(mousePos);

        for (int i = 0; i < dirs.Count; i++)
        {
            //var worldPos = Camera.main.ScreenToWorldPoint(points[i]);
            DebugLines.DrawLine(dirs[i].origin, dirs[i].origin + dirs[i].direction, Color.red);
        }
    }
 private void Update()
 {
     if (mIsColliding)
     {
         foreach (var contact in mContactPoints)
         {
             var point = contact.point;
             point -= contact.normal * 0.1f;
             mDeformer.AddDeformingForce(point, mCollisionDeformerForce);
             DebugLines.DrawLine(transform.position, point, Color.red);
         }
     }
 }
        /// <summary>
        /// Load content for the screen.
        /// </summary>
        /// <param name="GraphicInfo"></param>
        /// <param name="factory"></param>
        /// <param name="contentManager"></param>
        protected override void LoadContent(GraphicInfo GraphicInfo, GraphicFactory factory, IContentManager contentManager)
        {
            base.LoadContent(GraphicInfo, factory, contentManager);

            RegisterDebugDrawCommand rc = new RegisterDebugDrawCommand(ddrawer);

            CommandProcessor.getCommandProcessor().SendCommandAssyncronous(rc);
            dlines = new DebugLines();
            ddrawer.AddShape(dlines);

            Picking pick = new Picking(this, 2000);

            pick.OnPickedLeftButton += new OnPicked(pick_OnPickedLeftButton);

            wh = new WaypointHandler();

            SimpleModel simpleModel = new SimpleModel(factory, "Model//block");

            simpleModel.SetTexture(factory.CreateTexture2DColor(1, 1, Color.White), TextureType.DIFFUSE);
            ///Physic info (position, rotation and scale are set here)
            BoxObject tmesh = new BoxObject(Vector3.Zero, 1, 1, 1, 10, new Vector3(1000, 1, 1000), Matrix.Identity, MaterialDescription.DefaultBepuMaterial());

            tmesh.isMotionLess = true;
            ///Forward Shader (look at this shader construction for more info)
            ForwardXNABasicShader shader = new ForwardXNABasicShader();
            ///Deferred material
            ForwardMaterial fmaterial = new ForwardMaterial(shader);
            ///The object itself
            IObject obj = new IObject(fmaterial, simpleModel, tmesh);

            ///Add to the world
            this.World.AddObject(obj);

            {
                InputPlayableKeyBoard ipk = new SimpleConcreteKeyboardInputPlayable(StateKey.PRESS, Microsoft.Xna.Framework.Input.Keys.Space);
                ipk.KeyStateChange += new KeyStateChange(ipk_KeyStateChange);
                this.BindInput(ipk);
            }

            {
                InputPlayableKeyBoard ipk = new SimpleConcreteKeyboardInputPlayable(StateKey.PRESS, Microsoft.Xna.Framework.Input.Keys.Enter);
                ipk.KeyStateChange += new KeyStateChange(ipk_KeyStateChange2);
                this.BindInput(ipk);
            }

            ///add a camera
            this.World.CameraManager.AddCamera(new CameraFirstPerson(GraphicInfo));
        }
    protected List <EdgeType[]> CollectChildLoops(SubdividableEdgeLoop <EdgeType> parent, List <DividingEdge> dividingEdges)
    {
        List <EdgeType> knownEdges    = new List <EdgeType>(parent.GetEdgesEnumerable());
        Polygon         parentPoly    = parent.GetPolygon();
        Path            polygonAsClip = parentPoly.ClipperPath(HelperFunctions.clipperScale);

        Vector2[] parentPoints = parent.GetPoints();

        //kinda ugly, these two variables are implicitly paired together
        Paths edgePaths = new Paths();
        List <ILinkedGraphEdgeFactory <EdgeType> > edgePathFactories = new List <ILinkedGraphEdgeFactory <EdgeType> >();
        List <System.Object[]> edgePathFactoriesParams = new List <System.Object[]>();

        foreach (DividingEdge edge in dividingEdges)
        {
            Path edgePath = new Path();
            edgePath.Add(HelperFunctions.GetIntPoint(edge.p1));
            edgePath.Add(HelperFunctions.GetIntPoint(edge.p2));

            PolyTree clippedResults = new PolyTree();
            Clipper  clipper        = new Clipper();

            clipper.AddPath(edgePath, PolyType.ptSubject, false);
            clipper.AddPath(polygonAsClip, PolyType.ptClip, true);
            clipper.Execute(ClipType.ctIntersection, clippedResults);

            Paths subPaths = Clipper.OpenPathsFromPolyTree(clippedResults);
            edgePaths.AddRange(subPaths);
            //if this edge was split into multiple paths when intersecting with parent poly, note that each subpath has the same factory
            foreach (Path path in subPaths)
            {
                edgePathFactories.Add(edge.factory);
                edgePathFactoriesParams.Add(edge.factoryParams);
            }
        }

        DebugLines debug = GameObject.FindObjectOfType <DebugLines>();


        int totalAddedEdges = 0;

        for (int j = 0; j < edgePaths.Count; j++)
        {
            Path edgePath = edgePaths[j];
            ILinkedGraphEdgeFactory <EdgeType> edgeFactory = edgePathFactories[j];
            System.Object[] edgeParams = edgePathFactoriesParams[j];
            //this is almost always just 2 elements in which case it runs once
            for (int i = 0; i < edgePath.Count - 1; i++)
            {
                //convert path back into regular coordinates. Watch out that there is high enough resolution
                //that when this conversion happens, the linkedGraph still thinks points/edges are adjacent and connects them
                Vector2 p1 = HelperFunctions.GetPoint(edgePath[i]);
                Vector2 p2 = HelperFunctions.GetPoint(edgePath[i + 1]);

                LinkedGraph <EdgeType> .ConnectNewEdge(p1, p2, edgeFactory, edgeParams, knownEdges);

                totalAddedEdges++;
            }
        }

        List <EdgeType[]> formedChildLoops = parent.GetInteriorEdgeLoops();

        if (formedChildLoops.Count == 0)
        {
            Debug.Log("No Children " + parent.GetHashCode());
        }
        return(formedChildLoops);
    }
        /// <summary>
        /// Load content for the screen.
        /// </summary>
        /// <param name="GraphicInfo"></param>
        /// <param name="factory"></param>
        /// <param name="contentManager"></param>
        protected override void LoadContent(GraphicInfo GraphicInfo, GraphicFactory factory, IContentManager contentManager)
        {
            base.LoadContent(GraphicInfo, factory, contentManager);

            RegisterDebugDrawCommand rc = new RegisterDebugDrawCommand(ddrawer);

            CommandProcessor.getCommandProcessor().SendCommandAssyncronous(rc);

            path.AddCircularObstacle(Vector3.Zero, 10);

            path.AddCircularObstacle(new Vector3(0, 20, 0), 15);

            path.AddCircularObstacle(new Vector3(200), 10);

            foreach (var item in path.Obstacles)
            {
                SphericalObstacle SphericalObstacle = item as SphericalObstacle;
                DebugSphere       s = new DebugSphere(SphericalObstacle.Center, SphericalObstacle.Radius, Color.Blue);
                ddrawer.AddShape(s);
            }
            //DebugSphere.WireFrameEnabled = true;

            DebugLines dls = new DebugLines();

            ddrawer.AddShape(dls);
            for (int i = 0; i < path.PolyPath.pointCount - 1; i++)
            {
                dls.AddLine(path.PolyPath.points[i], path.PolyPath.points[i] + Vector3.Up * 200, Color.Brown);
                dls.AddLine(path.PolyPath.points[i], path.PolyPath.points[i + 1], Color.Red);
            }
            dls.AddLine(path.PolyPath.points[path.PolyPath.pointCount - 1], path.PolyPath.points[path.PolyPath.pointCount - 1] + Vector3.Up * 200, Color.Brown);

            PlugIn = new PedestrianPlugIn(this.World, path,
                                          (pd) =>
            {
                SimpleModel simpleModel = new SimpleModel(factory, "Model//block");
                simpleModel.SetTexture(factory.CreateTexture2DColor(1, 1, Color.Green), TextureType.DIFFUSE);
                ///Physic info (position, rotation and scale are set here)
                GhostObject tmesh = new GhostObject();
                ///Forward Shader (look at this shader construction for more info)
                ForwardXNABasicShader shader = new ForwardXNABasicShader();
                ///Deferred material
                ForwardMaterial fmaterial = new ForwardMaterial(shader);
                ///The object itself
                IObject obj = new IObject(fmaterial, simpleModel, tmesh);
                obj.IObjectAttachment.Add(new SteerAtachment(pd));
                return(obj);
            });

            PlugIn.Init();

            {
                SimpleModel simpleModel = new SimpleModel(factory, "Model//block");
                simpleModel.SetTexture(factory.CreateTexture2DColor(1, 1, Color.White), TextureType.DIFFUSE);
                ///Physic info (position, rotation and scale are set here)
                BoxObject tmesh = new BoxObject(Vector3.Zero, 1, 1, 1, 10, new Vector3(1000, 1, 1000), Matrix.Identity, MaterialDescription.DefaultBepuMaterial());
                tmesh.isMotionLess = true;
                ///Forward Shader (look at this shader construction for more info)
                ForwardXNABasicShader shader = new ForwardXNABasicShader();
                ///Deferred material
                ForwardMaterial fmaterial = new ForwardMaterial(shader);
                ///The object itself
                this.World.AddObject(new IObject(fmaterial, simpleModel, tmesh));
            }

            ///add a camera
            this.World.CameraManager.AddCamera(new CameraFirstPerson(GraphicInfo));
        }
Exemple #11
0
    public List <EdgeType> GetLocalLoop(EdgeType startingEdge, bool ccw)
    {
        List <EdgeType> foundEdges = new List <EdgeType>();

        foundEdges.Add(startingEdge);

        LinkedGraphVertex firstVertex = startingEdge.a;
        LinkedGraphVertex lastVertex  = startingEdge.b;
        bool foundLoop = false;
        int  edgesSeen = 0;

        while (!foundLoop)
        {
            EdgeLoopEdge lastEdge          = foundEdges[foundEdges.Count - 1];
            Vector2      lastEdgeDirection = lastEdge.GetOppositeVertex(lastVertex).pt - lastVertex.pt;

            float    minAngle     = float.MaxValue;
            EdgeType minAngleEdge = null;

            if (lastVertex.NumConnections() <= 1)
            {
                Debug.LogWarning("Reached end of loop while collecting loop.");
                return(null);
            }

            foreach (LinkedGraphEdge connection in lastVertex.GetConnections())
            {
                if (connection == lastEdge)
                {
                    continue;//ignore the connection if it is this instance.
                }
                //all connections must share lastVertex with lastEdge
                Vector2 thisEdgeDirection = connection.GetOppositeVertex(lastVertex).pt - lastVertex.pt;

                float angle = HelperFunctions.AngleBetween(thisEdgeDirection, lastEdgeDirection);
                if (!ccw)
                {
                    //we want to invert the smallest angle when its cw since angleBetween gets the ccw angle
                    angle = Mathf.PI * 2 - angle;
                }

                if (angle < minAngle)
                {
                    if (connection is EdgeType)
                    {
                        minAngle     = angle;
                        minAngleEdge = (EdgeType)connection;
                    }
                    else
                    {
                        Debug.LogWarning("Could not isolate loop because connected edges were not EdgeLoopEdges");
                    }
                }
                edgesSeen++;
                if (edgesSeen > MAXLOOPSIZE)
                {
                    Debug.LogWarning("Couldn't close loop. Failing");
                    DebugLines debug = GameObject.FindObjectOfType <DebugLines>();
                    foreach (EdgeType edge in foundEdges)
                    {
                        debug.AddEdge(edge, Color.red);
                    }
                    return(null);
                }
            }

            foundEdges.Add(minAngleEdge);
            lastVertex = minAngleEdge.GetOppositeVertex(lastVertex);

            if (lastVertex == firstVertex)
            {
                foundLoop = true;
            }
        }
        //maintain the loops go ccw paradigm
        if (!ccw)
        {
            foundEdges.Reverse();
        }
        return(foundEdges);
    }