public override void Initialize(Microsoft.Xna.Framework.Content.ContentManager contentLoader, ComponentManifest manifest)
        {
            SkyTexture = contentLoader.Load<TextureCube>((string)(manifest.Properties[ManifestKeys.TEXTURE]));
            OnEnvironmentMapAdded(EventArgs.Empty);

            base.Initialize(contentLoader, manifest);
        }
Beispiel #2
0
        public override void Initialize(ContentManager contentLoader, ComponentManifest manifest)
        {
            if (manifest.Properties.ContainsKey(ManifestKeys.ITEM_NAME))
                LoadItem((string)(manifest.Properties[ManifestKeys.ITEM_NAME]), contentLoader);

            Owner.ComponentsCreated += ComponentsCreatedHandler;
        }
        protected override void BuildSphereAndGeometryNodes(ComponentManifest manifest, SceneNode parent)
        {
            Vector4 specColor = (Vector4)(manifest.Properties[ManifestKeys.MAT_SPEC_COLOR]);
            Effect.Parameters[EffectRegistry.MATERIAL_SPECULAR_COLOR_PARAM_NAME].SetValue(specColor);
            Effect.Parameters[EffectRegistry.TEXTURE_PARAM_NAME].SetValue(mTexture);

            float brightness = 1.0f;
            if (manifest.Properties.ContainsKey(ManifestKeys.BRIGHTNESS))
                brightness = (float)(manifest.Properties[ManifestKeys.BRIGHTNESS]);
            Effect.Parameters[EffectRegistry.BRIGHTNESS_PARAM_NAME].SetValue(brightness);

            float contrast = 1.0f;
            if (manifest.Properties.ContainsKey(ManifestKeys.CONTRAST))
                contrast = (float)(manifest.Properties[ManifestKeys.CONTRAST]);
            Effect.Parameters[EffectRegistry.CONTRAST_PARAM_NAME].SetValue(contrast);

            // First, add the effect's params to the EffectRegistry so the ParamSetter can retrieve them.
            EffectRegistry.Add(Effect, RenderOptions.RequiresHDRLighting | RenderOptions.RequiresShadowMap);

            // Create the default material
            EffectApplication defaultMaterial = new EffectApplication(Effect, RenderStatePresets.Default);
            defaultMaterial.AddParamSetter(new CommonParamSetter());
            defaultMaterial.AddParamSetter(new HDRLightParamSetter());
            defaultMaterial.AddParamSetter(new FogParamSetter());
            defaultMaterial.AddParamSetter(new ShadowParamSetter());

            RawGeometryNode geometry = null;
            ExplicitBoundingSphereNode meshBound = null;
            switch ((Shape)(manifest.Properties[ManifestKeys.SHAPE]))
            {
                case Shape.Box:
                    geometry = new RawGeometryNode(GeneratedGeometry.Box, defaultMaterial);
                    meshBound = new ExplicitBoundingSphereNode(GeneratedGeometry.BoxBound);
                    break;
                case Shape.Sphere:
                    geometry = new RawGeometryNode(GeneratedGeometry.Sphere, defaultMaterial);
                    meshBound = new ExplicitBoundingSphereNode(GeneratedGeometry.SphereBound);
                    break;
            }

            parent.AddChild(meshBound);
            meshBound.AddChild(geometry);

            // Create the ShadowMap material
            // Default to CastsShadow = true
            if (!manifest.Properties.ContainsKey(ManifestKeys.CASTS_SHADOW) || (bool)(manifest.Properties[ManifestKeys.CASTS_SHADOW]))
            {
                EffectApplication depthOnlyMaterial;
                depthOnlyMaterial = new EffectApplication(EffectRegistry.DepthOnlyFx, RenderStatePresets.Default);
                depthOnlyMaterial.AddParamSetter(new WorldViewProjParamSetter());
                geometry.AddMaterial(TraversalContext.MaterialFlags.ShadowMap, depthOnlyMaterial);
            }
            else
            {
                geometry.AddMaterial(TraversalContext.MaterialFlags.ShadowMap, null);
            }

            // If the GeometryNode requires additional materials, they would need to be added here.
        }
 protected override void CreateSceneGraph(ComponentManifest manifest)
 {
     EffectApplication defaultMaterial = new EffectApplication(EffectRegistry.SkyboxFx, RenderStatePresets.Skybox);
     defaultMaterial.AddParamSetter(new SkyboxWvpParamSetter());
     defaultMaterial.AddParamSetter(new EnvironmentMapParamSetter());
     SceneGraph = new RawGeometryNode(GeneratedGeometry.Sphere, defaultMaterial);
     ((GeometryNode)SceneGraph).AddMaterial(TraversalContext.MaterialFlags.ShadowMap, null);
 }
        public override void Initialize(ContentManager contentLoader, ComponentManifest manifest)
        {
            if (manifest.Properties.ContainsKey(ManifestKeys.LEVEL_NAME))
                mLevelName = (string)(manifest.Properties[ManifestKeys.LEVEL_NAME]);

            Owner.ComponentsCreated += ComponentsCreatedHandler;
            GameResources.ActorManager.LevelLoaded += LevelLoadedHandler;
        }
