public AptSystem(Game game) : base(game) { RegisterComponentList(_guiComponents = new List <AptComponent>()); // TODO: Duplicated from SpriteComponent. var rasterizerState = RasterizerStateDescription.CullBackSolid; rasterizerState.IsFrontCounterClockwise = false; _pipelineStateHandle = new EffectPipelineState( rasterizerState, DepthStencilStateDescription.None, BlendStateDescription.AlphaBlend) .GetHandle(); switch (game.SageGame) { case SageGame.BattleForMiddleEarth: case SageGame.BattleForMiddleEarthII: break; default: // TODO: Handle other games. break; } }
private TerrainPatchComponent CreatePatch( TerrainEffect terrainEffect, EffectPipelineStateHandle pipelineStateHandle, HeightMap heightMap, BlendTileData blendTileData, Int32Rect patchBounds, GraphicsDevice graphicsDevice, ResourceUploadBatch uploadBatch, TerrainPatchIndexBufferCache indexBufferCache) { var indexBuffer = indexBufferCache.GetIndexBuffer( patchBounds.Width, patchBounds.Height, uploadBatch, out var indices); var vertexBuffer = AddDisposable(CreateVertexBuffer( graphicsDevice, uploadBatch, heightMap, patchBounds, indices, out var boundingBox, out var triangles)); return(new TerrainPatchComponent( terrainEffect, pipelineStateHandle, patchBounds, vertexBuffer, indexBuffer, triangles, boundingBox)); }
public RenderItem( RenderableComponent renderable, Effect effect, EffectPipelineStateHandle pipelineStateHandle, RenderCallback renderCallback) : base(effect, pipelineStateHandle, renderCallback) { Renderable = renderable; }
protected RenderItemBase( Effect effect, EffectPipelineStateHandle pipelineStateHandle, RenderCallback renderCallback) { Effect = effect; PipelineStateHandle = pipelineStateHandle; RenderCallback = renderCallback; }
public InstancedRenderItem( RenderInstanceData instanceData, Effect effect, EffectPipelineStateHandle pipelineStateHandle, RenderCallback renderCallback) : base(effect, pipelineStateHandle, renderCallback) { InstanceData = instanceData; }
private void CreatePatches( GraphicsDevice graphicsDevice, ResourceUploadBatch uploadBatch, Entity terrainEntity, HeightMap heightMap, BlendTileData blendTileData, TerrainEffect terrainEffect, EffectPipelineStateHandle pipelineStateHandle, TerrainPatchIndexBufferCache indexBufferCache) { const int numTilesPerPatch = TerrainComponent.PatchSize - 1; var numPatchesX = heightMap.Width / numTilesPerPatch; if (heightMap.Width % numTilesPerPatch != 0) { numPatchesX += 1; } var numPatchesY = heightMap.Height / numTilesPerPatch; if (heightMap.Height % numTilesPerPatch != 0) { numPatchesY += 1; } for (var y = 0; y < numPatchesY; y++) { for (var x = 0; x < numPatchesX; x++) { var patchX = x * numTilesPerPatch; var patchY = y * numTilesPerPatch; var patchBounds = new Int32Rect { X = patchX, Y = patchY, Width = Math.Min(TerrainComponent.PatchSize, heightMap.Width - patchX), Height = Math.Min(TerrainComponent.PatchSize, heightMap.Height - patchY) }; terrainEntity.Components.Add(CreatePatch( terrainEffect, pipelineStateHandle, heightMap, blendTileData, patchBounds, graphicsDevice, uploadBatch, indexBufferCache)); } } }
private void Draw( CommandEncoder commandEncoder, MeshEffect meshEffect, EffectPipelineStateHandle pipelineStateHandle, IEnumerable <ModelMeshMaterialPass> materialPasses, RenderInstanceData instanceData) { commandEncoder.SetVertexBuffer(2, instanceData.WorldBuffer); if (Skinned) { meshEffect.SetSkinningBuffer(instanceData.SkinningBuffer); meshEffect.SetNumBones(NumBones); } meshEffect.SetSkinningEnabled(Skinned); meshEffect.SetMaterials(_materialsBuffer); meshEffect.SetTextures(_textures); commandEncoder.SetVertexBuffer(0, _vertexBuffer); foreach (var materialPass in materialPasses) { meshEffect.SetTextureIndices(materialPass.TextureIndicesBuffer); meshEffect.SetMaterialIndices(materialPass.MaterialIndicesBuffer); meshEffect.SetNumTextureStages(materialPass.NumTextureStages); commandEncoder.SetVertexBuffer(1, materialPass.TexCoordVertexBuffer); foreach (var meshPart in materialPass.MeshParts) { if (meshPart.PipelineStateHandle != pipelineStateHandle) { continue; } meshEffect.SetPrimitiveOffset(meshPart.StartIndex / 3); meshEffect.SetAlphaTest(meshPart.AlphaTest); meshEffect.SetTexturing(meshPart.Texturing); meshEffect.Apply(commandEncoder); commandEncoder.DrawIndexedInstanced( PrimitiveType.TriangleList, meshPart.IndexCount, instanceData.NumInstances, _indexBuffer, meshPart.StartIndex); } } }
internal ModelMeshPart( uint startIndex, uint indexCount, bool alphaTest, bool texturing, EffectPipelineStateHandle pipelineStateHandle) { StartIndex = startIndex; IndexCount = indexCount; AlphaTest = alphaTest; Texturing = texturing; PipelineStateHandle = pipelineStateHandle; }
protected override void Start() { base.Start(); _effect = ContentManager.GetEffect <SpriteEffect>(); var rasterizerState = RasterizerStateDescription.CullBackSolid; rasterizerState.IsFrontCounterClockwise = false; _pipelineStateHandle = new EffectPipelineState( rasterizerState, DepthStencilStateDescription.None, BlendStateDescription.Opaque) .GetHandle(); }
internal TerrainPatchComponent( TerrainEffect terrainEffect, EffectPipelineStateHandle pipelineStateHandle, Int32Rect patchBounds, StaticBuffer <TerrainVertex> vertexBuffer, StaticBuffer <ushort> indexBuffer, Triangle[] triangles, BoundingBox boundingBox) { _terrainEffect = terrainEffect; _pipelineStateHandle = pipelineStateHandle; Bounds = patchBounds; _vertexBuffer = vertexBuffer; _indexBuffer = indexBuffer; LocalBoundingBox = boundingBox; BoundingBox = boundingBox; Triangles = triangles; }
protected override void Start() { base.Start(); _particleEffect = ContentManager.GetEffect <ParticleEffect>(); _velocityType = VelocityTypeUtility.GetImplementation(Definition.VelocityType); _volumeType = VolumeTypeUtility.GetImplementation(Definition.VolumeType); var texturePath = Path.Combine("Art", "Textures", Definition.ParticleName); _texture = ContentManager.Load <Texture>(texturePath, uploadBatch: null); var blendState = GetBlendState(Definition.Shader); _pipelineStateHandle = new EffectPipelineState( RasterizerStateDescription.CullBackSolid, DepthStencilStateDescription.DepthRead, blendState) .GetHandle(); _initialDelay = Definition.InitialDelay.GetRandomInt(); _startSizeRate = Definition.StartSizeRate.GetRandomFloat(); _startSize = 0; _colorKeyframes = new List <ParticleColorKeyframe>(); if (Definition.Color1 != null) { _colorKeyframes.Add(new ParticleColorKeyframe(Definition.Color1)); } void addColorKeyframe(RgbColorKeyframe keyframe, RgbColorKeyframe previous) { if (keyframe != null && keyframe.Time > previous.Time) { _colorKeyframes.Add(new ParticleColorKeyframe(keyframe)); } } addColorKeyframe(Definition.Color2, Definition.Color1); addColorKeyframe(Definition.Color3, Definition.Color2); addColorKeyframe(Definition.Color4, Definition.Color3); addColorKeyframe(Definition.Color5, Definition.Color4); addColorKeyframe(Definition.Color6, Definition.Color5); addColorKeyframe(Definition.Color7, Definition.Color6); addColorKeyframe(Definition.Color8, Definition.Color7); var maxParticles = CalculateMaxParticles(); _particles = new Particle[maxParticles]; for (var i = 0; i < _particles.Length; i++) { _particles[i].Dead = true; } _deadList = new List <int>(); _deadList.AddRange(Enumerable.Range(0, maxParticles)); _vertexBuffer = DynamicBuffer <ParticleVertex> .CreateArray( GraphicsDevice, maxParticles * 4, BufferUsageFlags.None); _vertices = new ParticleVertex[_vertexBuffer.ElementCount]; _indexBuffer = CreateIndexBuffer(GraphicsDevice, maxParticles); State = ParticleSystemState.Active; }
public RenderListPipelineStateGroup(EffectPipelineStateHandle pipelineStateHandle) { PipelineStateHandle = pipelineStateHandle; }