예제 #1
0
        public override void readBinary(MIStream arg0, uint length)
        {
            MIStream instream = new MIStream(MIStream.getCPtr(arg0).Handle, false);

            MStreamUtils.readDouble(arg0, out fValue, true);
            return;
        }
예제 #2
0
 public override void readBinary(MIStream stream, uint length)
 //
 // Description
 //     NOT IMPLEMENTED
 //
 {
     MGlobal.displayInfo("apiMeshData.readBinary is called.");
     return;
 }
예제 #3
0
		public override void readBinary(MIStream stream, uint length)
		//
		// Description
		//     NOT IMPLEMENTED
		//
		{
            MGlobal.displayInfo("apiMeshData.readBinary is called.");
			return;
		}
예제 #4
0
        public override void doCreate()
        {
            Associations associationsRead = null;
            MIStream     inStream         = MStreamUtils.CreateIFStream(fileName);
            string       errors           = "";

            associationsRead = fSerialize.read(inStream, ref errors);
            if (associationsRead == null)
            {
                String fmt = MStringResource.getString(MetaDataRegisterMStringResources.kImportMetadataFileReadFailed);
                String msg;
                if (errors == null || errors.Length < 1)
                {
                    errors = "No errors was given by the serializer when reading the metadata file.";
                }
                msg = String.Format(fmt, fileName, errors);
                displayError(msg);
                throw new System.ApplicationException(msg);
            }

            String resultFmt = MStringResource.getString(MetaDataRegisterMStringResources.kImportMetadataResult);

            for (int i = 0; i < fMeshes.length; ++i)
            {
                MFnMesh mesh = new MFnMesh(fMeshes[i]);
                // Should have filtered out non-meshes already but check anyway
                if (mesh == null)
                {
                    continue;
                }

                displayInfo(mesh.fullPathName);
                //We dont have the correct interface on MDGModifier to assign metadata so no undo redo for now
                Associations associationsMesh = mesh.metadata;
                associationsMesh.assign(associationsRead);

                for (int c = 0; c < associationsRead.channelCount; ++c)
                {
                    Autodesk.Maya.MetaData.Channel channel = associationsRead.channelAt((uint)c);
                    String cName = channel.nameProperty;
                    for (int s = 0; s < channel.dataStreamCount; ++s)
                    {
                        Autodesk.Maya.MetaData.Stream cStream = channel.dataStream((uint)s);
                        if (cStream != null)
                        {
                            String sName = cStream.name;
                            String msg   = String.Format(resultFmt, mesh.fullPathName, cName, sName);
                            appendToResult(msg);
                        }
                    }
                }
            }
            MStreamUtils.Close(inStream);
            inStream = null;
        }
예제 #5
0
		public override Structure read(MIStream cSrc, ref string errors)
		{
			int errCount = 0;
			Structure newStructure = null;
			errors = "";

			uint size = MStreamUtils.getLength(cSrc);
			string myString = "";

			// The last argument is true since we don't want to stop reading a stream when a WhiteSpace is encountered.
			MStreamUtils.readCharBuffer(cSrc, out myString, size, true);

			XmlReader reader = XmlReader.Create(new System.IO.StringReader (myString));
			string elementName = "";
			while (reader.Read())
			{
				// Skip anything unrecognized, for maximum flexibility
				if (reader.NodeType != XmlNodeType.Element)
				{
					continue;
				}

				elementName = reader.Name;

				// Root must be a <structure> tag
				if (elementName == structureTag)
				{
					bool isStrucNameFound = reader.MoveToAttribute (structureNameAttribute);
					if (isStrucNameFound)
					{
						string structureName = reader.ReadContentAsString();
						newStructure = new Structure( structureName );
					}
					else
					{
						string msgFmt = MStringResource.getString(MetaDataRegisterMStringResources.kStructureXMLStructureNameNotFound);
						IXmlLineInfo xmlInfo = (IXmlLineInfo)reader;
						int lineNumber = xmlInfo.LineNumber;
						string errorMsg = String.Format(msgFmt, lineNumber.ToString());

						errors += errorMsg;
						errCount++;
						continue;
					}
				}

				if (newStructure == null)
				{
					continue;
				}

				// All children must all be <member> tags
				if (elementName == memberTag)
				{
					uint memberDim = 1;
					string memberName = "";
					string memberType = "";

					bool isMemberNameFound = reader.MoveToAttribute (memberNameAttribute);
					if (isMemberNameFound)
					{
						memberName = reader.ReadContentAsString();
					}
					else
					{
						string msgFmt = MStringResource.getString(MetaDataRegisterMStringResources.kStructureXMLMemberNameNotFound);
						IXmlLineInfo xmlInfo = (IXmlLineInfo)reader;
						int lineNumber = xmlInfo.LineNumber;
						string errorMsg = String.Format(msgFmt, lineNumber.ToString());
						errors += errorMsg;
						continue;
					}
					bool isMemberTypeFound = reader.MoveToAttribute (memberTypeAttribute);
					if (isMemberTypeFound)
					{
						memberType = reader.ReadContentAsString();
					}
					else
					{
						string msgFmt = MStringResource.getString(MetaDataRegisterMStringResources.kStructureXMLMemberTypeNotFound);
						IXmlLineInfo xmlInfo = (IXmlLineInfo)reader;
						int lineNumber = xmlInfo.LineNumber;
						string errorMsg = String.Format(msgFmt, lineNumber.ToString());
						errors += errorMsg;
						continue;
					}

                    bool isMemberDimFound = reader.MoveToAttribute(memberDimAttribute);
                    if (isMemberDimFound)
                        memberDim = (uint)reader.ReadContentAsInt();
                    else
                        memberDim = 1;

                    newStructure.addMember( Member.typeFromName(memberType),memberDim, memberName );
				}


			}

			// If there were errors any structure created will be incorrect so pass
			// back nothing rather than bad data.
			if( errCount > 0 )
				newStructure = null;

			return newStructure;
		}