Beispiel #6
0
        public override void Initialize(ContentManager contentLoader, ComponentManifest manifest)
        {
            Color = (Color)(manifest.Properties[ManifestKeys.COLOR]);
            Start = (float)(manifest.Properties[ManifestKeys.START]);
            End = (float)(manifest.Properties[ManifestKeys.END]);

            Owner.ActorInitialized += ActorInitializedHandler;
        }
        public override void Initialize(ContentManager contentLoader, ComponentManifest manifest)
        {
            if (manifest.Properties.ContainsKey(ManifestKeys.SPEED))
                mSpeed = (float)(manifest.Properties[ManifestKeys.SPEED]);

            if (manifest.Properties.ContainsKey(ManifestKeys.DAMAGE))
                mDamage = (int)(manifest.Properties[ManifestKeys.DAMAGE]);

            Owner.ComponentsCreated += ComponentsCreatedHandler;
            GameResources.ActorManager.PreAnimationUpdateStep += PreAnimationUpdateHandler;
        }
        public override void Initialize(ContentManager contentLoader, ComponentManifest manifest)
        {
            base.Initialize(contentLoader, manifest);

            LevitationHandlingDesc levitationDesc = new LevitationHandlingDesc();
            levitationDesc.DampingForce = GameOptions.MovementForceDamping;
            levitationDesc.DampingRotationForce = GameOptions.MovementRotationForceDamping;
            levitationDesc.MaxRotationVelocity = GameOptions.MovementRotationVelocity;
            levitationDesc.MaxVelocity = GameOptions.MovementVelocity;

            mController = new LevitationMovementController(levitationDesc);
            GameResources.ActorManager.PreAnimationUpdateStep += PreAnimationUpdateHandler;
        }
        public override void Initialize(ContentManager contentLoader, ComponentManifest manifest)
        {
            Effect genericEffect = contentLoader.Load<Effect>("shaders\\PhongShadow");

            // If we have several of these objects, the content manager will return
            // a single shared effect instance to them all. But we want to preconfigure
            // the effect with parameters that are specific to this particular
            // object. By cloning the effect, we prevent one
            // from stomping over the parameter settings of another.

            Effect = genericEffect.Clone();
            mTexture = contentLoader.Load<Texture>((string)(manifest.Properties[ManifestKeys.TEXTURE]));

            base.Initialize(contentLoader, manifest);
        }
        public override void Initialize(ContentManager contentLoader, ComponentManifest manifest)
        {
            float radius = (float)(manifest.Properties[ManifestKeys.RADIUS]);

            if (manifest.Properties.ContainsKey(ManifestKeys.MASS))
            {
                float mass = (float)(manifest.Properties[ManifestKeys.MASS]);
                mSimSphere = new Sphere(BEPUutilities.Vector3.Zero, radius, mass);
            }
            else
            {
                mSimSphere = new Sphere(BEPUutilities.Vector3.Zero, radius);
            }

            base.Initialize(contentLoader, manifest);
        }
        public override void Initialize(ContentManager contentLoader, ComponentManifest manifest)
        {
            TerrainAsset = contentLoader.Load<Terrain>((string)(manifest.Properties[ManifestKeys.TERRAIN]));
            Heights = TerrainAsset.GetGeometry();

            EffectRegistry.Add(TerrainAsset.Effect, (RenderOptions)(TerrainAsset.Tag));

            mDefaultMaterial = new EffectApplication(TerrainAsset.Effect, RenderStatePresets.Default);
            mDefaultMaterial.AddParamSetter(new CommonParamSetter());
            mDefaultMaterial.AddParamSetter(new ShadowParamSetter());
            mDefaultMaterial.AddParamSetter(new HDRLightParamSetter());
            mDefaultMaterial.AddParamSetter(new FogParamSetter());
            mDepthOnlyMaterial = new EffectApplication(EffectRegistry.DepthOnlyFx, RenderStatePresets.Default);
            mDepthOnlyMaterial.AddParamSetter(new WorldViewProjParamSetter());

            base.Initialize(contentLoader, manifest);
        }
        protected override void CreateSceneGraph(ComponentManifest manifest)
        {
            SceneGraph = new ActorTransformNode(Owner);

            SceneNode sphereParent = SceneGraph;

            Matrix modelAdjustment = Matrix.Identity;
            if (manifest.Properties.ContainsKey(ManifestKeys.MODEL_ADJUSTMENT))
                modelAdjustment = (Matrix)(manifest.Properties[ManifestKeys.MODEL_ADJUSTMENT]);

            if (modelAdjustment != Matrix.Identity)
            {
                sphereParent = new StaticTransformNode(modelAdjustment);
                SceneGraph.AddChild(sphereParent);
            }

            BuildSphereAndGeometryNodes(manifest, sphereParent);
        }
        public override void Initialize(ContentManager contentLoader, ComponentManifest manifest)
        {
            float width = (float)(manifest.Properties[ManifestKeys.WIDTH]);
            float height = (float)(manifest.Properties[ManifestKeys.HEIGHT]);
            float length = (float)(manifest.Properties[ManifestKeys.LENGTH]);

            if (manifest.Properties.ContainsKey(ManifestKeys.MASS))
            {
                float mass = (float)(manifest.Properties[ManifestKeys.MASS]);
                mSimBox = new Box(BEPUutilities.Vector3.Zero, width, height, length, mass);
            }
            else
            {
                mSimBox = new Box(BEPUutilities.Vector3.Zero, width, height, length);
            }

            base.Initialize(contentLoader, manifest);
        }
        public override void Initialize(ContentManager contentLoader, ComponentManifest manifest)
        {
            base.Initialize(contentLoader, manifest);

            if (manifest.Properties.ContainsKey(ManifestKeys.NO_SOLVER) && (bool)(manifest.Properties[ManifestKeys.NO_SOLVER]))   // Setting this to true will allow the object to pass through others.
                Entity.CollisionInformation.CollisionRules.Personal = BEPUphysics.CollisionRuleManagement.CollisionRule.NoSolver;

            if (manifest.Properties.ContainsKey(ManifestKeys.TRANSFORM_OFFSET))
                mTransformOffset = (Vector3)(manifest.Properties[ManifestKeys.TRANSFORM_OFFSET]);

            if (manifest.Properties.ContainsKey(ManifestKeys.BOUNCINESS))
                Entity.Material.Bounciness = (float)(manifest.Properties[ManifestKeys.BOUNCINESS]);

            if (manifest.Properties.ContainsKey(ManifestKeys.STATIC_FRICTION))
                Entity.Material.StaticFriction = (float)(manifest.Properties[ManifestKeys.STATIC_FRICTION]);

            if (manifest.Properties.ContainsKey(ManifestKeys.KINETIC_FRICTION))
                Entity.Material.KineticFriction = (float)(manifest.Properties[ManifestKeys.KINETIC_FRICTION]);

            if (manifest.Properties.ContainsKey(ManifestKeys.LOCK_ROTATION) && (bool)(manifest.Properties[ManifestKeys.LOCK_ROTATION]))   // Setting this to true will prevent the object from rotating
                Entity.LocalInertiaTensorInverse = new BEPUutilities.Matrix3x3(0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f);
        }
 public override void Initialize(ContentManager contentLoader, ComponentManifest manifest)
 {
     base.Initialize(contentLoader, manifest);
     ProjectileTemplateName = (string)(manifest.Properties[ManifestKeys.PROJECTILE_NAME]);
 }
