/// <summary> /// Initializes a new instance of the GhostObject class. /// DEfault Object in 0,0,0 identity rotation and 1,1,1 scale /// </summary> /// <param name="bb">The bb.</param> public PhysxGhostObject(BoundingBox?bb = null) { this.pos = Vector3.Zero; this.ori = Matrix.Identity; this.scale = Vector3.One; this.bb = bb; }
/// <summary> /// Initializes a new instance of the <see cref="PhysxGhostObject"/> class. /// </summary> /// <param name="position">The position.</param> /// <param name="orientation">The orientation.</param> /// <param name="scale">The scale.</param> /// <param name="bb">The bb.</param> public PhysxGhostObject(Vector3 position, Matrix orientation, Vector3 scale, BoundingBox?bb = null) { this.pos = position; this.ori = orientation; this.scale = scale; this.bb = bb; }
internal void UpdateRenderEntitiesData(ref MatrixD worldMatrixD, bool useTransparency, float transparency) { int model = this.Model; bool flag = this.RenderObjectId != uint.MaxValue; if (this.InstanceCount <= 0) { if (flag) { this.UnloadRenderObjects(); } } else { RenderFlags flags = RenderFlags.Visible | RenderFlags.CastShadows; if (!flag) { string byId = MyModel.GetById(model); this.RenderObjectId = MyRenderProxy.CreateRenderEntity("Instance parts, part: " + model, byId, this.Parent.SectorMatrix, MyMeshDrawTechnique.MESH, flags, CullingOptions.Default, Vector3.One, Vector3.Zero, useTransparency ? transparency : 0f, this.MaxViewDistance, 0, 1f, true); } MyRenderProxy.SetInstanceBuffer(this.RenderObjectId, this.InstanceBuffer, 0, this.InstanceData.Count, this.Parent.SectorBox, null); MyRenderProxy.UpdateRenderEntity(this.RenderObjectId, new Color?(Vector3.One), new Vector3?(Vector3.Zero), new float?(useTransparency ? transparency : 0f), true); MatrixD sectorMatrix = this.Parent.SectorMatrix; BoundingBox?aabb = null; Matrix? localMatrix = null; MyRenderProxy.UpdateRenderObject(this.RenderObjectId, new MatrixD?(sectorMatrix), aabb, -1, localMatrix); } }
public BoundingBox GetCellFaceBoundingBox(Point3 point) { int cellValue = m_subsystemTerrain.Terrain.GetCellValue(point.X, point.Y, point.Z); BoundingBox[] customCollisionBoxes = BlocksManager.Blocks[Terrain.ExtractContents(cellValue)].GetCustomCollisionBoxes(m_subsystemTerrain, cellValue); Vector3 vector = new Vector3(point.X, point.Y, point.Z); if (customCollisionBoxes.Length != 0) { BoundingBox?boundingBox = null; for (int i = 0; i < customCollisionBoxes.Length; i++) { if (customCollisionBoxes[i] != default(BoundingBox)) { boundingBox = (boundingBox.HasValue ? BoundingBox.Union(boundingBox.Value, customCollisionBoxes[i]) : customCollisionBoxes[i]); } } if (!boundingBox.HasValue) { boundingBox = new BoundingBox(Vector3.Zero, Vector3.One); } return(new BoundingBox(boundingBox.Value.Min + vector, boundingBox.Value.Max + vector)); } return(new BoundingBox(vector, vector + Vector3.One)); }
public DGRP3DMesh(DGRP dgrp, Stream source, GraphicsDevice gd) { using (var cstream = new GZipStream(source, CompressionMode.Decompress)) { using (var io = IoBuffer.FromStream(cstream, ByteOrder.LITTLE_ENDIAN)) { var fsom = io.ReadCString(4); Version = io.ReadInt32(); ReconstructVersion = io.ReadInt32(); Name = io.ReadPascalString(); var geomCount = io.ReadInt32(); Geoms = new List <Dictionary <Texture2D, DGRP3DGeometry> >(); for (int i = 0; i < geomCount; i++) { var d = new Dictionary <Texture2D, DGRP3DGeometry>(); var subCount = io.ReadInt32(); for (int j = 0; j < subCount; j++) { var geom = new DGRP3DGeometry(io, dgrp, gd); d.Add(geom.Pixel, geom); } Geoms.Add(d); } var x = io.ReadFloat(); var y = io.ReadFloat(); var z = io.ReadFloat(); var x2 = io.ReadFloat(); var y2 = io.ReadFloat(); var z2 = io.ReadFloat(); Bounds = new BoundingBox(new Vector3(x, y, z), new Vector3(x2, y2, z2)); } } }
/// <summary> /// Initializes a new instance of the <see cref="GhostObject"/> class. /// </summary> /// <param name="position">The position.</param> /// <param name="orientation">The orientation.</param> /// <param name="scale">The scale.</param> public GhostObject(Vector3 position, Matrix orientation, Vector3 scale, BoundingBox?bb = null) : base(MaterialDescription.DefaultBepuMaterial(), 0) { this.pos = position; this.ori = orientation; this.scale = scale; this.bb = bb; }
private BSP(Node root, BoundingBox?bounds, object[] description, bool createDescription = true) { _root = root; Bounds = bounds; _description = description; _createDescription = createDescription; }
/// <summary> /// Create a DGRPMesh from a .OBJ file. /// </summary> public DGRP3DMesh(DGRP dgrp, OBJ source, GraphicsDevice gd) { Bounds = source.Vertices.Count > 0?BoundingBox.CreateFromPoints(source.Vertices):new BoundingBox(); Geoms = new List <Dictionary <Texture2D, DGRP3DGeometry> >(); if (dgrp == null) { return; } Name = dgrp.ChunkParent.Filename.Replace('.', '_').Replace("spf", "iff") + "_" + dgrp.ChunkID; foreach (var obj in source.FacesByObjgroup.OrderBy(x => x.Key)) { if (obj.Key == "_default") { continue; } var split = obj.Key.Split('_'); //0: dynsprite id, 1: SPR or custom, 2: rotation, 3: index var id = int.Parse(split[0]); while (Geoms.Count <= id) { Geoms.Add(new Dictionary <Texture2D, DGRP3DGeometry>()); } var dict = Geoms[id]; var geom = new DGRP3DGeometry(split, source, obj.Value, dgrp, gd); dict[geom.Pixel] = geom; } }
/// <summary> /// Invalidates the internal cache /// </summary> public void InvalidateCache() { this.updatePoints = true; this.updateTriangles = true; this.boundingSphere = null; this.boundingBox = null; }
/// <summary> /// Initializes a new instance of the <see cref="GhostObject"/> class. /// DEfault Object in 0,0,0 identity rotation and 1,1,1 scale /// </summary> public GhostObject(BoundingBox?bb = null) : base(MaterialDescription.DefaultBepuMaterial(), 0) { this.pos = Vector3.Zero; this.ori = Matrix.Identity; this.scale = Vector3.One; this.bb = bb; }
public void Update(MatrixD gridWorldMatrix, float transparency) { MatrixD xd = this.LocalMatrix * gridWorldMatrix; BoundingBox?aabb = null; Matrix? localMatrix = null; MyRenderProxy.UpdateRenderObject(this.RenderEntityId, new MatrixD?(xd), aabb, -1, localMatrix); MyRenderProxy.UpdateRenderEntity(this.RenderEntityId, new Color?(Vector3.One), new Vector3?(this.ColorMashHsv), new float?(transparency), false); }
internal IndexedMesh(IBuffer vb, IBuffer ib, int countIndices, GpuValueType indexType, BoundingBox?bbox = null) { vertexBuffer = vb; indexBuffer = ib; drawCall = new DrawIndexedAttribs(true); drawCall.NumIndices = countIndices; drawCall.IndexType = indexType; drawCall.Flags = DrawFlags.VerifyAll; boundingBox = bbox; }
public override void InvalidateRenderObjects() { if (this.m_cullRenderId != uint.MaxValue) { MatrixD worldMatrix = base.Container.Entity.PositionComp.WorldMatrix; BoundingBox?aabb = null; Matrix? localMatrix = null; MyRenderProxy.UpdateRenderObject(this.m_cullRenderId, new MatrixD?(worldMatrix), aabb, base.LastMomentUpdateIndex, localMatrix); } }
/// <summary> /// Create a DGRPMesh from a .OBJ file. /// </summary> public DGRP3DMesh(DGRP dgrp, OBJ source, GraphicsDevice gd) { Bounds = source.Vertices.Count > 0?BoundingBox.CreateFromPoints(source.Vertices):new BoundingBox(); Geoms = new List <Dictionary <Texture2D, DGRP3DGeometry> >(); if (dgrp == null) { return; } Name = dgrp.ChunkParent.Filename.Replace('.', '_').Replace("spf", "iff") + "_" + dgrp.ChunkID; foreach (var obj in source.FacesByObjgroup.OrderBy(x => x.Key)) { if (obj.Key == "_default") { continue; } var split = obj.Key.Split('_'); if (split[0] == "DEPTH") { DepthMask = new DGRP3DGeometry(split, source, obj.Value, dgrp, gd); if (split.Length > 2 && split[2] == "PORTAL") { MaskType = DGRP3DMaskType.Portal; var verts = new List <Vector3>(); var objs = source.FacesByObjgroup.Where(x => !x.Key.StartsWith("DEPTH_MASK_PORTAL")).Select(x => x.Value); foreach (var obj2 in objs) { foreach (var tri in obj2) { verts.Add(source.Vertices[tri[0] - 1]); } } Bounds = BoundingBox.CreateFromPoints(verts); } else { MaskType = DGRP3DMaskType.Normal; } } else { //0: dynsprite id, 1: SPR or custom, 2: rotation, 3: index var id = int.Parse(split[0]); while (Geoms.Count <= id) { Geoms.Add(new Dictionary <Texture2D, DGRP3DGeometry>()); } var dict = Geoms[id]; var geom = new DGRP3DGeometry(split, source, obj.Value, dgrp, gd); dict[geom.Pixel] = geom; } } }
public void AddGeometry(IGeometry geometry) { if (_currentBox == null) { _currentBox = geometry.BoundingBox; } else { _currentBox = _currentBox.Join(geometry.BoundingBox); } }
internal void SetLocalAabb(BoundingBox localAabb) { m_localAabb = localAabb; Aabb = m_localAabb.Value.Transform(WorldMatrix); for (int i = 0; i < m_components.Count; i++) { m_components[i].OnAabbChange(); } }
/// <summary> /// Initializes a new instance of the <see cref="IParticleSystem"/> class. /// </summary> /// <param name="name">The name.</param> public IParticleSystem(String name, BoundingBox?BoundingBox = null) { this.BoundingBox = BoundingBox; if (String.IsNullOrEmpty(name)) { ActiveLogger.LogMessage("ParticleSystem name cannot be null/empty", LogLevel.FatalError); throw new Exception("ParticleSystem name cannot be null/empty"); } this.Name = name; }
public override void InvalidateRenderObjects() { MatrixD worldMatrix = base.Container.Entity.PositionComp.WorldMatrix; if (((base.Container.Entity.Visible || base.Container.Entity.CastShadows) && (base.Container.Entity.InScene && base.Container.Entity.InvalidateOnMove)) && (base.m_renderObjectIDs.Length != 0)) { BoundingBox?aabb = null; Matrix? localMatrix = null; MyRenderProxy.UpdateRenderObject(base.m_renderObjectIDs[0], new MatrixD?(worldMatrix), aabb, -1, localMatrix); } }
public UI3DThumb(VMEntity ent) { Camera = new BasicCamera(GameFacade.GraphicsDevice, new Vector3(3, 1, 0), new Vector3(0, 0, 0), new Vector3(0, 1, 0)); Camera.NearPlane = 0.001f; Scene = new _3DTargetScene(GameFacade.GraphicsDevice, Camera, new Point(150, 150), 0); Scene.Initialize(GameFacade.Scenes); if (Comp3D != null) { foreach (var e in Comp3D) { e.Dispose(); Scene.Remove(e); } } Comp3D = new List <Debug3DDGRPComponent>(); BoundingBox?total = null; var pos = ent.MultitileGroup.GetBasePositions(); var i = 0; foreach (var obj in ent.MultitileGroup.Objects) { var c = new Debug3DDGRPComponent(); var dgrp = ((ObjectComponent)obj.WorldUI).DGRP; c.Mesh = (dgrp == null) ? null : Content.Content.Get().RCMeshes.Get(dgrp, obj.Object.OBJ); //new DGRP3DMesh(((ObjectComponent)obj.WorldUI).DGRP, obj.Object.OBJ, GameFacade.GraphicsDevice, null); Scene.Add(c); if (c.Mesh == null) { i++; continue; } var vp = pos[i++]; c.Position = new Vector3((vp.X - 0.5f), vp.Z, (vp.Y - 0.5f)); if (total == null) { total = OffsetBox(c.Mesh.Bounds ?? new BoundingBox(), c.Position); } else { total = BoundingBox.CreateMerged(total.Value, OffsetBox(c.Mesh.Bounds ?? new BoundingBox(), c.Position)); } c.Initialize(); Comp3D.Add(c); } if (total != null) { Ctr = new Vector3((total.Value.Max.X + total.Value.Min.X) / 2, (total.Value.Max.Y + total.Value.Min.Y) / 2, (total.Value.Max.Z + total.Value.Min.Z) / 2); var diag = total.Value.Max - total.Value.Min; Size = diag.Length(); } }
public void UpdateRenderObjectMatrices(Matrix matrix) { for (int i = 0; i < base.m_renderObjectIDs.Length; i++) { if (base.m_renderObjectIDs[i] != uint.MaxValue) { BoundingBox?aabb = null; Matrix? localMatrix = null; MyRenderProxy.UpdateRenderObject(base.RenderObjectIDs[i], new MatrixD?(matrix), aabb, base.LastMomentUpdateIndex, localMatrix); } } }
public DGRP3DMesh(DGRP dgrp, Stream source, GraphicsDevice gd) { using (var cstream = new GZipStream(source, CompressionMode.Decompress)) { using (var io = IoBuffer.FromStream(cstream, ByteOrder.LITTLE_ENDIAN)) { var fsom = io.ReadCString(4); Version = io.ReadInt32(); ReconstructVersion = io.ReadInt32(); if (ReconstructVersion != 0 && ReconstructVersion < CURRENT_RECONSTRUCT) { throw new Exception("Reconstruction outdated, must be rerun!"); } Name = io.ReadPascalString(); var geomCount = io.ReadInt32(); Geoms = new List <Dictionary <Texture2D, DGRP3DGeometry> >(); for (int i = 0; i < geomCount; i++) { var d = new Dictionary <Texture2D, DGRP3DGeometry>(); var subCount = io.ReadInt32(); for (int j = 0; j < subCount; j++) { var geom = new DGRP3DGeometry(io, dgrp, gd, Version); if (geom.Pixel == null && geom.PrimCount > 0) { throw new Exception("Invalid Mesh! (old format)"); } d.Add(geom.Pixel, geom); } Geoms.Add(d); } if (Version > 2) { MaskType = (DGRP3DMaskType)io.ReadInt32(); if (MaskType > DGRP3DMaskType.None) { DepthMask = new DGRP3DGeometry(io, dgrp, gd, Version); } } var x = io.ReadFloat(); var y = io.ReadFloat(); var z = io.ReadFloat(); var x2 = io.ReadFloat(); var y2 = io.ReadFloat(); var z2 = io.ReadFloat(); Bounds = new BoundingBox(new Vector3(x, y, z), new Vector3(x2, y2, z2)); } } }
internal void Construct() { m_components.Clear(); m_visible = true; m_renderProxyDirty = true; m_ID = new MyIDTracker <MyActor>(); m_localAabb = null; m_relativeTransform = null; Aabb = BoundingBoxD.CreateInvalid(); }
internal void Construct() { m_components.Clear(); m_visible = true; MyUtils.Init(ref m_ID); m_ID.Clear(); LocalAabb = null; RelativeTransform = null; Aabb = BoundingBoxD.CreateInvalid(); }
/// <summary> /// Updates the internal bounding box /// </summary> protected virtual void UpdateBoundingBox() { var tmp = mergedBoundingBox; mergedBoundingBox = new BoundingBox( this.boundingBox.Minimum + this.Position, this.boundingBox.Maximum + this.Position); if (tmp != null) { mergedBoundingBox = BoundingBox.Merge(tmp.Value, mergedBoundingBox.Value); } }
internal void Construct() { m_components.Clear(); m_visible = true; m_renderProxyDirty = true; m_ID = new MyIDTracker<MyActor>(); m_localAabb = null; m_relativeTransform = null; Aabb = BoundingBoxD.CreateInvalid(); }
public override BoundingBox GetBoundingBox() { if (_boundingBox == null) { float xMax = (mapInfoWidth - 1) * mapCellSize; float yMax = mapDeltaHeight; float zMax = (mapInfoHeight - 1) * mapCellSize; _boundingBox = new BoundingBox(Vector3.Zero, new Vector3(xMax, yMax, zMax)); } return((BoundingBox)_boundingBox); }
/// <summary> /// Gets bounding box /// </summary> /// <param name="refresh">Sets if the cache must be refresehd or not</param> /// <returns>Returns bounding box. Empty if the vertex type hasn't position channel</returns> public BoundingBox GetBoundingBox(bool refresh) { if (refresh || this.boundingBox == null) { var points = this.GetPoints(refresh); if (points.Any()) { this.boundingBox = BoundingBox.FromPoints(points); } } return(this.boundingBox ?? new BoundingBox(this.Manipulator.Position, this.Manipulator.Position)); }
private void Complete(GraphicsDevice gd) { Bounds = (BoundPts.Count == 0) ? new BoundingBox() : BoundingBox.CreateFromPoints(BoundPts); BoundPts = null; Save(); foreach (var g in Geoms) { foreach (var e in g) { e.Value.SComplete(gd); } } }
public Octree(Vector3 center, float size, Octree parent = null) { _parent = parent; _center = center; _size = size; _children = new List <Octree>(8); _points = new List <ColoredPoint>(); _pointsDic = new Dictionary <Color, List <ColoredPoint> >(); var diagonalVector = new Vector3(size / 2f); _bbox = new BoundingBox(center - diagonalVector, center + diagonalVector); }
public void Displace(float xDisp, float yDisp) { _position.X += xDisp; _position.Y += yDisp; if (_hitbox != null) { BoundingBox newHitbox = _hitbox.GetValueOrDefault(); newHitbox.Min.X += xDisp; newHitbox.Max.X += xDisp; newHitbox.Min.Y += yDisp; newHitbox.Max.Y += yDisp; _hitbox = newHitbox; } }
public BoundingBox?GetSceneBoundingBox() { BoundingBox?result = null; foreach (var visualObject in visualObjects) { var visualObjectBb = visualObject.GetBoundingBox(); result = result.HasValue ? BoundingBox.CreateMerged(result.Value, visualObjectBb) : visualObjectBb; } return(result); }
protected void SetMesh(string mesh) { //mesh = "models/supcom/default.mesh"; //m = Root.Instance.ResourceManager.Load<SkeletalMesh>(mesh); //try { m = Root.Instance.ResourceManager.Load<Mesh>(mesh); } //catch (Exception e) //{ // m = Root.Instance.ResourceManager.Load<Model>(mesh); //} // //m = Root.Instance.ResourceManager.Load<SupComMap>("maps/SCMP_005/SCMP_005.scmap"); if (m is Model) { bbox = ((Model)m).Mesh.BBox; } else if (m is Mesh) { bbox = ((Mesh)m).BBox; } }
public void CreateBoundingBox(float width, float height, float depth, Vector3 offset) { var max = new Vector3(width / 2.0f, height / 2.0f, depth / 2.0f); var min = -max; _relativeBoundingBox = new BoundingBox(min + offset, max + offset); BoundingBox = _relativeBoundingBox; }
internal void SetLocalAabb(BoundingBox localAabb) { m_localAabb = localAabb; Aabb = m_localAabb.Value.Transform(WorldMatrix); for (int i = 0; i < m_components.Count; i++) m_components[i].OnAabbChange(); }
public void SetBoundingBox(BoundingBox bb) { this.bb = bb; }