예제 #6
0
		public override void readBinary(MIStream arg0, uint length)
		{
			MIStream instream = new MIStream(MIStream.getCPtr(arg0).Handle, false);
			MStreamUtils.readDouble(arg0, out fValue, true);
			return;
		}
예제 #7
0
 //
 // Description
 //     NOT IMPLEMENTED
 //
 public override void readBinary(MIStream stream, uint length)
 {
     MGlobal.displayInfo("apiMeshData.readBinary is called.");
     return;
 }
예제 #8
0
        public override Structure read(MIStream cSrc, ref string errors)
        {
            int       errCount     = 0;
            Structure newStructure = null;

            errors = "";

            uint   size     = MStreamUtils.getLength(cSrc);
            string myString = "";

            // The last argument is true since we don't want to stop reading a stream when a WhiteSpace is encountered.
            MStreamUtils.readCharBuffer(cSrc, out myString, size, true);

            XmlReader reader      = XmlReader.Create(new System.IO.StringReader(myString));
            string    elementName = "";

            while (reader.Read())
            {
                // Skip anything unrecognized, for maximum flexibility
                if (reader.NodeType != XmlNodeType.Element)
                {
                    continue;
                }

                elementName = reader.Name;

                // Root must be a <structure> tag
                if (elementName == structureTag)
                {
                    bool isStrucNameFound = reader.MoveToAttribute(structureNameAttribute);
                    if (isStrucNameFound)
                    {
                        string structureName = reader.ReadContentAsString();
                        newStructure = new Structure(structureName);
                    }
                    else
                    {
                        string       msgFmt     = MStringResource.getString(MetaDataRegisterMStringResources.kStructureXMLStructureNameNotFound);
                        IXmlLineInfo xmlInfo    = (IXmlLineInfo)reader;
                        int          lineNumber = xmlInfo.LineNumber;
                        string       errorMsg   = String.Format(msgFmt, lineNumber.ToString());

                        errors += errorMsg;
                        errCount++;
                        continue;
                    }
                }

                if (newStructure == null)
                {
                    continue;
                }

                // All children must all be <member> tags
                if (elementName == memberTag)
                {
                    uint   memberDim  = 1;
                    string memberName = "";
                    string memberType = "";

                    bool isMemberNameFound = reader.MoveToAttribute(memberNameAttribute);
                    if (isMemberNameFound)
                    {
                        memberName = reader.ReadContentAsString();
                    }
                    else
                    {
                        string       msgFmt     = MStringResource.getString(MetaDataRegisterMStringResources.kStructureXMLMemberNameNotFound);
                        IXmlLineInfo xmlInfo    = (IXmlLineInfo)reader;
                        int          lineNumber = xmlInfo.LineNumber;
                        string       errorMsg   = String.Format(msgFmt, lineNumber.ToString());
                        errors += errorMsg;
                        continue;
                    }
                    bool isMemberTypeFound = reader.MoveToAttribute(memberTypeAttribute);
                    if (isMemberTypeFound)
                    {
                        memberType = reader.ReadContentAsString();
                    }
                    else
                    {
                        string       msgFmt     = MStringResource.getString(MetaDataRegisterMStringResources.kStructureXMLMemberTypeNotFound);
                        IXmlLineInfo xmlInfo    = (IXmlLineInfo)reader;
                        int          lineNumber = xmlInfo.LineNumber;
                        string       errorMsg   = String.Format(msgFmt, lineNumber.ToString());
                        errors += errorMsg;
                        continue;
                    }

                    bool isMemberDimFound = reader.MoveToAttribute(memberDimAttribute);
                    if (isMemberDimFound)
                    {
                        memberDim = (uint)reader.ReadContentAsInt();
                    }
                    else
                    {
                        memberDim = 1;
                    }

                    newStructure.addMember(Member.typeFromName(memberType), memberDim, memberName);
                }
            }

            // If there were errors any structure created will be incorrect so pass
            // back nothing rather than bad data.
            if (errCount > 0)
            {
                newStructure = null;
            }

            return(newStructure);
        }