Beispiel #16
0
 public override void Initialize(ContentManager contentLoader, ComponentManifest manifest)
 {
     if (manifest.Properties.ContainsKey(ManifestKeys.REGENERATION_RATE))
         RegenerationRate = (float)(manifest.Properties[ManifestKeys.REGENERATION_RATE]);
 }
Beispiel #17
0
        public override void Initialize(Microsoft.Xna.Framework.Content.ContentManager contentLoader, Manifracture.ComponentManifest manifest)
        {
            IrradianceMap      = contentLoader.Load <Texture2D>((string)(manifest.Properties[ManifestKeys.IRRADIANCEMAP]));
            SpecPrefilter      = contentLoader.Load <Texture2D>((string)(manifest.Properties[ManifestKeys.SPECPREFILTER]));
            NumSpecLevels      = (int)(manifest.Properties[ManifestKeys.NUMSPECLEVELS]);
            SpecExponentFactor = (float)(manifest.Properties[ManifestKeys.SPECEXPONENTFACTOR]);
            AmbientLight       = (Vector3)(manifest.Properties[ManifestKeys.AMBIENTLIGHT]);

            Owner.ActorInitialized += ActorInitializedHandler;
        }
        protected override void BuildSphereAndGeometryNodes(ComponentManifest manifest, SceneNode parent)
        {
            BoundingSphere bound = new BoundingSphere();
            bound.Center = Vector3.Zero;
            // TODO: P2: Magic number?
            bound.Radius = 120.0f;
            ExplicitBoundingSphereNode meshBound = new ExplicitBoundingSphereNode(bound);
            parent.AddChild(meshBound);

            // Create the default material
            EffectApplication defaultMaterial = new EffectApplication(mEffect, mSettings.RenderState);
            defaultMaterial.AddParamSetter(new ParticlesParamSetter(delegate() { return mCurrentTime; }));

            ParticleSystemGeometryNode geometry = new ParticleSystemGeometryNode(mParticleData, delegate() { mDrawCounter++; }, defaultMaterial);
            meshBound.AddChild(geometry);

            // It won't cast a shadow.
            geometry.AddMaterial(TraversalContext.MaterialFlags.ShadowMap, null);
        }
