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:
28
Programs/examples/Heightmap/Heightmap.cs
Normal file
28
Programs/examples/Heightmap/Heightmap.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Heightmap
|
||||
{
|
||||
static class Heightmap
|
||||
{
|
||||
/// <summary>
|
||||
/// The main entry point for the application.
|
||||
/// </summary>
|
||||
[STAThread]
|
||||
static void Main(string[] args)
|
||||
{
|
||||
if (args.Length != 3)
|
||||
{
|
||||
Console.WriteLine("Usage: [FirstName] [LastName] [password]");
|
||||
Console.WriteLine("Press any key to continue...");
|
||||
Console.ReadKey();
|
||||
return;
|
||||
}
|
||||
|
||||
Application.EnableVisualStyles();
|
||||
Application.SetCompatibleTextRenderingDefault(false);
|
||||
Application.Run(new frmHeightmap(args[0], args[1], args[2]));
|
||||
}
|
||||
}
|
||||
}
|
||||
81
Programs/examples/Heightmap/Heightmap.csproj
Normal file
81
Programs/examples/Heightmap/Heightmap.csproj
Normal file
@@ -0,0 +1,81 @@
|
||||
<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>{D9669D08-AC81-4F45-AD23-82787C6EFBBA}</ProjectGuid>
|
||||
<OutputType>Exe</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>Heightmap</RootNamespace>
|
||||
<AssemblyName>Heightmap</AssemblyName>
|
||||
<StartupObject>
|
||||
</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\</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.Deployment" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="frmHeightmap.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="frmHeightmap.Designer.cs">
|
||||
<DependentUpon>frmHeightmap.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Heightmap.cs" />
|
||||
<EmbeddedResource Include="frmHeightmap.resx">
|
||||
<SubType>Designer</SubType>
|
||||
<DependentUpon>frmHeightmap.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\OpenMetaverse.csproj">
|
||||
<Project>{D9CDEDFB-8169-4B03-B57F-0DF638F044EC}</Project>
|
||||
<Name>OpenMetaverse</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="Properties\" />
|
||||
</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>
|
||||
50
Programs/examples/Heightmap/frmHeightmap.Designer.cs
generated
Normal file
50
Programs/examples/Heightmap/frmHeightmap.Designer.cs
generated
Normal file
@@ -0,0 +1,50 @@
|
||||
namespace Heightmap
|
||||
{
|
||||
partial class frmHeightmap
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// frmHeightmap
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(256, 256);
|
||||
this.Name = "frmHeightmap";
|
||||
this.Text = "Heightmap";
|
||||
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.frmHeightmap_FormClosing);
|
||||
this.Load += new System.EventHandler(this.frmHeightmap_Load);
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
165
Programs/examples/Heightmap/frmHeightmap.cs
Normal file
165
Programs/examples/Heightmap/frmHeightmap.cs
Normal file
@@ -0,0 +1,165 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Imaging;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using OpenMetaverse;
|
||||
using OpenMetaverse.Packets;
|
||||
|
||||
namespace Heightmap
|
||||
{
|
||||
public partial class frmHeightmap : Form
|
||||
{
|
||||
private GridClient Client = new GridClient();
|
||||
private PictureBox[,] Boxes = new PictureBox[16, 16];
|
||||
private System.Timers.Timer UpdateTimer = new System.Timers.Timer(1000);
|
||||
private string FirstName, LastName, Password;
|
||||
|
||||
double heading = -Math.PI;
|
||||
|
||||
public frmHeightmap(string firstName, string lastName, string password)
|
||||
{
|
||||
FirstName = firstName;
|
||||
LastName = lastName;
|
||||
Password = password;
|
||||
|
||||
Client.Network.OnLogin += new NetworkManager.LoginCallback(Network_OnLogin);
|
||||
|
||||
// Throttle land up and other things down
|
||||
Client.Throttle.Cloud = 0;
|
||||
Client.Throttle.Land = 1000000;
|
||||
Client.Throttle.Wind = 0;
|
||||
|
||||
Client.Settings.MULTIPLE_SIMS = false;
|
||||
|
||||
// Build the picture boxes
|
||||
this.SuspendLayout();
|
||||
for (int y = 0; y < 16; y++)
|
||||
{
|
||||
for (int x = 0; x < 16; x++)
|
||||
{
|
||||
Boxes[x, y] = new System.Windows.Forms.PictureBox();
|
||||
PictureBox box = Boxes[x, y];
|
||||
((System.ComponentModel.ISupportInitialize)(box)).BeginInit();
|
||||
box.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||
box.Name = x + "," + y;
|
||||
box.Location = new System.Drawing.Point(x * 16, y * 16);
|
||||
box.Size = new System.Drawing.Size(16, 16);
|
||||
box.Visible = true;
|
||||
box.MouseUp += new MouseEventHandler(box_MouseUp);
|
||||
((System.ComponentModel.ISupportInitialize)(box)).EndInit();
|
||||
|
||||
this.Controls.Add(box);
|
||||
}
|
||||
}
|
||||
this.ResumeLayout();
|
||||
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void Network_OnLogin(LoginStatus login, string message)
|
||||
{
|
||||
if (login == LoginStatus.Success)
|
||||
{
|
||||
UpdateTimer.Elapsed += new System.Timers.ElapsedEventHandler(UpdateTimer_Elapsed);
|
||||
UpdateTimer.Start();
|
||||
}
|
||||
else if (login == LoginStatus.Failed)
|
||||
{
|
||||
Console.WriteLine("Login failed: " + Client.Network.LoginMessage);
|
||||
Console.ReadKey();
|
||||
this.Close();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
private void frmHeightmap_Load(object sender, EventArgs e)
|
||||
{
|
||||
Client.Terrain.OnLandPatch += new TerrainManager.LandPatchCallback(Terrain_OnLandPatch);
|
||||
// Only needed so we can do lookups with TerrainHeightAtPoint
|
||||
Client.Settings.STORE_LAND_PATCHES = true;
|
||||
|
||||
LoginParams loginParams = Client.Network.DefaultLoginParams(FirstName, LastName, Password, "Heightmap",
|
||||
"1.0.0");
|
||||
Client.Network.BeginLogin(loginParams);
|
||||
}
|
||||
|
||||
private void box_MouseUp(object sender, MouseEventArgs e)
|
||||
{
|
||||
for (int y = 0; y < 16; y++)
|
||||
{
|
||||
for (int x = 0; x < 16; x++)
|
||||
{
|
||||
if (Boxes[x, y] == sender)
|
||||
{
|
||||
float height;
|
||||
if (Client.Terrain.TerrainHeightAtPoint(Client.Network.CurrentSim.Handle,
|
||||
x * 16 + e.X, y * 16 + e.Y, out height))
|
||||
{
|
||||
MessageBox.Show(height.ToString());
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Unknown height");
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void UpdateTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
|
||||
{
|
||||
// Spin our camera in circles at the center of the sim to load all the terrain
|
||||
heading += 0.5d;
|
||||
if (heading > Math.PI) heading = -Math.PI;
|
||||
|
||||
Client.Self.Movement.UpdateFromHeading(heading, false);
|
||||
}
|
||||
|
||||
void Terrain_OnLandPatch(Simulator simulator, int x, int y, int width, float[] data)
|
||||
{
|
||||
if (x >= 16 || y >= 16)
|
||||
{
|
||||
Console.WriteLine("Bad patch coordinates, x = " + x + ", y = " + y);
|
||||
return;
|
||||
}
|
||||
|
||||
if (width != 16)
|
||||
{
|
||||
Console.WriteLine("Unhandled patch size " + width + "x" + width);
|
||||
return;
|
||||
}
|
||||
|
||||
Bitmap patch = new Bitmap(16, 16, PixelFormat.Format24bppRgb);
|
||||
|
||||
for (int yp = 0; yp < 16; yp++)
|
||||
{
|
||||
for (int xp = 0; xp < 16; xp++)
|
||||
{
|
||||
float height = data[yp * 16 + xp];
|
||||
int colorVal = Helpers.FloatToByte(height, 0.0f, 60.0f);
|
||||
int lesserVal = (int)((float)colorVal * 0.75f);
|
||||
Color color;
|
||||
|
||||
if (height >= simulator.WaterHeight)
|
||||
color = Color.FromArgb(lesserVal, colorVal, lesserVal);
|
||||
else
|
||||
color = Color.FromArgb(lesserVal, lesserVal, colorVal);
|
||||
|
||||
patch.SetPixel(xp, yp, color);
|
||||
}
|
||||
}
|
||||
|
||||
Boxes[x, y].Image = (System.Drawing.Image)patch;
|
||||
}
|
||||
|
||||
private void frmHeightmap_FormClosing(object sender, FormClosingEventArgs e)
|
||||
{
|
||||
Client.Network.Logout();
|
||||
}
|
||||
}
|
||||
}
|
||||
120
Programs/examples/Heightmap/frmHeightmap.resx
Normal file
120
Programs/examples/Heightmap/frmHeightmap.resx
Normal file
@@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
Reference in New Issue
Block a user