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:
186
Programs/VisualParamGenerator/VisualParamGenerator.cs
Normal file
186
Programs/VisualParamGenerator/VisualParamGenerator.cs
Normal file
@@ -0,0 +1,186 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Xml;
|
||||
|
||||
namespace VisualParamGenerator
|
||||
{
|
||||
class VisualParamGenerator
|
||||
{
|
||||
public static readonly System.Globalization.CultureInfo EnUsCulture =
|
||||
new System.Globalization.CultureInfo("en-us");
|
||||
|
||||
static void Main(string[] args)
|
||||
{
|
||||
if (args.Length < 2)
|
||||
{
|
||||
Console.WriteLine("Usage: VisualParamGenerator.exe [template.cs] [_VisualParams_.cs]");
|
||||
return;
|
||||
}
|
||||
else if (!File.Exists(args[0]))
|
||||
{
|
||||
Console.WriteLine("Couldn't find file " + args[0]);
|
||||
return;
|
||||
}
|
||||
|
||||
XmlNodeList list;
|
||||
TextWriter writer;
|
||||
|
||||
try
|
||||
{
|
||||
writer = new StreamWriter(args[1]);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
Console.WriteLine("Couldn't open " + args[1] + " for writing");
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
// Read in the template.cs file and write it to our output
|
||||
TextReader reader = new StreamReader(args[0]);
|
||||
writer.WriteLine(reader.ReadToEnd());
|
||||
reader.Close();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
Console.WriteLine("Couldn't read from file " + args[0]);
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
// Read in avatar_lad.xml
|
||||
Stream stream = OpenMetaverse.Helpers.GetResourceStream("avatar_lad.xml");
|
||||
StreamReader reader = new StreamReader(stream);
|
||||
|
||||
if (stream != null)
|
||||
{
|
||||
XmlDocument doc = new XmlDocument();
|
||||
doc.LoadXml(reader.ReadToEnd());
|
||||
list = doc.GetElementsByTagName("param");
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("Failed to load resource avatar_lad.xml. Are you missing a data folder?");
|
||||
return;
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine(e.ToString());
|
||||
return;
|
||||
}
|
||||
|
||||
SortedList<int, string> IDs = new SortedList<int, string>();
|
||||
StringWriter output = new StringWriter();
|
||||
|
||||
// Make sure we end up with 218 Group-0 VisualParams as a sanity check
|
||||
int count = 0;
|
||||
|
||||
foreach (XmlNode node in list)
|
||||
{
|
||||
if (node.Attributes["group"] == null)
|
||||
{
|
||||
// Sanity check that a group is assigned
|
||||
Console.WriteLine("Encountered a param with no group set!");
|
||||
continue;
|
||||
}
|
||||
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))
|
||||
{
|
||||
// This param is calculated by the client based on other params
|
||||
continue;
|
||||
}
|
||||
|
||||
// Confirm this is a valid VisualParam
|
||||
if (node.Attributes["id"] != null &&
|
||||
node.Attributes["name"] != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
int id = Int32.Parse(node.Attributes["id"].Value);
|
||||
|
||||
// Check for duplicates
|
||||
if (IDs.ContainsKey(id))
|
||||
continue;
|
||||
|
||||
string name = node.Attributes["name"].Value;
|
||||
int group = Int32.Parse(node.Attributes["group"].Value);
|
||||
|
||||
string wearable = "null";
|
||||
if (node.Attributes["wearable"] != null)
|
||||
wearable = "\"" + node.Attributes["wearable"].Value + "\"";
|
||||
|
||||
string label = "String.Empty";
|
||||
if (node.Attributes["label"] != null)
|
||||
label = "\"" + node.Attributes["label"].Value + "\"";
|
||||
|
||||
string label_min = "String.Empty";
|
||||
if (node.Attributes["label_min"] != null)
|
||||
label_min = "\"" + node.Attributes["label_min"].Value + "\"";
|
||||
|
||||
string label_max = "String.Empty";
|
||||
if (node.Attributes["label_max"] != null)
|
||||
label_max = "\"" + node.Attributes["label_max"].Value + "\"";
|
||||
|
||||
float min = Single.Parse(node.Attributes["value_min"].Value,
|
||||
System.Globalization.NumberStyles.Float, EnUsCulture.NumberFormat);
|
||||
float max = Single.Parse(node.Attributes["value_max"].Value,
|
||||
System.Globalization.NumberStyles.Float, EnUsCulture.NumberFormat);
|
||||
|
||||
float def;
|
||||
if (node.Attributes["value_default"] != null)
|
||||
def = Single.Parse(node.Attributes["value_default"].Value,
|
||||
System.Globalization.NumberStyles.Float, EnUsCulture.NumberFormat);
|
||||
else
|
||||
def = min;
|
||||
|
||||
IDs.Add(id,
|
||||
String.Format(" Params[{0}] = new VisualParam({0}, \"{1}\", {2}, {3}, {4}, {5}, {6}, {7}f, {8}f, {9}f);{10}",
|
||||
id, name, group, wearable, label, label_min, label_max, def, min, max, Environment.NewLine));
|
||||
|
||||
if (group == 0)
|
||||
++count;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine(e.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (count != 218)
|
||||
{
|
||||
Console.WriteLine("Ended up with the wrong number of Group-8 VisualParams! Exiting...");
|
||||
return;
|
||||
}
|
||||
|
||||
// Now that we've collected all the entries and sorted them, add them to our output buffer
|
||||
foreach (string line in IDs.Values)
|
||||
{
|
||||
output.Write(line);
|
||||
}
|
||||
|
||||
output.Write(" }" + Environment.NewLine);
|
||||
output.Write(" }" + Environment.NewLine);
|
||||
output.Write("}" + Environment.NewLine);
|
||||
|
||||
try
|
||||
{
|
||||
writer.Write(output.ToString());
|
||||
writer.Close();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine(e.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
62
Programs/VisualParamGenerator/VisualParamGenerator.csproj
Normal file
62
Programs/VisualParamGenerator/VisualParamGenerator.csproj
Normal file
@@ -0,0 +1,62 @@
|
||||
<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>{D2A514C5-5590-4789-9032-6E5B4C297B80}</ProjectGuid>
|
||||
<OutputType>Exe</OutputType>
|
||||
<RootNamespace>VisualParamGenerator</RootNamespace>
|
||||
<AssemblyName>VisualParamGenerator</AssemblyName>
|
||||
</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\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release-docs|AnyCPU' ">
|
||||
<OutputPath>bin\Release-docs\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<CodeAnalysisRuleAssemblies>C:\Program Files\Microsoft Visual Studio 8\Team Tools\Static Analysis Tools\FxCop\\rules</CodeAnalysisRuleAssemblies>
|
||||
<CodeAnalysisUseTypeNameInSuppression>true</CodeAnalysisUseTypeNameInSuppression>
|
||||
<CodeAnalysisModuleSuppressionsFile>GlobalSuppressions.cs</CodeAnalysisModuleSuppressionsFile>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="VisualParamGenerator.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\OpenMetaverse.csproj">
|
||||
<Project>{D9CDEDFB-8169-4B03-B57F-0DF638F044EC}</Project>
|
||||
<Name>OpenMetaverse</Name>
|
||||
</ProjectReference>
|
||||
</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>
|
||||
77
Programs/VisualParamGenerator/template.cs
Normal file
77
Programs/VisualParamGenerator/template.cs
Normal file
@@ -0,0 +1,77 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace libsecondlife
|
||||
{
|
||||
/// <summary>
|
||||
/// A single visual characteristic of an avatar mesh, such as eyebrow height
|
||||
/// </summary>
|
||||
public struct VisualParam
|
||||
{
|
||||
/// <summary>Index of this visual param</summary>
|
||||
public int ParamID;
|
||||
/// <summary>Internal name</summary>
|
||||
public string Name;
|
||||
/// <summary>Group ID this parameter belongs to</summary>
|
||||
public int Group;
|
||||
/// <summary>Name of the wearable this parameter belongs to</summary>
|
||||
public string Wearable;
|
||||
/// <summary>Displayable label of this characteristic</summary>
|
||||
public string Label;
|
||||
/// <summary>Displayable label for the minimum value of this characteristic</summary>
|
||||
public string LabelMin;
|
||||
/// <summary>Displayable label for the maximum value of this characteristic</summary>
|
||||
public string LabelMax;
|
||||
/// <summary>Default value</summary>
|
||||
public float DefaultValue;
|
||||
/// <summary>Minimum value</summary>
|
||||
public float MinValue;
|
||||
/// <summary>Maximum value</summary>
|
||||
public float MaxValue;
|
||||
|
||||
/// <summary>
|
||||
/// Set all the values through the constructor
|
||||
/// </summary>
|
||||
/// <param name="paramID">Index of this visual param</param>
|
||||
/// <param name="name">Internal name</param>
|
||||
/// <param name="group"></param>
|
||||
/// <param name="wearable"></param>
|
||||
/// <param name="label">Displayable label of this characteristic</param>
|
||||
/// <param name="labelMin">Displayable label for the minimum value of this characteristic</param>
|
||||
/// <param name="labelMax">Displayable label for the maximum value of this characteristic</param>
|
||||
/// <param name="def">Default value</param>
|
||||
/// <param name="min">Minimum value</param>
|
||||
/// <param name="max">Maximum value</param>
|
||||
public VisualParam(int paramID, string name, int group, string wearable, string label, string labelMin, string labelMax, float def, float min, float max)
|
||||
{
|
||||
ParamID = paramID;
|
||||
Name = name;
|
||||
Group = group;
|
||||
Wearable = wearable;
|
||||
Label = label;
|
||||
LabelMin = labelMin;
|
||||
LabelMax = labelMax;
|
||||
DefaultValue = def;
|
||||
MaxValue = max;
|
||||
MinValue = min;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Holds the Params array of all the avatar appearance parameters
|
||||
/// </summary>
|
||||
public static class VisualParams
|
||||
{
|
||||
public static VisualParam Find(string name, string wearable)
|
||||
{
|
||||
foreach (KeyValuePair<int, VisualParam> param in Params)
|
||||
if (param.Value.Name == name && param.Value.Wearable == wearable)
|
||||
return param.Value;
|
||||
|
||||
return new VisualParam();
|
||||
}
|
||||
|
||||
public static SortedList<int, VisualParam> Params = new SortedList<int, VisualParam>();
|
||||
|
||||
static VisualParams()
|
||||
{
|
||||
Reference in New Issue
Block a user