Work in progress of adding a embedded java vm for scripting testing /prototyping.

Currently the vm is at a early stage and very limited:
currently only supports static methods (instance methods support is nearly finished though)
currently a class can't have member variables, so currently only local variables in the methods.
Also in this branch, connecting the vm to opensim is not completely finished: it is being uploaded just for viewing purposes.
scripting-jvm
MW 2007-04-10 15:44:54 +00:00
commit d67b5fa474
301 changed files with 41870 additions and 0 deletions

View File

@ -0,0 +1,31 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// Information about this assembly is defined by the following
// attributes.
//
// change them to the information which is associated with the assembly
// you compile.
[assembly: AssemblyTitle("GridConfig")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("GridConfig")]
[assembly: AssemblyCopyright("")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// This sets the default COM visibility of types in the assembly to invisible.
// If you need to expose a type to COM, use [ComVisible(true)] on that type.
[assembly: ComVisible(false)]
// The assembly version has following format :
//
// Major.Minor.Build.Revision
//
// You can specify all values by your own or you can build default build and revision
// numbers with the '*' character (the default):
[assembly: AssemblyVersion("1.0.*")]

View File

@ -0,0 +1,112 @@
/*
* Copyright (c) OpenSim project, http://sim.opensecondlife.org/
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the <organization> nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System;
using System.Collections.Generic;
using OpenSim.Framework.Console;
using OpenSim.Framework.Interfaces;
using Db4objects.Db4o;
namespace OpenGrid.Config.GridConfigDb4o
{
public class Db40ConfigPlugin: IGridConfig
{
public GridConfig GetConfigObject()
{
OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Loading Db40Config dll");
return ( new DbGridConfig());
}
}
public class DbGridConfig : GridConfig
{
private IObjectContainer db;
public void LoadDefaults() {
OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Config.cs:LoadDefaults() - Please press enter to retain default or enter new settings");
this.GridOwner = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("Grid owner [OGS development team]: ", "OGS development team");
this.DefaultAssetServer = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("Default asset server [no default]: ");
this.AssetSendKey = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("Key to send to asset server: ");
this.AssetRecvKey = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("Key to expect from asset server: ");
this.DefaultUserServer = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("Default user server [no default]: ");
this.UserSendKey = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("Key to send to user server: ");
this.UserRecvKey = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("Key to expect from user server: ");
this.SimSendKey = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("Key to send to sims: ");
this.SimRecvKey = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("Key to expect from sims: ");
}
public override void InitConfig() {
try {
db = Db4oFactory.OpenFile("opengrid.yap");
IObjectSet result = db.Get(typeof(DbGridConfig));
if(result.Count==1) {
OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Config.cs:InitConfig() - Found a GridConfig object in the local database, loading");
foreach (DbGridConfig cfg in result) {
this.GridOwner=cfg.GridOwner;
this.DefaultAssetServer=cfg.DefaultAssetServer;
this.AssetSendKey=cfg.AssetSendKey;
this.AssetRecvKey=cfg.AssetRecvKey;
this.DefaultUserServer=cfg.DefaultUserServer;
this.UserSendKey=cfg.UserSendKey;
this.UserRecvKey=cfg.UserRecvKey;
this.SimSendKey=cfg.SimSendKey;
this.SimRecvKey=cfg.SimRecvKey;
}
} else {
OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Config.cs:InitConfig() - Could not find object in database, loading precompiled defaults");
LoadDefaults();
OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Writing out default settings to local database");
db.Set(this);
db.Close();
}
} catch(Exception e) {
OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Config.cs:InitConfig() - Exception occured");
OpenSim.Framework.Console.MainConsole.Instance.WriteLine(e.ToString());
}
OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Grid settings loaded:");
OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Grid owner: " + this.GridOwner);
OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Default asset server: " + this.DefaultAssetServer);
OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Key to send to asset server: " + this.AssetSendKey);
OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Key to expect from asset server: " + this.AssetRecvKey);
OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Default user server: " + this.DefaultUserServer);
OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Key to send to user server: " + this.UserSendKey);
OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Key to expect from user server: " + this.UserRecvKey);
OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Key to send to sims: " + this.SimSendKey);
OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Key to expect from sims: " + this.SimRecvKey);
}
public void Shutdown() {
db.Close();
}
}
}

View File

@ -0,0 +1,111 @@
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ProjectType>Local</ProjectType>
<ProductVersion>8.0.50727</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{B0027747-0000-0000-0000-000000000000}</ProjectGuid>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ApplicationIcon></ApplicationIcon>
<AssemblyKeyContainerName>
</AssemblyKeyContainerName>
<AssemblyName>OpenGrid.Config.GridConfigDb4o</AssemblyName>
<DefaultClientScript>JScript</DefaultClientScript>
<DefaultHTMLPageLayout>Grid</DefaultHTMLPageLayout>
<DefaultTargetSchema>IE50</DefaultTargetSchema>
<DelaySign>false</DelaySign>
<OutputType>Library</OutputType>
<AppDesignerFolder></AppDesignerFolder>
<RootNamespace>OpenGrid.Config.GridConfigDb4o</RootNamespace>
<StartupObject></StartupObject>
<FileUpgradeFlags>
</FileUpgradeFlags>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>
<BaseAddress>285212672</BaseAddress>
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
<ConfigurationOverrideFile>
</ConfigurationOverrideFile>
<DefineConstants>TRACE;DEBUG</DefineConstants>
<DocumentationFile></DocumentationFile>
<DebugSymbols>True</DebugSymbols>
<FileAlignment>4096</FileAlignment>
<Optimize>False</Optimize>
<OutputPath>..\..\bin\</OutputPath>
<RegisterForComInterop>False</RegisterForComInterop>
<RemoveIntegerChecks>False</RemoveIntegerChecks>
<TreatWarningsAsErrors>False</TreatWarningsAsErrors>
<WarningLevel>4</WarningLevel>
<NoWarn></NoWarn>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>
<BaseAddress>285212672</BaseAddress>
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
<ConfigurationOverrideFile>
</ConfigurationOverrideFile>
<DefineConstants>TRACE</DefineConstants>
<DocumentationFile></DocumentationFile>
<DebugSymbols>False</DebugSymbols>
<FileAlignment>4096</FileAlignment>
<Optimize>True</Optimize>
<OutputPath>..\..\bin\</OutputPath>
<RegisterForComInterop>False</RegisterForComInterop>
<RemoveIntegerChecks>False</RemoveIntegerChecks>
<TreatWarningsAsErrors>False</TreatWarningsAsErrors>
<WarningLevel>4</WarningLevel>
<NoWarn></NoWarn>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" >
<HintPath>System.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="System.Data.dll" >
<HintPath>..\..\bin\System.Data.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="System.Xml" >
<HintPath>System.Xml.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="libsecondlife.dll" >
<HintPath>..\..\bin\libsecondlife.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Db4objects.Db4o.dll" >
<HintPath>..\..\bin\Db4objects.Db4o.dll</HintPath>
<Private>False</Private>
</Reference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\OpenSim.Framework\OpenSim.Framework.csproj">
<Name>OpenSim.Framework</Name>
<Project>{8ACA2445-0000-0000-0000-000000000000}</Project>
<Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
<Private>False</Private>
</ProjectReference>
<ProjectReference Include="..\..\OpenSim.Framework.Console\OpenSim.Framework.Console.csproj">
<Name>OpenSim.Framework.Console</Name>
<Project>{A7CD0630-0000-0000-0000-000000000000}</Project>
<Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
<Private>False</Private>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Compile Include="AssemblyInfo.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="DbGridConfig.cs">
<SubType>Code</SubType>
</Compile>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" />
<PropertyGroup>
<PreBuildEvent>
</PreBuildEvent>
<PostBuildEvent>
</PostBuildEvent>
</PropertyGroup>
</Project>

View File

@ -0,0 +1,12 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ReferencePath>C:\New Folder\second-life-viewer\opensim-dailys2\opensim02-04\bin\</ReferencePath>
<LastOpenVersion>8.0.50727</LastOpenVersion>
<ProjectView>ProjectFiles</ProjectView>
<ProjectTrust>0</ProjectTrust>
</PropertyGroup>
<PropertyGroup Condition = " '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' " />
<PropertyGroup Condition = " '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
</Project>

View File

@ -0,0 +1,46 @@
<?xml version="1.0" ?>
<project name="OpenGrid.Config.GridConfigDb4o" default="build">
<target name="build">
<echo message="Build Directory is ${project::get-base-directory()}/${build.dir}" />
<mkdir dir="${project::get-base-directory()}/${build.dir}" />
<copy todir="${project::get-base-directory()}/${build.dir}">
<fileset basedir="${project::get-base-directory()}">
</fileset>
</copy>
<csc target="library" debug="${build.debug}" unsafe="False" define="TRACE" output="${project::get-base-directory()}/${build.dir}/${project::get-name()}.dll">
<resources prefix="OpenGrid.Config.GridConfigDb4o" dynamicprefix="true" >
</resources>
<sources failonempty="true">
<include name="AssemblyInfo.cs" />
<include name="DbGridConfig.cs" />
</sources>
<references basedir="${project::get-base-directory()}">
<lib>
<include name="${project::get-base-directory()}" />
<include name="${project::get-base-directory()}/${build.dir}" />
</lib>
<include name="System.dll" />
<include name="System.Data.dll.dll" />
<include name="System.Xml.dll" />
<include name="../../bin/libsecondlife.dll" />
<include name="../../bin/Db4objects.Db4o.dll" />
<include name="../../bin/OpenSim.Framework.dll" />
<include name="../../bin/OpenSim.Framework.Console.dll" />
</references>
</csc>
<echo message="Copying from [${project::get-base-directory()}/${build.dir}/] to [${project::get-base-directory()}/../../bin/" />
<mkdir dir="${project::get-base-directory()}/../../bin/"/>
<copy todir="${project::get-base-directory()}/../../bin/">
<fileset basedir="${project::get-base-directory()}/${build.dir}/" >
<include name="*.dll"/>
<include name="*.exe"/>
</fileset>
</copy>
</target>
<target name="clean">
<delete dir="${bin.dir}" failonerror="false" />
<delete dir="${obj.dir}" failonerror="false" />
</target>
<target name="doc" description="Creates documentation.">
</target>
</project>

View File

@ -0,0 +1,229 @@
/*
Copyright (c) OpenGrid project, http://osgrid.org/
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the <organization> nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System;
using System.Text;
using Nwc.XmlRpc;
using System.Threading;
using System.Text.RegularExpressions;
using System.Net;
using System.Xml;
using System.IO;
using System.Collections;
using System.Collections.Generic;
using libsecondlife;
using OpenSim.Framework.Sims;
using OpenSim.Framework.Console;
namespace OpenGridServices.GridServer
{
public class GridHTTPServer {
public Thread HTTPD;
public HttpListener Listener;
public GridHTTPServer() {
MainConsole.Instance.WriteLine("Starting up HTTP Server");
HTTPD = new Thread(new ThreadStart(StartHTTP));
HTTPD.Start();
}
public void StartHTTP() {
MainConsole.Instance.WriteLine("GridHttp.cs:StartHTTP() - Spawned main thread OK");
Listener = new HttpListener();
Listener.Prefixes.Add("http://+:8001/sims/");
Listener.Prefixes.Add("http://+:8001/gods/");
Listener.Prefixes.Add("http://+:8001/highestuuid/");
Listener.Prefixes.Add("http://+:8001/uuidblocks/");
Listener.Start();
MainConsole.Instance.WriteLine("GridHttp.cs:StartHTTP() - Successfully bound to port 8001");
HttpListenerContext context;
while(true) {
context = Listener.GetContext();
ThreadPool.QueueUserWorkItem(new WaitCallback(HandleRequest), context);
}
}
static string ParseXMLRPC(string requestBody, string referrer) {
try{
XmlRpcRequest request = (XmlRpcRequest)(new XmlRpcRequestDeserializer()).Deserialize(requestBody);
Hashtable requestData = (Hashtable)request.Params[0];
switch(request.MethodName) {
case "simulator_login":
if(!(referrer=="simulator")) {
XmlRpcResponse ErrorResp = new XmlRpcResponse();
Hashtable ErrorRespData = new Hashtable();
ErrorRespData["error"]="Only simulators can login with this method";
ErrorResp.Value=ErrorRespData;
return(Regex.Replace(XmlRpcResponseSerializer.Singleton.Serialize(ErrorResp),"utf-16","utf-8"));
}
if(!((string)requestData["authkey"]==OpenGrid_Main.thegrid.SimRecvKey)) {
XmlRpcResponse ErrorResp = new XmlRpcResponse();
Hashtable ErrorRespData = new Hashtable();
ErrorRespData["error"]="invalid key";
ErrorResp.Value=ErrorRespData;
return(Regex.Replace(XmlRpcResponseSerializer.Singleton.Serialize(ErrorResp),"utf-16","utf-8"));
}
SimProfileBase TheSim = OpenGrid_Main.thegrid._regionmanager.GetProfileByLLUUID(new LLUUID((string)requestData["UUID"]));
XmlRpcResponse SimLoginResp = new XmlRpcResponse();
Hashtable SimLoginRespData = new Hashtable();
ArrayList SimNeighboursData = new ArrayList();
SimProfileBase neighbour;
Hashtable NeighbourBlock;
for(int x=-1; x<2; x++) for(int y=-1; y<2; y++) {
if(OpenGrid_Main.thegrid._regionmanager.GetProfileByHandle(Helpers.UIntsToLong((uint)((TheSim.RegionLocX+x)*256), (uint)(TheSim.RegionLocY+y)*256))!=null) {
neighbour=OpenGrid_Main.thegrid._regionmanager.GetProfileByHandle(Helpers.UIntsToLong((uint)((TheSim.RegionLocX+x)*256), (uint)(TheSim.RegionLocY+y)*256));
NeighbourBlock = new Hashtable();
NeighbourBlock["sim_ip"] = neighbour.sim_ip;
NeighbourBlock["sim_port"] = neighbour.sim_port.ToString();
NeighbourBlock["region_locx"] = neighbour.RegionLocX.ToString();
NeighbourBlock["region_locy"] = neighbour.RegionLocY.ToString();
NeighbourBlock["UUID"] = neighbour.UUID.ToString();
SimNeighboursData.Add(NeighbourBlock);
}
}
SimLoginRespData["region_locx"]=TheSim.RegionLocX.ToString();
SimLoginRespData["region_locy"]=TheSim.RegionLocY.ToString();
SimLoginRespData["regionname"]=TheSim.regionname;
SimLoginRespData["estate_id"]="1";
SimLoginRespData["neighbours"]=SimNeighboursData;
SimLoginRespData["asset_url"]=OpenGrid_Main.thegrid.DefaultAssetServer;
SimLoginRespData["asset_sendkey"]=OpenGrid_Main.thegrid.AssetSendKey;
SimLoginRespData["asset_recvkey"]=OpenGrid_Main.thegrid.AssetRecvKey;
SimLoginRespData["user_url"]=OpenGrid_Main.thegrid.DefaultUserServer;
SimLoginRespData["user_sendkey"]=OpenGrid_Main.thegrid.UserSendKey;
SimLoginRespData["user_recvkey"]=OpenGrid_Main.thegrid.UserRecvKey;
SimLoginRespData["authkey"]=OpenGrid_Main.thegrid.SimSendKey;
SimLoginResp.Value=SimLoginRespData;
return(Regex.Replace(XmlRpcResponseSerializer.Singleton.Serialize(SimLoginResp),"utf-16","utf-8"));
break;
}
} catch(Exception e) {
Console.WriteLine(e.ToString());
}
return "";
}
static string ParseREST(string requestBody, string requestURL, string HTTPmethod) {
char[] splitter = {'/'};
string[] rest_params = requestURL.Split(splitter);
string req_type = rest_params[0]; // First part of the URL is the type of request -
string respstring;
switch(req_type) {
case "sims":
LLUUID UUID = new LLUUID((string)rest_params[1]);
SimProfileBase TheSim = OpenGrid_Main.thegrid._regionmanager.GetProfileByLLUUID(UUID);
if(!(TheSim==null)) {
switch(HTTPmethod) {
case "GET":
respstring="<authkey>" + OpenGrid_Main.thegrid.SimSendKey + "</authkey>";
respstring+="<sim>";
respstring+="<uuid>" + TheSim.UUID.ToString() + "</uuid>";
respstring+="<regionname>" + TheSim.regionname + "</regionname>";
respstring+="<sim_ip>" + TheSim.sim_ip + "</sim_ip>";
respstring+="<sim_port>" + TheSim.sim_port.ToString() + "</sim_port>";
respstring+="<region_locx>" + TheSim.RegionLocX.ToString() + "</region_locx>";
respstring+="<region_locy>" + TheSim.RegionLocY.ToString() + "</region_locy>";
respstring+="<estate_id>1</estate_id>";
respstring+="</sim>";
break;
case "POST":
XmlDocument doc = new XmlDocument();
doc.LoadXml(requestBody);
XmlNode authkeynode = doc.FirstChild;
if (authkeynode.Name != "authkey")
respstring = "<error>bad XML - expected authkey tag</error>";
XmlNode simnode = doc.ChildNodes[1];
if (simnode.Name != "sim")
respstring = "<error>bad XML - expected sim tag</error>";
break;
}
}
break;
}
return "";
}
static void HandleRequest(Object stateinfo) {
HttpListenerContext context=(HttpListenerContext)stateinfo;
HttpListenerRequest request = context.Request;
HttpListenerResponse response = context.Response;
response.KeepAlive=false;
response.SendChunked=false;
System.IO.Stream body = request.InputStream;
System.Text.Encoding encoding = System.Text.Encoding.UTF8;
System.IO.StreamReader reader = new System.IO.StreamReader(body, encoding);
string requestBody = reader.ReadToEnd();
body.Close();
reader.Close();
// TODO: AUTHENTICATION!!!!!!!!! MUST ADD!!!!!!!!!! SCRIPT KIDDIES LOVE LACK OF IT!!!!!!!!!!
string responseString="";
switch(request.ContentType) {
case "text/xml":
// must be XML-RPC, so pass to the XML-RPC parser
responseString=ParseXMLRPC(requestBody,request.Headers["Referer"]);
response.AddHeader("Content-type","text/xml");
break;
case null:
// must be REST or invalid crap, so pass to the REST parser
responseString=ParseREST(request.Url.OriginalString,requestBody,request.HttpMethod);
break;
}
byte[] buffer = System.Text.Encoding.UTF8.GetBytes(responseString);
System.IO.Stream output = response.OutputStream;
response.SendChunked=false;
response.ContentLength64=buffer.Length;
output.Write(buffer,0,buffer.Length);
output.Close();
}
}
}

View File

@ -0,0 +1,189 @@
/*
Copyright (c) OpenSim project, http://osgrid.org/
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the <organization> nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System;
using System.IO;
using System.Text;
using System.Timers;
using System.Net;
using System.Reflection;
using libsecondlife;
using OpenSim.Framework;
using OpenSim.Framework.Sims;
using OpenSim.Framework.Console;
using OpenSim.Framework.Interfaces;
namespace OpenGridServices.GridServer
{
/// <summary>
/// </summary>
public class OpenGrid_Main : conscmd_callback
{
private string ConfigDll = "OpenGrid.Config.GridConfigDb4o.dll";
private GridConfig Cfg;
public static OpenGrid_Main thegrid;
public string GridOwner;
public string DefaultStartupMsg;
public string DefaultAssetServer;
public string AssetSendKey;
public string AssetRecvKey;
public string DefaultUserServer;
public string UserSendKey;
public string UserRecvKey;
public string SimSendKey;
public string SimRecvKey;
public LLUUID highestUUID;
public GridHTTPServer _httpd;
public SimProfileManager _regionmanager;
private ConsoleBase m_console;
private Timer SimCheckTimer;
[STAThread]
public static void Main(string[] args)
{
Console.WriteLine("Starting...\n");
thegrid = new OpenGrid_Main();
thegrid.Startup();
thegrid.Work();
}
private void Work()
{
m_console.WriteLine("\nEnter help for a list of commands\n");
while (true)
{
m_console.MainConsolePrompt();
}
}
private OpenGrid_Main()
{
m_console = new ConsoleBase("opengrid-gridserver-console.log", "OpenGrid", this);
MainConsole.Instance = m_console;
}
public void Startup()
{
m_console.WriteLine("Main.cs:Startup() - Loading configuration");
Cfg = this.LoadConfigDll(this.ConfigDll);
Cfg.InitConfig();
m_console.WriteLine("Main.cs:Startup() - Loading sim profiles from database");
this._regionmanager = new SimProfileManager();
_regionmanager.LoadProfiles();
m_console.WriteLine("Main.cs:Startup() - Starting HTTP process");
_httpd = new GridHTTPServer();
m_console.WriteLine("Main.cs:Startup() - Starting sim status checker");
SimCheckTimer = new Timer();
SimCheckTimer.Interval = 300000; // 5 minutes
SimCheckTimer.Elapsed+=new ElapsedEventHandler(CheckSims);
SimCheckTimer.Enabled=true;
}
private GridConfig LoadConfigDll(string dllName)
{
Assembly pluginAssembly = Assembly.LoadFrom(dllName);
GridConfig config = null;
foreach (Type pluginType in pluginAssembly.GetTypes())
{
if (pluginType.IsPublic)
{
if (!pluginType.IsAbstract)
{
Type typeInterface = pluginType.GetInterface("IGridConfig", true);
if (typeInterface != null)
{
IGridConfig plug = (IGridConfig)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
config = plug.GetConfigObject();
break;
}
typeInterface = null;
}
}
}
pluginAssembly = null;
return config;
}
public void CheckSims(object sender, ElapsedEventArgs e) {
foreach(SimProfileBase sim in _regionmanager.SimProfiles.Values) {
string SimResponse="";
try {
WebRequest CheckSim = WebRequest.Create("http://" + sim.sim_ip + ":" + sim.sim_port.ToString() + "/checkstatus/");
CheckSim.Method = "GET";
CheckSim.ContentType = "text/plaintext";
CheckSim.ContentLength = 0;
StreamWriter stOut = new StreamWriter(CheckSim.GetRequestStream(), System.Text.Encoding.ASCII);
stOut.Write("");
stOut.Close();
StreamReader stIn = new StreamReader(CheckSim.GetResponse().GetResponseStream());
SimResponse = stIn.ReadToEnd();
stIn.Close();
} catch(Exception exception) {
}
if(SimResponse=="OK") {
_regionmanager.SimProfiles[sim.UUID].online=true;
} else {
_regionmanager.SimProfiles[sim.UUID].online=false;
}
}
}
public void RunCmd(string cmd, string[] cmdparams)
{
switch (cmd)
{
case "help":
m_console.WriteLine("shutdown - shutdown the grid (USE CAUTION!)");
break;
case "shutdown":
m_console.Close();
Environment.Exit(0);
break;
}
}
public void Show(string ShowWhat)
{
}
}
}

View File

@ -0,0 +1,117 @@
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ProjectType>Local</ProjectType>
<ProductVersion>8.0.50727</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{21BFC8E2-0000-0000-0000-000000000000}</ProjectGuid>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ApplicationIcon></ApplicationIcon>
<AssemblyKeyContainerName>
</AssemblyKeyContainerName>
<AssemblyName>OpenGridServices.GridServer</AssemblyName>
<DefaultClientScript>JScript</DefaultClientScript>
<DefaultHTMLPageLayout>Grid</DefaultHTMLPageLayout>
<DefaultTargetSchema>IE50</DefaultTargetSchema>
<DelaySign>false</DelaySign>
<OutputType>Exe</OutputType>
<AppDesignerFolder></AppDesignerFolder>
<RootNamespace>OpenGridServices.GridServer</RootNamespace>
<StartupObject></StartupObject>
<FileUpgradeFlags>
</FileUpgradeFlags>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>
<BaseAddress>285212672</BaseAddress>
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
<ConfigurationOverrideFile>
</ConfigurationOverrideFile>
<DefineConstants>TRACE;DEBUG</DefineConstants>
<DocumentationFile></DocumentationFile>
<DebugSymbols>True</DebugSymbols>
<FileAlignment>4096</FileAlignment>
<Optimize>False</Optimize>
<OutputPath>..\bin\</OutputPath>
<RegisterForComInterop>False</RegisterForComInterop>
<RemoveIntegerChecks>False</RemoveIntegerChecks>
<TreatWarningsAsErrors>False</TreatWarningsAsErrors>
<WarningLevel>4</WarningLevel>
<NoWarn></NoWarn>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>
<BaseAddress>285212672</BaseAddress>
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
<ConfigurationOverrideFile>
</ConfigurationOverrideFile>
<DefineConstants>TRACE</DefineConstants>
<DocumentationFile></DocumentationFile>
<DebugSymbols>False</DebugSymbols>
<FileAlignment>4096</FileAlignment>
<Optimize>True</Optimize>
<OutputPath>..\bin\</OutputPath>
<RegisterForComInterop>False</RegisterForComInterop>
<RemoveIntegerChecks>False</RemoveIntegerChecks>
<TreatWarningsAsErrors>False</TreatWarningsAsErrors>
<WarningLevel>4</WarningLevel>
<NoWarn></NoWarn>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" >
<HintPath>System.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="System.Data" >
<HintPath>System.Data.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="System.Xml" >
<HintPath>System.Xml.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="libsecondlife.dll" >
<HintPath>..\bin\libsecondlife.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Db4objects.Db4o.dll" >
<HintPath>..\bin\Db4objects.Db4o.dll</HintPath>
<Private>False</Private>
</Reference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\OpenSim.Framework\OpenSim.Framework.csproj">
<Name>OpenSim.Framework</Name>
<Project>{8ACA2445-0000-0000-0000-000000000000}</Project>
<Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
<Private>False</Private>
</ProjectReference>
<ProjectReference Include="..\OpenSim.Framework.Console\OpenSim.Framework.Console.csproj">
<Name>OpenSim.Framework.Console</Name>
<Project>{A7CD0630-0000-0000-0000-000000000000}</Project>
<Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
<Private>False</Private>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Compile Include="GridHttp.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Main.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="SimProfiles.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Properties\AssemblyInfo.cs">
<SubType>Code</SubType>
</Compile>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" />
<PropertyGroup>
<PreBuildEvent>
</PreBuildEvent>
<PostBuildEvent>
</PostBuildEvent>
</PropertyGroup>
</Project>

View File

@ -0,0 +1,12 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ReferencePath>C:\New Folder\second-life-viewer\opensim-dailys2\opensim02-04\bin\</ReferencePath>
<LastOpenVersion>8.0.50727</LastOpenVersion>
<ProjectView>ProjectFiles</ProjectView>
<ProjectTrust>0</ProjectTrust>
</PropertyGroup>
<PropertyGroup Condition = " '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' " />
<PropertyGroup Condition = " '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
</Project>

View File

@ -0,0 +1,48 @@
<?xml version="1.0" ?>
<project name="OpenGridServices.GridServer" default="build">
<target name="build">
<echo message="Build Directory is ${project::get-base-directory()}/${build.dir}" />
<mkdir dir="${project::get-base-directory()}/${build.dir}" />
<copy todir="${project::get-base-directory()}/${build.dir}">
<fileset basedir="${project::get-base-directory()}">
</fileset>
</copy>
<csc target="exe" debug="${build.debug}" unsafe="False" define="TRACE" output="${project::get-base-directory()}/${build.dir}/${project::get-name()}.exe">
<resources prefix="OpenGridServices.GridServer" dynamicprefix="true" >
</resources>
<sources failonempty="true">
<include name="GridHttp.cs" />
<include name="Main.cs" />
<include name="SimProfiles.cs" />
<include name="Properties/AssemblyInfo.cs" />
</sources>
<references basedir="${project::get-base-directory()}">
<lib>
<include name="${project::get-base-directory()}" />
<include name="${project::get-base-directory()}/${build.dir}" />
</lib>
<include name="System.dll" />
<include name="System.Data.dll" />
<include name="System.Xml.dll" />
<include name="../bin/OpenSim.Framework.dll" />
<include name="../bin/OpenSim.Framework.Console.dll" />
<include name="../bin/libsecondlife.dll" />
<include name="../bin/Db4objects.Db4o.dll" />
</references>
</csc>
<echo message="Copying from [${project::get-base-directory()}/${build.dir}/] to [${project::get-base-directory()}/../bin/" />
<mkdir dir="${project::get-base-directory()}/../bin/"/>
<copy todir="${project::get-base-directory()}/../bin/">
<fileset basedir="${project::get-base-directory()}/${build.dir}/" >
<include name="*.dll"/>
<include name="*.exe"/>
</fileset>
</copy>
</target>
<target name="clean">
<delete dir="${bin.dir}" failonerror="false" />
<delete dir="${obj.dir}" failonerror="false" />
</target>
<target name="doc" description="Creates documentation.">
</target>
</project>

View File

@ -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("OGS-GridServer")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("OGS-GridServer")]
[assembly: AssemblyCopyright("Copyright © 2007")]
[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("b541b244-3d1d-4625-9003-bc2a3a6a39a4")]
// 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")]

View File

@ -0,0 +1,142 @@
/*
Copyright (c) OpenGrid project, http://osgrid.org/
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the <organization> nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System;
using System.Text;
using System.Collections;
using System.Collections.Generic;
using libsecondlife;
using OpenSim.Framework.Utilities;
using OpenSim.Framework.Console;
using OpenSim.Framework.Sims;
using Db4objects.Db4o;
namespace OpenGridServices.GridServer
{
/// <summary>
/// </summary>
public class SimProfileManager {
public Dictionary<LLUUID, SimProfileBase> SimProfiles = new Dictionary<LLUUID, SimProfileBase>();
public SimProfileManager() {
}
public void LoadProfiles() { // should abstract this out
IObjectContainer db;
db = Db4oFactory.OpenFile("simprofiles.yap");
IObjectSet result = db.Get(typeof(SimProfileBase));
foreach (SimProfileBase simprof in result) {
SimProfiles.Add(simprof.UUID, simprof);
}
MainConsole.Instance.WriteLine("SimProfiles.Cs:LoadProfiles() - Successfully loaded " + result.Count.ToString() + " from database");
db.Close();
}
public SimProfileBase GetProfileByHandle(ulong reqhandle) {
foreach (libsecondlife.LLUUID UUID in SimProfiles.Keys) {
if(SimProfiles[UUID].regionhandle==reqhandle) return SimProfiles[UUID];
}
return null;
}
public SimProfileBase GetProfileByLLUUID(LLUUID ProfileLLUUID) {
return SimProfiles[ProfileLLUUID];
}
public bool AuthenticateSim(LLUUID RegionUUID, uint regionhandle, string simrecvkey) {
SimProfileBase TheSim=GetProfileByHandle(regionhandle);
if(TheSim != null)
if(TheSim.recvkey==simrecvkey) {
return true;
} else {
return false;
} else return false;
}
public string GetXMLNeighbours(ulong reqhandle) {
string response="";
SimProfileBase central_region = GetProfileByHandle(reqhandle);
SimProfileBase neighbour;
for(int x=-1; x<2; x++) for(int y=-1; y<2; y++) {
if(GetProfileByHandle(Util.UIntsToLong((uint)((central_region.RegionLocX+x)*256), (uint)(central_region.RegionLocY+y)*256))!=null) {
neighbour=GetProfileByHandle(Util.UIntsToLong((uint)((central_region.RegionLocX+x)*256), (uint)(central_region.RegionLocY+y)*256));
response+="<neighbour>";
response+="<sim_ip>" + neighbour.sim_ip + "</sim_ip>";
response+="<sim_port>" + neighbour.sim_port.ToString() + "</sim_port>";
response+="<locx>" + neighbour.RegionLocX.ToString() + "</locx>";
response+="<locy>" + neighbour.RegionLocY.ToString() + "</locy>";
response+="<regionhandle>" + neighbour.regionhandle.ToString() + "</regionhandle>";
response+="</neighbour>";
}
}
return response;
}
public SimProfileBase CreateNewProfile(string regionname, string caps_url, string sim_ip, uint sim_port, uint RegionLocX, uint RegionLocY, string sendkey, string recvkey) {
SimProfileBase newprofile = new SimProfileBase();
newprofile.regionname=regionname;
newprofile.sim_ip=sim_ip;
newprofile.sim_port=sim_port;
newprofile.RegionLocX=RegionLocX;
newprofile.RegionLocY=RegionLocY;
newprofile.caps_url="http://" + sim_ip + ":9000/";
newprofile.sendkey=sendkey;
newprofile.recvkey=recvkey;
newprofile.regionhandle=Util.UIntsToLong((RegionLocX*256), (RegionLocY*256));
newprofile.UUID=LLUUID.Random();
this.SimProfiles.Add(newprofile.UUID,newprofile);
return newprofile;
}
}
/* is in OpenSim.Framework
public class SimProfileBase {
public LLUUID UUID;
public ulong regionhandle;
public string regionname;
public string sim_ip;
public uint sim_port;
public string caps_url;
public uint RegionLocX;
public uint RegionLocY;
public string sendkey;
public string recvkey;
public SimProfileBase() {
}
}*/
}