Beispiel #19
0
 public override void Initialize(ContentManager contentLoader, ComponentManifest manifest)
 {
     base.Initialize(contentLoader, manifest);
     Damage = (int)(manifest.Properties[ManifestKeys.DAMAGE]);
 }
Beispiel #20
0
 public override void Initialize(ContentManager contentLoader, ComponentManifest manifest)
 {
     base.Initialize(contentLoader, manifest);
     Category = (SlotCategory)(manifest.Properties[ManifestKeys.EQUIP_SLOT_CATEGORY]);
     EquippedBehaviorAssetName = (string)(manifest.Properties[ManifestKeys.EQUIPPED_BEHAVIOR_NAME]);
 }
Beispiel #21
0
 public override void Initialize(ContentManager contentLoader, ComponentManifest manifest)
 {
     Owner.ComponentsCreated += ComponentsCreatedHandler;
     GameResources.ActorManager.PreAnimationUpdateStep += PreAnimationUpdateHandler;
 }
Beispiel #22
0
 // If you override this, this one probably should get called _after_ the derived method does its stuff.
 public override void Initialize(ContentManager contentLoader, ComponentManifest manifest)
 {
     CreateSceneGraph(manifest);
     Owner.ComponentsCreated += ComponentsCreatedHandler;
     Owner.ActorInitialized += ActorInitializedHandler;
 }
