void OnInitialize(InitializeMessage msg) { m_Device = msg.Device; RasterizerState rasterizerState = new RasterizerState(); rasterizerState.CullMode = CullMode.None; m_Device.RasterizerState = rasterizerState; m_Device.BlendState = BlendState.AlphaBlend; m_SceneTarget = new RenderTarget2D(m_Device, m_Device.Viewport.Width, m_Device.Viewport.Height, false, SurfaceFormat.Color, DepthFormat.Depth24); m_LightMap = new RenderTarget2D(m_Device, m_Device.Viewport.Width, m_Device.Viewport.Height, false, SurfaceFormat.Color, DepthFormat.None); m_DataTarget = new RenderTarget2D(m_Device, m_Device.Viewport.Width, m_Device.Viewport.Height, false, SurfaceFormat.Color, DepthFormat.None); m_DepthTarget = new RenderTarget2D(m_Device, m_Device.Viewport.Width, m_Device.Viewport.Height, false, SurfaceFormat.Single, DepthFormat.None); foreach (int i in Enumerable.Range(0, INTERMEDIATE_TARGET_COUNT)) { m_IntermediateTargets[i] = new RenderTarget2D(m_Device, m_Device.Viewport.Width, m_Device.Viewport.Height, false, m_Device.PresentationParameters.BackBufferFormat, m_Device.PresentationParameters.DepthStencilFormat); } }
void OnInitialize(InitializeMessage msg) { m_Batch = new SpriteBatch(msg.Device); m_Font = (ContentResource<SpriteFont>)Owner.GetComponent<ResourceLoader>().GetResource("Fonts/debug"); }
void OnInitialize(InitializeMessage msg) { m_Device = msg.Device; }
void OnInititialize(InitializeMessage msg) { int width = (int)(0.5 * msg.Device.Viewport.Width); int height = (int)(0.5 * msg.Device.Viewport.Height); m_ParticleTarget = new RenderTarget2D(msg.Device, width, height, false, SurfaceFormat.Color, DepthFormat.None); m_DataTarget = new RenderTarget2D(msg.Device, width, height, false, SurfaceFormat.Color, DepthFormat.None); var billboard = (CustomResource<VertexBufferResource<VertexPositionTexture>>) Owner.Engine.GetComponent<ResourceLoader>().GetResource("particle_billboard"); m_ParticleBuffer = billboard; m_InstanceBuffer = new DynamicVertexBuffer(msg.Device, typeof(VertexPositionTexture), 100, BufferUsage.WriteOnly); m_IndexBuffer = new IndexBuffer(msg.Device, IndexElementSize.SixteenBits, 6, BufferUsage.None); m_IndexBuffer.SetData(new short[] { 0, 1, 2, 3, 4, 5 }); }
void OnInitialize(InitializeMessage msg) { CreateResources(msg.Device); Entity level = Owner.CreateEntity(); ContentResource<Model> levelmodel = (ContentResource<Model>)Loader.GetResource(levelmodelname); var meshdata = levelmodel.Get<Model>().ExtractData(); Octree leveltree = new Octree(meshdata.Vertices.Select(item => item.ToJitter()).ToList(), meshdata.Indices); level.AddComponent(new RigidBodyComponent( new Jitter.Dynamics.RigidBody( new Jitter.Collision.Shapes.TriangleMeshShape(leveltree)) { IsStatic = true })); Entity levelVisuals = level.CreateChild(); levelVisuals.AddComponent(new Handle<Model>(levelmodelname)); Entity placeholder = Owner.CreateEntity(); placeholder.Transform.Local = Matrix.CreateTranslation(10 * Vector3.UnitY); CreatePlaceholder(placeholder); Entity box = Owner.CreateEntity(); box.Transform.Translate(new Vector3(5, 5, 5)); CreateBox(box); box = Owner.CreateEntity(); box.Transform.Translate(new Vector3(-5, 5, 5)); CreateBox(box); box = Owner.CreateEntity(); box.Transform.Translate(new Vector3(-5, 5, -5)); CreateBox(box); Entity sphere = Owner.CreateEntity(); sphere.Transform.Translate(new Vector3(0, 5, 0)); CreateSphere(sphere); sphere = Owner.CreateEntity(); sphere.Transform.Translate(new Vector3(0, 5, 10)); CreateSphere(sphere); sphere = Owner.CreateEntity(); sphere.Transform.Translate(new Vector3(10, 5, 0)); CreateSphere(sphere); //Entity placeholdertwo = Owner.CreateEntity(); //placeholdertwo.Transform = Matrix.CreateTranslation(5 * Vector3.UnitY + 2 * Vector3.UnitZ); //CreatePlaceholder(placeholdertwo); Entity player = Owner.CreateEntity(); player.Transform.Local = Matrix.CreateRotationY(MathHelper.ToRadians(-120)) * Matrix.CreateTranslation(new Vector3(-20, 10, -14)); CreatePredator(player); Entity camroot = player.CreateChild(); camroot.Transform.Local = Matrix.CreateTranslation(new Vector3(0, 3f, 0)); Entity camera = camroot.CreateChild(); camera.AddComponent(new SpeedTilt(10, 150)); camera.AddComponent(new Camera()); camera.AddComponent(new ParticleEffect()); camera.AddComponent(Loader.GetResource("screen_billboard").ToHandle()); camera.AddComponent(new RenderSettings() { Hidden = true }); //so that the screen_billboard mesh isn't rendered }