View File

@ -0,0 +1,176 @@
/*
Copyright (c) OpenSim project, http://osgrid.org/
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the <organization> nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System;
using System.Collections;
using System.Collections.Generic;
using System.Reflection;
using System.IO;
using System.Text;
using libsecondlife;
using OpenSim.Framework.User;
using OpenSim.Framework.Sims;
using OpenSim.Framework.Inventory;
using OpenSim.Framework.Interfaces;
using OpenSim.Framework.Console;
namespace OpenGridServices.UserServer
{
/// <summary>
/// </summary>
public class OpenUser_Main : conscmd_callback
{
private string ConfigDll = "OpenUser.Config.UserConfigDb4o.dll";
private UserConfig Cfg;
public static OpenUser_Main userserver;
public UserHTTPServer _httpd;
public UserProfileManager _profilemanager;
public Dictionary<LLUUID, UserProfile> UserSessions = new Dictionary<LLUUID, UserProfile>();
ConsoleBase m_console;
[STAThread]
public static void Main( string[] args )
{
Console.WriteLine("Starting...\n");
userserver = new OpenUser_Main();
userserver.Startup();
userserver.Work();
}
private OpenUser_Main()
{
m_console = new ConsoleBase("opengrid-userserver-console.log", "OpenUser", this);
MainConsole.Instance = m_console;
}
private void Work()
{
m_console.WriteLine("\nEnter help for a list of commands\n");
while (true)
{
m_console.MainConsolePrompt();
}
}
public void Startup() {
MainConsole.Instance.WriteLine("Main.cs:Startup() - Loading configuration");
Cfg = this.LoadConfigDll(this.ConfigDll);
Cfg.InitConfig();
MainConsole.Instance.WriteLine("Main.cs:Startup() - Creating user profile manager");
_profilemanager = new UserProfileManager();
_profilemanager.InitUserProfiles();
_profilemanager.SetKeys(Cfg.GridSendKey, Cfg.GridRecvKey, Cfg.GridServerURL, Cfg.DefaultStartupMsg);
MainConsole.Instance.WriteLine("Main.cs:Startup() - Starting HTTP process");
_httpd = new UserHTTPServer();
}
public void RunCmd(string cmd, string[] cmdparams)
{
switch (cmd)
{
case "help":
m_console.WriteLine("create user - create a new user");
m_console.WriteLine("shutdown - shutdown the grid (USE CAUTION!)");
break;
case "create user":
m_console.WriteLine("Creating new user profile");
string tempfirstname;
string templastname;
string tempMD5Passwd;
tempfirstname=m_console.CmdPrompt("First name: ");
templastname=m_console.CmdPrompt("Last name: ");
tempMD5Passwd=m_console.PasswdPrompt("Password: ");
System.Security.Cryptography.MD5CryptoServiceProvider x = new System.Security.Cryptography.MD5CryptoServiceProvider();
byte[] bs = System.Text.Encoding.UTF8.GetBytes(tempMD5Passwd);
bs = x.ComputeHash(bs);
System.Text.StringBuilder s = new System.Text.StringBuilder();
foreach (byte b in bs)
{
s.Append(b.ToString("x2").ToLower());
}
tempMD5Passwd = "$1$" + s.ToString();
UserProfile newuser=_profilemanager.CreateNewProfile(tempfirstname,templastname,tempMD5Passwd);
newuser.homelookat = new LLVector3(-0.57343f, -0.819255f, 0f);
newuser.homepos = new LLVector3(128f,128f,23f);
_profilemanager.SaveUserProfiles();
break;
case "shutdown":
m_console.Close();
Environment.Exit(0);
break;
}
}
private UserConfig LoadConfigDll(string dllName)
{
Assembly pluginAssembly = Assembly.LoadFrom(dllName);
UserConfig config = null;
foreach (Type pluginType in pluginAssembly.GetTypes())
{
if (pluginType.IsPublic)
{
if (!pluginType.IsAbstract)
{
Type typeInterface = pluginType.GetInterface("IUserConfig", true);
if (typeInterface != null)
{
IUserConfig plug = (IUserConfig)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
config = plug.GetConfigObject();
break;
}
typeInterface = null;
}
}
}
pluginAssembly = null;
return config;
}
public void Show(string ShowWhat)
{
}
}
}

View File

@ -0,0 +1,63 @@
<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>{D45B6E48-5668-478D-B9CB-6D46E665FACF}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>OGS_UserServer</RootNamespace>
<AssemblyName>OGS-UserServer</AssemblyName>
<StartupObject>OpenGridServices.OpenUser_Main</StartupObject>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</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="libsecondlife, Version=0.9.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\common\bin\libsecondlife.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\..\common\src\OGS-Console.cs">
<Link>OGS-Console.cs</Link>
</Compile>
<Compile Include="..\..\common\VersionInfo\VersionInfo.cs">
<Link>VersionInfo.cs</Link>
</Compile>
<Compile Include="ConsoleCmds.cs" />
<Compile Include="Main.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="UserHttp.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\OpenSim.FrameWork\OpenSim.Framework.csproj">
<Project>{2E46A825-3168-492F-93BC-637126B5B72B}</Project>
<Name>OpenSim.Framework</Name>
</ProjectReference>
<ProjectReference Include="..\..\ServerConsole\ServerConsole.csproj">
<Project>{7667E6E2-F227-41A2-B1B2-315613E1BAFC}</Project>
<Name>ServerConsole</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
</Project>

View File

@ -0,0 +1,8 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<PublishUrlHistory>publish\</PublishUrlHistory>
<ApplicationRevision>0</ApplicationRevision>
<FallbackCulture>en-US</FallbackCulture>
<VerifyUploadedFiles>false</VerifyUploadedFiles>
</PropertyGroup>
</Project>

View File

@ -0,0 +1,114 @@
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ProjectType>Local</ProjectType>
<ProductVersion>8.0.50727</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{66591469-0000-0000-0000-000000000000}</ProjectGuid>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ApplicationIcon></ApplicationIcon>
<AssemblyKeyContainerName>
</AssemblyKeyContainerName>
<AssemblyName>OpenGridServices.UserServer</AssemblyName>
<DefaultClientScript>JScript</DefaultClientScript>
<DefaultHTMLPageLayout>Grid</DefaultHTMLPageLayout>
<DefaultTargetSchema>IE50</DefaultTargetSchema>
<DelaySign>false</DelaySign>
<OutputType>Exe</OutputType>
<AppDesignerFolder></AppDesignerFolder>
<RootNamespace>OpenGridServices.UserServer</RootNamespace>
<StartupObject></StartupObject>
<FileUpgradeFlags>
</FileUpgradeFlags>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>
<BaseAddress>285212672</BaseAddress>
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
<ConfigurationOverrideFile>
</ConfigurationOverrideFile>
<DefineConstants>TRACE;DEBUG</DefineConstants>
<DocumentationFile></DocumentationFile>
<DebugSymbols>True</DebugSymbols>
<FileAlignment>4096</FileAlignment>
<Optimize>False</Optimize>
<OutputPath>..\bin\</OutputPath>
<RegisterForComInterop>False</RegisterForComInterop>
<RemoveIntegerChecks>False</RemoveIntegerChecks>
<TreatWarningsAsErrors>False</TreatWarningsAsErrors>
<WarningLevel>4</WarningLevel>
<NoWarn></NoWarn>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>
<BaseAddress>285212672</BaseAddress>
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
<ConfigurationOverrideFile>
</ConfigurationOverrideFile>
<DefineConstants>TRACE</DefineConstants>
<DocumentationFile></DocumentationFile>
<DebugSymbols>False</DebugSymbols>
<FileAlignment>4096</FileAlignment>
<Optimize>True</Optimize>
<OutputPath>..\bin\</OutputPath>
<RegisterForComInterop>False</RegisterForComInterop>
<RemoveIntegerChecks>False</RemoveIntegerChecks>
<TreatWarningsAsErrors>False</TreatWarningsAsErrors>
<WarningLevel>4</WarningLevel>
<NoWarn></NoWarn>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" >
<HintPath>System.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="System.Data" >
<HintPath>System.Data.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="System.Xml" >
<HintPath>System.Xml.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="libsecondlife.dll" >
<HintPath>..\bin\libsecondlife.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Db4objects.Db4o.dll" >
<HintPath>..\bin\Db4objects.Db4o.dll</HintPath>
<Private>False</Private>
</Reference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\OpenSim.Framework\OpenSim.Framework.csproj">
<Name>OpenSim.Framework</Name>
<Project>{8ACA2445-0000-0000-0000-000000000000}</Project>
<Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
<Private>False</Private>
</ProjectReference>
<ProjectReference Include="..\OpenSim.Framework.Console\OpenSim.Framework.Console.csproj">
<Name>OpenSim.Framework.Console</Name>
<Project>{A7CD0630-0000-0000-0000-000000000000}</Project>
<Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
<Private>False</Private>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Compile Include="Main.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="UserHttp.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Properties\AssemblyInfo.cs">
<SubType>Code</SubType>
</Compile>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" />
<PropertyGroup>
<PreBuildEvent>
</PreBuildEvent>
<PostBuildEvent>
</PostBuildEvent>
</PropertyGroup>
</Project>

View File

@ -0,0 +1,12 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ReferencePath>C:\New Folder\second-life-viewer\opensim-dailys2\opensim02-04\bin\</ReferencePath>
<LastOpenVersion>8.0.50727</LastOpenVersion>
<ProjectView>ProjectFiles</ProjectView>
<ProjectTrust>0</ProjectTrust>
</PropertyGroup>
<PropertyGroup Condition = " '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' " />
<PropertyGroup Condition = " '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
</Project>

View File

@ -0,0 +1,47 @@
<?xml version="1.0" ?>
<project name="OpenGridServices.UserServer" default="build">
<target name="build">
<echo message="Build Directory is ${project::get-base-directory()}/${build.dir}" />
<mkdir dir="${project::get-base-directory()}/${build.dir}" />
<copy todir="${project::get-base-directory()}/${build.dir}">
<fileset basedir="${project::get-base-directory()}">
</fileset>
</copy>
<csc target="exe" debug="${build.debug}" unsafe="False" define="TRACE" output="${project::get-base-directory()}/${build.dir}/${project::get-name()}.exe">
<resources prefix="OpenGridServices.UserServer" dynamicprefix="true" >
</resources>
<sources failonempty="true">
<include name="Main.cs" />
<include name="UserHttp.cs" />
<include name="Properties/AssemblyInfo.cs" />
</sources>
<references basedir="${project::get-base-directory()}">
<lib>
<include name="${project::get-base-directory()}" />
<include name="${project::get-base-directory()}/${build.dir}" />
</lib>
<include name="System.dll" />
<include name="System.Data.dll" />
<include name="System.Xml.dll" />
<include name="../bin/OpenSim.Framework.dll" />
<include name="../bin/OpenSim.Framework.Console.dll" />
<include name="../bin/libsecondlife.dll" />
<include name="../bin/Db4objects.Db4o.dll" />
</references>
</csc>
<echo message="Copying from [${project::get-base-directory()}/${build.dir}/] to [${project::get-base-directory()}/../bin/" />
<mkdir dir="${project::get-base-directory()}/../bin/"/>
<copy todir="${project::get-base-directory()}/../bin/">
<fileset basedir="${project::get-base-directory()}/${build.dir}/" >
<include name="*.dll"/>
<include name="*.exe"/>
</fileset>
</copy>
</target>
<target name="clean">
<delete dir="${bin.dir}" failonerror="false" />
<delete dir="${obj.dir}" failonerror="false" />
</target>
<target name="doc" description="Creates documentation.">
</target>
</project>

View File

@ -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("OGS-UserServer")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("OGS-UserServer")]
[assembly: AssemblyCopyright("Copyright © 2007")]
[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("e266513a-090b-4d38-80f6-8599eef68c8c")]
// 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")]

View File

@ -0,0 +1,157 @@
/*
Copyright (c) OpenGrid project, http://osgrid.org/
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the <organization> nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System;
using System.Text;
using Nwc.XmlRpc;
using System.Threading;
using System.Text.RegularExpressions;
using System.Net;
using System.IO;
using System.Collections;
using System.Collections.Generic;
using libsecondlife;
using OpenSim.Framework.User;
using OpenSim.Framework.Sims;
using OpenSim.Framework.Inventory;
using OpenSim.Framework.Console;
namespace OpenGridServices.UserServer
{
public class UserHTTPServer
{
public Thread HTTPD;
public HttpListener Listener;
public UserHTTPServer()
{
MainConsole.Instance.WriteLine("Starting up HTTP Server");
HTTPD = new Thread(new ThreadStart(StartHTTP));
HTTPD.Start();
}
public void StartHTTP()
{
MainConsole.Instance.WriteLine("UserHttp.cs:StartHTTP() - Spawned main thread OK");
Listener = new HttpListener();
Listener.Prefixes.Add("http://+:8002/userserver/");
Listener.Prefixes.Add("http://+:8002/usersessions/");
Listener.Start();
HttpListenerContext context;
while (true)
{
context = Listener.GetContext();
ThreadPool.QueueUserWorkItem(new WaitCallback(HandleRequest), context);
}
}
static string ParseXMLRPC(string requestBody)
{
return OpenUser_Main.userserver._profilemanager.ParseXMLRPC(requestBody);
}
static string ParseREST(HttpListenerRequest www_req)
{
Console.WriteLine("INCOMING REST - " + www_req.RawUrl);
char[] splitter = { '/' };
string[] rest_params = www_req.RawUrl.Split(splitter);
string req_type = rest_params[1]; // First part of the URL is the type of request - usersessions/userprofiles/inventory/blabla
switch (req_type)
{
case "usersessions":
LLUUID sessionid = new LLUUID(rest_params[2]); // get usersessions/sessionid
if (www_req.HttpMethod == "DELETE")
{
foreach (libsecondlife.LLUUID UUID in OpenUser_Main.userserver._profilemanager.UserProfiles.Keys)
{
if (OpenUser_Main.userserver._profilemanager.UserProfiles[UUID].CurrentSessionID == sessionid)
{
OpenUser_Main.userserver._profilemanager.UserProfiles[UUID].CurrentSessionID = null;
OpenUser_Main.userserver._profilemanager.UserProfiles[UUID].CurrentSecureSessionID = null;
OpenUser_Main.userserver._profilemanager.UserProfiles[UUID].Circuits.Clear();
}
}
}
return "OK";
}
return "";
}
static void HandleRequest(Object stateinfo)
{
HttpListenerContext context = (HttpListenerContext)stateinfo;
HttpListenerRequest request = context.Request;
HttpListenerResponse response = context.Response;
response.KeepAlive = false;
response.SendChunked = false;
System.IO.Stream body = request.InputStream;
System.Text.Encoding encoding = System.Text.Encoding.UTF8;
System.IO.StreamReader reader = new System.IO.StreamReader(body, encoding);
string requestBody = reader.ReadToEnd();
body.Close();
reader.Close();
string responseString = "";
switch (request.ContentType)
{
case "text/xml":
// must be XML-RPC, so pass to the XML-RPC parser
responseString = ParseXMLRPC(requestBody);
response.AddHeader("Content-type", "text/xml");
break;
case "text/plaintext":
responseString = ParseREST(request);
response.AddHeader("Content-type", "text/plaintext");
break;
}
byte[] buffer = System.Text.Encoding.UTF8.GetBytes(responseString);
System.IO.Stream output = response.OutputStream;
response.SendChunked = false;
response.ContentLength64 = buffer.Length;
output.Write(buffer, 0, buffer.Length);
output.Close();
}
}
}

View File

@ -0,0 +1,31 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// Information about this assembly is defined by the following
// attributes.
//
// change them to the information which is associated with the assembly
// you compile.
[assembly: AssemblyTitle("ServerConsole")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ServerConsole")]
[assembly: AssemblyCopyright("")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// This sets the default COM visibility of types in the assembly to invisible.
// If you need to expose a type to COM, use [ComVisible(true)] on that type.
[assembly: ComVisible(false)]
// The assembly version has following format :
//
// Major.Minor.Build.Revision
//
// You can specify all values by your own or you can build default build and revision
// numbers with the '*' character (the default):
[assembly: AssemblyVersion("1.0.*")]

View File

@ -0,0 +1,151 @@
using System;
using System.IO;
namespace OpenSim.Framework.Console
{
public class ConsoleBase
{
StreamWriter Log;
public conscmd_callback cmdparser;
public string componentname;
// STUPID HACK ALERT!!!! STUPID HACK ALERT!!!!!
// constype - the type of console to use (see enum ConsoleType)
// sparam - depending on the console type:
// TCP - the IP to bind to (127.0.0.1 if blank)
// Local - param ignored
// and for the iparam:
// TCP - the port to bind to
// Local - param ignored
// LogFile - duh
// componentname - which component of the OGS system? (user, asset etc)
// cmdparser - a reference to a conscmd_callback object
public ConsoleBase(string LogFile, string componentname, conscmd_callback cmdparser)
{
this.componentname = componentname;
this.cmdparser = cmdparser;
System.Console.WriteLine("ServerConsole.cs - creating new local console");
System.Console.WriteLine("Logs will be saved to current directory in " + LogFile);
Log = File.AppendText(LogFile);
Log.WriteLine("========================================================================");
Log.WriteLine(componentname + " Started at " + DateTime.Now.ToString());
}
public void Close()
{
Log.WriteLine("Shutdown at " + DateTime.Now.ToString());
Log.Close();
}
public void Write(string format, params object[] args)
{
Log.Write(format, args);
System.Console.Write(format, args);
return;
}
public void WriteLine(string format, params object[] args)
{
Log.WriteLine(format, args);
System.Console.WriteLine(format, args);
return;
}
public string ReadLine()
{
string TempStr = System.Console.ReadLine();
Log.WriteLine(TempStr);
return TempStr;
}
public int Read()
{
int TempInt = System.Console.Read();
Log.Write((char)TempInt);
return TempInt;
}
// Displays a prompt and waits for the user to enter a string, then returns that string
// Done with no echo and suitable for passwords
public string PasswdPrompt(string prompt)
{
// FIXME: Needs to be better abstracted
Log.WriteLine(prompt);
this.Write(prompt);
ConsoleColor oldfg = System.Console.ForegroundColor;
System.Console.ForegroundColor = System.Console.BackgroundColor;
string temp = System.Console.ReadLine();
System.Console.ForegroundColor = oldfg;
return temp;
}
// Displays a command prompt and waits for the user to enter a string, then returns that string
public string CmdPrompt(string prompt)
{
this.Write(prompt);
return this.ReadLine();
}
// Displays a command prompt and returns a default value if the user simply presses enter
public string CmdPrompt(string prompt, string defaultresponse)
{
string temp = CmdPrompt(prompt);
if (temp == "")
{
return defaultresponse;
}
else
{
return temp;
}
}
// Displays a command prompt and returns a default value, user may only enter 1 of 2 options
public string CmdPrompt(string prompt, string defaultresponse, string OptionA, string OptionB)
{
bool itisdone = false;
string temp = CmdPrompt(prompt, defaultresponse);
while (itisdone == false)
{
if ((temp == OptionA) || (temp == OptionB))
{
itisdone = true;
}
else
{
this.WriteLine("Valid options are " + OptionA + " or " + OptionB);
temp = CmdPrompt(prompt, defaultresponse);
}
}
return temp;
}
// Runs a command with a number of parameters
public Object RunCmd(string Cmd, string[] cmdparams)
{
cmdparser.RunCmd(Cmd, cmdparams);
return null;
}
// Shows data about something
public void ShowCommands(string ShowWhat)
{
cmdparser.Show(ShowWhat);
}
public void MainConsolePrompt()
{
string[] tempstrarray;
string tempstr = this.CmdPrompt(this.componentname + "# ");
tempstrarray = tempstr.Split(' ');
string cmd = tempstrarray[0];
Array.Reverse(tempstrarray);
Array.Resize<string>(ref tempstrarray, tempstrarray.Length - 1);
Array.Reverse(tempstrarray);
string[] cmdparams = (string[])tempstrarray;
RunCmd(cmd, cmdparams);
}
}
}

View File

@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace OpenSim.Framework.Console
{
public interface conscmd_callback
{
void RunCmd(string cmd, string[] cmdparams);
void Show(string ShowWhat);
}
}

View File

@ -0,0 +1,48 @@
/*
* Copyright (c) OpenSim project, http://sim.opensecondlife.org/
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the <organization> nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System;
namespace OpenSim.Framework.Console
{
public class MainConsole {
private static ConsoleBase instance;
public static ConsoleBase Instance
{
get
{
return instance;
}
set
{
instance = value;
}
}
}
}

View File

@ -0,0 +1,89 @@
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ProjectType>Local</ProjectType>
<ProductVersion>8.0.50727</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{A7CD0630-0000-0000-0000-000000000000}</ProjectGuid>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ApplicationIcon></ApplicationIcon>
<AssemblyKeyContainerName>
</AssemblyKeyContainerName>
<AssemblyName>OpenSim.Framework.Console</AssemblyName>
<DefaultClientScript>JScript</DefaultClientScript>
<DefaultHTMLPageLayout>Grid</DefaultHTMLPageLayout>
<DefaultTargetSchema>IE50</DefaultTargetSchema>
<DelaySign>false</DelaySign>
<OutputType>Library</OutputType>
<AppDesignerFolder></AppDesignerFolder>
<RootNamespace>OpenSim.Framework.Console</RootNamespace>
<StartupObject></StartupObject>
<FileUpgradeFlags>
</FileUpgradeFlags>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>
<BaseAddress>285212672</BaseAddress>
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
<ConfigurationOverrideFile>
</ConfigurationOverrideFile>
<DefineConstants>TRACE;DEBUG</DefineConstants>
<DocumentationFile></DocumentationFile>
<DebugSymbols>True</DebugSymbols>
<FileAlignment>4096</FileAlignment>
<Optimize>False</Optimize>
<OutputPath>..\bin\</OutputPath>
<RegisterForComInterop>False</RegisterForComInterop>
<RemoveIntegerChecks>False</RemoveIntegerChecks>
<TreatWarningsAsErrors>False</TreatWarningsAsErrors>
<WarningLevel>4</WarningLevel>
<NoWarn></NoWarn>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>
<BaseAddress>285212672</BaseAddress>
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
<ConfigurationOverrideFile>
</ConfigurationOverrideFile>
<DefineConstants>TRACE</DefineConstants>
<DocumentationFile></DocumentationFile>
<DebugSymbols>False</DebugSymbols>
<FileAlignment>4096</FileAlignment>
<Optimize>True</Optimize>
<OutputPath>..\bin\</OutputPath>
<RegisterForComInterop>False</RegisterForComInterop>
<RemoveIntegerChecks>False</RemoveIntegerChecks>
<TreatWarningsAsErrors>False</TreatWarningsAsErrors>
<WarningLevel>4</WarningLevel>
<NoWarn></NoWarn>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" >
<HintPath>System.dll</HintPath>
<Private>False</Private>
</Reference>
</ItemGroup>
<ItemGroup>
</ItemGroup>
<ItemGroup>
<Compile Include="AssemblyInfo.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="ConsoleBase.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="ConsoleCallbacksBase.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="MainConsole.cs">
<SubType>Code</SubType>
</Compile>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" />
<PropertyGroup>
<PreBuildEvent>
</PreBuildEvent>
<PostBuildEvent>
</PostBuildEvent>
</PropertyGroup>
</Project>

View File

@ -0,0 +1,12 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ReferencePath>C:\New Folder\second-life-viewer\opensim-dailys2\opensim02-04\bin\</ReferencePath>
<LastOpenVersion>8.0.50727</LastOpenVersion>
<ProjectView>ProjectFiles</ProjectView>
<ProjectTrust>0</ProjectTrust>
</PropertyGroup>
<PropertyGroup Condition = " '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' " />
<PropertyGroup Condition = " '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
</Project>

View File

@ -0,0 +1,42 @@
<?xml version="1.0" ?>
<project name="OpenSim.Framework.Console" default="build">
<target name="build">
<echo message="Build Directory is ${project::get-base-directory()}/${build.dir}" />
<mkdir dir="${project::get-base-directory()}/${build.dir}" />
<copy todir="${project::get-base-directory()}/${build.dir}">
<fileset basedir="${project::get-base-directory()}">
</fileset>
</copy>
<csc target="library" debug="${build.debug}" unsafe="False" define="TRACE" output="${project::get-base-directory()}/${build.dir}/${project::get-name()}.dll">
<resources prefix="OpenSim.Framework.Console" dynamicprefix="true" >
</resources>
<sources failonempty="true">
<include name="AssemblyInfo.cs" />
<include name="ConsoleBase.cs" />
<include name="ConsoleCallbacksBase.cs" />
<include name="MainConsole.cs" />
</sources>
<references basedir="${project::get-base-directory()}">
<lib>
<include name="${project::get-base-directory()}" />
<include name="${project::get-base-directory()}/${build.dir}" />
</lib>
<include name="System.dll" />
</references>
</csc>
<echo message="Copying from [${project::get-base-directory()}/${build.dir}/] to [${project::get-base-directory()}/../bin/" />
<mkdir dir="${project::get-base-directory()}/../bin/"/>
<copy todir="${project::get-base-directory()}/../bin/">
<fileset basedir="${project::get-base-directory()}/${build.dir}/" >
<include name="*.dll"/>
<include name="*.exe"/>
</fileset>
</copy>
</target>
<target name="clean">
<delete dir="${bin.dir}" failonerror="false" />
<delete dir="${obj.dir}" failonerror="false" />
</target>
<target name="doc" description="Creates documentation.">
</target>
</project>

View File

@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Text;
using libsecondlife;
namespace OpenSim.Framework.Interfaces
{
public class AgentCircuitData
{
public AgentCircuitData() { }
public LLUUID AgentID;
public LLUUID SessionID;
public LLUUID SecureSessionID;
public string firstname;
public string lastname;
public uint circuitcode;
public bool child;
}
}

View File

@ -0,0 +1,242 @@
using System;
using System.Collections.Generic;
using System.Text;
using libsecondlife;
using libsecondlife.Packets;
using OpenSim.Framework.Assets;
namespace OpenSim.Framework.Inventory
{
public class AgentInventory
{
//Holds the local copy of Inventory info for a agent
public Dictionary<LLUUID, InventoryFolder> InventoryFolders;
public Dictionary<LLUUID, InventoryItem> InventoryItems;
public InventoryFolder InventoryRoot = new InventoryFolder();
public int LastCached; //maybe used by opensim app, time this was last stored/compared to user server
public LLUUID AgentID;
public AvatarWearable[] Wearables;
public AgentInventory()
{
InventoryFolders = new Dictionary<LLUUID, InventoryFolder>();
InventoryItems = new Dictionary<LLUUID, InventoryItem>();
this.Initialise();
}
public virtual void Initialise()
{
Wearables = new AvatarWearable[13]; //should be 12 of these
for (int i = 0; i < 13; i++)
{
Wearables[i] = new AvatarWearable();
}
InventoryRoot = new InventoryFolder();
InventoryRoot.FolderID = LLUUID.Random();
InventoryRoot.ParentID = LLUUID.Zero;
InventoryRoot.Version = 1;
InventoryRoot.DefaultType = 8;
InventoryRoot.OwnerID = this.AgentID;
InventoryRoot.FolderName = "My Inventory";
InventoryFolders.Add(InventoryRoot.FolderID, InventoryRoot);
}
public bool CreateNewFolder(LLUUID folderID, ushort type)
{
InventoryFolder Folder = new InventoryFolder();
Folder.FolderID = folderID;
Folder.OwnerID = this.AgentID;
Folder.DefaultType = type;
this.InventoryFolders.Add(Folder.FolderID, Folder);
return (true);
}
public void CreateRootFolder(LLUUID newAgentID, bool createTextures)
{
this.AgentID = newAgentID;
/* InventoryRoot = new InventoryFolder();
InventoryRoot.FolderID = LLUUID.Random();
InventoryRoot.ParentID = new LLUUID();
InventoryRoot.Version = 1;
InventoryRoot.DefaultType = 8;
InventoryRoot.OwnerID = this.AgentID;
InventoryRoot.FolderName = "My Inventory-";
InventoryFolders.Add(InventoryRoot.FolderID, InventoryRoot);*/
InventoryRoot.OwnerID = this.AgentID;
if (createTextures)
{
this.CreateNewFolder(LLUUID.Random(), 0, "Textures", InventoryRoot.FolderID);
}
}
public bool CreateNewFolder(LLUUID folderID, ushort type, string folderName)
{
InventoryFolder Folder = new InventoryFolder();
Folder.FolderID = folderID;
Folder.OwnerID = this.AgentID;
Folder.DefaultType = type;
Folder.FolderName = folderName;
this.InventoryFolders.Add(Folder.FolderID, Folder);
return (true);
}
public bool CreateNewFolder(LLUUID folderID, ushort type, string folderName, LLUUID parent)
{
Console.WriteLine("creating new folder called " + folderName + " in agents inventory");
InventoryFolder Folder = new InventoryFolder();
Folder.FolderID = folderID;
Folder.OwnerID = this.AgentID;
Folder.DefaultType = type;
Folder.FolderName = folderName;
Folder.ParentID = parent;
this.InventoryFolders.Add(Folder.FolderID, Folder);
return (true);
}
public bool HasFolder(LLUUID folderID)
{
if (this.InventoryFolders.ContainsKey(folderID))
{
return true;
}
return false;
}
public bool UpdateItemAsset(LLUUID itemID, AssetBase asset)
{
if(this.InventoryItems.ContainsKey(itemID))
{
InventoryItem Item = this.InventoryItems[itemID];
Item.AssetID = asset.FullID;
Console.WriteLine("updated inventory item " + itemID.ToStringHyphenated() + " so it now is set to asset " + asset.FullID.ToStringHyphenated());
//TODO need to update the rest of the info
}
return true;
}
public bool UpdateItemDetails(LLUUID itemID, UpdateInventoryItemPacket.InventoryDataBlock packet)
{
Console.WriteLine("updating inventory item details");
if (this.InventoryItems.ContainsKey(itemID))
{
Console.WriteLine("changing name to "+ Helpers.FieldToString(packet.Name));
InventoryItem Item = this.InventoryItems[itemID];
Item.Name = Helpers.FieldToString(packet.Name);
Console.WriteLine("updated inventory item " + itemID.ToStringHyphenated());
//TODO need to update the rest of the info
}
return true;
}
public LLUUID AddToInventory(LLUUID folderID, AssetBase asset)
{
if (this.InventoryFolders.ContainsKey(folderID))
{
LLUUID NewItemID = LLUUID.Random();
InventoryItem Item = new InventoryItem();
Item.FolderID = folderID;
Item.OwnerID = AgentID;
Item.AssetID = asset.FullID;
Item.ItemID = NewItemID;
Item.Type = asset.Type;
Item.Name = asset.Name;
Item.Description = asset.Description;
Item.InvType = asset.InvType;
this.InventoryItems.Add(Item.ItemID, Item);
InventoryFolder Folder = InventoryFolders[Item.FolderID];
Folder.Items.Add(Item);
return (Item.ItemID);
}
else
{
return (null);
}
}
public bool DeleteFromInventory(LLUUID itemID)
{
bool res = false;
if (this.InventoryItems.ContainsKey(itemID))
{
InventoryItem item = this.InventoryItems[itemID];
this.InventoryItems.Remove(itemID);
foreach (InventoryFolder fold in InventoryFolders.Values)
{
if (fold.Items.Contains(item))
{
fold.Items.Remove(item);
break;
}
}
res = true;
}
return res;
}
}
public class InventoryFolder
{
public List<InventoryItem> Items;
//public List<InventoryFolder> Subfolders;
public LLUUID FolderID;
public LLUUID OwnerID;
public LLUUID ParentID = LLUUID.Zero;
public string FolderName;
public ushort DefaultType;
public ushort Version;
public InventoryFolder()
{
Items = new List<InventoryItem>();
//Subfolders = new List<InventoryFolder>();
}
}
public class InventoryItem
{
public LLUUID FolderID;
public LLUUID OwnerID;
public LLUUID ItemID;
public LLUUID AssetID;
public LLUUID CreatorID;
public sbyte InvType;
public sbyte Type;
public string Name ="";
public string Description;
public InventoryItem()
{
this.CreatorID = LLUUID.Zero;
}
public string ExportString()
{
string typ = "notecard";
string result = "";
result += "\tinv_object\t0\n\t{\n";
result += "\t\tobj_id\t%s\n";
result += "\t\tparent_id\t"+ ItemID.ToString() +"\n";
result += "\t\ttype\t"+ typ +"\n";
result += "\t\tname\t" + Name+"|\n";
result += "\t}\n";
return result;
}
}
public class AvatarWearable
{
public LLUUID AssetID = new LLUUID("00000000-0000-0000-0000-000000000000");
public LLUUID ItemID = new LLUUID("00000000-0000-0000-0000-000000000000");
public AvatarWearable()
{
}
}
}

