Moving examples, mapgenerator, and VisualParamGenerator to Programs folder (SVN is seriously ruined still, don't check out yet)
git-svn-id: http://libopenmetaverse.googlecode.com/svn/trunk@1961 52acb1d6-8a22-11de-b505-999d5b087335
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>8.0.50727</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{98C44481-3F15-4305-840D-037EA0D9C221}</ProjectGuid>
|
||||
<OutputType>Exe</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>BodyPartMorphGenerator</RootNamespace>
|
||||
<AssemblyName>GenBodyParams</AssemblyName>
|
||||
<StartupObject>BodyPartMorphGenerator.GenBodyParams</StartupObject>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>..\..\..\bin\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="GenBodyParams.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
||||
@@ -0,0 +1,33 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("BodyPartMorphGenerator")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("BodyPartMorphGenerator")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2006")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("d60d839c-ea04-4784-a308-b94f8698b388")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
342
Programs/examples/BodyPartMorphGenerator/genbodyparams.cs
Normal file
342
Programs/examples/BodyPartMorphGenerator/genbodyparams.cs
Normal file
@@ -0,0 +1,342 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Xml;
|
||||
|
||||
namespace BodyPartMorphGenerator
|
||||
{
|
||||
class GenBodyParams
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
string FileName = "avatar_lad.xml";
|
||||
string outFileParts = "_BodyShapeParams_.cs";
|
||||
|
||||
if (args.Length < 1)
|
||||
{
|
||||
if (!File.Exists(FileName))
|
||||
{
|
||||
Console.WriteLine("Usage: genbodyparams [" + FileName + "]");
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
FileName = args[0];
|
||||
if (!File.Exists(FileName))
|
||||
{
|
||||
Console.WriteLine("Could not find file: " + FileName);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (args.Length == 2)
|
||||
{
|
||||
outFileParts = args[1];
|
||||
}
|
||||
|
||||
XmlDocument doc = new XmlDocument();
|
||||
doc.LoadXml(File.ReadAllText(FileName));
|
||||
|
||||
XmlNodeList list = doc.GetElementsByTagName("param");
|
||||
|
||||
StringWriter MasterClass = new StringWriter();
|
||||
MasterClass.WriteLine("using System;");
|
||||
MasterClass.WriteLine("using System.Collections.Generic;");
|
||||
MasterClass.WriteLine("using System.IO;");
|
||||
MasterClass.WriteLine("using System.Text;");
|
||||
// MasterClass.WriteLine();
|
||||
// MasterClass.WriteLine("using libsecondlife.AssetSystem.BodyShape;");
|
||||
MasterClass.WriteLine();
|
||||
MasterClass.WriteLine("namespace libsecondlife.AssetSystem");
|
||||
MasterClass.WriteLine("{");
|
||||
MasterClass.WriteLine(" public class BodyShapeParams");
|
||||
MasterClass.WriteLine(" {");
|
||||
|
||||
StringWriter Labels = new StringWriter();
|
||||
Labels.WriteLine(" public static string GetLabel( uint Param )");
|
||||
Labels.WriteLine(" {");
|
||||
Labels.WriteLine(" switch( Param )");
|
||||
Labels.WriteLine(" {");
|
||||
Labels.WriteLine(" default:");
|
||||
Labels.WriteLine(" return \"\";");
|
||||
|
||||
StringWriter LabelMin = new StringWriter();
|
||||
LabelMin.WriteLine(" public static string GetLabelMin( uint Param )");
|
||||
LabelMin.WriteLine(" {");
|
||||
LabelMin.WriteLine(" switch( Param )");
|
||||
LabelMin.WriteLine(" {");
|
||||
LabelMin.WriteLine(" default:");
|
||||
LabelMin.WriteLine(" throw new Exception(\"Unknown Body Part Parameter: \" + Param);");
|
||||
|
||||
StringWriter LabelMax = new StringWriter();
|
||||
LabelMax.WriteLine(" public static string GetLabelMax( uint Param )");
|
||||
LabelMax.WriteLine(" {");
|
||||
LabelMax.WriteLine(" switch( Param )");
|
||||
LabelMax.WriteLine(" {");
|
||||
LabelMax.WriteLine(" default:");
|
||||
LabelMax.WriteLine(" throw new Exception(\"Unknown Body Part Parameter: \" + Param);");
|
||||
|
||||
|
||||
StringWriter Names = new StringWriter();
|
||||
Names.WriteLine(" public static string GetName( uint Param )");
|
||||
Names.WriteLine(" {");
|
||||
Names.WriteLine(" switch( Param )");
|
||||
Names.WriteLine(" {");
|
||||
Names.WriteLine(" default:");
|
||||
Names.WriteLine(" throw new Exception(\"Unknown Body Part Parameter: \" + Param);");
|
||||
|
||||
StringWriter ValueMin = new StringWriter();
|
||||
ValueMin.WriteLine(" public static float GetValueMin( uint Param )");
|
||||
ValueMin.WriteLine(" {");
|
||||
ValueMin.WriteLine(" switch( Param )");
|
||||
ValueMin.WriteLine(" {");
|
||||
ValueMin.WriteLine(" default:");
|
||||
ValueMin.WriteLine(" throw new Exception(\"Unknown Body Part Parameter: \" + Param);");
|
||||
|
||||
StringWriter ValueMax = new StringWriter();
|
||||
ValueMax.WriteLine(" public static float GetValueMax( uint Param )");
|
||||
ValueMax.WriteLine(" {");
|
||||
ValueMax.WriteLine(" switch( Param )");
|
||||
ValueMax.WriteLine(" {");
|
||||
ValueMax.WriteLine(" default:");
|
||||
ValueMax.WriteLine(" throw new Exception(\"Unknown Body Part Parameter: \" + Param);");
|
||||
|
||||
StringWriter ValueDefault = new StringWriter();
|
||||
ValueDefault.WriteLine(" public static float GetValueDefault( uint Param )");
|
||||
ValueDefault.WriteLine(" {");
|
||||
ValueDefault.WriteLine(" switch( Param )");
|
||||
ValueDefault.WriteLine(" {");
|
||||
ValueDefault.WriteLine(" default:");
|
||||
ValueDefault.WriteLine(" throw new Exception(\"Unknown Body Part Parameter: \" + Param);");
|
||||
|
||||
StringWriter ValueValid = new StringWriter();
|
||||
ValueValid.WriteLine(" public static bool IsValueValid( uint Param, float Value )");
|
||||
ValueValid.WriteLine(" {");
|
||||
ValueValid.WriteLine(" switch( Param )");
|
||||
ValueValid.WriteLine(" {");
|
||||
ValueValid.WriteLine(" default:");
|
||||
ValueValid.WriteLine(" throw new Exception(\"Unknown Body Part Parameter: \" + Param);");
|
||||
|
||||
|
||||
List<string> EditGroups = new List<string>();
|
||||
|
||||
// XmlTextWriter xtw = new XmlTextWriter(sw);
|
||||
|
||||
File.Delete("ParamTable.csv");
|
||||
StreamWriter ParamTable = File.AppendText("ParamTable.csv");
|
||||
ParamTable.WriteLine("ID\tName\tEditGroup\tLabel\tLabelMin\tLabelMax\tMinValue\tMaxValue");
|
||||
|
||||
foreach( XmlNode node in list )
|
||||
{
|
||||
if ((node.Attributes["shared"] != null) && (node.Attributes["shared"].Value.Equals("1")))
|
||||
{
|
||||
// this param will have been already been defined
|
||||
continue;
|
||||
}
|
||||
|
||||
if (
|
||||
(node.Attributes["edit_group"] != null)
|
||||
&& ( node.Attributes["edit_group"].Value.Equals("driven")
|
||||
// || node.Attributes["edit_group"].Value.Equals("dummy")
|
||||
)
|
||||
)
|
||||
{
|
||||
// this param is calculated by the client based on other params
|
||||
continue;
|
||||
}
|
||||
/*
|
||||
if( node.Attributes["edit_group"] != null )
|
||||
{
|
||||
if( !EditGroups.Contains( node.Attributes["edit_group"].Value ) )
|
||||
{
|
||||
EditGroups.Add(node.Attributes["edit_group"].Value);
|
||||
Console.WriteLine(node.Attributes["edit_group"].Value);
|
||||
}
|
||||
}
|
||||
*/
|
||||
// Used to identify which nodes are bodyshape parameter nodes
|
||||
if ( node.Attributes["id"] != null
|
||||
&& node.Attributes["name"] != null
|
||||
&& node.Attributes["wearable"] != null
|
||||
// && ( (node.Attributes["label"] != null) || (node.Attributes["label_min"] != null) )
|
||||
)
|
||||
{
|
||||
string ParamName = node.Attributes["name"].Value;
|
||||
Console.WriteLine(ParamName);
|
||||
string ParamEditGroup = "";
|
||||
if( node.Attributes["edit_group"] != null )
|
||||
{
|
||||
ParamEditGroup = node.Attributes["edit_group"].Value;
|
||||
}
|
||||
|
||||
string ParamLabel = "";
|
||||
string ParamLabelMin = "";
|
||||
string ParamLabelMax = "";
|
||||
string ParamMin = "";
|
||||
string ParamMax = "";
|
||||
|
||||
|
||||
string ID = node.Attributes["id"].Value;
|
||||
|
||||
|
||||
|
||||
if (node.Attributes["label"] != null)
|
||||
{
|
||||
// Label
|
||||
Labels.WriteLine(" case " + ID + ":");
|
||||
Labels.WriteLine(" return \"" + node.Attributes["label"].Value + "\";");
|
||||
|
||||
ParamLabel = node.Attributes["label"].Value;
|
||||
}
|
||||
|
||||
if (node.Attributes["label_min"] != null)
|
||||
{
|
||||
// Label Min
|
||||
LabelMin.WriteLine(" case " + ID + ":");
|
||||
LabelMin.WriteLine(" return \"" + node.Attributes["label_min"].Value + "\";");
|
||||
|
||||
ParamLabelMin = node.Attributes["label_min"].Value;
|
||||
}
|
||||
|
||||
if (node.Attributes["label_max"] != null)
|
||||
{
|
||||
// Label Max
|
||||
LabelMax.WriteLine(" case " + ID + ":");
|
||||
LabelMax.WriteLine(" return \"" + node.Attributes["label_max"].Value + "\";");
|
||||
|
||||
ParamLabelMax = node.Attributes["label_max"].Value;
|
||||
}
|
||||
|
||||
// Name
|
||||
Names.WriteLine(" case " + ID + ":");
|
||||
Names.WriteLine(" return \"" + node.Attributes["name"].Value + "\";");
|
||||
|
||||
// Min Values
|
||||
ValueMin.WriteLine(" case " + ID + ":");
|
||||
ValueMin.WriteLine(" return " + node.Attributes["value_min"].Value + "f;");
|
||||
|
||||
ParamMin = node.Attributes["value_min"].Value;
|
||||
|
||||
// Max Values
|
||||
ValueMax.WriteLine(" case " + ID + ":");
|
||||
ValueMax.WriteLine(" return " + node.Attributes["value_max"].Value + "f;");
|
||||
|
||||
ParamMax = node.Attributes["value_max"].Value;
|
||||
|
||||
// Default values
|
||||
if (node.Attributes["value_default"] != null)
|
||||
{
|
||||
ValueDefault.WriteLine(" case " + ID + ":");
|
||||
ValueDefault.WriteLine(" return " + node.Attributes["value_default"].Value + "f;");
|
||||
}
|
||||
else
|
||||
{
|
||||
ValueDefault.WriteLine(" case " + ID + ":");
|
||||
ValueDefault.WriteLine(" return " + node.Attributes["value_min"].Value + "f;");
|
||||
}
|
||||
|
||||
// Validation Values
|
||||
ValueValid.WriteLine(" case " + node.Attributes["id"].Value + ":");
|
||||
ValueValid.WriteLine(" return ( (Value >= " + node.Attributes["value_min"].Value + "f) && (Value <= " + node.Attributes["value_max"].Value + "f) );");
|
||||
|
||||
ParamTable.WriteLine( ID
|
||||
+ "\t" + ParamName
|
||||
+ "\t" + ParamEditGroup
|
||||
+ "\t" + ParamLabel
|
||||
+ "\t" + ParamLabelMin
|
||||
+ "\t" + ParamLabelMax
|
||||
+ "\t" + ParamMin
|
||||
+ "\t" + ParamMax);
|
||||
}
|
||||
}
|
||||
|
||||
ParamTable.Flush();
|
||||
ParamTable.Close();
|
||||
|
||||
// Finish up name stuff
|
||||
Names.WriteLine(" }"); // Close switch
|
||||
Names.WriteLine(" }"); // Close method
|
||||
|
||||
// Finish up label stuff
|
||||
Labels.WriteLine(" }"); // Close switch
|
||||
Labels.WriteLine(" }"); // Close method
|
||||
|
||||
// Finish up min label stuff
|
||||
LabelMin.WriteLine(" }"); // Close switch
|
||||
LabelMin.WriteLine(" }"); // Close method
|
||||
|
||||
// Finish up max label stuff
|
||||
LabelMax.WriteLine(" }"); // Close switch
|
||||
LabelMax.WriteLine(" }"); // Close method
|
||||
|
||||
// Finish up Max Value stuff
|
||||
ValueMin.WriteLine(" }"); // Close switch
|
||||
ValueMin.WriteLine(" }"); // Close method
|
||||
|
||||
// Finish up Min Value stuff
|
||||
ValueMax.WriteLine(" }"); // Close switch
|
||||
ValueMax.WriteLine(" }"); // Close method
|
||||
|
||||
// Finish up Default Value stuff
|
||||
ValueDefault.WriteLine(" }"); // Close switch
|
||||
ValueDefault.WriteLine(" }"); // Close method
|
||||
|
||||
// Finish up Value Valid stuff
|
||||
ValueValid.WriteLine(" }"); // Close switch
|
||||
ValueValid.WriteLine(" }"); // Close method
|
||||
|
||||
|
||||
StringWriter ValidateAll = new StringWriter();
|
||||
ValidateAll.WriteLine(" public static bool IsValid( Dictionary<uint,float> BodyShape )");
|
||||
ValidateAll.WriteLine(" {");
|
||||
ValidateAll.WriteLine(" foreach(KeyValuePair<uint, float> kvp in BodyShape)");
|
||||
ValidateAll.WriteLine(" {");
|
||||
ValidateAll.WriteLine(" if( !IsValueValid(kvp.Key, kvp.Value) ) { return false; }");
|
||||
ValidateAll.WriteLine(" }");
|
||||
ValidateAll.WriteLine("");
|
||||
ValidateAll.WriteLine(" return true;");
|
||||
ValidateAll.WriteLine(" }");
|
||||
|
||||
StringWriter ToString = new StringWriter();
|
||||
ToString.WriteLine(" public static string ToString( Dictionary<uint,float> BodyShape )");
|
||||
ToString.WriteLine(" {");
|
||||
ToString.WriteLine(" StringWriter sw = new StringWriter();");
|
||||
ToString.WriteLine("");
|
||||
ToString.WriteLine(" foreach(KeyValuePair<uint, float> kvp in BodyShape)");
|
||||
ToString.WriteLine(" {");
|
||||
ToString.WriteLine(" sw.Write( kvp.Key + \":\" );");
|
||||
ToString.WriteLine(" sw.Write( GetLabel(kvp.Key) + \":\" );");
|
||||
ToString.WriteLine(" sw.WriteLine( kvp.Value );");
|
||||
ToString.WriteLine(" }");
|
||||
ToString.WriteLine("");
|
||||
ToString.WriteLine(" return sw.ToString();");
|
||||
ToString.WriteLine(" }");
|
||||
|
||||
|
||||
|
||||
// Combine Master Class
|
||||
MasterClass.Write(Names.ToString());
|
||||
MasterClass.Write(Labels.ToString());
|
||||
MasterClass.Write(LabelMin.ToString());
|
||||
MasterClass.Write(LabelMax.ToString());
|
||||
MasterClass.Write(ValueMin.ToString());
|
||||
MasterClass.Write(ValueMax.ToString());
|
||||
MasterClass.Write(ValueDefault.ToString());
|
||||
MasterClass.Write(ValueValid.ToString());
|
||||
MasterClass.Write(ValidateAll.ToString());
|
||||
MasterClass.Write(ToString.ToString());
|
||||
|
||||
// Finish up the file
|
||||
MasterClass.WriteLine(" }"); // Close Class
|
||||
MasterClass.WriteLine("}"); // Close Namespace
|
||||
|
||||
Console.WriteLine("Writing " + outFileParts + "...");
|
||||
File.WriteAllText(outFileParts, MasterClass.ToString());
|
||||
|
||||
// Console.WriteLine(PartClasses.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user