public static void PushClipVolumes( Box[] volumes ) { clipVolumes.Push( (Box[])volumes.Clone() ); UpdateTotalClipVolumes(); }
protected override Body[] OnVolumeCast( Box box, int contactGroup ) { Vec3 origin = box.Center; Vec3 halfExtents = box.Extents; Quat rotation = box.Axis.ToQuat(); int shapeCount = PhysXNativeScene.OverlapOBBShapes( nativeScene, ref origin, ref halfExtents, ref rotation, GetContactGroupMask( contactGroup ) ); if( shapeCount == 0 ) return emptyVolumeCastResult; return GetBodiesFromVolumeCastResult( shapeCount ); }
protected override Body[] OnVolumeCast( Box box, int contactGroup ) { dGeomID volumeCastGeomID = Ode.dCreateBox( rootSpaceID, box.Extents.X * 2, box.Extents.Y * 2, box.Extents.Z * 2 ); Mat3 mat3 = box.Axis; Ode.dMatrix3 odeMat3; Convert.ToODE( ref mat3, out odeMat3 ); Ode.dGeomSetRotation( volumeCastGeomID, ref odeMat3 ); Ode.dGeomSetPosition( volumeCastGeomID, box.Center.X, box.Center.Y, box.Center.Z ); Body[] result = DoVolumeCastGeneral( volumeCastGeomID, contactGroup ); Ode.dGeomDestroy( volumeCastGeomID ); return result; }
/// <summary> /// Return all tiles' bounding polygons in a specified region. /// </summary> public List<BoundingPolygon> GetBoundingPolygonsInRegion(Box boundingBox, int layer) { List<BoundingPolygon> polygons = new List<BoundingPolygon>(); int minTileX = (int)Math.Max((boundingBox.Left - OffsetX) / Tilesize, 0.0); int maxTileX = (int)Math.Min((boundingBox.Right - OffsetX) / Tilesize, Width-1); int minTileY = (int)Math.Max((boundingBox.Bottom - OffsetY) / Tilesize, 0); int maxTileY = (int)Math.Min((boundingBox.Top - OffsetY) / Tilesize, Height-1); for (int xTile = minTileX; xTile <= maxTileX; xTile++) { for (int yTile = minTileY; yTile <= maxTileY; yTile++) { BoundingPolygon p = map[xTile, yTile, layer].BoundingPolygon; if (p != null && p.Vertices.Count > 1) polygons.Add(p); } } return polygons; }
protected override void OnRender(Camera camera) { base.OnRender(camera); if ((EngineDebugSettings.DrawGameSpecificDebugGeometry || EngineApp.Instance.ApplicationType == EngineApp.ApplicationTypes.ResourceEditor || EngineApp.Instance.ApplicationType == EngineApp.ApplicationTypes.MapEditor || EngineApp.Instance.ApplicationType == EngineApp.ApplicationTypes.Simulation) && camera.Purpose == Camera.Purposes.MainCamera) { if (Active) { Vec3 min = Position + new Vec3(0, 0, 0); //min Vec3 max = Position + new Vec3(Type.BoxSize.X * BoxLength * Scale.X, Type.BoxSize.Y * BoxWidth * Scale.Y, Type.BoxSize.Z * BoxHeight * Scale.Z); //max Mat3 rotation = new Mat3(1, 0, 0, 0, 1, 0, 0, 0, 1); camera.DebugGeometry.Color = new ColorValue(0, 1, 0, .5f); bounds = new Bounds(min, max); box = new Box(bounds); box.Axis = rotation * Rotation.ToMat3(); box.Center = Position + new Vec3(0, 0, ((max.Z - min.Z) / 2) + .1f); box.Expand(.1f); camera.DebugGeometry.AddBox(box); } } }
/// <summary>Overridden from <see cref="Engine.EntitySystem.Entity.OnPostCreate(Boolean)"/>.</summary> protected override void OnPostCreate(bool loaded) { base.OnPostCreate(loaded); if (EntitySystemWorld.Instance.IsServer()) { if (Active) { Vec3 min = Position + new Vec3(0, 0, 0); //min Vec3 max = Position + new Vec3(Type.BoxSize.X * BoxLength * Scale.X, Type.BoxSize.Y * BoxWidth * Scale.Y, Type.BoxSize.Z * BoxHeight * Scale.Z); //max Mat3 rotation = new Mat3(1, 0, 0, 0, 1, 0, 0, 0, 1); //camera.DebugGeometry.Color = new ColorValue(0, 1, 0, .5f); bounds = new Bounds(min, max); box = new Box(bounds); box.Axis = rotation * Rotation.ToMat3(); box.Center = Position + new Vec3(0, 0, ((max.Z - min.Z) / 2) + .1f); box.Expand(.1f); //camera.DebugGeometry.AddBox(box); } } SubscribeToTickEvent(); UpdateAttachedObjects(); }
protected override void OnDebugRender( DebugGeometry debugGeometry, ref Mat4 bodyTransform, bool simpleGeometry ) { Bounds localBounds = new Bounds( -halfDimensions, halfDimensions ); Mat4 t = bodyTransform; if( !IsIdentityTransform ) t *= GetTransform(); Box box = new Box( localBounds ) * t; debugGeometry.AddBox( box ); }