View File

@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Text;
using libsecondlife;
namespace OpenSim.Framework.Assets
{
public class AssetBase
{
public byte[] Data;
public LLUUID FullID;
public sbyte Type;
public sbyte InvType;
public string Name;
public string Description;
public AssetBase()
{
}
}
}

View File

@ -0,0 +1,33 @@
using System;
using System.Threading;
using System.Collections.Generic;
using System.Text;
namespace OpenSim.Framework.Utilities
{
public class BlockingQueue<T>
{
private Queue<T> _queue = new Queue<T>();
private object _queueSync = new object();
public void Enqueue(T value)
{
lock (_queueSync)
{
_queue.Enqueue(value);
Monitor.Pulse(_queueSync);
}
}
public T Dequeue()
{
lock (_queueSync)
{
if (_queue.Count < 1)
Monitor.Wait(_queueSync);
return _queue.Dequeue();
}
}
}
}

View File

@ -0,0 +1,149 @@
/*
* Copyright (c) OpenSim project, http://sim.opensecondlife.org/
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the <organization> nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System;
namespace OpenSim.Framework.Terrain
{
public class HeightmapGenHills
{
private Random Rand = new Random();
private int NumHills;
private float HillMin;
private float HillMax;
private bool Island;
private float[] heightmap;
public float[] GenerateHeightmap(int numHills, float hillMin, float hillMax, bool island)
{
NumHills = numHills;
HillMin = hillMin;
HillMax = hillMax;
Island = island;
heightmap = new float[256 * 256];
for (int i = 0; i < numHills; i++)
{
AddHill();
}
Normalize();
return heightmap;
}
private void AddHill()
{
float x, y;
float radius = RandomRange(HillMin, HillMax);
if (Island)
{
// Which direction from the center of the map the hill is placed
float theta = RandomRange(0, 6.28f);
// How far from the center of the map to place the hill. The radius
// is subtracted from the range to prevent any part of the hill from
// reaching the edge of the map
float distance = RandomRange(radius / 2.0f, 128.0f - radius);
x = 128.0f + (float)Math.Cos(theta) * distance;
y = 128.0f + (float)Math.Sin(theta) * distance;
}
else
{
x = RandomRange(-radius, 256.0f + radius);
y = RandomRange(-radius, 256.0f + radius);
}
float radiusSq = radius * radius;
float distSq;
float height;
int xMin = (int)(x - radius) - 1;
int xMax = (int)(x + radius) + 1;
if (xMin < 0) xMin = 0;
if (xMax > 255) xMax = 255;
int yMin = (int)(y - radius) - 1;
int yMax = (int)(y + radius) + 1;
if (yMin < 0) yMin = 0;
if (yMax > 255) yMax = 255;
// Loop through each affected cell and determine the height at that point
for (int v = yMin; v <= yMax; ++v)
{
float fv = (float)v;
for (int h = xMin; h <= xMax; ++h)
{
float fh = (float)h;
// Determine how far from the center of this hill this point is
distSq = (x - fh) * (x - fh) + (y - fv) * (y - fv);
height = radiusSq - distSq;
// Don't add negative hill values
if (height > 0.0f) heightmap[h + v * 256] += height;
}
}
}
private void Normalize()
{
float min = heightmap[0];
float max = heightmap[0];
for (int x = 0; x < 256; x++)
{
for (int y = 0; y < 256; y++)
{
if (heightmap[x + y * 256] < min) min = heightmap[x + y * 256];
if (heightmap[x + y * 256] > max) max = heightmap[x + y * 256];
}
}
// Avoid a rare divide by zero
if (min != max)
{
for (int x = 0; x < 256; x++)
{
for (int y = 0; y < 256; y++)
{
heightmap[x + y * 256] = ((heightmap[x + y * 256] - min) / (max - min)) * (HillMax - HillMin);
}
}
}
}
private float RandomRange(float min, float max)
{
return (float)Rand.NextDouble() * (max - min) + min;
}
}
}

View File

@ -0,0 +1,68 @@
/*
* Copyright (c) OpenSim project, http://sim.opensecondlife.org/
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the <organization> nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System;
using System.Net;
using System.Net.Sockets;
using System.IO;
using System.Threading;
using libsecondlife;
using OpenSim.Framework.Assets;
namespace OpenSim.Framework.Interfaces
{
/// <summary>
/// Description of IAssetServer.
/// </summary>
public interface IAssetServer
{
void SetReceiver(IAssetReceiver receiver);
void RequestAsset(LLUUID assetID, bool isTexture);
void UpdateAsset(AssetBase asset);
void UploadNewAsset(AssetBase asset);
void SetServerInfo(string ServerUrl, string ServerKey);
void Close();
}
// could change to delegate?
public interface IAssetReceiver
{
void AssetReceived(AssetBase asset, bool IsTexture);
void AssetNotFound(AssetBase asset);
}
public interface IAssetPlugin
{
IAssetServer GetAssetServer();
}
public struct ARequest
{
public LLUUID AssetID;
public bool IsTexture;
}
}

View File

@ -0,0 +1,76 @@
/*
Copyright (c) OpenSim project, http://osgrid.org/
* Copyright (c) <year>, <copyright holder>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the <organization> nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System;
using System.Collections.Generic;
using System.IO;
using libsecondlife;
//using OpenSim.world;
namespace OpenSim.Framework.Interfaces
{
/// <summary>
/// This class handles connection to the underlying database used for configuration of the region.
/// Region content is also stored by this class. The main entry point is InitConfig() which attempts to locate
/// opensim.yap in the current working directory. If opensim.yap can not be found, default settings are loaded from
/// what is hardcoded here and then saved into opensim.yap for future startups.
/// </summary>
public abstract class SimConfig
{
public string RegionName;
public uint RegionLocX;
public uint RegionLocY;
public ulong RegionHandle;
public int IPListenPort;
public string IPListenAddr;
public string AssetURL;
public string AssetSendKey;
public string GridURL;
public string GridSendKey;
public string GridRecvKey;
public string UserURL;
public string UserSendKey;
public string UserRecvKey;
public abstract void InitConfig(bool sandboxMode);
public abstract void LoadFromGrid();
}
public interface ISimConfig
{
SimConfig GetConfigObject();
}
}

View File

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace OpenSim.Framework.Interfaces
{
public interface IGenericConfig
{
void LoadData();
string GetAttribute(string attributeName);
bool SetAttribute(string attributeName, string attributeValue);
void Commit();
void Close();
}
}

View File

@ -0,0 +1,64 @@
/*
Copyright (c) OpenSim project, http://osgrid.org/
* Copyright (c) <year>, <copyright holder>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the <organization> nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System;
using System.Collections.Generic;
using System.IO;
using libsecondlife;
//using OpenSim.world;
namespace OpenSim.Framework.Interfaces
{
/// <summary>
/// </summary>
public abstract class GridConfig
{
public string GridOwner;
public string DefaultStartupMsg;
public string DefaultAssetServer;
public string AssetSendKey;
public string AssetRecvKey;
public string DefaultUserServer;
public string UserSendKey;
public string UserRecvKey;
public string SimSendKey;
public string SimRecvKey;
public abstract void InitConfig();
}
public interface IGridConfig
{
GridConfig GetConfigObject();
}
}

View File

@ -0,0 +1,78 @@
/*
* Copyright (c) OpenSim project, http://sim.opensecondlife.org/
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the <organization> nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System;
using System.Collections.Generic;
using System.Net;
using System.Net.Sockets;
using System.IO;
using libsecondlife;
using OpenSim;
namespace OpenSim.Framework.Interfaces
{
/// <summary>
/// Handles connection to Grid Servers.
/// also Sim to Sim connections?
/// </summary>
public interface IGridServer
{
UUIDBlock RequestUUIDBlock();
NeighbourInfo[] RequestNeighbours(); //should return a array of neighbouring regions
AuthenticateResponse AuthenticateSession(LLUUID sessionID, LLUUID agentID, uint circuitCode);
bool LogoutSession(LLUUID sessionID, LLUUID agentID, uint circuitCode);
string GetName();
bool RequestConnection(LLUUID SimUUID, string sim_ip, uint sim_port);
void SetServerInfo(string ServerUrl, string SendKey, string RecvKey);
void Close();
}
public struct UUIDBlock
{
public LLUUID BlockStart;
public LLUUID BlockEnd;
}
public class AuthenticateResponse
{
public bool Authorised;
public Login LoginInfo;
public AuthenticateResponse()
{
}
}
public interface IGridPlugin
{
IGridServer GetGridServer();
}
}

View File

@ -0,0 +1,53 @@
/*
* Copyright (c) OpenSim project, http://sim.opensecondlife.org/
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the <organization> nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System;
using libsecondlife;
using OpenSim.Framework.Assets;
namespace OpenSim.Framework.Interfaces
{
/// <summary>
/// ILocalStorage. Really hacked together right now needs cleaning up
/// </summary>
public interface ILocalStorage
{
void StorePrim(PrimData prim);
void RemovePrim(LLUUID primID);
void LoadPrimitives(ILocalStorageReceiver receiver);
float[,] LoadWorld();
void SaveMap(float[,] heightmap);
void ShutDown();
}
public interface ILocalStorageReceiver
{
void PrimFromStorage(PrimData prim);
}
}

View File

@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace OpenSim.Framework.Interfaces
{
public interface IScriptAPI
{
OSVector3 GetEntityPosition(uint localID);
void SetEntityPosition(uint localID, float x, float y, float z);
uint GetRandomAvatarID();
}
}

View File

@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace OpenSim.Framework.Interfaces
{
public interface IScriptEngine
{
bool Init(IScriptAPI api);
string GetName();
void LoadScript(string script, string scriptName, uint entityID);
void OnFrame();
}
}

View File

@ -0,0 +1,58 @@
/*
Copyright (c) OpenSim project, http://osgrid.org/
* Copyright (c) <year>, <copyright holder>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the <organization> nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System;
using System.Collections.Generic;
using System.IO;
using libsecondlife;
//using OpenSim.world;
namespace OpenSim.Framework.Interfaces
{
/// <summary>
/// </summary>
public abstract class UserConfig
{
public string DefaultStartupMsg;
public string GridServerURL;
public string GridSendKey;
public string GridRecvKey;
public abstract void InitConfig();
}
public interface IUserConfig
{
UserConfig GetConfigObject();
}
}

View File

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Text;
using OpenSim.Framework.Inventory;
using libsecondlife;
namespace OpenSim.Framework.Interfaces
{
public interface IUserServer
{
AgentInventory RequestAgentsInventory(LLUUID agentID);
void SetServerInfo(string ServerUrl, string SendKey, string RecvKey);
bool UpdateAgentsInventory(LLUUID agentID, AgentInventory inventory);
}
}

View File

@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Text;
using libsecondlife;
namespace OpenSim.Framework.Interfaces
{
public abstract class LocalGridBase : IGridServer
{
public abstract UUIDBlock RequestUUIDBlock();
public abstract NeighbourInfo[] RequestNeighbours();
public abstract AuthenticateResponse AuthenticateSession(LLUUID sessionID, LLUUID agentID, uint circuitCode);
public abstract bool LogoutSession(LLUUID sessionID, LLUUID agentID, uint circuitCode);
public abstract string GetName();
public abstract bool RequestConnection(LLUUID SimUUID, string sim_ip, uint sim_port);
public abstract void SetServerInfo(string ServerUrl, string SendKey, string RecvKey);
public abstract void AddNewSession(Login session);
public abstract void Close();
}
}

View File

@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Text;
using libsecondlife;
namespace OpenSim.Framework.Interfaces
{
public class Login
{
public string First = "Test";
public string Last = "User";
public LLUUID Agent;
public LLUUID Session;
public LLUUID SecureSession = LLUUID.Zero;
public LLUUID InventoryFolder;
public LLUUID BaseFolder;
public Login()
{
}
}
}

View File

@ -0,0 +1,14 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using Nwc.XmlRpc;
using libsecondlife;
namespace OpenSim.Framework.Grid
{
public abstract class LoginService
{
}
}

View File

@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace OpenSim.Framework.Interfaces
{
public class NeighbourInfo
{
public NeighbourInfo()
{
}
public ulong regionhandle;
public uint RegionLocX;
public uint RegionLocY;
public string sim_ip;
public uint sim_port;
}
}

View File

@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace OpenSim.Framework
{
public class OSVector3
{
public float X;
public float Y;
public float Z;
public OSVector3()
{
}
}
}

View File

@ -0,0 +1,178 @@
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ProjectType>Local</ProjectType>
<ProductVersion>8.0.50727</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{8ACA2445-0000-0000-0000-000000000000}</ProjectGuid>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ApplicationIcon>
</ApplicationIcon>
<AssemblyKeyContainerName>
</AssemblyKeyContainerName>
<AssemblyName>OpenSim.Framework</AssemblyName>
<DefaultClientScript>JScript</DefaultClientScript>
<DefaultHTMLPageLayout>Grid</DefaultHTMLPageLayout>
<DefaultTargetSchema>IE50</DefaultTargetSchema>
<DelaySign>false</DelaySign>
<OutputType>Library</OutputType>
<AppDesignerFolder>
</AppDesignerFolder>
<RootNamespace>OpenSim.Framework</RootNamespace>
<StartupObject>
</StartupObject>
<FileUpgradeFlags>
</FileUpgradeFlags>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>
<BaseAddress>285212672</BaseAddress>
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
<ConfigurationOverrideFile>
</ConfigurationOverrideFile>
<DefineConstants>TRACE;DEBUG</DefineConstants>
<DocumentationFile>
</DocumentationFile>
<DebugSymbols>True</DebugSymbols>
<FileAlignment>4096</FileAlignment>
<Optimize>False</Optimize>
<OutputPath>..\bin\</OutputPath>
<RegisterForComInterop>False</RegisterForComInterop>
<RemoveIntegerChecks>False</RemoveIntegerChecks>
<TreatWarningsAsErrors>False</TreatWarningsAsErrors>
<WarningLevel>4</WarningLevel>
<NoWarn>
</NoWarn>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>
<BaseAddress>285212672</BaseAddress>
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
<ConfigurationOverrideFile>
</ConfigurationOverrideFile>
<DefineConstants>TRACE</DefineConstants>
<DocumentationFile>
</DocumentationFile>
<DebugSymbols>False</DebugSymbols>
<FileAlignment>4096</FileAlignment>
<Optimize>True</Optimize>
<OutputPath>..\bin\</OutputPath>
<RegisterForComInterop>False</RegisterForComInterop>
<RemoveIntegerChecks>False</RemoveIntegerChecks>
<TreatWarningsAsErrors>False</TreatWarningsAsErrors>
<WarningLevel>4</WarningLevel>
<NoWarn>
</NoWarn>
</PropertyGroup>
<ItemGroup>
<Reference Include="System">
<HintPath>System.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="System.Data" />
<Reference Include="System.Xml">
<HintPath>System.Xml.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="libsecondlife.dll">
<HintPath>..\bin\libsecondlife.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Db4objects.Db4o.dll">
<HintPath>..\bin\Db4objects.Db4o.dll</HintPath>
<Private>False</Private>
</Reference>
</ItemGroup>
<ItemGroup>
</ItemGroup>
<ItemGroup>
<Compile Include="AgentCiruitData.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="AgentInventory.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="AssetBase.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="BlockingQueue.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="HeightMapGenHills.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="IAssetServer.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="IConfig.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="IGenericConfig.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="IGridConfig.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="IGridServer.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="ILocalStorage.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="IScriptAPI.cs" />
<Compile Include="IScriptEngine.cs" />
<Compile Include="IUserConfig.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="IUserServer.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="LocalGridBase.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Login.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="LoginService.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="NeighbourInfo.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="OSVector3.cs" />
<Compile Include="PrimData.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="RemoteGridBase.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="SimProfile.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="SimProfileBase.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="UserProfile.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="UserProfileManager.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="UserProfileManagerBase.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Util.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Properties\AssemblyInfo.cs">
<SubType>Code</SubType>
</Compile>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" />
<PropertyGroup>
<PreBuildEvent>
</PreBuildEvent>
<PostBuildEvent>
</PostBuildEvent>
</PropertyGroup>
</Project>

View File

@ -0,0 +1,12 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ReferencePath>C:\New Folder\second-life-viewer\opensim-dailys2\opensim02-04\bin\</ReferencePath>
<LastOpenVersion>8.0.50727</LastOpenVersion>
<ProjectView>ProjectFiles</ProjectView>
<ProjectTrust>0</ProjectTrust>
</PropertyGroup>
<PropertyGroup Condition = " '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' " />
<PropertyGroup Condition = " '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
</Project>

View File

@ -0,0 +1,67 @@
<?xml version="1.0" ?>
<project name="OpenSim.Framework" default="build">
<target name="build">
<echo message="Build Directory is ${project::get-base-directory()}/${build.dir}" />
<mkdir dir="${project::get-base-directory()}/${build.dir}" />
<copy todir="${project::get-base-directory()}/${build.dir}">
<fileset basedir="${project::get-base-directory()}">
</fileset>
</copy>
<csc target="library" debug="${build.debug}" unsafe="False" define="TRACE" output="${project::get-base-directory()}/${build.dir}/${project::get-name()}.dll">
<resources prefix="OpenSim.Framework" dynamicprefix="true" >
</resources>
<sources failonempty="true">
<include name="AgentCiruitData.cs" />
<include name="AgentInventory.cs" />
<include name="AssetBase.cs" />
<include name="BlockingQueue.cs" />
<include name="HeightMapGenHills.cs" />
<include name="IAssetServer.cs" />
<include name="IConfig.cs" />
<include name="IGenericConfig.cs" />
<include name="IGridConfig.cs" />
<include name="IGridServer.cs" />
<include name="ILocalStorage.cs" />
<include name="IUserConfig.cs" />
<include name="IUserServer.cs" />
<include name="LocalGridBase.cs" />
<include name="Login.cs" />
<include name="LoginService.cs" />
<include name="NeighbourInfo.cs" />
<include name="PrimData.cs" />
<include name="RemoteGridBase.cs" />
<include name="SimProfile.cs" />
<include name="SimProfileBase.cs" />
<include name="UserProfile.cs" />
<include name="UserProfileManager.cs" />
<include name="UserProfileManagerBase.cs" />
<include name="Util.cs" />
<include name="Properties/AssemblyInfo.cs" />
</sources>
<references basedir="${project::get-base-directory()}">
<lib>
<include name="${project::get-base-directory()}" />
<include name="${project::get-base-directory()}/${build.dir}" />
</lib>
<include name="System.dll" />
<include name="System.Xml.dll" />
<include name="../bin/libsecondlife.dll" />
<include name="../bin/Db4objects.Db4o.dll" />
</references>
</csc>
<echo message="Copying from [${project::get-base-directory()}/${build.dir}/] to [${project::get-base-directory()}/../bin/" />
<mkdir dir="${project::get-base-directory()}/../bin/"/>
<copy todir="${project::get-base-directory()}/../bin/">
<fileset basedir="${project::get-base-directory()}/${build.dir}/" >
<include name="*.dll"/>
<include name="*.exe"/>
</fileset>
</copy>
</target>
<target name="clean">
<delete dir="${bin.dir}" failonerror="false" />
<delete dir="${obj.dir}" failonerror="false" />
</target>
<target name="doc" description="Creates documentation.">
</target>
</project>

View File

@ -0,0 +1,168 @@
using System;
using System.Collections.Generic;
using System.Text;
using libsecondlife;
namespace OpenSim.Framework.Assets
{
public class PrimData
{
private const uint FULL_MASK_PERMISSIONS = 2147483647;
public LLUUID OwnerID;
public byte PCode;
public byte PathBegin;
public byte PathEnd;
public byte PathScaleX;
public byte PathScaleY;
public byte PathShearX;
public byte PathShearY;
public sbyte PathSkew;
public byte ProfileBegin;
public byte ProfileEnd;
public LLVector3 Scale;
public byte PathCurve;
public byte ProfileCurve;
public uint ParentID = 0;
public byte ProfileHollow;
public sbyte PathRadiusOffset;
public byte PathRevolutions;
public sbyte PathTaperX;
public sbyte PathTaperY;
public sbyte PathTwist;
public sbyte PathTwistBegin;
public byte[] Texture;
public Int32 CreationDate;
public uint OwnerMask = FULL_MASK_PERMISSIONS;
public uint NextOwnerMask = FULL_MASK_PERMISSIONS;
public uint GroupMask = FULL_MASK_PERMISSIONS;
public uint EveryoneMask = FULL_MASK_PERMISSIONS;
public uint BaseMask = FULL_MASK_PERMISSIONS;
//following only used during prim storage
public LLVector3 Position;
public LLQuaternion Rotation = new LLQuaternion(0,1,0,0);
public uint LocalID;
public LLUUID FullID;
public PrimData()
{
}
public PrimData(byte[] data)
{
int i =0;
this.OwnerID = new LLUUID(data, i); i += 16;
this.PCode = data[i++];
this.PathBegin = data[i++];
this.PathEnd = data[i++];
this.PathScaleX = data[i++];
this.PathScaleY = data[i++];
this.PathShearX = data[i++];
this.PathShearY = data[i++];
this.PathSkew = (sbyte)data[i++];
this.ProfileBegin = data[i++];
this.ProfileEnd = data[i++];
this.Scale = new LLVector3(data, i); i += 12;
this.PathCurve = data[i++];
this.ProfileCurve = data[i++];
this.ParentID = (uint)(data[i++] + (data[i++] << 8) + (data[i++] << 16) + (data[i++] << 24));
this.ProfileHollow = data[i++];
this.PathRadiusOffset = (sbyte)data[i++];
this.PathRevolutions = data[i++];
this.PathTaperX = (sbyte)data[i++];
this.PathTaperY =(sbyte) data[i++];
this.PathTwist = (sbyte) data[i++];
this.PathTwistBegin = (sbyte) data[i++];
ushort length = (ushort)(data[i++] + (data[i++] << 8));
this.Texture = new byte[length];
Array.Copy(data, i, Texture, 0, length); i += length;
this.CreationDate = (Int32)(data[i++] + (data[i++] << 8) + (data[i++] << 16) + (data[i++] << 24));
this.OwnerMask = (uint)(data[i++] + (data[i++] << 8) + (data[i++] << 16) + (data[i++] << 24));
this.NextOwnerMask = (uint)(data[i++] + (data[i++] << 8) + (data[i++] << 16) + (data[i++] << 24));
this.GroupMask = (uint)(data[i++] + (data[i++] << 8) + (data[i++] << 16) + (data[i++] << 24));
this.EveryoneMask = (uint)(data[i++] + (data[i++] << 8) + (data[i++] << 16) + (data[i++] << 24));
this.BaseMask = (uint)(data[i++] + (data[i++] << 8) + (data[i++] << 16) + (data[i++] << 24));
this.Position = new LLVector3(data, i); i += 12;
this.Rotation = new LLQuaternion(data,i, true); i += 12;
this.LocalID = (uint)(data[i++] + (data[i++] << 8) + (data[i++] << 16) + (data[i++] << 24));
this.FullID = new LLUUID(data, i); i += 16;
}
public byte[] ToBytes()
{
int i = 0;
byte[] bytes = new byte[121 + Texture.Length];
Array.Copy(OwnerID.GetBytes(), 0, bytes, i, 16); i += 16;
bytes[i++] = this.PCode;
bytes[i++] = this.PathBegin;
bytes[i++] = this.PathEnd;
bytes[i++] = this.PathScaleX;
bytes[i++] = this.PathScaleY;
bytes[i++] = this.PathShearX;
bytes[i++] = this.PathShearY;
bytes[i++] = (byte)this.PathSkew;
bytes[i++] = this.ProfileBegin;
bytes[i++] = this.ProfileEnd;
Array.Copy(Scale.GetBytes(), 0, bytes, i, 12); i += 12;
bytes[i++] = this.PathCurve;
bytes[i++] = this.ProfileCurve;
bytes[i++] = (byte)(ParentID % 256);
bytes[i++] = (byte)((ParentID >> 8) % 256);
bytes[i++] = (byte)((ParentID >> 16) % 256);
bytes[i++] = (byte)((ParentID >> 24) % 256);
bytes[i++] = this.ProfileHollow;
bytes[i++] = ((byte)this.PathRadiusOffset);
bytes[i++] = this.PathRevolutions;
bytes[i++] = ((byte) this.PathTaperX);
bytes[i++] = ((byte) this.PathTaperY);
bytes[i++] = ((byte) this.PathTwist);
bytes[i++] = ((byte) this.PathTwistBegin);
bytes[i++] = (byte)(Texture.Length % 256);
bytes[i++] = (byte)((Texture.Length >> 8) % 256);
Array.Copy(Texture, 0, bytes, i, Texture.Length); i += Texture.Length;
bytes[i++] = (byte)(this.CreationDate % 256);
bytes[i++] = (byte)((this.CreationDate >> 8) % 256);
bytes[i++] = (byte)((this.CreationDate >> 16) % 256);
bytes[i++] = (byte)((this.CreationDate >> 24) % 256);
bytes[i++] = (byte)(this.OwnerMask % 256);
bytes[i++] = (byte)((this.OwnerMask >> 8) % 256);
bytes[i++] = (byte)((this.OwnerMask >> 16) % 256);
bytes[i++] = (byte)((this.OwnerMask >> 24) % 256);
bytes[i++] = (byte)(this.NextOwnerMask % 256);
bytes[i++] = (byte)((this.NextOwnerMask >> 8) % 256);
bytes[i++] = (byte)((this.NextOwnerMask >> 16) % 256);
bytes[i++] = (byte)((this.NextOwnerMask >> 24) % 256);
bytes[i++] = (byte)(this.GroupMask % 256);
bytes[i++] = (byte)((this.GroupMask >> 8) % 256);
bytes[i++] = (byte)((this.GroupMask >> 16) % 256);
bytes[i++] = (byte)((this.GroupMask >> 24) % 256);
bytes[i++] = (byte)(this.EveryoneMask % 256);
bytes[i++] = (byte)((this.EveryoneMask >> 8) % 256);
bytes[i++] = (byte)((this.EveryoneMask >> 16) % 256);
bytes[i++] = (byte)((this.EveryoneMask >> 24) % 256);
bytes[i++] = (byte)(this.BaseMask % 256);
bytes[i++] = (byte)((this.BaseMask >> 8) % 256);
bytes[i++] = (byte)((this.BaseMask >> 16) % 256);
bytes[i++] = (byte)((this.BaseMask >> 24) % 256);
Array.Copy(this.Position.GetBytes(), 0, bytes, i, 12); i += 12;
if (this.Rotation == new LLQuaternion(0,0,0,0))
{
this.Rotation = new LLQuaternion(0, 1, 0, 0);
}
Array.Copy(this.Rotation.GetBytes(), 0, bytes, i, 12); i += 12;
bytes[i++] = (byte)(this.LocalID % 256);
bytes[i++] = (byte)((this.LocalID >> 8) % 256);
bytes[i++] = (byte)((this.LocalID >> 16) % 256);
bytes[i++] = (byte)((this.LocalID >> 24) % 256);
Array.Copy(FullID.GetBytes(), 0, bytes, i, 16); i += 16;
return bytes;
}
}
}

View File

@ -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("OpenSim.FrameWork")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("OpenSim.FrameWork")]
[assembly: AssemblyCopyright("Copyright © 2007")]
[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("a08e20c7-f191-4137-b1f0-9291408fa521")]
// 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")]

View File

@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using System.Text;
using libsecondlife;
namespace OpenSim.Framework.Interfaces
{
public abstract class RemoteGridBase : IGridServer
{
public abstract Dictionary<uint, AgentCircuitData> agentcircuits
{
get;
set;
}
public abstract UUIDBlock RequestUUIDBlock();
public abstract NeighbourInfo[] RequestNeighbours();
public abstract AuthenticateResponse AuthenticateSession(LLUUID sessionID, LLUUID agentID, uint circuitCode);
public abstract bool LogoutSession(LLUUID sessionID, LLUUID agentID, uint circuitCode);
public abstract string GetName();
public abstract bool RequestConnection(LLUUID SimUUID, string sim_ip, uint sim_port);
public abstract void SetServerInfo(string ServerUrl, string SendKey, string RecvKey);
public abstract void Close();
}
}

View File

@ -0,0 +1,51 @@
using System;
using System.Collections.Generic;
using System.Collections;
using System.Xml;
using System.Text;
using libsecondlife;
using Nwc.XmlRpc;
namespace OpenSim.Framework.Sims
{
public class SimProfile : SimProfileBase
{
public SimProfile LoadFromGrid(ulong region_handle, string GridURL, string SendKey, string RecvKey)
{
try
{
Hashtable GridReqParams = new Hashtable();
GridReqParams["region_handle"] = region_handle.ToString();
GridReqParams["caller"] = "userserver";
GridReqParams["authkey"] = SendKey;
ArrayList SendParams = new ArrayList();
SendParams.Add(GridReqParams);
XmlRpcRequest GridReq = new XmlRpcRequest("get_sim_info", SendParams);
XmlRpcResponse GridResp = GridReq.Send(GridURL, 3000);
Hashtable RespData = (Hashtable)GridResp.Value;
this.UUID = new LLUUID((string)RespData["UUID"]);
this.regionhandle = (ulong)Convert.ToUInt64(RespData["regionhandle"]);
this.regionname = (string)RespData["regionname"];
this.sim_ip = (string)RespData["sim_ip"];
this.sim_port = (uint)Convert.ToUInt16(RespData["sim_port"]);
this.caps_url = (string)RespData["caps_url"];
this.RegionLocX = (uint)Convert.ToUInt32(RespData["RegionLocX"]);
this.RegionLocY = (uint)Convert.ToUInt32(RespData["RegionLocY"]);
this.sendkey = (string)RespData["sendkey"];
this.recvkey = (string)RespData["recvkey"];
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
}
return this;
}
public SimProfile()
{
}
}
}

View File

@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.Text;
using libsecondlife;
namespace OpenSim.Framework.Sims
{
public class SimProfileBase
{
public LLUUID UUID;
public ulong regionhandle;
public string regionname;
public string sim_ip;
public uint sim_port;
public string caps_url;
public uint RegionLocX;
public uint RegionLocY;
public string sendkey;
public string recvkey;
public bool online;
public SimProfileBase()
{
}
}
}

View File

@ -0,0 +1,51 @@
using System;
using System.Collections.Generic;
using System.Text;
using libsecondlife;
using OpenSim.Framework.Inventory;
namespace OpenSim.Framework.User
{
public class UserProfile
{
public string firstname;
public string lastname;
public ulong homeregionhandle;
public LLVector3 homepos;
public LLVector3 homelookat;
public bool IsGridGod = false;
public bool IsLocal = true; // will be used in future for visitors from foreign grids
public string AssetURL;
public string MD5passwd;
public LLUUID CurrentSessionID;
public LLUUID CurrentSecureSessionID;
public LLUUID UUID;
public Dictionary<LLUUID, uint> Circuits = new Dictionary<LLUUID, uint>(); // tracks circuit codes
public AgentInventory Inventory;
public UserProfile()
{
Circuits = new Dictionary<LLUUID, uint>();
Inventory = new AgentInventory();
homeregionhandle = Helpers.UIntsToLong((997 * 256), (996 * 256)); ;
}
public void InitSessionData()
{
CurrentSessionID = LLUUID.Random();
CurrentSecureSessionID = LLUUID.Random();
}
public void AddSimCircuit(uint circuitCode, LLUUID regionUUID)
{
if (this.Circuits.ContainsKey(regionUUID) == false)
this.Circuits.Add(regionUUID, circuitCode);
}
}
}

View File

@ -0,0 +1,250 @@
using System;
using System.Collections.Generic;
using System.Collections;
using System.Text;
using System.Text.RegularExpressions;
using System.Xml;
using libsecondlife;
using Nwc.XmlRpc;
using OpenSim.Framework.Sims;
using OpenSim.Framework.Inventory;
using OpenSim.Framework.Utilities;
namespace OpenSim.Framework.User
{
public class UserProfileManager : UserProfileManagerBase
{
public string GridURL;
public string GridSendKey;
public string GridRecvKey;
public string DefaultStartupMsg;
public UserProfileManager()
{
}
public void SetKeys(string sendKey, string recvKey, string url, string message)
{
GridRecvKey = recvKey;
GridSendKey = sendKey;
GridURL = url;
DefaultStartupMsg = message;
}
public virtual string ParseXMLRPC(string requestBody)
{
XmlRpcRequest request = (XmlRpcRequest)(new XmlRpcRequestDeserializer()).Deserialize(requestBody);
switch (request.MethodName)
{
case "login_to_simulator":
XmlRpcResponse response = XmlRpcLoginMethod(request);
return (Regex.Replace(XmlRpcResponseSerializer.Singleton.Serialize(response), "utf-16", "utf-8"));
}
return "";
}
public XmlRpcResponse XmlRpcLoginMethod(XmlRpcRequest request)
{
XmlRpcResponse response = new XmlRpcResponse();
Hashtable requestData = (Hashtable)request.Params[0];
bool GoodXML = (requestData.Contains("first") && requestData.Contains("last") && requestData.Contains("passwd"));
bool GoodLogin = false;
string firstname = "";
string lastname = "";
string passwd = "";
if (GoodXML)
{
firstname = (string)requestData["first"];
lastname = (string)requestData["last"];
passwd = (string)requestData["passwd"];
GoodLogin = AuthenticateUser(firstname, lastname, passwd);
}
if (!(GoodXML && GoodLogin))
{
response = CreateErrorConnectingToGridResponse();
}
else
{
UserProfile TheUser = GetProfileByName(firstname, lastname);
//we need to sort out how sessions are logged out , currently the sim tells the gridserver
//but if as this suggests the userserver handles it then please have the sim telling the userserver instead
//as it really makes things messy for sandbox mode
//if (!((TheUser.CurrentSessionID == null) && (TheUser.CurrentSecureSessionID == null)))
// {
// response = CreateAlreadyLoggedInResponse();
// }
//else
//{
try
{
Hashtable responseData = new Hashtable();
LLUUID AgentID = TheUser.UUID;
TheUser.InitSessionData();
// SimProfile SimInfo = new SimProfile();
// SimInfo = SimInfo.LoadFromGrid(TheUser.homeregionhandle, GridURL, GridSendKey, GridRecvKey);
Hashtable GlobalT = new Hashtable();
GlobalT["sun_texture_id"] = "cce0f112-878f-4586-a2e2-a8f104bba271";
GlobalT["cloud_texture_id"] = "fc4b9f0b-d008-45c6-96a4-01dd947ac621";
GlobalT["moon_texture_id"] = "fc4b9f0b-d008-45c6-96a4-01dd947ac621";
ArrayList GlobalTextures = new ArrayList();
GlobalTextures.Add(GlobalT);
Hashtable LoginFlagsHash = new Hashtable();
LoginFlagsHash["daylight_savings"] = "N";
LoginFlagsHash["stipend_since_login"] = "N";
LoginFlagsHash["gendered"] = "Y";
LoginFlagsHash["ever_logged_in"] = "Y";
ArrayList LoginFlags = new ArrayList();
LoginFlags.Add(LoginFlagsHash);
Hashtable uiconfig = new Hashtable();
uiconfig["allow_first_life"] = "Y";
ArrayList ui_config = new ArrayList();
ui_config.Add(uiconfig);
Hashtable ClassifiedCategoriesHash = new Hashtable();
ClassifiedCategoriesHash["category_name"] = "bla bla";
ClassifiedCategoriesHash["category_id"] = (Int32)1;
ArrayList ClassifiedCategories = new ArrayList();
ClassifiedCategories.Add(ClassifiedCategoriesHash);
ArrayList AgentInventory = new ArrayList();
Console.WriteLine("adding inventory to response");
foreach (InventoryFolder InvFolder in TheUser.Inventory.InventoryFolders.Values)
{
Hashtable TempHash = new Hashtable();
Console.WriteLine("adding folder " + InvFolder.FolderName + ", ID: " + InvFolder.FolderID.ToStringHyphenated() + " with parent: " + InvFolder.ParentID.ToStringHyphenated());
TempHash["name"] = InvFolder.FolderName;
TempHash["parent_id"] = InvFolder.ParentID.ToStringHyphenated();
TempHash["version"] = (Int32)InvFolder.Version;
TempHash["type_default"] = (Int32)InvFolder.DefaultType;
TempHash["folder_id"] = InvFolder.FolderID.ToStringHyphenated();
AgentInventory.Add(TempHash);
}
Hashtable InventoryRootHash = new Hashtable();
InventoryRootHash["folder_id"] = TheUser.Inventory.InventoryRoot.FolderID.ToStringHyphenated();
ArrayList InventoryRoot = new ArrayList();
InventoryRoot.Add(InventoryRootHash);
Hashtable InitialOutfitHash = new Hashtable();
InitialOutfitHash["folder_name"] = "Nightclub Female";
InitialOutfitHash["gender"] = "female";
ArrayList InitialOutfit = new ArrayList();
InitialOutfit.Add(InitialOutfitHash);
uint circode = (uint)(Util.RandomClass.Next());
//TheUser.AddSimCircuit(circode, SimInfo.UUID);
responseData["last_name"] = TheUser.lastname;
responseData["ui-config"] = ui_config;
responseData["sim_ip"] = "127.0.0.1"; //SimInfo.sim_ip.ToString();
responseData["login-flags"] = LoginFlags;
responseData["global-textures"] = GlobalTextures;
responseData["classified_categories"] = ClassifiedCategories;
responseData["event_categories"] = new ArrayList();
responseData["inventory-skeleton"] = AgentInventory;
responseData["inventory-skel-lib"] = new ArrayList();
responseData["inventory-root"] = InventoryRoot;
responseData["event_notifications"] = new ArrayList();
responseData["gestures"] = new ArrayList();
responseData["inventory-lib-owner"] = new ArrayList();
responseData["initial-outfit"] = InitialOutfit;
responseData["seconds_since_epoch"] = (Int32)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds;
responseData["start_location"] = "last";
responseData["home"] = "{'region_handle':[r" + (997 * 256).ToString() + ",r" + (996 * 256).ToString() + "], 'position':[r" + TheUser.homepos.X.ToString() + ",r" + TheUser.homepos.Y.ToString() + ",r" + TheUser.homepos.Z.ToString() + "], 'look_at':[r" + TheUser.homelookat.X.ToString() + ",r" + TheUser.homelookat.Y.ToString() + ",r" + TheUser.homelookat.Z.ToString() + "]}";
responseData["message"] = DefaultStartupMsg;
responseData["first_name"] = TheUser.firstname;
responseData["circuit_code"] = (Int32)circode;
responseData["sim_port"] = 9000; //(Int32)SimInfo.sim_port;
responseData["secure_session_id"] = TheUser.CurrentSecureSessionID.ToStringHyphenated();
responseData["look_at"] = "\n[r" + TheUser.homelookat.X.ToString() + ",r" + TheUser.homelookat.Y.ToString() + ",r" + TheUser.homelookat.Z.ToString() + "]\n";
responseData["agent_id"] = AgentID.ToStringHyphenated();
responseData["region_y"] = (Int32)996 * 256; // (Int32)SimInfo.RegionLocY * 256;
responseData["region_x"] = (Int32)997 * 256; //SimInfo.RegionLocX * 256;
responseData["seed_capability"] = null;
responseData["agent_access"] = "M";
responseData["session_id"] = TheUser.CurrentSessionID.ToStringHyphenated();
responseData["login"] = "true";
this.CustomiseResponse(ref responseData, TheUser);
response.Value = responseData;
//TheUser.SendDataToSim(SimInfo);
}
catch (Exception E)
{
Console.WriteLine(E.ToString());
}
//}
}
return response;
}
private static XmlRpcResponse CreateErrorConnectingToGridResponse()
{
XmlRpcResponse response = new XmlRpcResponse();
Hashtable ErrorRespData = new Hashtable();
ErrorRespData["reason"] = "key";
ErrorRespData["message"] = "Error connecting to grid. Please double check your login details and check with the grid owner if you are sure these are correct";
ErrorRespData["login"] = "false";
response.Value = ErrorRespData;
return response;
}
private static XmlRpcResponse CreateAlreadyLoggedInResponse()
{
XmlRpcResponse response = new XmlRpcResponse();
Hashtable PresenceErrorRespData = new Hashtable();
PresenceErrorRespData["reason"] = "presence";
PresenceErrorRespData["message"] = "You appear to be already logged in, if this is not the case please wait for your session to timeout, if this takes longer than a few minutes please contact the grid owner";
PresenceErrorRespData["login"] = "false";
response.Value = PresenceErrorRespData;
return response;
}
public virtual void CustomiseResponse(ref Hashtable response, UserProfile theUser)
{
//default method set up to act as ogs user server
SimProfile SimInfo = new SimProfile();
//get siminfo from grid server
SimInfo = SimInfo.LoadFromGrid(theUser.homeregionhandle, GridURL, GridSendKey, GridRecvKey);
Int32 circode = (Int32)response["circuit_code"];
theUser.AddSimCircuit((uint)circode, SimInfo.UUID);
response["home"] = "{'region_handle':[r" + (SimInfo.RegionLocX * 256).ToString() + ",r" + (SimInfo.RegionLocY * 256).ToString() + "], 'position':[r" + theUser.homepos.X.ToString() + ",r" + theUser.homepos.Y.ToString() + ",r" + theUser.homepos.Z.ToString() + "], 'look_at':[r" + theUser.homelookat.X.ToString() + ",r" + theUser.homelookat.Y.ToString() + ",r" + theUser.homelookat.Z.ToString() + "]}";
response["sim_ip"] = SimInfo.sim_ip.ToString();
response["sim_port"] = (Int32)SimInfo.sim_port;
response["region_y"] = (Int32)SimInfo.RegionLocY * 256;
response["region_x"] = (Int32)SimInfo.RegionLocX * 256;
//default is ogs user server, so let the sim know about the user via a XmlRpcRequest
Console.WriteLine(SimInfo.caps_url);
Hashtable SimParams = new Hashtable();
SimParams["session_id"] = theUser.CurrentSessionID.ToString();
SimParams["secure_session_id"] = theUser.CurrentSecureSessionID.ToString();
SimParams["firstname"] = theUser.firstname;
SimParams["lastname"] = theUser.lastname;
SimParams["agent_id"] = theUser.UUID.ToString();
SimParams["circuit_code"] = (Int32)theUser.Circuits[SimInfo.UUID];
ArrayList SendParams = new ArrayList();
SendParams.Add(SimParams);
XmlRpcRequest GridReq = new XmlRpcRequest("expect_user", SendParams);
XmlRpcResponse GridResp = GridReq.Send(SimInfo.caps_url, 3000);
}
}
}

View File

@ -0,0 +1,124 @@
using System;
using System.Collections.Generic;
using System.Text;
using libsecondlife;
using OpenSim.Framework.Utilities;
using OpenSim.Framework.Inventory;
using Db4objects.Db4o;
namespace OpenSim.Framework.User
{
public class UserProfileManagerBase
{
public Dictionary<LLUUID, UserProfile> UserProfiles = new Dictionary<LLUUID, UserProfile>();
public UserProfileManagerBase()
{
}
public virtual void InitUserProfiles()
{
IObjectContainer db;
db = Db4oFactory.OpenFile("userprofiles.yap");
IObjectSet result = db.Get(typeof(UserProfile));
foreach (UserProfile userprof in result)
{
UserProfiles.Add(userprof.UUID, userprof);
}
Console.WriteLine("UserProfiles.Cs:InitUserProfiles() - Successfully loaded " + result.Count.ToString() + " from database");
db.Close();
}
public virtual void SaveUserProfiles() // ZOMG! INEFFICIENT!
{
IObjectContainer db;
db = Db4oFactory.OpenFile("userprofiles.yap");
IObjectSet result = db.Get(typeof(UserProfile));
foreach (UserProfile userprof in result)
{
db.Delete(userprof);
db.Commit();
}
foreach (UserProfile userprof in UserProfiles.Values)
{
db.Set(userprof);
db.Commit();
}
db.Close();
}
public UserProfile GetProfileByName(string firstname, string lastname)
{
foreach (libsecondlife.LLUUID UUID in UserProfiles.Keys)
{
if ((UserProfiles[UUID].firstname == firstname) && (UserProfiles[UUID].lastname == lastname))
{
return UserProfiles[UUID];
}
}
return null;
}
public UserProfile GetProfileByLLUUID(LLUUID ProfileLLUUID)
{
return UserProfiles[ProfileLLUUID];
}
public virtual bool AuthenticateUser(string firstname, string lastname, string passwd)
{
UserProfile TheUser = GetProfileByName(firstname, lastname);
passwd = passwd.Remove(0, 3); //remove $1$
if (TheUser != null)
{
if (TheUser.MD5passwd == passwd)
{
Console.WriteLine("UserProfile - authorised ");
return true;
}
else
{
Console.WriteLine("UserProfile - not authorised, password not match " + TheUser.MD5passwd + " and " + passwd);
return false;
}
}
else
{
Console.WriteLine("UserProfile - not authorised , unkown: " + firstname + " , " + lastname);
return false;
}
}
public void SetGod(LLUUID GodID)
{
this.UserProfiles[GodID].IsGridGod = true;
}
public virtual UserProfile CreateNewProfile(string firstname, string lastname, string MD5passwd)
{
Console.WriteLine("creating new profile for : " + firstname + " , " + lastname);
UserProfile newprofile = new UserProfile();
newprofile.homeregionhandle = Helpers.UIntsToLong((997 * 256), (996 * 256));
newprofile.firstname = firstname;
newprofile.lastname = lastname;
newprofile.MD5passwd = MD5passwd;
newprofile.UUID = LLUUID.Random();
newprofile.Inventory.CreateRootFolder(newprofile.UUID, true);
this.UserProfiles.Add(newprofile.UUID, newprofile);
return newprofile;
}
public virtual AgentInventory GetUsersInventory(LLUUID agentID)
{
UserProfile user = this.GetProfileByLLUUID(agentID);
if (user != null)
{
return user.Inventory;
}
return null;
}
}
}

45
OpenSim.Framework/Util.cs Normal file
View File

@ -0,0 +1,45 @@
using System;
using System.Collections.Generic;
using System.Text;
using libsecondlife;
using libsecondlife.Packets;
namespace OpenSim.Framework.Utilities
{
public class Util
{
private static Random randomClass = new Random();
private static uint nextXferID = 5000;
private static object XferLock = new object();
public static ulong UIntsToLong(uint X, uint Y)
{
return Helpers.UIntsToLong(X, Y);
}
public static Random RandomClass
{
get
{
return randomClass;
}
}
public static uint GetNextXferID()
{
uint id = 0;
lock(XferLock)
{
id = nextXferID;
nextXferID++;
}
return id;
}
public Util()
{
}
}
}

7241
OpenSim.FxCop Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,93 @@
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ProjectType>Local</ProjectType>
<ProductVersion>8.0.50727</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{E88EF749-0000-0000-0000-000000000000}</ProjectGuid>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ApplicationIcon></ApplicationIcon>
<AssemblyKeyContainerName>
</AssemblyKeyContainerName>
<AssemblyName>OpenSim.GenericConfig.Xml</AssemblyName>
<DefaultClientScript>JScript</DefaultClientScript>
<DefaultHTMLPageLayout>Grid</DefaultHTMLPageLayout>
<DefaultTargetSchema>IE50</DefaultTargetSchema>
<DelaySign>false</DelaySign>
<OutputType>Library</OutputType>
<AppDesignerFolder></AppDesignerFolder>
<RootNamespace>OpenSim.GenericConfig.Xml</RootNamespace>
<StartupObject></StartupObject>
<FileUpgradeFlags>
</FileUpgradeFlags>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>
<BaseAddress>285212672</BaseAddress>
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
<ConfigurationOverrideFile>
</ConfigurationOverrideFile>
<DefineConstants>TRACE;DEBUG</DefineConstants>
<DocumentationFile></DocumentationFile>
<DebugSymbols>True</DebugSymbols>
<FileAlignment>4096</FileAlignment>
<Optimize>False</Optimize>
<OutputPath>..\..\bin\</OutputPath>
<RegisterForComInterop>False</RegisterForComInterop>
<RemoveIntegerChecks>False</RemoveIntegerChecks>
<TreatWarningsAsErrors>False</TreatWarningsAsErrors>
<WarningLevel>4</WarningLevel>
<NoWarn></NoWarn>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>
<BaseAddress>285212672</BaseAddress>
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
<ConfigurationOverrideFile>
</ConfigurationOverrideFile>
<DefineConstants>TRACE</DefineConstants>
<DocumentationFile></DocumentationFile>
<DebugSymbols>False</DebugSymbols>
<FileAlignment>4096</FileAlignment>
<Optimize>True</Optimize>
<OutputPath>..\..\bin\</OutputPath>
<RegisterForComInterop>False</RegisterForComInterop>
<RemoveIntegerChecks>False</RemoveIntegerChecks>
<TreatWarningsAsErrors>False</TreatWarningsAsErrors>
<WarningLevel>4</WarningLevel>
<NoWarn></NoWarn>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" >
<HintPath>System.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="System.Xml" >
<HintPath>System.Xml.dll</HintPath>
<Private>False</Private>
</Reference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\OpenSim.Framework\OpenSim.Framework.csproj">
<Name>OpenSim.Framework</Name>
<Project>{8ACA2445-0000-0000-0000-000000000000}</Project>
<Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
<Private>False</Private>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Compile Include="XmlConfig.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Properties\AssemblyInfo.cs">
<SubType>Code</SubType>
</Compile>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" />
<PropertyGroup>
<PreBuildEvent>
</PreBuildEvent>
<PostBuildEvent>
</PostBuildEvent>
</PropertyGroup>
</Project>

View File

@ -0,0 +1,12 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ReferencePath>C:\New Folder\second-life-viewer\opensim-dailys2\opensim02-04\bin\</ReferencePath>
<LastOpenVersion>8.0.50727</LastOpenVersion>
<ProjectView>ProjectFiles</ProjectView>
<ProjectTrust>0</ProjectTrust>
</PropertyGroup>
<PropertyGroup Condition = " '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' " />
<PropertyGroup Condition = " '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
</Project>

View File

@ -0,0 +1,42 @@
<?xml version="1.0" ?>
<project name="OpenSim.GenericConfig.Xml" default="build">
<target name="build">
<echo message="Build Directory is ${project::get-base-directory()}/${build.dir}" />
<mkdir dir="${project::get-base-directory()}/${build.dir}" />
<copy todir="${project::get-base-directory()}/${build.dir}">
<fileset basedir="${project::get-base-directory()}">
</fileset>
</copy>
<csc target="library" debug="${build.debug}" unsafe="False" define="TRACE" output="${project::get-base-directory()}/${build.dir}/${project::get-name()}.dll">
<resources prefix="OpenSim.GenericConfig.Xml" dynamicprefix="true" >
</resources>
<sources failonempty="true">
<include name="XmlConfig.cs" />
<include name="Properties/AssemblyInfo.cs" />
</sources>
<references basedir="${project::get-base-directory()}">
<lib>
<include name="${project::get-base-directory()}" />
<include name="${project::get-base-directory()}/${build.dir}" />
</lib>
<include name="System.dll" />
<include name="System.Xml.dll" />
<include name="../bin/OpenSim.Framework.dll" />
</references>
</csc>
<echo message="Copying from [${project::get-base-directory()}/${build.dir}/] to [${project::get-base-directory()}/../bin/" />
<mkdir dir="${project::get-base-directory()}/../bin/"/>
<copy todir="${project::get-base-directory()}/../bin/">
<fileset basedir="${project::get-base-directory()}/${build.dir}/" >
<include name="*.dll"/>
<include name="*.exe"/>
</fileset>
</copy>
</target>
<target name="clean">
<delete dir="${bin.dir}" failonerror="false" />
<delete dir="${obj.dir}" failonerror="false" />
</target>
<target name="doc" description="Creates documentation.">
</target>
</project>

View File

@ -0,0 +1,35 @@
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("OpenSim.GenericConfig")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("OpenSim.GenericConfig")]
[assembly: AssemblyCopyright("Copyright © 2007")]
[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("285a3047-f165-46c8-8767-b51428738a09")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@ -0,0 +1,109 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;
using OpenSim.Framework.Interfaces;
namespace OpenSim.GenericConfig
{
public class XmlConfig : IGenericConfig
{
private XmlDocument doc;
private XmlNode rootNode;
private XmlNode configNode;
private string fileName;
private bool createdFile = false;
public XmlConfig(string filename)
{
fileName = filename;
}
public void LoadData()
{
doc = new XmlDocument();
try
{
if (System.IO.File.Exists(fileName))
{
XmlTextReader reader = new XmlTextReader(fileName);
reader.WhitespaceHandling = WhitespaceHandling.None;
doc.Load(reader);
reader.Close();
}
else
{
createdFile = true;
rootNode = doc.CreateNode(XmlNodeType.Element, "Root", "");
doc.AppendChild(rootNode);
configNode = doc.CreateNode(XmlNodeType.Element, "Config", "");
rootNode.AppendChild(configNode);
}
}
catch (Exception e)
{
Console.WriteLine(e.Message);
return;
}
try
{
rootNode = doc.FirstChild;
if (rootNode.Name != "Root")
throw new Exception("Error: Invalid .xml File. Missing <Root>");
configNode = rootNode.FirstChild;
if (configNode.Name != "Config")
throw new Exception("Error: Invalid .xml File. <Root> first child should be <Config>");
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
if (createdFile)
{
this.Commit();
}
}
public string GetAttribute(string attributeName)
{
string result = "";
if (configNode.Attributes[attributeName] != null)
{
result = ((XmlAttribute)configNode.Attributes.GetNamedItem(attributeName)).Value;
}
return result;
}
public bool SetAttribute(string attributeName, string attributeValue)
{
if (configNode.Attributes[attributeName] != null)
{
((XmlAttribute)configNode.Attributes.GetNamedItem(attributeName)).Value = attributeValue;
}
else
{
XmlAttribute attri;
attri = doc.CreateAttribute(attributeName);
attri.Value = attributeValue;
configNode.Attributes.Append(attri);
}
return true;
}
public void Commit()
{
doc.Save(fileName);
}
public void Close()
{
configNode = null;
rootNode = null;
doc = null;
}
}
}

View File

@ -0,0 +1,31 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// Information about this assembly is defined by the following
// attributes.
//
// change them to the information which is associated with the assembly
// you compile.
[assembly: AssemblyTitle("LocalGridServers")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("LocalGridServers")]
[assembly: AssemblyCopyright("")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// This sets the default COM visibility of types in the assembly to invisible.
// If you need to expose a type to COM, use [ComVisible(true)] on that type.
[assembly: ComVisible(false)]
// The assembly version has following format :
//
// Major.Minor.Build.Revision
//
// You can specify all values by your own or you can build default build and revision
// numbers with the '*' character (the default):
[assembly: AssemblyVersion("1.0.*")]

View File

@ -0,0 +1,248 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
using System.IO;
using OpenSim.Framework.Interfaces;
using OpenSim.Framework.Assets;
using OpenSim.Framework.Utilities;
using libsecondlife;
using Db4objects.Db4o;
using Db4objects.Db4o.Query;
namespace OpenSim.GridInterfaces.Local
{
public class LocalAssetPlugin : IAssetPlugin
{
public LocalAssetPlugin()
{
}
public IAssetServer GetAssetServer()
{
return (new LocalAssetServer());
}
}
public class LocalAssetServer : IAssetServer
{
private IAssetReceiver _receiver;
private BlockingQueue<ARequest> _assetRequests;
private IObjectContainer db;
private Thread _localAssetServerThread;
public LocalAssetServer()
{
bool yapfile;
this._assetRequests = new BlockingQueue<ARequest>();
yapfile = System.IO.File.Exists("assets.yap");
OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Local Asset Server class created");
try
{
db = Db4oFactory.OpenFile("assets.yap");
OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Db4 Asset database creation");
}
catch (Exception e)
{
db.Close();
OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Db4 Asset server :Constructor - Exception occured");
OpenSim.Framework.Console.MainConsole.Instance.WriteLine(e.ToString());
}
if (!yapfile)
{
this.SetUpAssetDatabase();
}
this._localAssetServerThread = new Thread(new ThreadStart(RunRequests));
this._localAssetServerThread.IsBackground = true;
this._localAssetServerThread.Start();
}
public void SetReceiver(IAssetReceiver receiver)
{
this._receiver = receiver;
}
public void RequestAsset(LLUUID assetID, bool isTexture)
{
ARequest req = new ARequest();
req.AssetID = assetID;
req.IsTexture = isTexture;
this._assetRequests.Enqueue(req);
}
public void UpdateAsset(AssetBase asset)
{
}
public void UploadNewAsset(AssetBase asset)
{
AssetStorage store = new AssetStorage();
store.Data = asset.Data;
store.Name = asset.Name;
store.UUID = asset.FullID;
db.Set(store);
db.Commit();
}
public void SetServerInfo(string ServerUrl, string ServerKey)
{
}
public void Close()
{
if (db != null)
{
Console.WriteLine("Closing local Asset server database");
db.Close();
}
}
private void RunRequests()
{
while (true)
{
byte[] idata = null;
bool found = false;
AssetStorage foundAsset = null;
ARequest req = this._assetRequests.Dequeue();
IObjectSet result = db.Query(new AssetUUIDQuery(req.AssetID));
if (result.Count > 0)
{
foundAsset = (AssetStorage)result.Next();
found = true;
}
AssetBase asset = new AssetBase();
if (found)
{
asset.FullID = foundAsset.UUID;
asset.Type = foundAsset.Type;
asset.InvType = foundAsset.Type;
asset.Name = foundAsset.Name;
idata = foundAsset.Data;
}
else
{
asset.FullID = LLUUID.Zero;
}
asset.Data = idata;
_receiver.AssetReceived(asset, req.IsTexture);
}
}
private void SetUpAssetDatabase()
{
try
{
Console.WriteLine("setting up Asset database");
AssetBase Image = new AssetBase();
Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000001");
Image.Name = "Bricks";
this.LoadAsset(Image, true, "bricks.jp2");
AssetStorage store = new AssetStorage();
store.Data = Image.Data;
store.Name = Image.Name;
store.UUID = Image.FullID;
db.Set(store);
db.Commit();
Image = new AssetBase();
Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000002");
Image.Name = "Plywood";
this.LoadAsset(Image, true, "plywood.jp2");
store = new AssetStorage();
store.Data = Image.Data;
store.Name = Image.Name;
store.UUID = Image.FullID;
db.Set(store);
db.Commit();
Image = new AssetBase();
Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000003");
Image.Name = "Rocks";
this.LoadAsset(Image, true, "rocks.jp2");
store = new AssetStorage();
store.Data = Image.Data;
store.Name = Image.Name;
store.UUID = Image.FullID;
db.Set(store);
db.Commit();
Image = new AssetBase();
Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000004");
Image.Name = "Granite";
this.LoadAsset(Image, true, "granite.jp2");
store = new AssetStorage();
store.Data = Image.Data;
store.Name = Image.Name;
store.UUID = Image.FullID;
db.Set(store);
db.Commit();
Image = new AssetBase();
Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000005");
Image.Name = "Hardwood";
this.LoadAsset(Image, true, "hardwood.jp2");
store = new AssetStorage();
store.Data = Image.Data;
store.Name = Image.Name;
store.UUID = Image.FullID;
db.Set(store);
db.Commit();
Image = new AssetBase();
Image.FullID = new LLUUID("00000000-0000-0000-5005-000000000005");
Image.Name = "Prim Base Texture";
this.LoadAsset(Image, true, "plywood.jp2");
store = new AssetStorage();
store.Data = Image.Data;
store.Name = Image.Name;
store.UUID = Image.FullID;
db.Set(store);
db.Commit();
Image = new AssetBase();
Image.FullID = new LLUUID("66c41e39-38f9-f75a-024e-585989bfab73");
Image.Name = "Shape";
this.LoadAsset(Image, false, "base_shape.dat");
store = new AssetStorage();
store.Data = Image.Data;
store.Name = Image.Name;
store.UUID = Image.FullID;
db.Set(store);
db.Commit();
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
}
private void LoadAsset(AssetBase info, bool image, string filename)
{
//should request Asset from storage manager
//but for now read from file
string dataPath = Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, "assets"); //+ folder;
string fileName = Path.Combine(dataPath, filename);
FileInfo fInfo = new FileInfo(fileName);
long numBytes = fInfo.Length;
FileStream fStream = new FileStream(fileName, FileMode.Open, FileAccess.Read);
byte[] idata = new byte[numBytes];
BinaryReader br = new BinaryReader(fStream);
idata = br.ReadBytes((int)numBytes);
br.Close();
fStream.Close();
info.Data = idata;
//info.loaded=true;
}
}
}

View File

@ -0,0 +1,156 @@
/*
* Copyright (c) OpenSim project, http://sim.opensecondlife.org/
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the <organization> nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System;
using System.Collections.Generic;
using System.Threading;
using System.IO;
using OpenSim.Framework.Interfaces;
using OpenSim.Framework.Assets;
using libsecondlife;
using Db4objects.Db4o;
using Db4objects.Db4o.Query;
namespace OpenSim.GridInterfaces.Local
{
/// <summary>
///
/// </summary>
///
public class LocalGridPlugin : IGridPlugin
{
public LocalGridPlugin()
{
}
public IGridServer GetGridServer()
{
return(new LocalGridServer());
}
}
public class LocalGridServer : LocalGridBase
{
public List<Login> Sessions = new List<Login>();
public LocalGridServer()
{
Sessions = new List<Login>();
OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Local Grid Server class created");
}
public override bool RequestConnection(LLUUID SimUUID, string sim_ip, uint sim_port)
{
return true;
}
public override string GetName()
{
return "Local";
}
public override AuthenticateResponse AuthenticateSession(LLUUID sessionID, LLUUID agentID, uint circuitCode)
{
//we are running local
AuthenticateResponse user = new AuthenticateResponse();
lock(this.Sessions)
{
for(int i = 0; i < Sessions.Count; i++)
{
if((Sessions[i].Agent == agentID) && (Sessions[i].Session == sessionID))
{
user.Authorised = true;
user.LoginInfo = Sessions[i];
}
}
}
return(user);
}
public override bool LogoutSession(LLUUID sessionID, LLUUID agentID, uint circuitCode)
{
return(true);
}
public override UUIDBlock RequestUUIDBlock()
{
UUIDBlock uuidBlock = new UUIDBlock();
return(uuidBlock);
}
public override NeighbourInfo[] RequestNeighbours()
{
return null;
}
public override void SetServerInfo(string ServerUrl, string SendKey, string RecvKey)
{
}
public override void Close()
{
}
/// <summary>
/// used by the local login server to inform us of new sessions
/// </summary>
/// <param name="session"></param>
public override void AddNewSession(Login session)
{
lock(this.Sessions)
{
this.Sessions.Add(session);
}
}
}
public class AssetUUIDQuery : Predicate
{
private LLUUID _findID;
public AssetUUIDQuery(LLUUID find)
{
_findID = find;
}
public bool Match(AssetStorage asset)
{
return (asset.UUID == _findID);
}
}
public class AssetStorage
{
public byte[] Data;
public sbyte Type;
public string Name;
public LLUUID UUID;
}
}

View File

@ -0,0 +1,110 @@
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ProjectType>Local</ProjectType>
<ProductVersion>8.0.50727</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{546099CD-0000-0000-0000-000000000000}</ProjectGuid>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ApplicationIcon></ApplicationIcon>
<AssemblyKeyContainerName>
</AssemblyKeyContainerName>
<AssemblyName>OpenSim.GridInterfaces.Local</AssemblyName>
<DefaultClientScript>JScript</DefaultClientScript>
<DefaultHTMLPageLayout>Grid</DefaultHTMLPageLayout>
<DefaultTargetSchema>IE50</DefaultTargetSchema>
<DelaySign>false</DelaySign>
<OutputType>Library</OutputType>
<AppDesignerFolder></AppDesignerFolder>
<RootNamespace>OpenSim.GridInterfaces.Local</RootNamespace>
<StartupObject></StartupObject>
<FileUpgradeFlags>
</FileUpgradeFlags>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>
<BaseAddress>285212672</BaseAddress>
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
<ConfigurationOverrideFile>
</ConfigurationOverrideFile>
<DefineConstants>TRACE;DEBUG</DefineConstants>
<DocumentationFile></DocumentationFile>
<DebugSymbols>True</DebugSymbols>
<FileAlignment>4096</FileAlignment>
<Optimize>False</Optimize>
<OutputPath>..\..\bin\</OutputPath>
<RegisterForComInterop>False</RegisterForComInterop>
<RemoveIntegerChecks>False</RemoveIntegerChecks>
<TreatWarningsAsErrors>False</TreatWarningsAsErrors>
<WarningLevel>4</WarningLevel>
<NoWarn></NoWarn>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>
<BaseAddress>285212672</BaseAddress>
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
<ConfigurationOverrideFile>
</ConfigurationOverrideFile>
<DefineConstants>TRACE</DefineConstants>
<DocumentationFile></DocumentationFile>
<DebugSymbols>False</DebugSymbols>
<FileAlignment>4096</FileAlignment>
<Optimize>True</Optimize>
<OutputPath>..\..\bin\</OutputPath>
<RegisterForComInterop>False</RegisterForComInterop>
<RemoveIntegerChecks>False</RemoveIntegerChecks>
<TreatWarningsAsErrors>False</TreatWarningsAsErrors>
<WarningLevel>4</WarningLevel>
<NoWarn></NoWarn>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" >
<HintPath>System.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="System.Xml" >
<HintPath>System.Xml.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Db4objects.Db4o.dll" >
<HintPath>..\..\bin\Db4objects.Db4o.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="libsecondlife.dll" >
<HintPath>..\..\bin\libsecondlife.dll</HintPath>
<Private>False</Private>
</Reference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\OpenSim.Framework\OpenSim.Framework.csproj">
<Name>OpenSim.Framework</Name>
<Project>{8ACA2445-0000-0000-0000-000000000000}</Project>
<Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
<Private>False</Private>
</ProjectReference>
<ProjectReference Include="..\..\OpenSim.Framework.Console\OpenSim.Framework.Console.csproj">
<Name>OpenSim.Framework.Console</Name>
<Project>{A7CD0630-0000-0000-0000-000000000000}</Project>
<Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
<Private>False</Private>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Compile Include="AssemblyInfo.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="LocalAssetServer.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="LocalGridServer.cs">
<SubType>Code</SubType>
</Compile>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" />
<PropertyGroup>
<PreBuildEvent>
</PreBuildEvent>
<PostBuildEvent>
</PostBuildEvent>
</PropertyGroup>
</Project>

View File

@ -0,0 +1,12 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ReferencePath>C:\New Folder\second-life-viewer\opensim-dailys2\opensim02-04\bin\</ReferencePath>
<LastOpenVersion>8.0.50727</LastOpenVersion>
<ProjectView>ProjectFiles</ProjectView>
<ProjectTrust>0</ProjectTrust>
</PropertyGroup>
<PropertyGroup Condition = " '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' " />
<PropertyGroup Condition = " '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
</Project>

View File

@ -0,0 +1,46 @@
<?xml version="1.0" ?>
<project name="OpenSim.GridInterfaces.Local" default="build">
<target name="build">
<echo message="Build Directory is ${project::get-base-directory()}/${build.dir}" />
<mkdir dir="${project::get-base-directory()}/${build.dir}" />
<copy todir="${project::get-base-directory()}/${build.dir}">
<fileset basedir="${project::get-base-directory()}">
</fileset>
</copy>
<csc target="library" debug="${build.debug}" unsafe="False" define="TRACE" output="${project::get-base-directory()}/${build.dir}/${project::get-name()}.dll">
<resources prefix="OpenSim.GridInterfaces.Local" dynamicprefix="true" >
</resources>
<sources failonempty="true">
<include name="AssemblyInfo.cs" />
<include name="LocalAssetServer.cs" />
<include name="LocalGridServer.cs" />
</sources>
<references basedir="${project::get-base-directory()}">
<lib>
<include name="${project::get-base-directory()}" />
<include name="${project::get-base-directory()}/${build.dir}" />
</lib>
<include name="System.dll" />
<include name="System.Xml.dll" />
<include name="../../bin/Db4objects.Db4o.dll" />
<include name="../../bin/libsecondlife.dll" />
<include name="../../bin/OpenSim.Framework.dll" />
<include name="../../bin/OpenSim.Framework.Console.dll" />
</references>
</csc>
<echo message="Copying from [${project::get-base-directory()}/${build.dir}/] to [${project::get-base-directory()}/../../bin/" />
<mkdir dir="${project::get-base-directory()}/../../bin/"/>
<copy todir="${project::get-base-directory()}/../../bin/">
<fileset basedir="${project::get-base-directory()}/${build.dir}/" >
<include name="*.dll"/>
<include name="*.exe"/>
</fileset>
</copy>
</target>
<target name="clean">
<delete dir="${bin.dir}" failonerror="false" />
<delete dir="${obj.dir}" failonerror="false" />
</target>
<target name="doc" description="Creates documentation.">
</target>
</project>

View File

@ -0,0 +1,31 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// Information about this assembly is defined by the following
// attributes.
//
// change them to the information which is associated with the assembly
// you compile.
[assembly: AssemblyTitle("RemoteGridServers")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("RemoteGridServers")]
[assembly: AssemblyCopyright("")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// This sets the default COM visibility of types in the assembly to invisible.
// If you need to expose a type to COM, use [ComVisible(true)] on that type.
[assembly: ComVisible(false)]
// The assembly version has following format :
//
// Major.Minor.Build.Revision
//
// You can specify all values by your own or you can build default build and revision
// numbers with the '*' character (the default):
[assembly: AssemblyVersion("1.0.*")]

View File

@ -0,0 +1,106 @@
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ProjectType>Local</ProjectType>
<ProductVersion>8.0.50727</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{B55C0B5D-0000-0000-0000-000000000000}</ProjectGuid>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ApplicationIcon></ApplicationIcon>
<AssemblyKeyContainerName>
</AssemblyKeyContainerName>
<AssemblyName>OpenSim.GridInterfaces.Remote</AssemblyName>
<DefaultClientScript>JScript</DefaultClientScript>
<DefaultHTMLPageLayout>Grid</DefaultHTMLPageLayout>
<DefaultTargetSchema>IE50</DefaultTargetSchema>
<DelaySign>false</DelaySign>
<OutputType>Library</OutputType>
<AppDesignerFolder></AppDesignerFolder>
<RootNamespace>OpenSim.GridInterfaces.Remote</RootNamespace>
<StartupObject></StartupObject>
<FileUpgradeFlags>
</FileUpgradeFlags>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>
<BaseAddress>285212672</BaseAddress>
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
<ConfigurationOverrideFile>
</ConfigurationOverrideFile>
<DefineConstants>TRACE;DEBUG</DefineConstants>
<DocumentationFile></DocumentationFile>
<DebugSymbols>True</DebugSymbols>
<FileAlignment>4096</FileAlignment>
<Optimize>False</Optimize>
<OutputPath>..\..\bin\</OutputPath>
<RegisterForComInterop>False</RegisterForComInterop>
<RemoveIntegerChecks>False</RemoveIntegerChecks>
<TreatWarningsAsErrors>False</TreatWarningsAsErrors>
<WarningLevel>4</WarningLevel>
<NoWarn></NoWarn>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>
<BaseAddress>285212672</BaseAddress>
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
<ConfigurationOverrideFile>
</ConfigurationOverrideFile>
<DefineConstants>TRACE</DefineConstants>
<DocumentationFile></DocumentationFile>
<DebugSymbols>False</DebugSymbols>
<FileAlignment>4096</FileAlignment>
<Optimize>True</Optimize>
<OutputPath>..\..\bin\</OutputPath>
<RegisterForComInterop>False</RegisterForComInterop>
<RemoveIntegerChecks>False</RemoveIntegerChecks>
<TreatWarningsAsErrors>False</TreatWarningsAsErrors>
<WarningLevel>4</WarningLevel>
<NoWarn></NoWarn>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" >
<HintPath>System.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="System.Xml" >
<HintPath>System.Xml.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="libsecondlife.dll" >
<HintPath>..\..\bin\libsecondlife.dll</HintPath>
<Private>False</Private>
</Reference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\OpenSim.Framework\OpenSim.Framework.csproj">
<Name>OpenSim.Framework</Name>
<Project>{8ACA2445-0000-0000-0000-000000000000}</Project>
<Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
<Private>False</Private>
</ProjectReference>
<ProjectReference Include="..\..\OpenSim.Framework.Console\OpenSim.Framework.Console.csproj">
<Name>OpenSim.Framework.Console</Name>
<Project>{A7CD0630-0000-0000-0000-000000000000}</Project>
<Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
<Private>False</Private>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Compile Include="AssemblyInfo.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="RemoteAssetServer.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="RemoteGridServer.cs">
<SubType>Code</SubType>
</Compile>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" />
<PropertyGroup>
<PreBuildEvent>
</PreBuildEvent>
<PostBuildEvent>
</PostBuildEvent>
</PropertyGroup>
</Project>

View File

@ -0,0 +1,12 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ReferencePath>C:\New Folder\second-life-viewer\opensim-dailys2\opensim02-04\bin\</ReferencePath>
<LastOpenVersion>8.0.50727</LastOpenVersion>
<ProjectView>ProjectFiles</ProjectView>
<ProjectTrust>0</ProjectTrust>
</PropertyGroup>
<PropertyGroup Condition = " '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' " />
<PropertyGroup Condition = " '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
</Project>

View File

@ -0,0 +1,45 @@
<?xml version="1.0" ?>
<project name="OpenSim.GridInterfaces.Remote" default="build">
<target name="build">
<echo message="Build Directory is ${project::get-base-directory()}/${build.dir}" />
<mkdir dir="${project::get-base-directory()}/${build.dir}" />
<copy todir="${project::get-base-directory()}/${build.dir}">
<fileset basedir="${project::get-base-directory()}">
</fileset>
</copy>
<csc target="library" debug="${build.debug}" unsafe="False" define="TRACE" output="${project::get-base-directory()}/${build.dir}/${project::get-name()}.dll">
<resources prefix="OpenSim.GridInterfaces.Remote" dynamicprefix="true" >
</resources>
<sources failonempty="true">
<include name="AssemblyInfo.cs" />
<include name="RemoteAssetServer.cs" />
<include name="RemoteGridServer.cs" />
</sources>
<references basedir="${project::get-base-directory()}">
<lib>
<include name="${project::get-base-directory()}" />
<include name="${project::get-base-directory()}/${build.dir}" />
</lib>
<include name="System.dll" />
<include name="System.Xml.dll" />
<include name="../../bin/libsecondlife.dll" />
<include name="../../bin/OpenSim.Framework.dll" />
<include name="../../bin/OpenSim.Framework.Console.dll" />
</references>
</csc>
<echo message="Copying from [${project::get-base-directory()}/${build.dir}/] to [${project::get-base-directory()}/../../bin/" />
<mkdir dir="${project::get-base-directory()}/../../bin/"/>
<copy todir="${project::get-base-directory()}/../../bin/">
<fileset basedir="${project::get-base-directory()}/${build.dir}/" >
<include name="*.dll"/>
<include name="*.exe"/>
</fileset>
</copy>
</target>
<target name="clean">
<delete dir="${bin.dir}" failonerror="false" />
<delete dir="${obj.dir}" failonerror="false" />
</target>
<target name="doc" description="Creates documentation.">
</target>
</project>

View File

@ -0,0 +1,102 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
using System.Net;
using System.Net.Sockets;
using System.IO;
using libsecondlife;
using OpenSim.Framework.Interfaces;
using OpenSim.Framework.Assets;
using OpenSim.Framework.Utilities;
namespace OpenSim.GridInterfaces.Remote
{
public class RemoteAssetServer : IAssetServer
{
private IAssetReceiver _receiver;
private BlockingQueue<ARequest> _assetRequests;
private Thread _remoteAssetServerThread;
private string AssetServerUrl;
private string AssetSendKey;
public RemoteAssetServer()
{
this._assetRequests = new BlockingQueue<ARequest>();
this._remoteAssetServerThread = new Thread(new ThreadStart(RunRequests));
this._remoteAssetServerThread.IsBackground = true;
this._remoteAssetServerThread.Start();
OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Remote Asset Server class created");
}
public void SetReceiver(IAssetReceiver receiver)
{
this._receiver = receiver;
}
public void RequestAsset(LLUUID assetID, bool isTexture)
{
ARequest req = new ARequest();
req.AssetID = assetID;
req.IsTexture = isTexture;
this._assetRequests.Enqueue(req);
}
public void UpdateAsset(AssetBase asset)
{
}
public void UploadNewAsset(AssetBase asset)
{
}
public void SetServerInfo(string ServerUrl, string ServerKey)
{
this.AssetServerUrl = ServerUrl;
this.AssetSendKey = ServerKey;
}
private void RunRequests()
{
while (true)
{
//we need to add support for the asset server not knowing about a requested asset
ARequest req = this._assetRequests.Dequeue();
LLUUID assetID = req.AssetID;
OpenSim.Framework.Console.MainConsole.Instance.WriteLine(" RemoteAssetServer- Got a AssetServer request, processing it");
WebRequest AssetLoad = WebRequest.Create(this.AssetServerUrl + "getasset/" + AssetSendKey + "/" + assetID + "/data");
WebResponse AssetResponse = AssetLoad.GetResponse();
byte[] idata = new byte[(int)AssetResponse.ContentLength];
BinaryReader br = new BinaryReader(AssetResponse.GetResponseStream());
idata = br.ReadBytes((int)AssetResponse.ContentLength);
br.Close();
AssetBase asset = new AssetBase();
asset.FullID = assetID;
asset.Data = idata;
_receiver.AssetReceived(asset, req.IsTexture);
}
}
public void Close()
{
}
}
public class RemoteAssetPlugin : IAssetPlugin
{
public RemoteAssetPlugin()
{
}
public IAssetServer GetAssetServer()
{
return (new RemoteAssetServer());
}
}
}

View File

@ -0,0 +1,176 @@
/*
* Copyright (c) OpenSim project, http://sim.opensecondlife.org/
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the <organization> nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System;
using System.Collections;
using System.Collections.Generic;
using System.Threading;
using System.Net;
using System.Net.Sockets;
using System.IO;
using libsecondlife;
using Nwc.XmlRpc;
using OpenSim.Framework.Interfaces;
using OpenSim.Framework.Assets;
namespace OpenSim.GridInterfaces.Remote
{
public class RemoteGridServer : RemoteGridBase
{
private string GridServerUrl;
private string GridSendKey;
private string GridRecvKey;
private Dictionary<uint, AgentCircuitData> AgentCircuits = new Dictionary<uint, AgentCircuitData>();
public override Dictionary<uint, AgentCircuitData> agentcircuits
{
get { return AgentCircuits; }
set { AgentCircuits = value; }
}
public RemoteGridServer()
{
OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Remote Grid Server class created");
}
public override bool RequestConnection(LLUUID SimUUID, string sim_ip, uint sim_port)
{
Hashtable GridParams = new Hashtable();
GridParams["authkey"]=GridSendKey;
GridParams["UUID"]=SimUUID.ToString();
GridParams["sim_ip"]=sim_ip;
GridParams["sim_port"]=sim_port.ToString();
ArrayList SendParams = new ArrayList();
SendParams.Add(GridParams);
XmlRpcRequest GridReq = new XmlRpcRequest("simulator_login", SendParams);
XmlRpcResponse GridResp = GridReq.Send(this.GridServerUrl, 3000);
Hashtable GridRespData = (Hashtable)GridResp.Value;
if(GridRespData.ContainsKey("error")) {
string errorstring = (string)GridRespData["error"];
OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Error connecting to grid:");
OpenSim.Framework.Console.MainConsole.Instance.WriteLine(errorstring);
return false;
}
return true;
}
public override AuthenticateResponse AuthenticateSession(LLUUID sessionID, LLUUID agentID, uint circuitcode)
{
AgentCircuitData validcircuit = null;
if (this.AgentCircuits.ContainsKey(circuitcode))
{
validcircuit = this.AgentCircuits[circuitcode];
}
AuthenticateResponse user = new AuthenticateResponse();
if (validcircuit == null)
{
//don't have this circuit code in our list
user.Authorised = false;
return (user);
}
if ((sessionID == validcircuit.SessionID) && (agentID == validcircuit.AgentID))
{
// YAY! Valid login
user.Authorised = true;
user.LoginInfo = new Login();
user.LoginInfo.Agent = agentID;
user.LoginInfo.Session = sessionID;
user.LoginInfo.SecureSession = validcircuit.SecureSessionID;
user.LoginInfo.First = validcircuit.firstname;
user.LoginInfo.Last = validcircuit.lastname;
}
else
{
// Invalid
user.Authorised = false;
}
return (user);
}
public override bool LogoutSession(LLUUID sessionID, LLUUID agentID, uint circuitCode)
{
WebRequest DeleteSession = WebRequest.Create(GridServerUrl + "/usersessions/" + sessionID.ToString());
DeleteSession.Method = "DELETE";
DeleteSession.ContentType = "text/plaintext";
DeleteSession.ContentLength = 0;
StreamWriter stOut = new StreamWriter(DeleteSession.GetRequestStream(), System.Text.Encoding.ASCII);
stOut.Write("");
stOut.Close();
StreamReader stIn = new StreamReader(DeleteSession.GetResponse().GetResponseStream());
string GridResponse = stIn.ReadToEnd();
stIn.Close();
return (true);
}
public override UUIDBlock RequestUUIDBlock()
{
UUIDBlock uuidBlock = new UUIDBlock();
return (uuidBlock);
}
public override NeighbourInfo[] RequestNeighbours()
{
return null;
}
public override void SetServerInfo(string ServerUrl, string SendKey, string RecvKey)
{
this.GridServerUrl = ServerUrl;
this.GridSendKey = SendKey;
this.GridRecvKey = RecvKey;
}
public override string GetName()
{
return "Remote";
}
public override void Close()
{
}
}
public class RemoteGridPlugin : IGridPlugin
{
public RemoteGridPlugin()
{
}
public IGridServer GetGridServer()
{
return (new RemoteGridServer());
}
}
}

View File

@ -0,0 +1,31 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// Information about this assembly is defined by the following
// attributes.
//
// change them to the information which is associated with the assembly
// you compile.
[assembly: AssemblyTitle("PhysXplugin")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("PhysXplugin")]
[assembly: AssemblyCopyright("")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// This sets the default COM visibility of types in the assembly to invisible.
// If you need to expose a type to COM, use [ComVisible(true)] on that type.
[assembly: ComVisible(false)]
// The assembly version has following format :
//
// Major.Minor.Build.Revision
//
// You can specify all values by your own or you can build default build and revision
// numbers with the '*' character (the default):
[assembly: AssemblyVersion("1.0.*")]

View File

@ -0,0 +1,256 @@
/*
* Copyright (c) OpenSim project, http://sim.opensecondlife.org/
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the <organization> nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System;
using System.Collections.Generic;
using OpenSim.Physics.Manager;
namespace OpenSim.Physics.BasicPhysicsPlugin
{
/// <summary>
/// Will be the PhysX plugin but for now will be a very basic physics engine
/// </summary>
public class BasicPhysicsPlugin : IPhysicsPlugin
{
private BasicScene _mScene;
public BasicPhysicsPlugin()
{
}
public bool Init()
{
return true;
}
public PhysicsScene GetScene()
{
if(_mScene == null)
{
_mScene = new BasicScene();
}
return(_mScene);
}
public string GetName()
{
return("basicphysics");
}
public void Dispose()
{
}
}
public class BasicScene :PhysicsScene
{
private List<BasicActor> _actors = new List<BasicActor>();
private float[] _heightMap;
public BasicScene()
{
}
public override PhysicsActor AddAvatar(PhysicsVector position)
{
BasicActor act = new BasicActor();
act.Position = position;
_actors.Add(act);
return act;
}
public override PhysicsActor AddPrim(PhysicsVector position, PhysicsVector size)
{
return null;
}
public override void Simulate(float timeStep)
{
foreach (BasicActor actor in _actors)
{
actor.Position.X = actor.Position.X + (actor.Velocity.X * timeStep);
actor.Position.Y = actor.Position.Y + (actor.Velocity.Y * timeStep);
actor.Position.Z = actor.Position.Z + (actor.Velocity.Z * timeStep);
/*if(actor.Flying)
{
actor.Position.Z = actor.Position.Z + (actor.Velocity.Z * timeStep);
}
else
{
actor.Position.Z = actor.Position.Z + ((-9.8f + actor.Velocity.Z) * timeStep);
}
if(actor.Position.Z < (_heightMap[(int)actor.Position.Y * 256 + (int)actor.Position.X]+1))
{*/
actor.Position.Z = _heightMap[(int)actor.Position.Y * 256 + (int)actor.Position.X]+1;
//}
if(actor.Position.X<0)
{
actor.Position.X = 0;
actor.Velocity.X = 0;
}
if(actor.Position.Y < 0)
{
actor.Position.Y = 0;
actor.Velocity.Y = 0;
}
if(actor.Position.X > 255)
{
actor.Position.X = 255;
actor.Velocity.X = 0;
}
if(actor.Position.Y > 255)
{
actor.Position.Y = 255;
actor.Velocity.X = 0;
}
}
}
public override void GetResults()
{
}
public override bool IsThreaded
{
get
{
return(false); // for now we won't be multithreaded
}
}
public override void SetTerrain(float[] heightMap)
{
this._heightMap = heightMap;
}
public override void DeleteTerrain()
{
}
}
public class BasicActor : PhysicsActor
{
private PhysicsVector _position;
private PhysicsVector _velocity;
private PhysicsVector _acceleration;
private bool flying;
public BasicActor()
{
_velocity = new PhysicsVector();
_position = new PhysicsVector();
_acceleration = new PhysicsVector();
}
public override bool Flying
{
get
{
return false;
}
set
{
flying= value;
}
}
public override PhysicsVector Position
{
get
{
return _position;
}
set
{
_position = value;
}
}
public override PhysicsVector Velocity
{
get
{
return _velocity;
}
set
{
_velocity = value;
}
}
public override Axiom.MathLib.Quaternion Orientation
{
get
{
return Axiom.MathLib.Quaternion.Identity;
}
set
{
}
}
public override PhysicsVector Acceleration
{
get
{
return _acceleration;
}
}
public override bool Kinematic
{
get
{
return true;
}
set
{
}
}
public void SetAcceleration (PhysicsVector accel)
{
this._acceleration = accel;
}
public override void AddForce(PhysicsVector force)
{
}
public override void SetMomentum(PhysicsVector momentum)
{
}
}
}

