public Matrix GetLightVolumeWorldMatrix(Cell c, GameObjectReference objRef) { Matrix scale, rotate, translate; float fRadius = (float)Math.Tan(objRef.OuterAngle * 0.5f) * objRef.MaxRange; scale = Matrix.Scaling(fRadius * 2.0f, objRef.MaxRange * 2.0f, fRadius * 2.0f); rotate = RotateToFace(WorldSpace.GetRealWorldPos(objRef.Position, c), WorldSpace.GetRealWorldPos(objRef.Target, c), Vector3.UnitY); translate = WorldSpace.GetRealWorldMatrix(objRef.Position, c); return(scale * rotate * translate); }
public Matrix GetLightVolumeMatrix(Cell c, Vector3 pos, Vector3 endPoint, float maxRange) { Vector3 l = WorldSpace.GetRealWorldPos(pos, c) - WorldSpace.GetRealWorldPos(endPoint, c); Vector3 p1 = WorldSpace.GetRealWorldPos(pos, c), p2 = WorldSpace.GetRealWorldPos(endPoint, c); Vector3 midpoint = new Vector3((p1.X + p2.X) / 2, (p1.Y + p2.Y) / 2, (p1.Z + p2.Z) / 2); float f = 3.0f; l.X = Math.Abs(l.X); l.Y = Math.Abs(l.Y); l.Z = Math.Abs(l.Z); l.X += maxRange * f; l.Y += maxRange * f; l.Z += maxRange * f; return(Matrix.Scaling(l) * Matrix.Translation(midpoint)); }
public override void RenderDebugLightVolume(GameObjectReference objRef, Cell c, Vector4 GridColor) { //if (targetMesh == null) // targetMesh = new GameObjectRef(@"system/box.mesh", "box.mesh", MeshInputElements10.PositionOnly4); Model targetMesh = WorldData.GetObject("light_target") as Model; Matrix scale, rotate, translate, matWVP; float fRadius = (float)Math.Tan(objRef.OuterAngle * 0.5f) * objRef.MaxRange; scale = Matrix.Scaling(fRadius, objRef.MaxRange, fRadius); rotate = RotateToFace(WorldSpace.GetRealWorldPos(objRef.Position, c), WorldSpace.GetRealWorldPos(objRef.Target, c), Vector3.UnitY); translate = WorldSpace.GetRealWorldMatrix(objRef.Position, c); matWVP = scale * rotate * translate; RenderingFunctions.DrawLightVolume(DeferredRenderer.lightVolume[(int)LightType.Spot], matWVP, GridColor); RenderingFunctions.DrawLightVolume(targetMesh, Matrix.Scaling(1, 1, 1) * WorldSpace.GetRealWorldMatrix(objRef.Target, c), GridColor); }
public Matrix GetLightVolumeMatrix(Cell c, GameObjectReference objRef) { return(Matrix.Scaling(objRef.BoxDepth, objRef.BoxHeight, objRef.BoxWidth) * Matrix.Translation(WorldSpace.GetRealWorldPos(objRef.Position, c))); }
public override void RenderDebugLightVolume(GameObjectReference objRef, Cell c, Vector4 GridColor) { Vector3 max = DeferredRenderer.lightVolume[(int)LightType.Box].Mesh3d.bb.Maximum; Vector3 min = DeferredRenderer.lightVolume[(int)LightType.Box].Mesh3d.bb.Minimum; Matrix m = GetLightVolumeMatrix(c, objRef); Vector3 pos = objRef.Position; pos.Y += objRef.BoxHeight; RenderingFunctions.DrawLightVolume(DeferredRenderer.lightVolume[(int)LightType.Box], Matrix.Translation(WorldSpace.GetRealWorldPos(pos, c)), GridColor); RenderingFunctions.DrawLightVolume(DeferredRenderer.lightVolume[(int)LightType.Box], m, GridColor); RenderingFunctions.DrawLightVolume(DeferredRenderer.lightVolume[(int)LightType.Box], Matrix.Scaling(2, 2, 2) * Matrix.Translation(WorldSpace.GetRealWorldPos(objRef.Target, c)), GridColor); }