コード例 #1
0
ファイル: PathVoxelizer.cs プロジェクト: drt-ftl/VAME
 public void MakeNew(Vector3 pos, LineSegment line)
 {
     pos = pos / divisions;
     if (!voxels.ContainsKey(pos))
     {
         var vc = new VoxelClass();
         vc.Voxel = Instantiate(voxel, pos, Quaternion.identity) as GameObject;
         var sc = (1.0f / divisions) * 0.9f;
         vc.Voxel.transform.localScale = new Vector3(sc, sc, sc);
         vc.Voxel.GetComponent<vTest>().Id = voxels.Count;
         vc.IntersectedByLines = new List<LineSegment>();
         voxels.Add(pos, vc);
         highlights.Add(pos);
     }
     voxels[pos].IntersectedByLines.Add(line);
 }
コード例 #2
0
ファイル: MeshVoxelizer.cs プロジェクト: drt-ftl/VAME
 public void HandleIt(Vector3 testPosition, Vector3 position)
 {
     var coords = (position / divisions);
     if (IsPointInside(MM.GetMesh(), testPosition / divisions) && !voxels.ContainsKey(coords))
     {
         var v = Instantiate(voxel, coords, Quaternion.identity) as GameObject;
         v.transform.SetParent(transform);
         v.GetComponent<SingleCube>().Voxel();
         var scale = 1.0f / divisions;
         v.transform.localScale = new Vector3(scale, scale, scale);
         var small = SingleCube.scale;
         v.GetComponent<BoxCollider>().size = new Vector3(small, small, small);
         var vc = new VoxelClass();
         vc.Voxel = v;
         v.GetComponent<SingleCube>().Id = voxels.Count;
         voxels.Add(coords, vc);
         highlights.Add(coords);
     }
 }
コード例 #3
0
ファイル: SurfaceVoxelizer.cs プロジェクト: drt-ftl/VAME
 public void InstVoxel(Vector3 pos)
 {
     if (!voxels.ContainsKey(pos))
     {
         var v = Instantiate(voxel, pos, Quaternion.identity) as GameObject;
         var scale = (1.0f / divisions) * 0.9f;
         v.transform.localScale = new Vector3(scale, scale, scale);
         v.transform.SetParent(GameObject.Find("voxelHolder").transform);
         var color = new Color(pos.x, pos.y, pos.z, 1f);
         var spec = new Color(pos.x, pos.y, pos.z, 1f);
         v.GetComponent<MeshRenderer>().material.SetColor("_SpecColor", spec);
         v.GetComponent<Renderer>().material.color = color;
         var vc = new VoxelClass();
         vc.Voxel = v;
         v.GetComponent<vTest>().Id = voxels.Count;
         voxels.Add(pos, vc);
         highlights.Add(pos);
     }
 }
コード例 #4
0
ファイル: PathFitter.cs プロジェクト: drt-ftl/VAME
 public void MakeNew(VoxelClass vc, LineSegment line)
 {
     //vc.IntersectedByLines.Add(line);
     //if (vc.IntersectedByLines.Count > maxPathsThrough)
     //    maxPathsThrough = vc.IntersectedByLines.Count;
 }