View File

@ -0,0 +1,93 @@
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ProjectType>Local</ProjectType>
<ProductVersion>8.0.50727</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{4F874463-0000-0000-0000-000000000000}</ProjectGuid>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ApplicationIcon></ApplicationIcon>
<AssemblyKeyContainerName>
</AssemblyKeyContainerName>
<AssemblyName>OpenSim.Physics.BasicPhysicsPlugin</AssemblyName>
<DefaultClientScript>JScript</DefaultClientScript>
<DefaultHTMLPageLayout>Grid</DefaultHTMLPageLayout>
<DefaultTargetSchema>IE50</DefaultTargetSchema>
<DelaySign>false</DelaySign>
<OutputType>Library</OutputType>
<AppDesignerFolder></AppDesignerFolder>
<RootNamespace>OpenSim.Physics.BasicPhysicsPlugin</RootNamespace>
<StartupObject></StartupObject>
<FileUpgradeFlags>
</FileUpgradeFlags>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>
<BaseAddress>285212672</BaseAddress>
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
<ConfigurationOverrideFile>
</ConfigurationOverrideFile>
<DefineConstants>TRACE;DEBUG</DefineConstants>
<DocumentationFile></DocumentationFile>
<DebugSymbols>True</DebugSymbols>
<FileAlignment>4096</FileAlignment>
<Optimize>False</Optimize>
<OutputPath>..\..\bin\Physics\</OutputPath>
<RegisterForComInterop>False</RegisterForComInterop>
<RemoveIntegerChecks>False</RemoveIntegerChecks>
<TreatWarningsAsErrors>False</TreatWarningsAsErrors>
<WarningLevel>4</WarningLevel>
<NoWarn></NoWarn>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>
<BaseAddress>285212672</BaseAddress>
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
<ConfigurationOverrideFile>
</ConfigurationOverrideFile>
<DefineConstants>TRACE</DefineConstants>
<DocumentationFile></DocumentationFile>
<DebugSymbols>False</DebugSymbols>
<FileAlignment>4096</FileAlignment>
<Optimize>True</Optimize>
<OutputPath>..\..\bin\Physics\</OutputPath>
<RegisterForComInterop>False</RegisterForComInterop>
<RemoveIntegerChecks>False</RemoveIntegerChecks>
<TreatWarningsAsErrors>False</TreatWarningsAsErrors>
<WarningLevel>4</WarningLevel>
<NoWarn></NoWarn>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" >
<HintPath>System.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Axiom.MathLib.dll" >
<HintPath>..\..\bin\Axiom.MathLib.dll</HintPath>
<Private>False</Private>
</Reference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Manager\OpenSim.Physics.Manager.csproj">
<Name>OpenSim.Physics.Manager</Name>
<Project>{8BE16150-0000-0000-0000-000000000000}</Project>
<Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
<Private>False</Private>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Compile Include="AssemblyInfo.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="BasicPhysicsPlugin.cs">
<SubType>Code</SubType>
</Compile>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" />
<PropertyGroup>
<PreBuildEvent>
</PreBuildEvent>
<PostBuildEvent>
</PostBuildEvent>
</PropertyGroup>
</Project>

