Exemplo n.º 1
0
 public static extern Int32 rtcNewSubdivisionMesh(IntPtr scene,
                                                  GeometryFlags flags,
                                                  UIntPtr numFaces,
                                                  UIntPtr numEdges,
                                                  UIntPtr numVertices,
                                                  UIntPtr numEdgeCreases,
                                                  UIntPtr numVertexCreases,
                                                  UIntPtr numHoles,
                                                  UIntPtr numTimeSteps);
Exemplo n.º 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MagickGeometry"/> class using the specified geometry.
        /// </summary>
        /// <param name="value">Geometry specifications in the form: &lt;width&gt;x&lt;height&gt;
        /// {+-}&lt;xoffset&gt;{+-}&lt;yoffset&gt; (where width, height, xoffset, and yoffset are numbers)</param>
        public MagickGeometry(string value)
        {
            Throw.IfNullOrEmpty(nameof(value), value);

            using (NativeMagickGeometry instance = new NativeMagickGeometry())
            {
                GeometryFlags flags = instance.Initialize(value);
                Initialize(instance, flags);
            }
        }
Exemplo n.º 3
0
        public void Deserialize(BitReader reader)
        {
            Mesh = new Mesh();

            Header = new byte[4];

            for (var i = 0; i < 4; i++)
            {
                Header[i] = reader.Read <byte>();

                Console.Write($" [{Header[i]}] ");
            }

            var vertexCount = reader.Read <uint>();
            var indexCount  = reader.Read <uint>();

            Flags = (GeometryFlags)reader.Read <uint>();

            Mesh.Vertices = new Vector3[vertexCount];

            for (var i = 0; i < vertexCount; i++)
            {
                Mesh.Vertices[i] = reader.Read <Vector3>();
            }

            Mesh.Normals = new Vector3[vertexCount];

            if ((Flags & GeometryFlags.Normals) == GeometryFlags.Normals)
            {
                for (var i = 0; i < vertexCount; i++)
                {
                    Mesh.Normals[i] = reader.Read <Vector3>();
                }
            }

            Mesh.Uv = new Vector2[vertexCount];

            if ((Flags & GeometryFlags.Uv) == GeometryFlags.Uv)
            {
                for (var i = 0; i < vertexCount; i++)
                {
                    Mesh.Uv[i] = reader.Read <Vector2>();
                }
            }

            Mesh.Triangles = new int[indexCount];

            for (var i = 0; i < indexCount; i++)
            {
                Mesh.Triangles[i] = (int)reader.Read <uint>();
            }

            // I'm aware there is more stuff to be read with different flags, but the content is unknown. If you
            // want to add them, be my guest.
        }
Exemplo n.º 4
0
        private void Initialize(NativeMagickGeometry instance, GeometryFlags flags)
        {
            Throw.IfTrue(nameof(flags), flags == GeometryFlags.NoValue, "Invalid geometry specified.");

            Initialize(instance);

            IsPercentage      = EnumHelper.HasFlag(flags, GeometryFlags.PercentValue);
            IgnoreAspectRatio = EnumHelper.HasFlag(flags, GeometryFlags.IgnoreAspectRatio);
            FillArea          = EnumHelper.HasFlag(flags, GeometryFlags.FillArea);
            Greater           = EnumHelper.HasFlag(flags, GeometryFlags.Greater);
            Less        = EnumHelper.HasFlag(flags, GeometryFlags.Less);
            LimitPixels = EnumHelper.HasFlag(flags, GeometryFlags.LimitPixels);
        }
Exemplo n.º 5
0
    private void Initialize(NativeMagickGeometry instance, GeometryFlags flags)
    {
      Throw.IfTrue(nameof(flags), flags == GeometryFlags.NoValue, "Invalid geometry specified.");

      Initialize(instance);

      IsPercentage = EnumHelper.HasFlag(flags, GeometryFlags.PercentValue);
      IgnoreAspectRatio = EnumHelper.HasFlag(flags, GeometryFlags.IgnoreAspectRatio);
      FillArea = EnumHelper.HasFlag(flags, GeometryFlags.FillArea);
      Greater = EnumHelper.HasFlag(flags, GeometryFlags.Greater);
      Less = EnumHelper.HasFlag(flags, GeometryFlags.Less);
      LimitPixels = EnumHelper.HasFlag(flags, GeometryFlags.LimitPixels);
    }