コード例 #5
0
ファイル: cSectionGCD.cs プロジェクト: drt-ftl/VAME
 public void AddSloxel(Vector3 centroid, CrossSectionLayer layer)
 {
     if (layer.SloxPositions.Contains(centroid)) return;
     layer.SloxPositions.Add(centroid);
     var slox = new Sloxel();
     slox.Layer = layer.Layer;
     slox.Position = centroid;
     slox.Dim = sloxelResolution.x;
     slox.Id = layer.Sloxels.Count;
     layer.Sloxels.Add(slox);
     var inc = 1 / sloxelResolution.x;
     foreach (var voxelLayer in voxelHeights)
     {
         if (Mathf.Abs(centroid.y - voxelLayer) <= voxelHeight / 2)
         {
             var voxPos = new Vector3(centroid.x, voxelLayer, centroid.z);
             if (!voxels.ContainsKey(voxPos))
             {
                 var voxObj = MonoBehaviour.Instantiate(GameObject.Find("VOXELIZER").GetComponent<MeshVoxelizer>().voxel, voxPos, Quaternion.identity) as GameObject;
                 voxObj.transform.SetParent(GameObject.Find("VOXELIZER").transform);
                 voxObj.GetComponent<SingleCube>().Voxel();
                 voxObj.GetComponent<SingleCube>().Id = voxels.Count;
                 voxObj.GetComponent<SingleCube>().Origin = voxPos;
                 var scale = increment * 0.9f;
                 voxObj.transform.localScale = new Vector3(scale, 0.9f * voxelHeight, scale);
                 var small = SingleCube.scale;
                 voxObj.GetComponent<BoxCollider>().size = new Vector3(small, small, small);
                 var newVox = new VoxelClass();
                 newVox.Id = (float)voxels.Count;
                 newVox.Origin = voxPos;
                 newVox.singleCube = voxObj.GetComponent<SingleCube>();
                 voxObj.GetComponent<SingleCube>().voxelClass = newVox;
                 newVox.Voxel = voxObj;
                 voxels.Add(voxPos, newVox);
                 highlights.Add(voxPos);
                 InspectorR.highlightVector = voxPos;
             }
             foreach (var line in layer.gcdLines)
             {
                 if (line.MovesInX)
                 {
                     if (line.p1.z >= slox.Position.z - inc / 2 && line.p1.z <= slox.Position.z + inc / 2)
                     {
                         var m = line.p2 - line.p1;
                         var sloxMinX = slox.Position.x - inc / 2;
                         var sloxMaxX = slox.Position.x + inc / 2;
                         var factorMinX = (sloxMinX - line.p1.x) / m.x;
                         var factorMaxX = (sloxMaxX - line.p1.x) / m.x;
                         if ((factorMinX >= 0 && factorMinX <= 1)
                             || (factorMaxX >= 0 && factorMaxX <= 1))
                         {
                             if (line.step < slox.MinLineNumber)
                                 slox.MinLineNumber = line.step;
                             if (line.step > slox.MaxLineNumber)
                                 slox.MaxLineNumber = line.step;
                             if (!slox.IntersectedByLines.Contains(line))
                             {
                                 foreach (var cb in line.CrazyBalls)
                                 {
                                     if (cb.t >= factorMinX && cb.t < factorMaxX)
                                     {
                                         slox.CrazyBalls.Add(cb);
                                     }
                                 }
                                 slox.IntersectedByLines.Add(line);
                             }
                         }
                     }
                 }
                 else if (line.MovesInZ)
                 {
                     if (line.p1.x >= slox.Position.x - inc / 2 && line.p1.x <= slox.Position.x + inc / 2)
                     {
                         var m = line.p2 - line.p1;
                         var sloxMinZ = slox.Position.z - inc / 2;
                         var sloxMaxZ = slox.Position.z + inc / 2;
                         var factorMinZ = (sloxMinZ - line.p1.z) / m.z;
                         var factorMaxZ = (sloxMaxZ - line.p1.z) / m.z;
                         if ((factorMinZ >= 0 && factorMinZ <= 1)
                             || (factorMaxZ >= 0 && factorMaxZ <= 1))
                         {
                             if (line.step < slox.MinLineNumber)
                                 slox.MinLineNumber = line.step;
                             if (line.step > slox.MaxLineNumber)
                                 slox.MaxLineNumber = line.step;
                             if (!slox.IntersectedByLines.Contains(line))
                             {
                                 foreach (var cb in line.CrazyBalls)
                                 {
                                     if (cb.t >= factorMinZ && cb.t < factorMaxZ)
                                     {
                                         slox.CrazyBalls.Add(cb);
                                     }
                                 }
                                 slox.IntersectedByLines.Add(line);
                             }
                         }
                     }
                 }
             }
             var v = voxels[voxPos];
             if (slox.MinLineNumber < v.MinLine)
                 v.MinLine = slox.MinLineNumber;
             if (slox.MaxLineNumber > v.MaxLine)
                 v.MaxLine = slox.MaxLineNumber;
             slox.Voxel = v;
             if (!layer.Voxels.Contains(v))
             {
                 layer.Voxels.Add(v);
             }
             slox.VoxelOrigin = voxPos;
             foreach (var cb in slox.CrazyBalls)
             {
                 v.CrazyBalls.Add(cb);
             }
             v.Sloxels.Add(slox);
         }
     }
 }