View File

@ -0,0 +1,12 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ReferencePath>C:\New Folder\second-life-viewer\opensim-dailys2\opensim02-04\bin\</ReferencePath>
<LastOpenVersion>8.0.50727</LastOpenVersion>
<ProjectView>ProjectFiles</ProjectView>
<ProjectTrust>0</ProjectTrust>
</PropertyGroup>
<PropertyGroup Condition = " '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' " />
<PropertyGroup Condition = " '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
</Project>

View File

@ -0,0 +1,42 @@
<?xml version="1.0" ?>
<project name="OpenSim.Physics.BasicPhysicsPlugin" default="build">
<target name="build">
<echo message="Build Directory is ${project::get-base-directory()}/${build.dir}" />
<mkdir dir="${project::get-base-directory()}/${build.dir}" />
<copy todir="${project::get-base-directory()}/${build.dir}">
<fileset basedir="${project::get-base-directory()}">
</fileset>
</copy>
<csc target="library" debug="${build.debug}" unsafe="False" define="TRACE" output="${project::get-base-directory()}/${build.dir}/${project::get-name()}.dll">
<resources prefix="OpenSim.Physics.BasicPhysicsPlugin" dynamicprefix="true" >
</resources>
<sources failonempty="true">
<include name="AssemblyInfo.cs" />
<include name="BasicPhysicsPlugin.cs" />
</sources>
<references basedir="${project::get-base-directory()}">
<lib>
<include name="${project::get-base-directory()}" />
<include name="${project::get-base-directory()}/${build.dir}" />
</lib>
<include name="System.dll" />
<include name="../../bin/Axiom.MathLib.dll" />
<include name="../../bin/OpenSim.Physics.Manager.dll" />
</references>
</csc>
<echo message="Copying from [${project::get-base-directory()}/${build.dir}/] to [${project::get-base-directory()}/../../bin/Physics/" />
<mkdir dir="${project::get-base-directory()}/../../bin/Physics/"/>
<copy todir="${project::get-base-directory()}/../../bin/Physics/">
<fileset basedir="${project::get-base-directory()}/${build.dir}/" >
<include name="*.dll"/>
<include name="*.exe"/>
</fileset>
</copy>
</target>
<target name="clean">
<delete dir="${bin.dir}" failonerror="false" />
<delete dir="${obj.dir}" failonerror="false" />
</target>
<target name="doc" description="Creates documentation.">
</target>
</project>

