Esempio n. 1
0
        public override void InitializeComponents()
        {
            var bot = new Component(new LPPMesh(botModel), position, Quaternion.Identity, scalevec);
            bot.SetCollision(botPI, true);
            Components.Add(bot); // Component 0 is the bottom
            var mid = new Component(new LPPMesh(midModel), position, Quaternion.Identity, scalevec);
            mid.SetCollision(midPI, true);
            Components.Add(mid); // 1 is the mid section
            var top = new Component(new LPPMesh(topModel), position, Quaternion.Identity, scalevec);
            top.SetCollision(topPI, true);
            Components.Add(top); // and 2 is the top

            foreach (Component component in Components)
            {
                Helpers.RemapEffects(component.Mesh.Model, liftEffect);
                liftEffect.Parameters["DiffuseMap"].SetValue(liftTexture);
                liftEffect.Parameters["NormalMap"].SetValue(liftNormal);
            }

            topPos = top.Entity.Position;
            midPos = mid.Entity.Position;
            botPos = bot.Entity.Position;

            base.InitializeComponents();
        }
Esempio n. 2
0
        public override void InitializeComponents()
        {
            Component shade;
            Light shadeLight;

            var toplink = new Component(Position, Quaternion.Identity, scalevec / 32.0f);
            toplink.Mesh = new LPPMesh(segmentModel);
            toplink.SetCollision(segmentPhys, true);

            Components.Add(toplink);

            Vector3 yVec = new Vector3(0.0f, scalevec.Y, 0.0f);

            var lastlink = toplink;

            for (int i = 0; i < numSegments; i++)
            {
                var link = new Component(Position - (yVec * (float)i * linklength), Quaternion.Identity, scalevec / 32.0f);
                link.Mesh = new LPPMesh(segmentModel);
                link.SetCollision(segmentPhys, false);
                CollisionRules.AddRule(lastlink.Entity, link.Entity, CollisionRule.NoBroadPhase);
                var joint = new DistanceJoint(lastlink.Entity, link.Entity, link.Position, link.Position);

                joint.SpringSettings.Advanced.UseAdvancedSettings = true;
                joint.SpringSettings.Advanced.ErrorReductionFactor = 0.99f;
                joint.SpringSettings.Advanced.Softness = 0.1f;

                Components.Add(link);
                Components.Add(new DummyComponent(joint));
                lastlink = link;
            }

            shade = new Component(Position - (yVec * ((numSegments * linklength) + 0.25f)), Quaternion.Identity, scalevec / 32.0f);
            shade.Mesh = new LPPMesh(lampModel);

            shadeLight = new Light();
            shadeLight.LocalTransform = Matrix.CreateTranslation(yVec * -0.3f);
            shadeLight.Shadow = true;
            shadeLight.LightType = "BakedShadow";
            shadeLight.Radius = 12.5f;
            shadeLight.Intensity = 0.75f;
            shadeLight.Color = lightColor;
            PhysicsInfo PI = new PhysicsInfo(lampPhys);
            PI.Density /= scalevec.Length() / Vector3.One.Length();
            shade.SetCollision(PI, false);
            shade.Lights.Add(shadeLight);
            shade.Entity.Tag = new EntityTag(this, shade);

            shadeLight = new Light();
            shadeLight.Color = lightColor;
            shadeLight.LocalTransform = Matrix.CreateTranslation(yVec);
            shadeLight.Radius = 11.9f;
            shadeLight.Intensity = 0.75f;
            shadeLight.Shadow = false;
            shade.Lights.Add(shadeLight);

            shadeLight = new Light();
            shadeLight.Intensity = 1.0f;
            shadeLight.Radius = 0.5f;
            shade.Lights.Add(shadeLight);
            Components.Add(shade);

            CollisionRules.AddRule(shade.Entity, lastlink.Entity, CollisionRule.NoBroadPhase);
            var joint1 = new DistanceJoint(lastlink.Entity, shade.Entity, shade.Position, lastlink.Position);
            joint1.SpringSettings.DampingConstant = 1000000f;
            joint1.SpringSettings.StiffnessConstant = 600000f;
            var angularMotor1 = new AngularMotor(lastlink.Entity, shade.Entity);
            angularMotor1.Settings.MaximumForce = 50f;
            Components.Add(new DummyComponent(joint1));
            Components.Add(new DummyComponent(angularMotor1));
            base.InitializeComponents();
        }
