Exemplo n.º 1
0
        public static bool GenerateBoxSubMesh(CSGBrushSubMesh subMesh, UnityEngine.Vector3 min, UnityEngine.Vector3 max, CSGSurfaceAsset[] surfaceAssets, SurfaceDescription[] surfaceDescriptions)
        {
            if (!BoundsExtensions.IsValid(min, max))
            {
                return(false);
            }

            if (surfaceAssets.Length != 6 ||
                surfaceDescriptions.Length != 6)
            {
                return(false);
            }

            if (min.x > max.x)
            {
                float x = min.x; min.x = max.x; max.x = x;
            }
            if (min.y > max.y)
            {
                float y = min.y; min.y = max.y; max.y = y;
            }
            if (min.z > max.z)
            {
                float z = min.z; min.z = max.z; max.z = z;
            }

            subMesh.Polygons  = CreateBoxAssetPolygons(surfaceAssets, surfaceDescriptions);
            subMesh.HalfEdges = boxHalfEdges.ToArray();
            subMesh.Vertices  = BrushMeshFactory.CreateBoxVertices(min, max);
            return(true);
        }
Exemplo n.º 2
0
        public static bool GenerateBoxAsset(CSGBrushMeshAsset brushMeshAsset, UnityEngine.Vector3 min, UnityEngine.Vector3 max, CSGSurfaceAsset[] surfaceAssets, SurfaceFlags surfaceFlags = SurfaceFlags.None)
        {
            if (!BoundsExtensions.IsValid(min, max))
            {
                brushMeshAsset.Clear();
                return(false);
            }

            if (surfaceAssets.Length != 6)
            {
                brushMeshAsset.Clear();
                return(false);
            }

            if (min.x > max.x)
            {
                float x = min.x; min.x = max.x; max.x = x;
            }
            if (min.y > max.y)
            {
                float y = min.y; min.y = max.y; max.y = y;
            }
            if (min.z > max.z)
            {
                float z = min.z; min.z = max.z; max.z = z;
            }

            brushMeshAsset.Polygons  = CreateBoxAssetPolygons(surfaceAssets, surfaceFlags);
            brushMeshAsset.HalfEdges = boxHalfEdges.ToArray();
            brushMeshAsset.Vertices  = BrushMeshFactory.CreateBoxVertices(min, max);
            brushMeshAsset.CalculatePlanes();
            brushMeshAsset.SetDirty();
            return(true);
        }
Exemplo n.º 3
0
        public static bool GenerateBoxAsset(CSGBrushMeshAsset brushMeshAsset, UnityEngine.Vector3 min, UnityEngine.Vector3 max, CSGSurfaceAsset[] surfaceAssets, SurfaceDescription[] surfaceDescriptions)
        {
            if (!BoundsExtensions.IsValid(min, max))
            {
                brushMeshAsset.Clear();
                Debug.LogError("bounds is of an invalid size " + (max - min));
                return(false);
            }

            if (surfaceDescriptions == null || surfaceDescriptions.Length != 6)
            {
                brushMeshAsset.Clear();
                Debug.LogError("surfaceDescriptions needs to be an array of length 6");
                return(false);
            }

            if (surfaceAssets == null || surfaceAssets.Length != 6)
            {
                brushMeshAsset.Clear();
                Debug.LogError("surfaceAssets needs to be an array of length 6");
                return(false);
            }

            if (min.x > max.x)
            {
                float x = min.x; min.x = max.x; max.x = x;
            }
            if (min.y > max.y)
            {
                float y = min.y; min.y = max.y; max.y = y;
            }
            if (min.z > max.z)
            {
                float z = min.z; min.z = max.z; max.z = z;
            }

            brushMeshAsset.Polygons  = CreateBoxAssetPolygons(surfaceAssets, surfaceDescriptions);
            brushMeshAsset.HalfEdges = boxHalfEdges.ToArray();
            brushMeshAsset.Vertices  = BrushMeshFactory.CreateBoxVertices(min, max);
            brushMeshAsset.CalculatePlanes();
            brushMeshAsset.SetDirty();
            return(true);
        }