Exemplo n.º 6
0
        public static Int32 NewHairGeometry(IntPtr scene,
                                            GeometryFlags flags,
                                            UIntPtr numCurves,
                                            UIntPtr numVertices,
                                            UIntPtr numTimeSteps)
        {
            var retval = NativeMethods.rtcNewHairGeometry(scene,
                                                          flags,
                                                          numCurves,
                                                          numVertices,
                                                          numTimeSteps);

            CheckLastError();
            return(retval);
        }
Exemplo n.º 7
0
        public static Int32 NewTriangleMesh(IntPtr scene,
                                            GeometryFlags flags,
                                            int numTriangles,
                                            int numVertices,
                                            int numTimeSteps)
        {
            var retval = NativeMethods.rtcNewTriangleMesh(scene,
                                                          flags,
                                                          (UIntPtr)numTriangles,
                                                          (UIntPtr)numVertices,
                                                          (UIntPtr)numTimeSteps);

            CheckLastError();
            return(retval);
        }
Exemplo n.º 8
0
        public static Int32 NewSubdivisionMesh(IntPtr scene,
                                               GeometryFlags flags,
                                               UIntPtr numFaces,
                                               UIntPtr numEdges,
                                               UIntPtr numVertices,
                                               UIntPtr numEdgeCreases,
                                               UIntPtr numVertexCreases,
                                               UIntPtr numHoles,
                                               UIntPtr numTimeSteps)
        {
            var retval = NativeMethods.rtcNewSubdivisionMesh(scene,
                                                             flags,
                                                             numFaces,
                                                             numEdges,
                                                             numVertices,
                                                             numEdgeCreases,
                                                             numVertexCreases,
                                                             numHoles,
                                                             numTimeSteps);

            CheckLastError();
            return(retval);
        }
        public GeometryStruct_0001 Read(BinaryReader binaryReader)
        {
            sectionIdentifier = Section.Struct;
            sectionSize       = binaryReader.ReadInt32();
            renderWareVersion = binaryReader.ReadInt32();

            if (ReadFileMethods.treatStuffAsByteArray)
            {
                sectionData = binaryReader.ReadBytes(sectionSize);
                return(this);
            }

            long startSectionPosition = binaryReader.BaseStream.Position;

            geometryFlags   = (GeometryFlags)binaryReader.ReadInt16();
            geometryFlags2  = (GeometryFlags2)binaryReader.ReadInt16();
            numTriangles    = binaryReader.ReadInt32();
            numVertices     = binaryReader.ReadInt32();
            numMorphTargets = binaryReader.ReadInt32();

            if (Shared.UnpackLibraryVersion(renderWareVersion) < 0x34000)
            {
                ambient  = binaryReader.ReadSingle();
                specular = binaryReader.ReadSingle();
                diffuse  = binaryReader.ReadSingle();
            }

            if ((geometryFlags2 & GeometryFlags2.isNativeGeometry) != 0)
            {
                binaryReader.BaseStream.Position = startSectionPosition + sectionSize;
                return(this);
            }

            if ((geometryFlags & GeometryFlags.hasVertexColors) != 0)
            {
                vertexColors = new Color[numVertices];
                for (int i = 0; i < numVertices; i++)
                {
                    vertexColors[i] = new Color()
                    {
                        R = binaryReader.ReadByte(),
                        G = binaryReader.ReadByte(),
                        B = binaryReader.ReadByte(),
                        A = binaryReader.ReadByte()
                    };
                }
            }

            if ((geometryFlags & GeometryFlags.hasTextCoords) != 0)
            {
                textCoords = new Vertex2[numVertices];
                for (int i = 0; i < numVertices; i++)
                {
                    textCoords[i] = new Vertex2()
                    {
                        X = binaryReader.ReadSingle(),
                        Y = binaryReader.ReadSingle()
                    };
                }

                if ((geometryFlags & GeometryFlags.hasTextCoords2) != 0)
                {
                    binaryReader.BaseStream.Position += numVertices * 8;
                }
            }
            else if ((geometryFlags & GeometryFlags.hasTextCoords2) != 0)
            {
                textCoords = new Vertex2[numVertices * 2];
                for (int i = 0; i < numVertices * 2; i++)
                {
                    textCoords[i] = new Vertex2()
                    {
                        X = binaryReader.ReadSingle(),
                        Y = binaryReader.ReadSingle()
                    };
                }
            }

            triangles = new Triangle[numTriangles];
            for (int i = 0; i < numTriangles; i++)
            {
                triangles[i] = new Triangle()
                {
                    vertex2       = binaryReader.ReadUInt16(),
                    vertex1       = binaryReader.ReadUInt16(),
                    materialIndex = binaryReader.ReadUInt16(),
                    vertex3       = binaryReader.ReadUInt16()
                };
            }

            morphTargets = new MorphTarget[numMorphTargets];
            for (int i = 0; i < numMorphTargets; i++)
            {
                MorphTarget m = new MorphTarget();

                m.sphereCenter.X = binaryReader.ReadSingle();
                m.sphereCenter.Y = binaryReader.ReadSingle();
                m.sphereCenter.Z = binaryReader.ReadSingle();
                m.radius         = binaryReader.ReadSingle();
                m.hasVertices    = binaryReader.ReadInt32();
                m.hasNormals     = binaryReader.ReadInt32();

                if (m.hasVertices != 0)
                {
                    m.vertices = new Vertex3[numVertices];
                    for (int j = 0; j < numVertices; j++)
                    {
                        m.vertices[j] = new Vertex3()
                        {
                            X = binaryReader.ReadSingle(),
                            Y = binaryReader.ReadSingle(),
                            Z = binaryReader.ReadSingle()
                        };
                    }
                }

                if (m.vertices == null)
                {
                    throw new Exception();
                }

                if (m.hasNormals != 0)
                {
                    m.normals = new Vertex3[numVertices];
                    for (int j = 0; j < numVertices; j++)
                    {
                        m.normals[j] = new Vertex3()
                        {
                            X = binaryReader.ReadSingle(),
                            Y = binaryReader.ReadSingle(),
                            Z = binaryReader.ReadSingle()
                        };
                    }
                }

                morphTargets[i] = m;
            }

            return(this);
        }
        public void ValidateGeometryReturnsExpectedResult(GeometryFlags flags, string value, bool expected)
        {
            var sut = new WktGeometryAttribute(flags);

            Assert.Equal(expected, sut.IsValid(value));
        }