Esempio n. 3
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.

            spriteBatch = new SpriteBatch(GraphicsDevice);

            #region models

            boxmodel = Content.Load<Model>("primitives/box");
            lppbox = Content.Load<Model>("primitives/lit/box");
            lppsphere = Content.Load<Model>("primitives/lit/sphere");
            lppcapsule = Content.Load<Model>("primitives/lit/capsule");
            lppcylinder = Content.Load<Model>("primitives/lit/cylinder");
            cylindermodel = Content.Load<Model>("primitives/cylinder");
            spheremodel = Content.Load<Model>("primitives/sphere");
            capsulemodel = Content.Load<Model>("primitives/capsule");
            floormodel = Content.Load<Model>("floor/floor");
            boxdata = Content.Load<PhysicsInfo>("walls/roomphys");
            circleimg = Content.Load<Texture2D>("textures/circle");
            Model blockman = Content.Load<Model>("floor/floor");
            //Model skullmodel = Content.Load<Model>("skull/skull");
            Model wallmodel = Content.Load<Model>("room/room");
            PhysicsInfo skullphys = Content.Load<PhysicsInfo>("skull/skullphys");
            ShadowEffect = Content.Load<Effect>("shaders/Shadow");
            Model sceneModel = Content.Load<Model>("scene/scenetest");
            PhysicsInfo scenePhys = Content.Load<PhysicsInfo>("scene/scenetestphys");

            #endregion

            #region Effects
            NormalEffect = Content.Load<Effect>("shaders/LPPNormalEffect");
            BasicEffect = Content.Load<Effect>("shaders/LPPBasicEffect");
            TexturedEffect = Content.Load<Effect>("shaders/LPPTexturedEffect");
            MainEffect = Content.Load<Effect>("shaders/LPPMainEffect");
            #endregion
            Vector3 lowerButton = new Vector3(134.988f, 61.178f, 126.411f) * (2.54f / 64.0f);
            Vector3 upperButton = new Vector3(134.988f, 64.803f, 126.411f) * (2.54f / 64.0f);
            float convFactor = 2.54f / 64.0f;

            Console.Parse("physdebug false");
            Console.Parse("drawconstraints false");
            Console.Parse("drawedgemask false");
            Console.Parse("drawdepth false");
            Console.Parse("drawnormal false");
            Console.Parse("drawall false");
            Console.Parse("drawspheres false");
            Console.Parse("blur true");
            Console.Parse("drawshadowmap false");
            Console.Parse("drawlightbuffer false");
            Console.Parse("showPosition true");

            Console.LoadContent(Content);

            /*boxdata = new PhysicsInfo();
            boxdata.CreateBox(new Vector3(-1, -1, -1), Matrix.Identity, Vector3.One);
            boxdata.CreateBox(new Vector3(1, 1, 1), Matrix.Identity, Vector3.One);
            boxdata.CreateSphere(new Vector3(1, 3, 1), 1);*/

            // TODO: use this.Content to load your game content here
            projmatrix = Matrix.CreatePerspectiveFieldOfView(MathHelper.ToRadians(45), (float)graphics.PreferredBackBufferWidth / (float)graphics.PreferredBackBufferHeight, 0.01f, 2500.0f);
            /*
            fallingBox = new Component(new Vector3(3.6f, 7.5f, -2.4f), Quaternion.Identity, Vector3.One / 2.0f);
            fallingBox.SetCollision(skullphys, false);
            fallingBox.Mesh = new LPPMesh(skullmodel);
            fallingBox.Mesh.Occlude = true;
            Actors.Add(new Actor(fallingBox));*/

            /*immovableBox = new TriangleMeshActor(floormodel, Vector3.Zero, Vector3.One / 8.0f);
            immovableBox.Mesh = new LPPMesh(floormodel);
            immovableBox.Mesh.Occlude = true;

            Entities.Add(new Entity(immovableBox));*/

            immovableBox = new TriangleMeshComponent(wallmodel, Vector3.Zero, Vector3.One / (64.0f / 2.54f));
            var lppmesh = new LPPMesh(wallmodel);

            var scene = new Component(new LPPMesh(sceneModel), new Vector3(3.8f, 7.5f, -3.0f), Quaternion.Identity, Vector3.One / 64.0f);
            scene.SetCollision(scenePhys, true);
            Actors.Add(new Actor(scene));
            Actors.Add(new LiftButton(upperButton, Vector3.One / 64.0f, "lift up"));
            Actors.Add(new LiftButton(lowerButton, Vector3.One / 64.0f, "lift down"));

            lppmesh.SpecularPower = 1.0f;
            lppmesh.Shininess = 1.0f;

            immovableBox.Mesh = lppmesh;

            Actors.Add(new Actor(immovableBox));

            Actors.Add(new CeilingLamp(new Vector3(-1.5f, 11.9f, 1.68f), 0.75f));
            Actors.Add(new Ladder(new Vector3(13.735f, 5.0f, -2.32f), 1.0f, 3.5f, 0.5f));
            lift = new Lift(Vector3.Zero, 1 / 64.0f);
            Actors.Add(lift);

            Actors.Add(new PulsingLight(new Vector3(12.86f, 3.43f, 5.84f), Color.Red, 7.5f, 1.0f, 0.2f, 3.0d));
            Actors.Add(new BareBulb(new Vector3(-14.5f, 11.4f, 3f), Vector3.One / 64.0f, Color.Wheat, 10.0f, 0.6f));
            font = Content.Load<SpriteFont>("font");

            RasterizerState rs = RasterizerState.CullCounterClockwise;
            GraphicsDevice.RasterizerState = rs;

            bs = GraphicsDevice.BlendState;

            cam = new Camera();
            cam.Aspect = (float)scrwidth / (float)scrheight;
            cam.Viewport = new Viewport(0, 0, scrwidth, scrheight);
            cam.NearClip = 0.01f;
            cam.FarClip = 100.0f;
            cam.Transform = Matrix.Identity;

            characterController = new CharacterController(new Vector3(-1.0f, 2.0f, 7.311f), 3.0f, 0.75f, 0.1f, 0.2f);
            characterInput = new CharacterControllerInput(space, cam);
            characterInput.CharacterController = characterController;
            characterInput.Activate();

            camcontrol = new CameraController(cam, Vector3.Zero, Vector2.Zero);
            Actors.Add(new Actor(new FollowLight(12.5f, 1.0f, Color.White, cam)));
            lppRenderer = new LPPRenderer(GraphicsDevice, Content, scrwidth, scrheight);

            for (int i = /*200*/0; i > 0; --i)
            {
                space.Update(0.0166f);
            }

            window = new Dialog(Manager);
            window.SetPosition(0, 0);
            window.SetSize(512, 512);
            window.Text = "Console";
            textBox = new TextBox(Manager);
            textBox.SetPosition(32, 32);
            window.Add(textBox, false);
            Manager.Add(window);
        }