View File

@ -0,0 +1,31 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// Information about this assembly is defined by the following
// attributes.
//
// change them to the information which is associated with the assembly
// you compile.
[assembly: AssemblyTitle("PhysicsManager")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("PhysicsManager")]
[assembly: AssemblyCopyright("")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// This sets the default COM visibility of types in the assembly to invisible.
// If you need to expose a type to COM, use [ComVisible(true)] on that type.
[assembly: ComVisible(false)]
// The assembly version has following format :
//
// Major.Minor.Build.Revision
//
// You can specify all values by your own or you can build default build and revision
// numbers with the '*' character (the default):
[assembly: AssemblyVersion("1.0.*")]

View File

@ -0,0 +1,112 @@
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ProjectType>Local</ProjectType>
<ProductVersion>8.0.50727</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{8BE16150-0000-0000-0000-000000000000}</ProjectGuid>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ApplicationIcon></ApplicationIcon>
<AssemblyKeyContainerName>
</AssemblyKeyContainerName>
<AssemblyName>OpenSim.Physics.Manager</AssemblyName>
<DefaultClientScript>JScript</DefaultClientScript>
<DefaultHTMLPageLayout>Grid</DefaultHTMLPageLayout>
<DefaultTargetSchema>IE50</DefaultTargetSchema>
<DelaySign>false</DelaySign>
<OutputType>Library</OutputType>
<AppDesignerFolder></AppDesignerFolder>
<RootNamespace>OpenSim.Physics.Manager</RootNamespace>
<StartupObject></StartupObject>
<FileUpgradeFlags>
</FileUpgradeFlags>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>
<BaseAddress>285212672</BaseAddress>
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
<ConfigurationOverrideFile>
</ConfigurationOverrideFile>
<DefineConstants>TRACE;DEBUG</DefineConstants>
<DocumentationFile></DocumentationFile>
<DebugSymbols>True</DebugSymbols>
<FileAlignment>4096</FileAlignment>
<Optimize>False</Optimize>
<OutputPath>..\..\bin\</OutputPath>
<RegisterForComInterop>False</RegisterForComInterop>
<RemoveIntegerChecks>False</RemoveIntegerChecks>
<TreatWarningsAsErrors>False</TreatWarningsAsErrors>
<WarningLevel>4</WarningLevel>
<NoWarn></NoWarn>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>
<BaseAddress>285212672</BaseAddress>
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
<ConfigurationOverrideFile>
</ConfigurationOverrideFile>
<DefineConstants>TRACE</DefineConstants>
<DocumentationFile></DocumentationFile>
<DebugSymbols>False</DebugSymbols>
<FileAlignment>4096</FileAlignment>
<Optimize>True</Optimize>
<OutputPath>..\..\bin\</OutputPath>
<RegisterForComInterop>False</RegisterForComInterop>
<RemoveIntegerChecks>False</RemoveIntegerChecks>
<TreatWarningsAsErrors>False</TreatWarningsAsErrors>
<WarningLevel>4</WarningLevel>
<NoWarn></NoWarn>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" >
<HintPath>System.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="System.Xml" >
<HintPath>System.Xml.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Axiom.MathLib.dll" >
<HintPath>..\..\bin\Axiom.MathLib.dll</HintPath>
<Private>False</Private>
</Reference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\OpenSim.Framework\OpenSim.Framework.csproj">
<Name>OpenSim.Framework</Name>
<Project>{8ACA2445-0000-0000-0000-000000000000}</Project>
<Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
<Private>False</Private>
</ProjectReference>
<ProjectReference Include="..\..\OpenSim.Framework.Console\OpenSim.Framework.Console.csproj">
<Name>OpenSim.Framework.Console</Name>
<Project>{A7CD0630-0000-0000-0000-000000000000}</Project>
<Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
<Private>False</Private>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Compile Include="AssemblyInfo.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="PhysicsActor.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="PhysicsManager.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="PhysicsScene.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="PhysicsVector.cs">
<SubType>Code</SubType>
</Compile>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" />
<PropertyGroup>
<PreBuildEvent>
</PreBuildEvent>
<PostBuildEvent>
</PostBuildEvent>
</PropertyGroup>
</Project>

View File

@ -0,0 +1,12 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ReferencePath>C:\New Folder\second-life-viewer\opensim-dailys2\opensim02-04\bin\</ReferencePath>
<LastOpenVersion>8.0.50727</LastOpenVersion>
<ProjectView>ProjectFiles</ProjectView>
<ProjectTrust>0</ProjectTrust>
</PropertyGroup>
<PropertyGroup Condition = " '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' " />
<PropertyGroup Condition = " '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
</Project>

View File

@ -0,0 +1,47 @@
<?xml version="1.0" ?>
<project name="OpenSim.Physics.Manager" default="build">
<target name="build">
<echo message="Build Directory is ${project::get-base-directory()}/${build.dir}" />
<mkdir dir="${project::get-base-directory()}/${build.dir}" />
<copy todir="${project::get-base-directory()}/${build.dir}">
<fileset basedir="${project::get-base-directory()}">
</fileset>
</copy>
<csc target="library" debug="${build.debug}" unsafe="False" define="TRACE" output="${project::get-base-directory()}/${build.dir}/${project::get-name()}.dll">
<resources prefix="OpenSim.Physics.Manager" dynamicprefix="true" >
</resources>
<sources failonempty="true">
<include name="AssemblyInfo.cs" />
<include name="PhysicsActor.cs" />
<include name="PhysicsManager.cs" />
<include name="PhysicsScene.cs" />
<include name="PhysicsVector.cs" />
</sources>
<references basedir="${project::get-base-directory()}">
<lib>
<include name="${project::get-base-directory()}" />
<include name="${project::get-base-directory()}/${build.dir}" />
</lib>
<include name="System.dll" />
<include name="System.Xml.dll" />
<include name="../../bin/Axiom.MathLib.dll" />
<include name="../../bin/OpenSim.Framework.dll" />
<include name="../../bin/OpenSim.Framework.Console.dll" />
</references>
</csc>
<echo message="Copying from [${project::get-base-directory()}/${build.dir}/] to [${project::get-base-directory()}/../../bin/" />
<mkdir dir="${project::get-base-directory()}/../../bin/"/>
<copy todir="${project::get-base-directory()}/../../bin/">
<fileset basedir="${project::get-base-directory()}/${build.dir}/" >
<include name="*.dll"/>
<include name="*.exe"/>
</fileset>
</copy>
</target>
<target name="clean">
<delete dir="${bin.dir}" failonerror="false" />
<delete dir="${obj.dir}" failonerror="false" />
</target>
<target name="doc" description="Creates documentation.">
</target>
</project>

View File

@ -0,0 +1,161 @@
/*
* Copyright (c) OpenSim project, http://sim.opensecondlife.org/
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the <organization> nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System;
using System.Collections.Generic;
using System.Text;
namespace OpenSim.Physics.Manager
{
public abstract class PhysicsActor
{
public static PhysicsActor Null
{
get
{
return new NullPhysicsActor();
}
}
public abstract PhysicsVector Position
{
get;
set;
}
public abstract PhysicsVector Velocity
{
get;
set;
}
public abstract PhysicsVector Acceleration
{
get;
}
public abstract Axiom.MathLib.Quaternion Orientation
{
get;
set;
}
public abstract bool Flying
{
get;
set;
}
public abstract bool Kinematic
{
get;
set;
}
public abstract void AddForce(PhysicsVector force);
public abstract void SetMomentum(PhysicsVector momentum);
}
public class NullPhysicsActor : PhysicsActor
{
public override PhysicsVector Position
{
get
{
return PhysicsVector.Zero;
}
set
{
return;
}
}
public override PhysicsVector Velocity
{
get
{
return PhysicsVector.Zero;
}
set
{
return;
}
}
public override Axiom.MathLib.Quaternion Orientation
{
get
{
return Axiom.MathLib.Quaternion.Identity;
}
set
{
}
}
public override PhysicsVector Acceleration
{
get { return PhysicsVector.Zero; }
}
public override bool Flying
{
get
{
return false;
}
set
{
return;
}
}
public override bool Kinematic
{
get
{
return true;
}
set
{
return;
}
}
public override void AddForce(PhysicsVector force)
{
return;
}
public override void SetMomentum(PhysicsVector momentum)
{
return;
}
}
}

View File

@ -0,0 +1,116 @@
/*
* Copyright (c) OpenSim project, http://sim.opensecondlife.org/
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the <organization> nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System;
using System.Collections.Generic;
using System.Collections;
using System.IO;
using System.Reflection;
using Axiom.MathLib;
namespace OpenSim.Physics.Manager
{
/// <summary>
/// Description of MyClass.
/// </summary>
public class PhysicsManager
{
private Dictionary<string, IPhysicsPlugin> _plugins=new Dictionary<string, IPhysicsPlugin>();
public PhysicsManager()
{
}
public PhysicsScene GetPhysicsScene(string engineName)
{
if (String.IsNullOrEmpty(engineName))
{
return new NullPhysicsScene();
}
if(_plugins.ContainsKey(engineName))
{
OpenSim.Framework.Console.MainConsole.Instance.WriteLine("creating "+engineName);
return _plugins[engineName].GetScene();
}
else
{
string error = String.Format("couldn't find physicsEngine: {0}", engineName);
OpenSim.Framework.Console.MainConsole.Instance.WriteLine(error);
throw new ArgumentException(error);
}
}
public void LoadPlugins()
{
string path = Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory ,"Physics");
string[] pluginFiles = Directory.GetFiles(path, "*.dll");
for(int i= 0; i<pluginFiles.Length; i++)
{
this.AddPlugin(pluginFiles[i]);
}
}
private void AddPlugin(string FileName)
{
Assembly pluginAssembly = Assembly.LoadFrom(FileName);
foreach (Type pluginType in pluginAssembly.GetTypes())
{
if (pluginType.IsPublic)
{
if (!pluginType.IsAbstract)
{
Type typeInterface = pluginType.GetInterface("IPhysicsPlugin", true);
if (typeInterface != null)
{
IPhysicsPlugin plug = (IPhysicsPlugin)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
plug.Init();
this._plugins.Add(plug.GetName(),plug);
}
typeInterface = null;
}
}
}
pluginAssembly = null;
}
}
public interface IPhysicsPlugin
{
bool Init();
PhysicsScene GetScene();
string GetName();
void Dispose();
}
}

View File

@ -0,0 +1,105 @@
/*
* Copyright (c) OpenSim project, http://sim.opensecondlife.org/
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the <organization> nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System;
using System.Collections.Generic;
using System.Text;
namespace OpenSim.Physics.Manager
{
public abstract class PhysicsScene
{
public static PhysicsScene Null
{
get
{
return new NullPhysicsScene();
}
}
public abstract PhysicsActor AddAvatar(PhysicsVector position);
public abstract PhysicsActor AddPrim(PhysicsVector position, PhysicsVector size);
public abstract void Simulate(float timeStep);
public abstract void GetResults();
public abstract void SetTerrain(float[] heightMap);
public abstract void DeleteTerrain();
public abstract bool IsThreaded
{
get;
}
}
public class NullPhysicsScene : PhysicsScene
{
private static int m_workIndicator;
public override PhysicsActor AddAvatar(PhysicsVector position)
{
OpenSim.Framework.Console.MainConsole.Instance.WriteLine("NullPhysicsScene : AddAvatar({0})", position);
return PhysicsActor.Null;
}
public override PhysicsActor AddPrim(PhysicsVector position, PhysicsVector size)
{
OpenSim.Framework.Console.MainConsole.Instance.WriteLine("NullPhysicsScene : AddPrim({0},{1})", position, size);
return PhysicsActor.Null;
}
public override void Simulate(float timeStep)
{
m_workIndicator = (m_workIndicator + 1) % 10;
//OpenSim.Framework.Console.MainConsole.Instance.SetStatus(m_workIndicator.ToString());
}
public override void GetResults()
{
OpenSim.Framework.Console.MainConsole.Instance.WriteLine("NullPhysicsScene : GetResults()");
}
public override void SetTerrain(float[] heightMap)
{
OpenSim.Framework.Console.MainConsole.Instance.WriteLine("NullPhysicsScene : SetTerrain({0} items)", heightMap.Length);
}
public override void DeleteTerrain()
{
}
public override bool IsThreaded
{
get { return false; }
}
}
}

View File

@ -0,0 +1,54 @@
/*
* Copyright (c) OpenSim project, http://sim.opensecondlife.org/
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the <organization> nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System;
using System.Collections.Generic;
using System.Text;
namespace OpenSim.Physics.Manager
{
public class PhysicsVector
{
public float X;
public float Y;
public float Z;
public PhysicsVector()
{
}
public PhysicsVector(float x, float y, float z)
{
X = x;
Y = y;
Z = z;
}
public static readonly PhysicsVector Zero = new PhysicsVector(0f, 0f, 0f);
}
}

View File

@ -0,0 +1,31 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// Information about this assembly is defined by the following
// attributes.
//
// change them to the information which is associated with the assembly
// you compile.
[assembly: AssemblyTitle("RealPhysXplugin")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("RealPhysXplugin")]
[assembly: AssemblyCopyright("")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// This sets the default COM visibility of types in the assembly to invisible.
// If you need to expose a type to COM, use [ComVisible(true)] on that type.
[assembly: ComVisible(false)]
// The assembly version has following format :
//
// Major.Minor.Build.Revision
//
// You can specify all values by your own or you can build default build and revision
// numbers with the '*' character (the default):
[assembly: AssemblyVersion("1.0.*")]

View File

@ -0,0 +1,447 @@
/*
* Copyright (c) OpenSim project, http://sim.opensecondlife.org/
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the <organization> nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System;
using System.Collections.Generic;
using OpenSim.Physics.Manager;
using Ode.NET;
namespace OpenSim.Physics.OdePlugin
{
/// <summary>
/// ODE plugin
/// </summary>
public class OdePlugin : IPhysicsPlugin
{
private OdeScene _mScene;
public OdePlugin()
{
}
public bool Init()
{
return true;
}
public PhysicsScene GetScene()
{
if (_mScene == null)
{
_mScene = new OdeScene();
}
return (_mScene);
}
public string GetName()
{
return ("OpenDynamicsEngine");
}
public void Dispose()
{
}
}
public class OdeScene : PhysicsScene
{
static public IntPtr world;
static public IntPtr space;
static private IntPtr contactgroup;
static private IntPtr LandGeom;
static private IntPtr Land;
private double[] _heightmap;
static private d.NearCallback nearCallback = near;
private List<OdeCharacter> _characters = new List<OdeCharacter>();
private static d.ContactGeom[] contacts = new d.ContactGeom[30];
private static d.Contact contact;
public OdeScene()
{
contact.surface.mode = d.ContactFlags.Bounce | d.ContactFlags.SoftCFM;
contact.surface.mu = d.Infinity;
contact.surface.mu2 = 0.0f;
contact.surface.bounce = 0.1f;
contact.surface.bounce_vel = 0.1f;
contact.surface.soft_cfm = 0.01f;
world = d.WorldCreate();
space = d.HashSpaceCreate(IntPtr.Zero);
contactgroup = d.JointGroupCreate(0);
d.WorldSetGravity(world, 0.0f, 0.0f, -0.5f);
//d.WorldSetCFM(world, 1e-5f);
d.WorldSetAutoDisableFlag(world, false);
d.WorldSetContactSurfaceLayer(world, 0.001f);
// d.CreatePlane(space, 0, 0, 1, 0);
this._heightmap = new double[65536];
}
// This function blatantly ripped off from BoxStack.cs
static private void near(IntPtr space, IntPtr g1, IntPtr g2)
{
//Console.WriteLine("collision callback");
IntPtr b1 = d.GeomGetBody(g1);
IntPtr b2 = d.GeomGetBody(g2);
if (b1 != IntPtr.Zero && b2 != IntPtr.Zero && d.AreConnectedExcluding(b1, b2, d.JointType.Contact))
return;
int count = d.Collide(g1, g2, 500, contacts, d.ContactGeom.SizeOf);
for (int i = 0; i < count; ++i)
{
contact.geom = contacts[i];
IntPtr joint = d.JointCreateContact(world, contactgroup, ref contact);
d.JointAttach(joint, b1, b2);
}
}
public override PhysicsActor AddAvatar(PhysicsVector position)
{
PhysicsVector pos = new PhysicsVector();
pos.X = position.X;
pos.Y = position.Y;
pos.Z = position.Z + 20;
OdeCharacter newAv = new OdeCharacter(this, pos);
this._characters.Add(newAv);
return newAv;
}
public override PhysicsActor AddPrim(PhysicsVector position, PhysicsVector size)
{
PhysicsVector pos = new PhysicsVector();
pos.X = position.X;
pos.Y = position.Y;
pos.Z = position.Z;
PhysicsVector siz = new PhysicsVector();
siz.X = size.X;
siz.Y = size.Y;
siz.Z = size.Z;
return new OdePrim();
}
public override void Simulate(float timeStep)
{
foreach (OdeCharacter actor in _characters)
{
actor.Move(timeStep * 5f);
}
d.SpaceCollide(space, IntPtr.Zero, nearCallback);
d.WorldQuickStep(world, timeStep * 5f);
d.JointGroupEmpty(contactgroup);
foreach (OdeCharacter actor in _characters)
{
actor.UpdatePosition();
}
}
public override void GetResults()
{
}
public override bool IsThreaded
{
get
{
return (false); // for now we won't be multithreaded
}
}
public override void SetTerrain(float[] heightMap)
{
for (int i = 0; i < 65536; i++)
{
this._heightmap[i] = (double)heightMap[i];
}
IntPtr HeightmapData = d.GeomHeightfieldDataCreate();
d.GeomHeightfieldDataBuildDouble(HeightmapData, _heightmap, 0, 256, 256, 256, 256, 1.0f, 0.0f, 2.0f, 0);
d.GeomHeightfieldDataSetBounds(HeightmapData, 256, 256);
LandGeom = d.CreateHeightfield(space, HeightmapData, 1);
d.Matrix3 R = new d.Matrix3();
Axiom.MathLib.Quaternion q1 =Axiom.MathLib.Quaternion.FromAngleAxis(1.5707f, new Axiom.MathLib.Vector3(1,0,0));
Axiom.MathLib.Quaternion q2 =Axiom.MathLib.Quaternion.FromAngleAxis(1.5707f, new Axiom.MathLib.Vector3(0,1,0));
//Axiom.MathLib.Quaternion q3 = Axiom.MathLib.Quaternion.FromAngleAxis(3.14f, new Axiom.MathLib.Vector3(0, 0, 1));
q1 = q1 * q2;
//q1 = q1 * q3;
Axiom.MathLib.Vector3 v3 = new Axiom.MathLib.Vector3();
float angle = 0;
q1.ToAngleAxis(ref angle, ref v3);
d.RFromAxisAndAngle(out R, v3.x, v3.y, v3.z, angle);
d.GeomSetRotation(LandGeom, ref R);
d.GeomSetPosition(LandGeom, 128, 128, 0);
}
public override void DeleteTerrain()
{
}
}
public class OdeCharacter : PhysicsActor
{
private PhysicsVector _position;
private PhysicsVector _velocity;
private PhysicsVector _acceleration;
private bool flying;
private float gravityAccel;
private IntPtr BoundingCapsule;
IntPtr capsule_geom;
d.Mass capsule_mass;
public OdeCharacter(OdeScene parent_scene, PhysicsVector pos)
{
_velocity = new PhysicsVector();
_position = pos;
_acceleration = new PhysicsVector();
d.MassSetCapsule(out capsule_mass, 5.0f, 3, 0.5f, 2f);
capsule_geom = d.CreateCapsule(OdeScene.space, 0.5f, 2f);
this.BoundingCapsule = d.BodyCreate(OdeScene.world);
d.BodySetMass(BoundingCapsule, ref capsule_mass);
d.BodySetPosition(BoundingCapsule, pos.X, pos.Y, pos.Z);
d.GeomSetBody(capsule_geom, BoundingCapsule);
}
public override bool Flying
{
get
{
return flying;
}
set
{
flying = value;
}
}
public override PhysicsVector Position
{
get
{
return _position;
}
set
{
_position = value;
}
}
public override PhysicsVector Velocity
{
get
{
return _velocity;
}
set
{
_velocity = value;
}
}
public override bool Kinematic
{
get
{
return false;
}
set
{
}
}
public override Axiom.MathLib.Quaternion Orientation
{
get
{
return Axiom.MathLib.Quaternion.Identity;
}
set
{
}
}
public override PhysicsVector Acceleration
{
get
{
return _acceleration;
}
}
public void SetAcceleration(PhysicsVector accel)
{
this._acceleration = accel;
}
public override void AddForce(PhysicsVector force)
{
}
public override void SetMomentum(PhysicsVector momentum)
{
}
public void Move(float timeStep)
{
PhysicsVector vec = new PhysicsVector();
vec.X = this._velocity.X * timeStep;
vec.Y = this._velocity.Y * timeStep;
if (flying)
{
vec.Z = (this._velocity.Z + 0.5f) * timeStep;
}
d.BodySetLinearVel(this.BoundingCapsule, vec.X, vec.Y, vec.Z);
}
public void UpdatePosition()
{
d.Vector3 vec = d.BodyGetPosition(BoundingCapsule);
this._position.X = vec.X;
this._position.Y = vec.Y;
this._position.Z = vec.Z;
}
}
public class OdePrim : PhysicsActor
{
private PhysicsVector _position;
private PhysicsVector _velocity;
private PhysicsVector _acceleration;
public OdePrim()
{
_velocity = new PhysicsVector();
_position = new PhysicsVector();
_acceleration = new PhysicsVector();
}
public override bool Flying
{
get
{
return false; //no flying prims for you
}
set
{
}
}
public override PhysicsVector Position
{
get
{
PhysicsVector pos = new PhysicsVector();
// PhysicsVector vec = this._prim.Position;
//pos.X = vec.X;
//pos.Y = vec.Y;
//pos.Z = vec.Z;
return pos;
}
set
{
/*PhysicsVector vec = value;
PhysicsVector pos = new PhysicsVector();
pos.X = vec.X;
pos.Y = vec.Y;
pos.Z = vec.Z;
this._prim.Position = pos;*/
}
}
public override PhysicsVector Velocity
{
get
{
return _velocity;
}
set
{
_velocity = value;
}
}
public override bool Kinematic
{
get
{
return false;
//return this._prim.Kinematic;
}
set
{
//this._prim.Kinematic = value;
}
}
public override Axiom.MathLib.Quaternion Orientation
{
get
{
Axiom.MathLib.Quaternion res = new Axiom.MathLib.Quaternion();
return res;
}
set
{
}
}
public override PhysicsVector Acceleration
{
get
{
return _acceleration;
}
}
public void SetAcceleration(PhysicsVector accel)
{
this._acceleration = accel;
}
public override void AddForce(PhysicsVector force)
{
}
public override void SetMomentum(PhysicsVector momentum)
{
}
}
}

