Esempio n. 1
0
        private static ToolResult ConvertObjToSmd(string objFile, string smdOutput, bool useTextureName)
        {
            bool    success = false;
            string  message = "";
            ObjData objData = ObjParser.TryParseObj(objFile);

            if (objData != null)
            {
                objData.UpdateMtlData();
                MtlData mtlData = objData.Mtl;

                if (mtlData == null)
                {
                    // No MTL means the SMD will use a default material name for all objects
                    useTextureName = false;
                }
                success = SmdExporter.WriteSmd(objData, mtlData, smdOutput, useTextureName);
                message = MessageBoxConstants.GetMessageExecutionCreation(success, smdOutput);
            }
            else
            {
                message = MessageBoxConstants.GetMessageExecutionErrorParse(objFile);
            }
            return(new ToolResult(message, success));
        }
Esempio n. 2
0
        private static ToolResult ConvertRefModelSmd(string objFile, string smdOutput, Dictionary <string, string> inputs)
        {
            bool          success = false;
            bool          warn    = false;
            StringBuilder sb      = new StringBuilder();
            ObjData       objData = ObjParser.TryParseObj(objFile);

            if (objData != null)
            {
                // Delete all materials
                ObjModifier.DeleteMaterials(objData);

                // Scale the model by the given value
                if (inputs.TryGetValue(DictConstants.ScaleValue, out string scaleStr))
                {
                    if (Double.TryParse(scaleStr, out double scaleValue))
                    {
                        ObjModifier.UniformScale(objData, scaleValue); // Scale Model
                    }
                    else
                    {
                        warn = true;
                        sb.AppendLine(MessageBoxConstants.MessageErrorScale + MessageBoxConstants.MessageInvalidScaleValue);
                    }
                }

                // The SMD will use a default material name for all objects
                success = SmdExporter.WriteSmd(objData, null, smdOutput, false);
                sb.Append(MessageBoxConstants.GetMessageExecutionCreation(success, smdOutput));
            }
            else
            {
                sb.Append(MessageBoxConstants.GetMessageExecutionErrorParse(objFile));
            }
            return(new ToolResult(sb.ToString(), success, warn));
        }