Ejemplo 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();
        }
Ejemplo n.º 2
0
 public Actor(Component component)
 {
     Components = new List<Component>();
     Components.Add(component);
     if (component.Entity != null)
         component.Entity.Tag = new EntityTag(this, component);
 }
Ejemplo n.º 3
0
 public Actor(Component component, string name)
 {
     Components = new List<Component>();
     Components.Add(component);
     if (component.Entity != null)
         component.Entity.Tag = new EntityTag(this, component);
     _name = name;
 }
Ejemplo n.º 4
0
 public EntityTag(Actor parentActor, Component parentComponent)
 {
     ParentActor = parentActor;
     ParentComponent = parentComponent;
     useType = UseType.Grab;
 }
Ejemplo n.º 5
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();
        }