View File

@ -0,0 +1,97 @@
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ProjectType>Local</ProjectType>
<ProductVersion>8.0.50727</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{63A05FE9-0000-0000-0000-000000000000}</ProjectGuid>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ApplicationIcon></ApplicationIcon>
<AssemblyKeyContainerName>
</AssemblyKeyContainerName>
<AssemblyName>OpenSim.Physics.OdePlugin</AssemblyName>
<DefaultClientScript>JScript</DefaultClientScript>
<DefaultHTMLPageLayout>Grid</DefaultHTMLPageLayout>
<DefaultTargetSchema>IE50</DefaultTargetSchema>
<DelaySign>false</DelaySign>
<OutputType>Library</OutputType>
<AppDesignerFolder></AppDesignerFolder>
<RootNamespace>OpenSim.Physics.OdePlugin</RootNamespace>
<StartupObject></StartupObject>
<FileUpgradeFlags>
</FileUpgradeFlags>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>
<BaseAddress>285212672</BaseAddress>
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
<ConfigurationOverrideFile>
</ConfigurationOverrideFile>
<DefineConstants>TRACE;DEBUG</DefineConstants>
<DocumentationFile></DocumentationFile>
<DebugSymbols>True</DebugSymbols>
<FileAlignment>4096</FileAlignment>
<Optimize>False</Optimize>
<OutputPath>..\..\bin\Physics\</OutputPath>
<RegisterForComInterop>False</RegisterForComInterop>
<RemoveIntegerChecks>False</RemoveIntegerChecks>
<TreatWarningsAsErrors>False</TreatWarningsAsErrors>
<WarningLevel>4</WarningLevel>
<NoWarn></NoWarn>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>
<BaseAddress>285212672</BaseAddress>
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
<ConfigurationOverrideFile>
</ConfigurationOverrideFile>
<DefineConstants>TRACE</DefineConstants>
<DocumentationFile></DocumentationFile>
<DebugSymbols>False</DebugSymbols>
<FileAlignment>4096</FileAlignment>
<Optimize>True</Optimize>
<OutputPath>..\..\bin\Physics\</OutputPath>
<RegisterForComInterop>False</RegisterForComInterop>
<RemoveIntegerChecks>False</RemoveIntegerChecks>
<TreatWarningsAsErrors>False</TreatWarningsAsErrors>
<WarningLevel>4</WarningLevel>
<NoWarn></NoWarn>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" >
<HintPath>System.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Axiom.MathLib.dll" >
<HintPath>..\..\bin\Axiom.MathLib.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Ode.NET.dll" >
<HintPath>..\..\bin\Ode.NET.dll</HintPath>
<Private>False</Private>
</Reference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Manager\OpenSim.Physics.Manager.csproj">
<Name>OpenSim.Physics.Manager</Name>
<Project>{8BE16150-0000-0000-0000-000000000000}</Project>
<Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
<Private>False</Private>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Compile Include="AssemblyInfo.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="OdePlugin.cs">
<SubType>Code</SubType>
</Compile>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" />
<PropertyGroup>
<PreBuildEvent>
</PreBuildEvent>
<PostBuildEvent>
</PostBuildEvent>
</PropertyGroup>
</Project>

