public ShadowRenderView(Light parent, Viewport viewport, int splitIndex, Matrix view, Matrix projection, Vector3 position, float nearPlane, float farPlane) : base(RenderViewType.SHADOWS, view, projection, position, nearPlane, farPlane) { this.parent = parent; this.viewPort = viewport; this.splitIndex = splitIndex; this.ElementManagers.Add(RenderPass.Shadows, new ShadowElementManager(this)); }
public ShadowRenderView(Light parent, Viewport viewport, int splitIndex, Matrix view, Matrix projection, Vector3 position, float nearPlane, float farPlane) : base(RenderViewType.SHADOWS, view, projection, position, nearPlane, farPlane) { this.parent = parent; this.viewPort = viewport; this.splitIndex = splitIndex; this.Name = "ShadowRenderView" + this.GetHashCode(); this.ElementManagers.Add(RenderPass.Shadows, new ShadowElementManager(this)); ShadowElementManager foliageManager = new ShadowElementManager(this); foliageManager.SetShaders(ResourceManager.Inst.GetShader("ShadowVSMTransparent"), ResourceManager.Inst.GetShader("ShadowVSMTransparentInst")); this.ElementManagers.Add(RenderPass.Foliage, foliageManager); }
void InitializeScene() { ResetScene(); Entities.Add("Sky", new Sky()); MainLight = new Sunlight(); MainTerrain = new TerrainVoxel(); /* MainTerrain = new TerrainHeightmap("Textures/Island_HM.png", 0, 100.0f); float width = (MainTerrain as TerrainHeightmap).GetWidth(); float height = (MainTerrain as TerrainHeightmap).MaximumHeight; MainTerrain.Transformation.SetScale(new Vector3(1, height / width, 1) * width); */ Entities.Add("MainCamera", new Camera()); Entities.Add("Terrain", MainTerrain); Entities.Add("Light", MainLight); Entities.Add("AmbientLight", new Light(LightType.Ambient, new Vector3(0.15f, 0.35f, 0.55f), Vector3.Zero, false)); CreateLandmarks(); AddEntity("Grass", new ClusterManager(new string[]{"Bush", "Fern", "Phila01", "ElephantEar", "BirdsNest", "PalmPlant", "TropicalPlant"}, 20, true));//120, true)); /* ForestManager grassMgr = new ForestManager(new string[] { "Bush", "Fern", "Phila01", "ElephantEar", "BirdsNest", "PalmPlant", "TropicalPlant" }, 8192); grassMgr.alignToSurface = true; AddEntity("Grass", grassMgr); */ AddEntity("Forest", new ForestManager(new string[] { "Cecropia", "Palm02", "QueensPalm01", "Tree01", "Tree02", "Palm01", "BeachPalm"}, 3000)); /* Raptor raptor = new Raptor(ResourceManager.Inst.GetDinosaurDatablock("Allosaurus")); raptor.SetSpawnPosition(FindEntity("Tent").Transformation.GetPosition()); AddEntity("Raptor", raptor); */ CreateTeams(); //Entities.Add("Light2", new Light(LightType.Directional, new Vector3(0.2797f, 0.344f, 0.43f), Vector3.Up, false)); Initialize(); GC.Collect(GC.MaxGeneration, GCCollectionMode.Forced); }
void InitializeScene() { ResetScene(); Entities.Add("Sky", new Sky()); MainLight = new Sunlight(); MainTerrain = new TerrainVoxel(); /* MainTerrain = new TerrainHeightmap("Textures/level1_hm.png", 0, 100.0f); float width = (MainTerrain as TerrainHeightmap).GetWidth(); float height = (MainTerrain as TerrainHeightmap).MaximumHeight; MainTerrain.Transformation.SetScale(new Vector3(1, height / width, 1) * width); */ MainPlayer = new Camera(); Entities.Add("MainCamera", MainPlayer); Entities.Add("Terrain", MainTerrain); Entities.Add("Light", MainLight); Entities.Add("Plane", new Model("Plane")); Entities.Add("AmbientLight", new Light(LightType.Ambient, new Vector3(0.15f, 0.35f, 0.55f), Vector3.Zero, false)); Entities.Add("TestTree", new Model("Palm02")); Entities["TestTree"].Transformation.SetPosition(Vector3.Forward * 10.0f); Entities.Add("TestTree2", new Model("JungleOverhang")); Entities["TestTree2"].Transformation.SetPosition(Vector3.Forward * 10.0f + Vector3.Right * 7.6f); //AddEntity("Grass", new GrassPlacement()); AddEntity("Forest", new ForestManager()); //CreateForest(); //Entities.Add("Grass", new ShapePlacement()); /* Model testGeom = new Model("test_level"); testGeom.Transformation.SetPosition(Vector3.Up*20.0f); Entities.Add("scene_geom1", testGeom); Model testGeom2 = new Model("cgWarehouse002story"); testGeom2.Transformation.SetPosition(Vector3.Up * 21.0f); Entities.Add("scene_geom2", testGeom2); */ AnimatedModel model = new AnimatedModel("Allosaurus"); model.Transformation.SetPosition(Vector3.Forward*10+Vector3.Up*68); model.Model.GetAnimationLayer().SetActiveAnimation("AllosaurusIdle", true);//.SetAnimationLayer("AllosaurusIdle", 1.0f); model.Model.SetCustomMatrix(Matrix.CreateScale(0.09f)*Matrix.CreateRotationX(-MathHelper.PiOver2)); //model.UpdateAnimation(); Entities.Add("TestCharacter", model); AnimatedModel model2 = new AnimatedModel("AlphaRaptor"); model2.Transformation.SetPosition(Vector3.Forward * -5 + Vector3.Up * 62); model2.Model.GetAnimationLayer().SetActiveAnimation("AlphaRaptorIdle", true);//.SetAnimationLayer("AlphaRaptorIdle", 1.0f); model2.Model.SetCustomMatrix(Matrix.CreateScale(0.12f) * Matrix.CreateRotationX(-MathHelper.PiOver2)); //model.UpdateAnimation(); Entities.Add("TestCharacter2", model2); Raptor raptor = new Raptor(ResourceManager.Inst.GetDinosaurDatablock("Coelophysis")); Entities.Add("Raptor", raptor); Chest weaponCrate = new Chest("Weapon Box", "WeaponBox"); weaponCrate.Transformation.SetPosition(Vector3.Up * 30.0f); Entities.Add("weaponCrate", weaponCrate); CreateTeams(); //Entities.Add("Light2", new Light(LightType.Directional, new Vector3(0.2797f, 0.344f, 0.43f), Vector3.Up, false)); Initialize(); }
void generateGem(Vector3 position) { position.Y = position.Y + 2.0f; float radiusMax = (DensityFieldSize / 2); float radiusMin = (DensityFieldSize / 16); Vector3 cylinderCenter = Vector3.One * DensityFieldSize * 0.5f; minPos = maxPos = cylinderCenter; DensityField = new byte[DensityFieldSize * DensityFieldSize * DensityFieldSize]; for (int x = 0; x < DensityFieldSize; x++) { for (int y = 1; y < (DensityFieldSize - 1); y++) { for (int z = 0; z < DensityFieldSize; z++) { Vector3 pos = new Vector3(x, y, z); float offset = Math.Abs(pos.Y - cylinderCenter.Y); pos.Y = cylinderCenter.Y; float radius = MathHelper.Lerp(radiusMax, radiusMin, offset/cylinderCenter.Y); float density = Math.Max(1.0f - (pos - cylinderCenter).Length() / (radius), 0.0f); if (density > 0.0f) { pos = (pos / DensityFieldSize) * 2.0f - Vector3.One; minPos = Vector3.Min(pos, minPos); maxPos = Vector3.Max(pos, maxPos); } DensityField[x + (y + z * DensityFieldSize) * DensityFieldSize] = (byte)(density * 255.0f); } } } gemGeometry = new VoxelGeometry(); gemGeometry.renderElement.Transform = new Matrix[1] { Matrix.CreateScale(5.0f) * Matrix.CreateTranslation(position) }; gemGeometry.GenerateGeometry(ref DensityField, IsoValue, DensityFieldSize, DensityFieldSize, DensityFieldSize, DensityFieldSize - 1, DensityFieldSize - 1, DensityFieldSize - 1, 0, 0, 0, 2.0f / (float)(DensityFieldSize - 1)); boundingBox = new BoundingBox(); boundingBox.Max = Vector3.Transform(maxPos, gemGeometry.renderElement.Transform[0]); boundingBox.Min = Vector3.Transform(minPos, gemGeometry.renderElement.Transform[0]); collected = false; Vector3 lightPosition = position; lightPosition.X = position.X + 12.0f; emitterLight = new Light(LightType.Point, new Vector3(0.83f, 0.06f, 0.36f), lightPosition, false); emitterLight.Parameters = new Vector4(70, 45, 0, 0); }
public override void Initialize(LevelEditor editor, string name) { base.Initialize(editor, name); light = (Light)target; }
void SetupLightParameters(Light light) { GFX.Device.SetPixelShaderConstant(GFXShaderConstants.PC_LIGHTPOS, light.Transformation.GetPosition()); GFX.Device.SetPixelShaderConstant(GFXShaderConstants.PC_LIGHTCOLOR, light.Color); GFX.Device.SetPixelShaderConstant(GFXShaderConstants.PC_LIGHTPARAMS, light.Parameters); }
public override void OnAdd(Scene scene) { emitter = new ParticleEmitter(Resources.ResourceManager.Inst.GetParticleEffect("PlayerParticles"), 60); emitter.SetColor(GetTeamColor()); emitterLight = new Light(LightType.Point, GetTeamColor(), this.Transformation.GetPosition(), false); emitterLight.Parameters = new Vector4(55, 50, 0, 0); scene.Entities.Add(emitter); scene.Entities.Add(emitterLight); scene.Actors.Add(this); base.OnAdd(scene); }
void InitializeScene() { Vector3[] directions = new Vector3[] { Vector3.Left, Vector3.Right, Vector3.Forward, Vector3.Backward, Vector3.Up }; foreach (Vector3 dir in directions) { Entities.Add(new Opponent(dir * 0.5f)); } Entities.Add(new Sky()); MainLight = new Sunlight(); MainTerrain = new Terrain(); MainPlayer = new Player(Vector3.Up * 0.25f); Entities.Add(MainPlayer); Entities.Add(MainTerrain); Entities.Add(MainLight); for (int i = 0; i < 50; i++) { Tree tree = new Tree(); tree.setNum(i % 8); Entities.Add(tree); } Random randomHelper = new Random(); for (int i = 0; i < NUM_GEMS; i++) { Entities.Add(new Gem(randomHelper)); Entities.Add(new Health(randomHelper)); } Entities.Add(new Light(LightType.Directional, new Vector3(0.1797f, 0.744f, 1.12f), Vector3.Right, false)); }