public Vector2 GetBoxFaceSizeAlongFaceLocalXZAxes(BoxFace boxFace, Vector3 boxXYZScale) { Vector3 size = Size; switch (boxFace) { case BoxFace.Front: case BoxFace.Back: return(new Vector2(size.x * boxXYZScale.x, size.y * boxXYZScale.y)); case BoxFace.Left: case BoxFace.Right: return(new Vector2(size.z * boxXYZScale.z, size.y * boxXYZScale.y)); case BoxFace.Top: case BoxFace.Bottom: return(new Vector2(size.x * boxXYZScale.x, size.z * boxXYZScale.z)); default: return(Vector2.zero); } }
public Plane GetBoxFacePlane(BoxFace boxFace) { Plane modelSpacePlane = _modelSpaceBox.GetBoxFacePlane(boxFace); Vector3 modelSpacePointOnPlane = _modelSpaceBox.GetBoxFaceCenter(boxFace); return(modelSpacePlane.Transform(TransformMatrix, modelSpacePointOnPlane)); }
public void GetFace(BoxFace face, BoxPrimitive.BoxTextureCoords uvs, out int index, out int count) { switch (face) { case BoxFace.Back: GetBackFace(uvs, out index, out count); return; case BoxFace.Front: GetFrontFace(uvs, out index, out count); return; case BoxFace.Left: GetLeftFace(uvs, out index, out count); return; case BoxFace.Right: GetRightFace(uvs, out index, out count); return; case BoxFace.Top: GetTopFace(uvs, out index, out count); return; case BoxFace.Bottom: GetBottomFace(uvs, out index, out count); return; } index = 0; count = 0; }
public Plane GetBoxFacePlane(BoxFace boxFace) { switch (boxFace) { case BoxFace.Back: return(new Plane(BoxFaces.GetFaceNormal(BoxFace.Back), GetBoxPoint(BoxPoint.BackBottomLeft))); case BoxFace.Front: return(new Plane(BoxFaces.GetFaceNormal(BoxFace.Front), GetBoxPoint(BoxPoint.FrontBottomLeft))); case BoxFace.Left: return(new Plane(BoxFaces.GetFaceNormal(BoxFace.Left), GetBoxPoint(BoxPoint.FrontBottomLeft))); case BoxFace.Right: return(new Plane(BoxFaces.GetFaceNormal(BoxFace.Right), GetBoxPoint(BoxPoint.FrontBottomRight))); case BoxFace.Top: return(new Plane(BoxFaces.GetFaceNormal(BoxFace.Top), GetBoxPoint(BoxPoint.FrontTopLeft))); case BoxFace.Bottom: return(new Plane(BoxFaces.GetFaceNormal(BoxFace.Bottom), GetBoxPoint(BoxPoint.FrontBottomLeft))); default: return(new Plane()); } }
private static bool IsFaceVisible(VoxelHandle V, BoxFace Face, ChunkManager Chunks, out VoxelHandle Neighbor) { var delta = NeighborVoxelCoordinateDeltas[(int)Face]; Neighbor = new VoxelHandle(Chunks, V.Coordinate + delta); return(IsFaceVisible(V, Neighbor, Face)); }
public static BoxFace GetOpposite(BoxFace boxFace) { if (boxFace == BoxFace.Back) { return(BoxFace.Front); } if (boxFace == BoxFace.Front) { return(BoxFace.Back); } if (boxFace == BoxFace.Left) { return(BoxFace.Right); } if (boxFace == BoxFace.Right) { return(BoxFace.Left); } if (boxFace == BoxFace.Bottom) { return(BoxFace.Top); } return(BoxFace.Bottom); }
protected static bool ShouldDrawFace(BoxFace face, RampType neighborRamp, RampType myRamp) { switch (face) { case BoxFace.Top: case BoxFace.Bottom: return(true); case BoxFace.Front: return(CheckRamps(myRamp, RampType.TopBackLeft, RampType.TopBackRight, neighborRamp, RampType.TopFrontLeft, RampType.TopFrontRight)); case BoxFace.Back: return(CheckRamps(myRamp, RampType.TopFrontLeft, RampType.TopFrontRight, neighborRamp, RampType.TopBackLeft, RampType.TopBackRight)); case BoxFace.Left: return(CheckRamps(myRamp, RampType.TopBackLeft, RampType.TopFrontLeft, neighborRamp, RampType.TopBackRight, RampType.TopFrontRight)); case BoxFace.Right: return(CheckRamps(myRamp, RampType.TopBackRight, RampType.TopFrontRight, neighborRamp, RampType.TopBackLeft, RampType.TopFrontLeft)); default: return(false); } }
public SceneGizmoAxisCap(SceneGizmo sceneGizmo, int id, AxisDescriptor gizmoAxisDesc) : base(sceneGizmo, id) { _axisDesc = gizmoAxisDesc; _midAxisBoxFace = _axisDesc.GetAssociatedBoxFace(); _cap.SetZoomFactorTransform(_zoomFactorTransform); if (_axisDesc.IsPositive) { if (_axisDesc.Index == 0) { _labelTexture = TexturePool.Get.XAxisLabel; } else if (_axisDesc.Index == 1) { _labelTexture = TexturePool.Get.YAxisLabel; } else { _labelTexture = TexturePool.Get.ZAxisLabel; } } _colorTransition = new ColorTransition(_color); _cap.Gizmo.PreUpdateBegin += OnGizmoPreUpdateBegin; _cap.Gizmo.PreHandlePicked += OnGizmoHandlePicked; _sceneGizmo.LookAndFeel.ConnectAxisCapLookAndFeel(_cap, _axisDesc.Index, _axisDesc.Sign); }
public BoxFaceAreaDesc GetWorldSnapAreaDesc(BoxFace boxFace) { Vector3 boxSize = _snapAreaBounds[(int)boxFace].Size; boxSize = Vector3.Scale(boxSize, _gameObject.transform.lossyScale.Abs()); return(BoxMath.GetBoxFaceAreaDesc(boxSize, boxFace)); }
public void NextExtensionPlane() { if (CanActivateNextExtensionPlane()) { _extensionPlaneBoxFace = BoxFaces.GetNext(_extensionPlaneBoxFace); SceneView.RepaintAll(); } }
public static bool ShouldDrawFace(BoxFace face, RampType neighborRamp, RampType myRamp) { if(face == BoxFace.Top || face == BoxFace.Bottom) { return true; } return FaceDrawMap[(int) face, (int) myRamp, (int) neighborRamp]; }
/// <summary> /// Generate the Remove handle for the TransformBox /// </summary> /// <param name="name"></param> /// <param name="face"></param> void CreateRemoveGizmo(string name, BoxFace face) { var gizmo = this.RemovePrefab; var position = (this.corners[0, 0] + this.corners[0, 1]) / 2; var instance = Instantiate(gizmo, position, Quaternion.identity); ConfigureGizmo(instance); instance.name = name; }
/// <summary> /// Method to generate the lines connecting faces /// </summary> /// <param name="parent"></param> /// <param name="corners"></param> /// <param name="name"></param> /// <param name="face"></param> private void CreateRing(GameObject parent, Vector3[,] corners, string name, BoxFace face) { for (int j = 0; j < 4; ++j) { var vectors = new Vector3[] { corners[0, j], corners[1, j] }; var line = new GameObject(name); AddLineRenderer(line).SetPositions(vectors); line.transform.parent = parent.transform; } }
public OrientedBoxRayHit(Ray ray, float hitEnter, OrientedBox hitBox) { _ray = ray; _hitEnter = hitEnter; _hitBox = new OrientedBox(hitBox); _hitPoint = ray.GetPoint(hitEnter); _hitFace = hitBox.GetBoxFaceClosestToPoint(_hitPoint); _hitNormal = hitBox.GetBoxFacePlane(_hitFace).normal; }
public CoordinateSystem GetBoxFaceCoordinateSystem(BoxFace boxFace) { CoordinateSystem coordSystem = _modelSpaceBox.GetBoxFaceCoordinateSystem(boxFace); TransformMatrix transformMatrix = TransformMatrix; coordSystem.Transform(transformMatrix); return(coordSystem); }
public static bool ShouldDrawFace(BoxFace face, RampType neighborRamp, RampType myRamp) { if (face == BoxFace.Top || face == BoxFace.Bottom) { return(true); } return(FaceDrawMap[(int)face, (int)myRamp, (int)neighborRamp]); }
private void CorrectHitDataForThinPlanes() { float boxSizeAlongHitNormal = _hitBox.GetSizeAlongDirection(_hitNormal); if (boxSizeAlongHitNormal < 1e-4f && Vector3.Dot(_hitNormal, SceneViewCamera.Camera.transform.forward) > 0.0f) { _hitFace = BoxFaces.GetOpposite(_hitFace); _hitNormal = _hitBox.GetBoxFacePlane(_hitFace).normal; } }
private void CalculateQuadXZSize(OrientedBox orientedBox, BoxFace boxFace) { Vector2 boxFaceSize = orientedBox.GetBoxFaceSizeAlongFaceLocalXZAxes(boxFace); float quadSize = boxFaceSize.x; if (quadSize < boxFaceSize.y) { quadSize = boxFaceSize.y; } _planeQuad.SizeOnBothXZAxes = quadSize; }
public OBB GetWorldSnapAreaBounds(BoxFace boxFace) { if (_gameObject == null) { return(OBB.GetInvalid()); } Transform objectTransform = _gameObject.transform; return(new OBB(_snapAreaBounds[(int)boxFace], objectTransform)); }
/// <summary> /// Method to generate the closed polygons for faces /// </summary> /// <param name="parent"></param> /// <param name="corners"></param> /// <param name="name"></param> /// <param name="face"></param> private void CreateLoop(GameObject parent, Vector3[,] corners, string name, BoxFace face) { for (int j = 0; j < 4; ++j) { int k = ((j + 1) % 4 == 0) ? 0 : (j + 1); var vectors = new Vector3[] { corners[(int)face, j], corners[(int)face, k] }; var line = new GameObject(name); AddLineRenderer(line).SetPositions(vectors); line.transform.parent = parent.transform; } }
public CoordinateSystem GetBoxFaceCoordinateSystem(BoxFace boxFace) { var coordSystem = new CoordinateSystem(); Vector3 origin = GetBoxFaceCenter(boxFace); Vector3 boxFaceUp = BoxFaces.GetFaceNormal(boxFace); Vector3 boxFaceLook = BoxFaces.GetFaceLookAxis(boxFace); coordSystem.SetOriginPosition(origin); coordSystem.SetRotation(Quaternion.LookRotation(boxFaceLook, boxFaceUp)); return(coordSystem); }
public OrientedBoxRayHit(Ray ray, float hitEnter, OrientedBox hitBox) { _ray = ray; _hitEnter = hitEnter; _hitBox = new OrientedBox(hitBox); _hitCollider = new Octave3DBoxCollider(_hitBox); _hitPoint = ray.GetPoint(hitEnter); _hitFace = hitBox.GetBoxFaceClosestToPoint(_hitPoint); _hitNormal = hitBox.GetBoxFacePlane(_hitFace).normal; CorrectHitDataForThinPlanes(); }
/// <summary> /// Method to generate rotate gizmos for the four sides of the TransformBox /// </summary> /// <param name="name"></param> /// <param name="face"></param> void CreateRotateGizmos(string name, BoxFace face) { var gizmo = this.RotatePrefab; for (int i = 0; i < 4; ++i) { var position = (this.corners[0, i] + this.corners[1, i]) / 2; var instance = Instantiate(gizmo, position, Quaternion.identity); ConfigureGizmo(instance); instance.AddComponent <HandRotate>().HostTransform = this.RootTransform; instance.name = name; } }
/// <summary> /// Method to generate scale gizmos for the four sides of the TransformBox /// </summary> /// <param name="name"></param> /// <param name="face"></param>g void CreateScaleGizmos(string name, BoxFace face) { var gizmo = this.ScalePrefab; for (int i = 0; i < 4; ++i) { var position = this.corners[(int)face, i]; var instance = Instantiate(gizmo, position, Quaternion.Euler(0, 180 - i * 90, (int)face * 90 - 90)); ConfigureGizmo(instance); instance.AddComponent <HandScale>().HostTransform = this.RootTransform; instance.name = name; } }
public void NextExtensionPlane() { if (Settings.TileConnectionSettings.UseTileConnections) { Debug.LogWarning("The extension plane can not be changed when using tile connections. For 3D tiles it will always reside at the bottom of the tiles (in local space) " + "and for 2D sprites it will reside behind the sprite plane (in local space)."); } if (CanActivateNextExtensionPlane()) { _extensionPlaneBoxFace = BoxFaces.GetNext(_extensionPlaneBoxFace); SceneView.RepaintAll(); } }
private void RestrictExtensionPlane() { if (Settings.TileConnectionSettings.UseTileConnections) { if (Settings.TileConnectionSettings.UsesSprites()) { _extensionPlaneBoxFace = BoxFace.Back; } else { _extensionPlaneBoxFace = BoxFace.Bottom; } } }
protected static bool IsFaceVisible(VoxelHandle voxel, VoxelHandle neighbor, BoxFace face) { return (!neighbor.IsValid || (neighbor.IsExplored && neighbor.IsEmpty) || (neighbor.Type.IsTransparent && !voxel.Type.IsTransparent) || !neighbor.IsVisible || ( neighbor.Type.CanRamp && neighbor.RampType != RampType.None && IsSideFace(face) && ShouldDrawFace(face, neighbor.RampType, voxel.RampType) )); }
private void AdjustObjectBoxCenterToSitOnSurface(OrientedBox objectBox, ObjectSurfaceData objectSurfaceData, DecorPaintObjectPlacementBrushElement brushElement) { if (brushElement.AlignToSurface) { objectBox.Center = objectSurfaceData.BasePosition + objectSurfaceData.SurfaceNormal * 0.5f * objectBox.GetSizeAlongDirection(objectSurfaceData.SurfaceNormal); } else { BoxFace boxFaceWhichFacesSurfaceNormal = objectBox.GetBoxFaceWhichFacesNormal(_workingBrushCircle.Plane.normal); Vector3 faceCenter = objectBox.GetBoxFaceCenter(boxFaceWhichFacesSurfaceNormal); Vector3 fromFaceCenterToBoxCenter = objectBox.Center - faceCenter; objectBox.Center = objectSurfaceData.BasePosition + fromFaceCenterToBoxCenter; } }
public List <Vector3> GetBoxFaceCornerPoints(BoxFace boxFace) { var points = new Vector3[BoxFaceCornerPoints.Count]; Vector3 boxFaceCenter = GetBoxFaceCenter(boxFace); Vector2 boxFaceXZSize = GetBoxFaceSizeAlongFaceLocalXZAxes(boxFace, Vector3.one); Vector2 halfXZSize = boxFaceXZSize * 0.5f; points[(int)BoxFaceCornerPoint.TopLeft] = boxFaceCenter - BoxFaces.GetFaceRightAxis(boxFace) * halfXZSize.x + BoxFaces.GetFaceLookAxis(boxFace) * halfXZSize.y; points[(int)BoxFaceCornerPoint.TopRight] = boxFaceCenter + BoxFaces.GetFaceRightAxis(boxFace) * halfXZSize.x + BoxFaces.GetFaceLookAxis(boxFace) * halfXZSize.y; points[(int)BoxFaceCornerPoint.BottomRight] = boxFaceCenter + BoxFaces.GetFaceRightAxis(boxFace) * halfXZSize.x - BoxFaces.GetFaceLookAxis(boxFace) * halfXZSize.y; points[(int)BoxFaceCornerPoint.BottomLeft] = boxFaceCenter - BoxFaces.GetFaceRightAxis(boxFace) * halfXZSize.x - BoxFaces.GetFaceLookAxis(boxFace) * halfXZSize.y; return(new List <Vector3>(points)); }
public override bool Raycast(Ray ray, out Octave3DColliderRayHit colliderRayHit) { colliderRayHit = null; float t; if (_orientedBox.Raycast(ray, out t)) { Vector3 hitPoint = ray.GetPoint(t); BoxFace faceWhichContainsHitPoint = _orientedBox.GetBoxFaceClosestToPoint(hitPoint); Vector3 hitNormal = _orientedBox.GetBoxFacePlane(faceWhichContainsHitPoint).normal; colliderRayHit = new Octave3DColliderRayHit(ray, t, hitPoint, hitNormal, this); } return(colliderRayHit != null); }
public static int GetFaceAxisIndex(BoxFace face) { if (face == BoxFace.Top || face == BoxFace.Bottom) { return(1); } if (face == BoxFace.Left || face == BoxFace.Right) { return(0); } if (face == BoxFace.Back || face == BoxFace.Front) { return(2); } return(-1); }
private static IEnumerable<ExtendedVertex> CreateWaterFace(Voxel voxel, BoxFace face, VoxelChunk chunk, int x, int y, int z, int totalDepth, bool top) { List<ExtendedVertex> toReturn = new List<ExtendedVertex>(); int idx = 0; int c = 0; int vertOffset = 0; int numVerts = 0; m_canconicalPrimitive.GetFace(face, m_canconicalPrimitive.UVs, out idx, out c, out vertOffset, out numVerts); for (int i = idx; i < idx + c; i++) { toReturn.Add(m_canconicalPrimitive.Vertices[m_canconicalPrimitive.Indices[i]]); } Vector3 origin = chunk.Origin + new Vector3(x, y, z); List<Voxel> neighborsVertex = new List<Voxel>(); for(int i = 0; i < toReturn.Count; i ++) { VoxelVertex currentVertex = VoxelChunk.GetNearestDelta(toReturn[i].Position); chunk.GetNeighborsVertex(currentVertex, voxel, neighborsVertex); int index = chunk.Data.IndexAt(x, y, z); float averageWaterLevel = chunk.Data.Water[index].WaterLevel; float count = 1.0f; float emptyNeighbors = 0.0f; foreach(byte level in neighborsVertex.Select(vox => vox.WaterLevel)) { averageWaterLevel += level; count++; if(level < 1) { emptyNeighbors++; } } averageWaterLevel = averageWaterLevel / count; float averageWaterHeight = (float) averageWaterLevel / 255.0f; float puddleness = 0; Vector2 uv; float foaminess = emptyNeighbors / count; if(foaminess <= 0.5f) { foaminess = 0.0f; } if(totalDepth < 5) { foaminess = 0.75f; puddleness = 0; uv = new Vector2((toReturn[i].Position.X + origin.X) / 80.0f, (toReturn[i].Position.Z + origin.Z) / 80.0f); } else { uv = new Vector2((toReturn[i].Position.X + origin.X) / 80.0f, (toReturn[i].Position.Z + origin.Z) / 80.0f); } Vector4 bounds = new Vector4(0, 0, 1, 1); if(chunk.Data.Water[index].IsFalling || !top) { averageWaterHeight = 1.0f; } if(face == BoxFace.Top) { toReturn[i] = new ExtendedVertex(toReturn[i].Position + origin + new Vector3(0, (averageWaterHeight * 0.4f - 1.0f), 0), new Color(foaminess, puddleness, (float) totalDepth / 512.0f, 1.0f), uv, bounds); } else { Vector3 offset = Vector3.Zero; switch(face) { case BoxFace.Back: case BoxFace.Front: uv = new Vector2((Math.Abs(toReturn[i].Position.X + origin.X) / 80.0f), (Math.Abs(toReturn[i].Position.Y + origin.Y) / 80.0f)); foaminess = 1.0f; offset = new Vector3(0, -0.5f, 0); break; case BoxFace.Right: case BoxFace.Left: uv = new Vector2((Math.Abs(toReturn[i].Position.Z + origin.Z) / 80.0f), (Math.Abs(toReturn[i].Position.Y + origin.Y) / 80.0f)); foaminess = 1.0f; offset = new Vector3(0, -0.5f, 0); break; case BoxFace.Top: offset = new Vector3(0, -0.5f, 0); break; } toReturn[i] = new ExtendedVertex(toReturn[i].Position + origin + offset, new Color(foaminess, 0.0f, 1.0f, 1.0f), uv, bounds); } } return toReturn; }
public static bool IsSideFace(BoxFace face) { return face != BoxFace.Top && face != BoxFace.Bottom; }
public static RampType UpdateRampType(BoxFace face) { switch(face) { case BoxFace.Back: return RampType.Back; case BoxFace.Front: return RampType.Front; case BoxFace.Left: return RampType.Left; case BoxFace.Right: return RampType.Right; default: return RampType.None; } }
public ExtendedVertex[] GetFace(BoxFace face) { switch (face) { case BoxFace.Back: return GetBackFace(); case BoxFace.Front: return GetFrontFace(); case BoxFace.Left: return GetLeftFace(); case BoxFace.Right: return GetRightFace(); case BoxFace.Top: return GetTopFace(); case BoxFace.Bottom: return GetBottomFace(); } return null; }
public void GetFace(BoxFace face, BoxPrimitive.BoxTextureCoords uvs, out int index, out int count, out int vertexOffset, out int vertexCount) { vertexCount = 4; count = 6; vertexOffset = 0; switch (face) { case BoxFace.Back: index = 6; vertexOffset = 4; return; case BoxFace.Front: index = 0; vertexOffset = 0; return; case BoxFace.Left: index = 24; vertexOffset = 16; return; case BoxFace.Right: index = 30; vertexOffset = 20; return; case BoxFace.Top: index = 12; vertexOffset = 8; return; case BoxFace.Bottom: index = 18; vertexOffset = 12; return; } index = 0; count = 0; }