View File

@ -0,0 +1,12 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ReferencePath>C:\New Folder\second-life-viewer\opensim-dailys2\opensim02-04\bin\</ReferencePath>
<LastOpenVersion>8.0.50727</LastOpenVersion>
<ProjectView>ProjectFiles</ProjectView>
<ProjectTrust>0</ProjectTrust>
</PropertyGroup>
<PropertyGroup Condition = " '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' " />
<PropertyGroup Condition = " '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
</Project>

View File

@ -0,0 +1,43 @@
<?xml version="1.0" ?>
<project name="OpenSim.Physics.OdePlugin" default="build">
<target name="build">
<echo message="Build Directory is ${project::get-base-directory()}/${build.dir}" />
<mkdir dir="${project::get-base-directory()}/${build.dir}" />
<copy todir="${project::get-base-directory()}/${build.dir}">
<fileset basedir="${project::get-base-directory()}">
</fileset>
</copy>
<csc target="library" debug="${build.debug}" unsafe="False" define="TRACE" output="${project::get-base-directory()}/${build.dir}/${project::get-name()}.dll">
<resources prefix="OpenSim.Physics.OdePlugin" dynamicprefix="true" >
</resources>
<sources failonempty="true">
<include name="AssemblyInfo.cs" />
<include name="OdePlugin.cs" />
</sources>
<references basedir="${project::get-base-directory()}">
<lib>
<include name="${project::get-base-directory()}" />
<include name="${project::get-base-directory()}/${build.dir}" />
</lib>
<include name="System.dll" />
<include name="../../bin/Axiom.MathLib.dll" />
<include name="../../bin/OpenSim.Physics.Manager.dll" />
<include name="../../bin/Ode.NET.dll" />
</references>
</csc>
<echo message="Copying from [${project::get-base-directory()}/${build.dir}/] to [${project::get-base-directory()}/../../bin/Physics/" />
<mkdir dir="${project::get-base-directory()}/../../bin/Physics/"/>
<copy todir="${project::get-base-directory()}/../../bin/Physics/">
<fileset basedir="${project::get-base-directory()}/${build.dir}/" >
<include name="*.dll"/>
<include name="*.exe"/>
</fileset>
</copy>
</target>
<target name="clean">
<delete dir="${bin.dir}" failonerror="false" />
<delete dir="${obj.dir}" failonerror="false" />
</target>
<target name="doc" description="Creates documentation.">
</target>
</project>

View File

@ -0,0 +1,31 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// Information about this assembly is defined by the following
// attributes.
//
// change them to the information which is associated with the assembly
// you compile.
[assembly: AssemblyTitle("RealPhysXplugin")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("RealPhysXplugin")]
[assembly: AssemblyCopyright("")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// This sets the default COM visibility of types in the assembly to invisible.
// If you need to expose a type to COM, use [ComVisible(true)] on that type.
[assembly: ComVisible(false)]
// The assembly version has following format :
//
// Major.Minor.Build.Revision
//
// You can specify all values by your own or you can build default build and revision
// numbers with the '*' character (the default):
[assembly: AssemblyVersion("1.0.*")]

View File

@ -0,0 +1,97 @@
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ProjectType>Local</ProjectType>
<ProductVersion>8.0.50727</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{988F0AC4-0000-0000-0000-000000000000}</ProjectGuid>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ApplicationIcon></ApplicationIcon>
<AssemblyKeyContainerName>
</AssemblyKeyContainerName>
<AssemblyName>OpenSim.Physics.PhysXPlugin</AssemblyName>
<DefaultClientScript>JScript</DefaultClientScript>
<DefaultHTMLPageLayout>Grid</DefaultHTMLPageLayout>
<DefaultTargetSchema>IE50</DefaultTargetSchema>
<DelaySign>false</DelaySign>
<OutputType>Library</OutputType>
<AppDesignerFolder></AppDesignerFolder>
<RootNamespace>OpenSim.Physics.PhysXPlugin</RootNamespace>
<StartupObject></StartupObject>
<FileUpgradeFlags>
</FileUpgradeFlags>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>
<BaseAddress>285212672</BaseAddress>
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
<ConfigurationOverrideFile>
</ConfigurationOverrideFile>
<DefineConstants>TRACE;DEBUG</DefineConstants>
<DocumentationFile></DocumentationFile>
<DebugSymbols>True</DebugSymbols>
<FileAlignment>4096</FileAlignment>
<Optimize>False</Optimize>
<OutputPath>..\..\bin\Physics\</OutputPath>
<RegisterForComInterop>False</RegisterForComInterop>
<RemoveIntegerChecks>False</RemoveIntegerChecks>
<TreatWarningsAsErrors>False</TreatWarningsAsErrors>
<WarningLevel>4</WarningLevel>
<NoWarn></NoWarn>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>
<BaseAddress>285212672</BaseAddress>
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
<ConfigurationOverrideFile>
</ConfigurationOverrideFile>
<DefineConstants>TRACE</DefineConstants>
<DocumentationFile></DocumentationFile>
<DebugSymbols>False</DebugSymbols>
<FileAlignment>4096</FileAlignment>
<Optimize>True</Optimize>
<OutputPath>..\..\bin\Physics\</OutputPath>
<RegisterForComInterop>False</RegisterForComInterop>
<RemoveIntegerChecks>False</RemoveIntegerChecks>
<TreatWarningsAsErrors>False</TreatWarningsAsErrors>
<WarningLevel>4</WarningLevel>
<NoWarn></NoWarn>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" >
<HintPath>System.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Axiom.MathLib.dll" >
<HintPath>..\..\bin\Axiom.MathLib.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="PhysX_Wrapper_Dotnet.dll" >
<HintPath>..\..\bin\PhysX_Wrapper_Dotnet.dll</HintPath>
<Private>False</Private>
</Reference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Manager\OpenSim.Physics.Manager.csproj">
<Name>OpenSim.Physics.Manager</Name>
<Project>{8BE16150-0000-0000-0000-000000000000}</Project>
<Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
<Private>False</Private>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Compile Include="AssemblyInfo.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="PhysXPlugin.cs">
<SubType>Code</SubType>
</Compile>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" />
<PropertyGroup>
<PreBuildEvent>
</PreBuildEvent>
<PostBuildEvent>
</PostBuildEvent>
</PropertyGroup>
</Project>

View File

@ -0,0 +1,12 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ReferencePath>C:\New Folder\second-life-viewer\opensim-dailys2\opensim02-04\bin\</ReferencePath>
<LastOpenVersion>8.0.50727</LastOpenVersion>
<ProjectView>ProjectFiles</ProjectView>
<ProjectTrust>0</ProjectTrust>
</PropertyGroup>
<PropertyGroup Condition = " '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' " />
<PropertyGroup Condition = " '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
</Project>

View File

@ -0,0 +1,43 @@
<?xml version="1.0" ?>
<project name="OpenSim.Physics.PhysXPlugin" default="build">
<target name="build">
<echo message="Build Directory is ${project::get-base-directory()}/${build.dir}" />
<mkdir dir="${project::get-base-directory()}/${build.dir}" />
<copy todir="${project::get-base-directory()}/${build.dir}">
<fileset basedir="${project::get-base-directory()}">
</fileset>
</copy>
<csc target="library" debug="${build.debug}" unsafe="False" define="TRACE" output="${project::get-base-directory()}/${build.dir}/${project::get-name()}.dll">
<resources prefix="OpenSim.Physics.PhysXPlugin" dynamicprefix="true" >
</resources>
<sources failonempty="true">
<include name="AssemblyInfo.cs" />
<include name="PhysXPlugin.cs" />
</sources>
<references basedir="${project::get-base-directory()}">
<lib>
<include name="${project::get-base-directory()}" />
<include name="${project::get-base-directory()}/${build.dir}" />
</lib>
<include name="System.dll" />
<include name="../../bin/Axiom.MathLib.dll" />
<include name="../../bin/PhysX_Wrapper_Dotnet.dll" />
<include name="../../bin/OpenSim.Physics.Manager.dll" />
</references>
</csc>
<echo message="Copying from [${project::get-base-directory()}/${build.dir}/] to [${project::get-base-directory()}/../../bin/Physics/" />
<mkdir dir="${project::get-base-directory()}/../../bin/Physics/"/>
<copy todir="${project::get-base-directory()}/../../bin/Physics/">
<fileset basedir="${project::get-base-directory()}/${build.dir}/" >
<include name="*.dll"/>
<include name="*.exe"/>
</fileset>
</copy>
</target>
<target name="clean">
<delete dir="${bin.dir}" failonerror="false" />
<delete dir="${obj.dir}" failonerror="false" />
</target>
<target name="doc" description="Creates documentation.">
</target>
</project>

View File

@ -0,0 +1,444 @@
/*
* Copyright (c) OpenSim project, http://sim.opensecondlife.org/
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the <organization> nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
/*
* Copyright (c) OpenSim project, http://sim.opensecondlife.org/
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the <organization> nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System;
using System.Collections.Generic;
using OpenSim.Physics.Manager;
using PhysXWrapper;
namespace OpenSim.Physics.PhysXPlugin
{
/// <summary>
/// Will be the PhysX plugin but for now will be a very basic physics engine
/// </summary>
public class PhysXPlugin : IPhysicsPlugin
{
private PhysXScene _mScene;
public PhysXPlugin()
{
}
public bool Init()
{
return true;
}
public PhysicsScene GetScene()
{
if(_mScene == null)
{
_mScene = new PhysXScene();
}
return(_mScene);
}
public string GetName()
{
return("RealPhysX");
}
public void Dispose()
{
}
}
public class PhysXScene :PhysicsScene
{
private List<PhysXCharacter> _characters = new List<PhysXCharacter>();
private List<PhysXPrim> _prims = new List<PhysXPrim>();
private float[] _heightMap = null;
private NxPhysicsSDK mySdk;
private NxScene scene;
public PhysXScene()
{
mySdk = NxPhysicsSDK.CreateSDK();
Console.WriteLine("Sdk created - now creating scene");
scene = mySdk.CreateScene();
}
public override PhysicsActor AddAvatar(PhysicsVector position)
{
Vec3 pos = new Vec3();
pos.X = position.X;
pos.Y = position.Y;
pos.Z = position.Z;
PhysXCharacter act = new PhysXCharacter( scene.AddCharacter(pos));
act.Position = position;
_characters.Add(act);
return act;
}
public override PhysicsActor AddPrim(PhysicsVector position, PhysicsVector size)
{
Vec3 pos = new Vec3();
pos.X = position.X;
pos.Y = position.Y;
pos.Z = position.Z;
Vec3 siz = new Vec3();
siz.X = size.X;
siz.Y = size.Y;
siz.Z = size.Z;
PhysXPrim act = new PhysXPrim( scene.AddNewBox(pos, siz));
_prims.Add(act);
return act;
}
public override void Simulate(float timeStep)
{
try
{
foreach (PhysXCharacter actor in _characters)
{
actor.Move(timeStep);
}
scene.Simulate(timeStep);
scene.FetchResults();
scene.UpdateControllers();
foreach (PhysXCharacter actor in _characters)
{
actor.UpdatePosition();
}
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
}
public override void GetResults()
{
}
public override bool IsThreaded
{
get
{
return(false); // for now we won't be multithreaded
}
}
public override void SetTerrain(float[] heightMap)
{
if (this._heightMap != null)
{
Console.WriteLine("PhysX - deleting old terrain");
this.scene.DeleteTerrain();
}
this._heightMap = heightMap;
this.scene.AddTerrain(heightMap);
}
public override void DeleteTerrain()
{
this.scene.DeleteTerrain();
}
}
public class PhysXCharacter : PhysicsActor
{
private PhysicsVector _position;
private PhysicsVector _velocity;
private PhysicsVector _acceleration;
private NxCharacter _character;
private bool flying;
private float gravityAccel;
public PhysXCharacter(NxCharacter character)
{
_velocity = new PhysicsVector();
_position = new PhysicsVector();
_acceleration = new PhysicsVector();
_character = character;
}
public override bool Flying
{
get
{
return flying;
}
set
{
flying = value;
}
}
public override PhysicsVector Position
{
get
{
return _position;
}
set
{
_position = value;
Vec3 ps = new Vec3();
ps.X = value.X;
ps.Y = value.Y;
ps.Z = value.Z;
this._character.Position = ps;
}
}
public override PhysicsVector Velocity
{
get
{
return _velocity;
}
set
{
_velocity = value;
}
}
public override bool Kinematic
{
get
{
return false;
}
set
{
}
}
public override Axiom.MathLib.Quaternion Orientation
{
get
{
return Axiom.MathLib.Quaternion.Identity;
}
set
{
}
}
public override PhysicsVector Acceleration
{
get
{
return _acceleration;
}
}
public void SetAcceleration (PhysicsVector accel)
{
this._acceleration = accel;
}
public override void AddForce(PhysicsVector force)
{
}
public override void SetMomentum(PhysicsVector momentum)
{
}
public void Move(float timeStep)
{
Vec3 vec = new Vec3();
vec.X = this._velocity.X * timeStep;
vec.Y = this._velocity.Y * timeStep;
if(flying)
{
vec.Z = ( this._velocity.Z) * timeStep;
}
else
{
gravityAccel+= -9.8f;
vec.Z = (gravityAccel + this._velocity.Z) * timeStep;
}
int res = this._character.Move(vec);
if(res == 1)
{
gravityAccel = 0;
}
}
public void UpdatePosition()
{
Vec3 vec = this._character.Position;
this._position.X = vec.X;
this._position.Y = vec.Y;
this._position.Z = vec.Z;
}
}
public class PhysXPrim : PhysicsActor
{
private PhysicsVector _position;
private PhysicsVector _velocity;
private PhysicsVector _acceleration;
private NxActor _prim;
public PhysXPrim(NxActor prim)
{
_velocity = new PhysicsVector();
_position = new PhysicsVector();
_acceleration = new PhysicsVector();
_prim = prim;
}
public override bool Flying
{
get
{
return false; //no flying prims for you
}
set
{
}
}
public override PhysicsVector Position
{
get
{
PhysicsVector pos = new PhysicsVector();
Vec3 vec = this._prim.Position;
pos.X = vec.X;
pos.Y = vec.Y;
pos.Z = vec.Z;
return pos;
}
set
{
PhysicsVector vec = value;
Vec3 pos = new Vec3();
pos.X = vec.X;
pos.Y = vec.Y;
pos.Z = vec.Z;
this._prim.Position = pos;
}
}
public override PhysicsVector Velocity
{
get
{
return _velocity;
}
set
{
_velocity = value;
}
}
public override bool Kinematic
{
get
{
return this._prim.Kinematic;
}
set
{
this._prim.Kinematic = value;
}
}
public override Axiom.MathLib.Quaternion Orientation
{
get
{
Axiom.MathLib.Quaternion res = new Axiom.MathLib.Quaternion();
PhysXWrapper.Quaternion quat = this._prim.GetOrientation();
res.w = quat.W;
res.x = quat.X;
res.y = quat.Y;
res.z = quat.Z;
return res;
}
set
{
}
}
public override PhysicsVector Acceleration
{
get
{
return _acceleration;
}
}
public void SetAcceleration (PhysicsVector accel)
{
this._acceleration = accel;
}
public override void AddForce(PhysicsVector force)
{
}
public override void SetMomentum(PhysicsVector momentum)
{
}
}
}

Some files were not shown because too many files have changed in this diff Show More