Example #1
0
 public float intersects(Triangle tri, ref Vector3 collisionPoint, ref Vector3 surfaceNormal)
 {
     throw new System.NotImplementedException("Triangle intersection not implemented yet. GPU only.");
 }
Example #2
0
 public float intersects(Triangle tri)
 {
     throw new System.NotImplementedException("Triangle intersection not implemented yet. GPU only.");
 }
Example #3
0
        public void addTriangle(Vector3 point0, Vector3 point1, Vector3 point2, int materialIndex)
        {
            // Pack triangle
            Triangle tri = new Triangle(point0, point1, point2, materialIndex);

            //_geometryArray[numTris++] = tri;

            // Translate to grid space.
            Vector3 p0 = point0 - _gridOrigin;
            Vector3 p1 = point1 - _gridOrigin;
            Vector3 p2 = point2 - _gridOrigin;

            int minX = (int)( System.Math.Min(p0.X, System.Math.Min(p1.X, p2.X))  / CellSize);
            int minY = (int)(System.Math.Min(p0.Y, System.Math.Min(p1.Y, p2.Y)) / CellSize);
            int minZ = (int)(System.Math.Min(p0.Z, System.Math.Min(p1.Z, p2.Z)) / CellSize);

            int maxX = (int)(System.Math.Max(p0.X, System.Math.Max(p1.X, p2.X)) / CellSize);
            int maxY = (int)(System.Math.Max(p0.Y, System.Math.Max(p1.Y, p2.Y)) / CellSize);
            int maxZ = (int)(System.Math.Max(p0.Z, System.Math.Max(p1.Z, p2.Z)) / CellSize);

            int cellCount = 0;

            // Add a reference to model to every cell the bounding box intesects
            for (int x = minX; x <= maxX; x++)
            {
                for (int y = minY; y <= maxY; y++)
                {
                    for (int z = minZ; z <= maxZ; z++)
                    {
                        Voxel voxelData = this[x, y, z];

                        int geometryIndex = (x * GridResolution * GridResolution + y * GridResolution + z) * VectorsPerVoxel;
                        _geometryArray[geometryIndex + voxelData.PrimitiveCount] = tri;

                        voxelData.PrimitiveCount += 1;
                        this[x, y, z] = voxelData;
                        cellCount++;
                    }
                }
            }
        }