Beispiel #23
0
 protected abstract void CreateSceneGraph(ComponentManifest manifest);
 public override void Initialize(ContentManager contentLoader, ComponentManifest manifest)
 {
     if (manifest.Properties.ContainsKey(ManifestKeys.CLIPS_CAMERA))
         mClipsCamera = (bool)(manifest.Properties[ManifestKeys.CLIPS_CAMERA]);
 }
        protected override void CreateSceneGraph(ComponentManifest manifest)
        {
            int numXSectors = (TerrainAsset.VertexCountAlongXAxis - 1) / TerrainAsset.SectorSize;
            int numZSectors = (TerrainAsset.VertexCountAlongZAxis - 1) / TerrainAsset.SectorSize;

            // Caution: Being a large hierarchy of ImplicitBoundingBox nodes, the SceneGraph property's meaning becomes
            // less clear as the scene graph grows. Other objects will be placed within the tree, making it quite difficult
            // to define how to remove this component from the game. Fortunately, that should never actually be necessary.
            SceneGraph = PartitionSectorGrid(0, numXSectors, 0, numZSectors);
        }
 public override void Initialize(ContentManager contentLoader, ComponentManifest manifest)
 {
     VisualModel = contentLoader.Load<Model>((string)(manifest.Properties[ManifestKeys.VISUAL_MODEL]));
     base.Initialize(contentLoader, manifest);
 }
