public void Draw(SharpDX.Direct3D11.DeviceContext context, int index) { if (_particules.Count == 0) { return; } //Accumulate particules here for this emitters, and render them ColoredParticule p; _particuleRenderer.Begin(context, true); for (int i = 0; i < _particules.Count; i++) { p = _particules[i]; Vector3 position = p.Position.ValueInterp.AsVector3(); ByteColor color = p.ParticuleColor; //Add a new Particule Matrix result; Matrix scaling = Matrix.Scaling(p.Size.X, p.Size.Y, p.Size.Y); Matrix rotation = Matrix.RotationQuaternion(p.RotationAngles.ValueInterp); //Identity rotation Matrix translation = Matrix.Translation(position); result = scaling * rotation * translation; _particuleRenderer.Processor.Draw(ref color, ref p.ColorReceived, ref result); } _particuleRenderer.End(context); }
/// <summary> /// Will draw : Name & Health Bar /// </summary> /// <param name="context"></param> private void DrawEntitiesOverHeadData(DeviceContext context) { _dynamicEntityNameRenderer.Begin(context, true); _dynamicEntityEnergyBarRenderer.Begin(context, true); foreach (VisualDynamicEntity dynamicEntity in _dynamicEntitiesDico.Values.Where(x => x.ModelInstance != null && x.ModelInstance.World != Matrix.Zero)) { bool isMultiline = false; string Name; Vector3 textPosition = dynamicEntity.WorldPosition.ValueInterp.AsVector3(); textPosition.Y += (dynamicEntity.ModelInstance.State.BoundingBox.Maximum.Y / 16); //Place the text above the BoundingBox ByteColor color = Color.White; if (dynamicEntity.DynamicEntity is CharacterEntity) { Name = ((CharacterEntity)dynamicEntity.DynamicEntity).CharacterName; //Is it the local player ? if (IsLocalPlayer(dynamicEntity.DynamicEntity.DynamicId)) { color = Color.Yellow; } else { Name += Environment.NewLine + "<" + dynamicEntity.DynamicEntity.Name + ">"; isMultiline = true; } } else { Name = dynamicEntity.DynamicEntity.Name; color = Color.WhiteSmoke; } var distance = MVector3.Distance(dynamicEntity.WorldPosition.ValueInterp, _camManager.ActiveCamera.WorldPosition.ValueInterp); float scaling = Math.Min(0.040f, Math.Max(0.01f, 0.01f / 12 * (float)distance)); _dynamicEntityNameRenderer.Processor.DrawText(Name, ref textPosition, scaling, ref color, _camManager.ActiveCamera, MultiLineHandling: isMultiline); //HBar rendering if (!IsLocalPlayer(dynamicEntity.DynamicEntity.DynamicId) && dynamicEntity.DynamicEntity.Health.CurrentAsPercent < 1 && dynamicEntity.DynamicEntity.Health.CurrentAsPercent > 0) { var size = new Vector2((dynamicEntity.ModelInstance.State.BoundingBox.Maximum.X / 8) * dynamicEntity.DynamicEntity.Health.CurrentAsPercent, 0.1f); Vector3 hbPosition = textPosition; hbPosition.Y += 0.05f; _dynamicEntityEnergyBarRenderer.Processor.Draw(ref hbPosition, ref size, ref hbColor, ref colorReceived); } } _dynamicEntityNameRenderer.End(context); _dynamicEntityEnergyBarRenderer.End(context); }
public void Draw(DeviceContext context, int index) { if (_particules.Count == 0) { return; } //Accumulate particules here for this emitters, and render them SpriteParticule p; _particuleRenderer.Begin(context, true); for (int i = 0; i < _particules.Count; i++) { p = _particules[i]; Vector3 position = p.Position.Value.AsVector3(); _particuleRenderer.Processor.Draw(ref position, ref p.Size, ref p.ColorModifier, p.ParticuleId); } _particuleRenderer.End(context); }