Exemplo n.º 11
0
 /// <summary>
 /// Initializes a new instance of the <see cref="WktGeometryAttribute"/> class.
 /// </summary>
 /// <param name="allowedTypes">The allowed geometry types.</param>
 public WktGeometryAttribute(GeometryFlags allowedTypes = GeometryFlags.Default)
 {
     this.AllowedTypes = allowedTypes;
 }
Exemplo n.º 12
0
 /// <summary>
 /// Initializes a new instance of the <see cref="WktGeometryAttribute"/> class.
 /// </summary>
 /// <param name="allowedTypes">The allowed geometry types.</param>
 public WktGeometryAttribute(GeometryFlags allowedTypes = GeometryFlags.Default)
 {
     this.AllowedTypes = allowedTypes;
 }
        public void ValidateGeometryReturnsExpectedResult(GeometryFlags flags, string value, bool expected)
        {
            var sut = new WktGeometryAttribute(flags);

            Assert.Equal(expected, sut.IsValid(value));
        }
Exemplo n.º 14
0
 public static extern Int32 rtcNewHairGeometry(IntPtr scene,
                                               GeometryFlags flags,
                                               UIntPtr numCurves,
                                               UIntPtr numVertices,
                                               UIntPtr numTimeSteps);
Exemplo n.º 15
0
 public static extern Int32 rtcNewTriangleMesh(IntPtr scene,
                                               GeometryFlags flags,
                                               UIntPtr numTriangles,
                                               UIntPtr numVertices,
                                               UIntPtr numTimeSteps);