Beispiel #27
0
 public virtual void Initialize(ContentManager contentLoader, ComponentManifest manifest)
 {
     ResourceCostToUse = (float)(manifest.Properties[ManifestKeys.RESOURCE_COST_TO_USE]);
     // TODO: P2: Init range info.
     GameResources.ActorManager.PreAnimationUpdateStep += PreAnimationUpdate;
 }
        protected override void BuildSphereAndGeometryNodes(ComponentManifest manifest, SceneNode parent)
        {
            foreach (ModelMesh mm in VisualModel.Meshes)
            {
                ExplicitBoundingSphereNode meshBound = new ExplicitBoundingSphereNode(mm.BoundingSphere);
                parent.AddChild(meshBound);

                foreach (ModelMeshPart mmp in mm.MeshParts)
                {
                    MaterialInfo mi = mmp.Tag as MaterialInfo;
                    if (mi == null)
                        throw new AssetFormatException("The VisualModel's ModelMeshParts do not contain the MaterialInfo in the Tag property.");

                    // First, add the effect's params to the EffectRegistry so the ParamSetter can retrieve them.
                    EffectRegistry.Add(mmp.Effect, mi.HandlingFlags);

                    // Create the default material
                    EffectApplication defaultMaterial = new EffectApplication(mmp.Effect, mi.RenderState);
                    defaultMaterial.AddParamSetter(new CommonParamSetter());
                    defaultMaterial.AddParamSetter(new FogParamSetter());

                    if ((mi.HandlingFlags & RenderOptions.RequiresHDRLighting) > 0)
                        defaultMaterial.AddParamSetter(new HDRLightParamSetter());

                    if ((mi.HandlingFlags & RenderOptions.RequiresSkeletalPose) > 0)
                        defaultMaterial.AddParamSetter(new SkinParamSetter());

                    if ((mi.HandlingFlags & RenderOptions.RequiresShadowMap) > 0)
                        defaultMaterial.AddParamSetter(new ShadowParamSetter());

                    if ((mi.HandlingFlags & RenderOptions.RequiresFringeMap) > 0)
                        defaultMaterial.AddParamSetter(new FringeMapParamSetter());

                    ModelGeometryNode geometry = new ModelGeometryNode(mmp, defaultMaterial);
                    meshBound.AddChild(geometry);

                    // Create the ShadowMap material
                    // Default to CastsShadow = true
                    if (!manifest.Properties.ContainsKey(ManifestKeys.CASTS_SHADOW) || (bool)(manifest.Properties[ManifestKeys.CASTS_SHADOW]))
                    {
                        EffectApplication depthOnlyMaterial;
                        if ((mi.HandlingFlags & RenderOptions.RequiresSkeletalPose) > 0)
                        {
                            depthOnlyMaterial = new EffectApplication(EffectRegistry.DepthOnlySkinFx, RenderStatePresets.Default);
                            depthOnlyMaterial.AddParamSetter(new SkinParamSetter());
                        }
                        else
                        {
                            depthOnlyMaterial = new EffectApplication(EffectRegistry.DepthOnlyFx, RenderStatePresets.Default);
                        }

                        depthOnlyMaterial.AddParamSetter(new WorldViewProjParamSetter());

                        geometry.AddMaterial(TraversalContext.MaterialFlags.ShadowMap, depthOnlyMaterial);
                    }
                    else
                    {
                        geometry.AddMaterial(TraversalContext.MaterialFlags.ShadowMap, null);
                    }

                    // If the GeometryNode requires additional materials, they would need to be added here.
                }
            }
        }
        public override void Initialize(ContentManager contentLoader, ComponentManifest manifest)
        {
            mSettings = contentLoader.Load<ParticleSystemSettings>((string)(manifest.Properties[ManifestKeys.PARTICLE_SYSTEM_SETTINGS]));

            string techniqueName = "StandardParticles";
            if (manifest.Properties.ContainsKey(ManifestKeys.TECHNIQUE_NAME))
                techniqueName = (string)(manifest.Properties[ManifestKeys.TECHNIQUE_NAME]);

            LoadParticleEffect(contentLoader, techniqueName);

            // Allocate the particle array, and fill in the corner fields (which never change).
            mParticles = new ParticleVertex[mSettings.MaxParticles * 4];

            for (int i = 0; i < mSettings.MaxParticles; ++i)
            {
                mParticles[i * 4 + 0].Corner = new Short2(-1.0f, -1.0f);
                mParticles[i * 4 + 1].Corner = new Short2(+1.0f, -1.0f);
                mParticles[i * 4 + 2].Corner = new Short2(+1.0f, +1.0f);
                mParticles[i * 4 + 3].Corner = new Short2(-1.0f, +1.0f);
            }

            mParticleData = new ParticleData();
            // Create a dynamic vertex buffer.
            mParticleData.VertexBuffer = new DynamicVertexBuffer(
                SharedResources.Game.GraphicsDevice,
                ParticleVertex.VertexDeclaration,
                mSettings.MaxParticles * 4,
                BufferUsage.WriteOnly);

            // Create and populate the index buffer.
            ushort[] indices = new ushort[mSettings.MaxParticles * 6];

            for (int i = 0; i < mSettings.MaxParticles; i++)
            {
                indices[i * 6 + 0] = (ushort)(i * 4 + 0);
                indices[i * 6 + 1] = (ushort)(i * 4 + 1);
                indices[i * 6 + 2] = (ushort)(i * 4 + 2);

                indices[i * 6 + 3] = (ushort)(i * 4 + 0);
                indices[i * 6 + 4] = (ushort)(i * 4 + 2);
                indices[i * 6 + 5] = (ushort)(i * 4 + 3);
            }

            mParticleData.IndexBuffer = new IndexBuffer(
                SharedResources.Game.GraphicsDevice,
                typeof(ushort),
                indices.Length,
                BufferUsage.None);

            mParticleData.IndexBuffer.SetData(indices);
            mParticleData.MaxParticles = mSettings.MaxParticles;

            GameResources.ActorManager.PreAnimationUpdateStep += PreAnimationUpdateHandler;
            GameResources.ActorManager.UpdateComplete += UpdateCompleteHandler;

            base.Initialize(contentLoader, manifest);
        }
Beispiel #30
0
 public override void Initialize(ContentManager contentLoader, ComponentManifest manifest)
 {
     Owner.ComponentsCreated += ComponentsCreatedHandler;
 }
 public override void Initialize(ContentManager contentLoader, ComponentManifest manifest)
 {
 }
Beispiel #32
0
 public override void Initialize(Microsoft.Xna.Framework.Content.ContentManager contentLoader, Manifracture.ComponentManifest manifest)
 {
     if (manifest.Properties.ContainsKey(ManifestKeys.RADIANCE))
     {
         Radiance = (Vector3)(manifest.Properties[ManifestKeys.RADIANCE]);
     }
 }