|
From: <duc...@us...> - 2008-08-09 01:18:20
|
Revision: 800
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=800&view=rev
Author: ducheneaut
Date: 2008-08-09 01:18:28 +0000 (Sat, 09 Aug 2008)
Log Message:
-----------
Fleshed out the Flash viewer:
- basic FlashViewer container (with a debugging console)
- basic Comet client
Note that the messaging system is less fancy than its Java ancestor, no support for multiple wire and message encoders (yet). Lots to do still, esp. actually processing the events when they come back :)
Modified Paths:
--------------
maven/trunk/ogoglio-viewer/.actionScriptProperties
maven/trunk/ogoglio-viewer/.flexProperties
maven/trunk/ogoglio-viewer/build.xml
maven/trunk/ogoglio-viewer/main.mxml
Added Paths:
-----------
maven/trunk/ogoglio-viewer/.settings/com.adobe.flexbuilder.project.prefs
maven/trunk/ogoglio-viewer/com/ogoglio/client/
maven/trunk/ogoglio-viewer/com/ogoglio/client/CometClient.as
maven/trunk/ogoglio-viewer/com/ogoglio/client/MessageFactory.as
maven/trunk/ogoglio-viewer/com/ogoglio/client/OgoglioView3D.as
maven/trunk/ogoglio-viewer/com/ogoglio/client/SpaceClient.as
maven/trunk/ogoglio-viewer/com/ogoglio/client/WebAPIDescriptor.as
maven/trunk/ogoglio-viewer/com/ogoglio/client/WebAPIUtil.as
maven/trunk/ogoglio-viewer/com/ogoglio/util/
maven/trunk/ogoglio-viewer/com/ogoglio/util/ArgumentUtils.as
maven/trunk/ogoglio-viewer/com/ogoglio/util/DebugInfo.as
maven/trunk/ogoglio-viewer/com/ogoglio/util/IllegalArgumentException.as
maven/trunk/ogoglio-viewer/com/ogoglio/util/SpaceClientException.as
maven/trunk/ogoglio-viewer/com/ogoglio/util/URLParser.as
maven/trunk/ogoglio-viewer/com/ogoglio/util/WebConstants.as
maven/trunk/ogoglio-viewer/com/ogoglio/viewer/FlashViewer.as
maven/trunk/ogoglio-viewer/resources/
maven/trunk/ogoglio-viewer/resources/body.jpg
maven/trunk/ogoglio-viewer/resources/jane.jpg
maven/trunk/ogoglio-viewer/resources/jane.obj
maven/trunk/ogoglio-viewer/resources/space.html
maven/trunk/ogoglio-viewer/resources/test.mtl
maven/trunk/ogoglio-viewer/resources/test.obj
Removed Paths:
-------------
maven/trunk/ogoglio-viewer/OgoglioView3D.as
maven/trunk/ogoglio-viewer/body.jpg
maven/trunk/ogoglio-viewer/jane.jpg
maven/trunk/ogoglio-viewer/jane.obj
maven/trunk/ogoglio-viewer/test.mtl
maven/trunk/ogoglio-viewer/test.obj
Property Changed:
----------------
maven/trunk/ogoglio-viewer/
Property changes on: maven/trunk/ogoglio-viewer
___________________________________________________________________
Modified: svn:ignore
- target
+ target
generated
Modified: maven/trunk/ogoglio-viewer/.actionScriptProperties
===================================================================
--- maven/trunk/ogoglio-viewer/.actionScriptProperties 2008-07-27 03:03:24 UTC (rev 799)
+++ maven/trunk/ogoglio-viewer/.actionScriptProperties 2008-08-09 01:18:28 UTC (rev 800)
@@ -1,24 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
-<actionScriptProperties mainApplicationPath="main.mxml" version="1">
-<compiler additionalCompilerArguments="-locale en_US" copyDependentFiles="true" generateAccessible="false" htmlExpressInstall="true" htmlGenerate="true" htmlHistoryManagement="true" htmlPlayerVersion="9.0.0" htmlPlayerVersionCheck="true" outputFolderPath="bin" strict="true" warn="true">
+<actionScriptProperties mainApplicationPath="main.mxml" version="3">
+<compiler additionalCompilerArguments="-locale en_US" copyDependentFiles="true" enableModuleDebug="false" generateAccessible="false" htmlExpressInstall="true" htmlGenerate="true" htmlHistoryManagement="true" htmlPlayerVersion="9.0.0" htmlPlayerVersionCheck="true" outputFolderPath="bin" strict="true" useApolloConfig="false" verifyDigests="true" warn="true">
<compilerSourcePath/>
-<libraryPath>
-<libraryPathEntry kind="3" linkType="2" path="${FRAMEWORKS}/libs/playerglobal.swc"/>
-<libraryPathEntry kind="3" linkType="1" path="${FRAMEWORKS}/libs/utilities.swc"/>
-<libraryPathEntry kind="3" linkType="1" path="${FRAMEWORKS}/libs/flex.swc" sourcepath="${FRAMEWORKS}/source"/>
-<libraryPathEntry kind="3" linkType="1" path="${FRAMEWORKS}/libs/framework.swc" sourcepath="${FRAMEWORKS}/source"/>
-<libraryPathEntry kind="3" linkType="1" path="${FRAMEWORKS}/libs/rpc.swc"/>
-<libraryPathEntry kind="3" linkType="1" path="${FRAMEWORKS}/libs/charts.swc" sourcepath="${FRAMEWORKS}/source"/>
-<libraryPathEntry kind="1" linkType="1" path="${FRAMEWORKS}/locale/{locale}"/>
+<libraryPath defaultLinkType="1">
+<libraryPathEntry kind="4" path="">
+<modifiedEntries>
+<libraryPathEntry kind="3" linkType="1" path="${PROJECT_FRAMEWORKS}/libs/framework.swc" sourcepath="${PROJECT_FRAMEWORKS}/source" useDefaultLinkType="true"/>
+</modifiedEntries>
+<excludedEntries>
+<libraryPathEntry kind="3" linkType="1" path="${PROJECT_FRAMEWORKS}/libs/automation_agent.swc" useDefaultLinkType="false"/>
+<libraryPathEntry kind="3" linkType="1" path="${PROJECT_FRAMEWORKS}/libs/automation.swc" useDefaultLinkType="false"/>
+<libraryPathEntry kind="3" linkType="1" path="${PROJECT_FRAMEWORKS}/libs/qtp.swc" useDefaultLinkType="false"/>
+<libraryPathEntry kind="3" linkType="1" path="${PROJECT_FRAMEWORKS}/libs/automation_dmv.swc" useDefaultLinkType="false"/>
+</excludedEntries>
+</libraryPathEntry>
</libraryPath>
<sourceAttachmentPath>
-<sourceAttachmentPathEntry kind="3" linkType="1" path="${FRAMEWORKS}/libs/flex.swc" sourcepath="${FRAMEWORKS}/source"/>
-<sourceAttachmentPathEntry kind="3" linkType="1" path="${FRAMEWORKS}/libs/framework.swc" sourcepath="${FRAMEWORKS}/source"/>
-<sourceAttachmentPathEntry kind="3" linkType="1" path="${FRAMEWORKS}/libs/charts.swc" sourcepath="${FRAMEWORKS}/source"/>
+<sourceAttachmentPathEntry kind="3" linkType="1" path="${PROJECT_FRAMEWORKS}/libs/flex.swc" sourcepath="${PROJECT_FRAMEWORKS}/source" useDefaultLinkType="false"/>
+<sourceAttachmentPathEntry kind="3" linkType="1" path="${PROJECT_FRAMEWORKS}/libs/framework.swc" sourcepath="${PROJECT_FRAMEWORKS}/source" useDefaultLinkType="false"/>
+<sourceAttachmentPathEntry kind="3" linkType="1" path="${PROJECT_FRAMEWORKS}/libs/datavisualization.swc" sourcepath="${PROJECT_FRAMEWORKS}/source" useDefaultLinkType="false"/>
</sourceAttachmentPath>
</compiler>
<applications>
<application path="main.mxml"/>
</applications>
+<modules/>
<buildCSSFiles/>
</actionScriptProperties>
Modified: maven/trunk/ogoglio-viewer/.flexProperties
===================================================================
--- maven/trunk/ogoglio-viewer/.flexProperties 2008-07-27 03:03:24 UTC (rev 799)
+++ maven/trunk/ogoglio-viewer/.flexProperties 2008-08-09 01:18:28 UTC (rev 800)
@@ -1,2 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
-<flexProperties flexServerType="0" toolCompile="true" version="1"/>
+<flexProperties flexServerType="0" toolCompile="true" useServerFlexSDK="false" version="1"/>
Added: maven/trunk/ogoglio-viewer/.settings/com.adobe.flexbuilder.project.prefs
===================================================================
--- maven/trunk/ogoglio-viewer/.settings/com.adobe.flexbuilder.project.prefs (rev 0)
+++ maven/trunk/ogoglio-viewer/.settings/com.adobe.flexbuilder.project.prefs 2008-08-09 01:18:28 UTC (rev 800)
@@ -0,0 +1,3 @@
+#Fri Aug 01 13:42:57 PDT 2008
+eclipse.preferences.version=1
+upgradeSDK/fb3=
Deleted: maven/trunk/ogoglio-viewer/OgoglioView3D.as
===================================================================
--- maven/trunk/ogoglio-viewer/OgoglioView3D.as 2008-07-27 03:03:24 UTC (rev 799)
+++ maven/trunk/ogoglio-viewer/OgoglioView3D.as 2008-08-09 01:18:28 UTC (rev 800)
@@ -1,84 +0,0 @@
-package
-{
- import away3d.materials.BitmapFileMaterial;
- import away3d.core.math.Number3D;
- import away3d.containers.View3D;
- import away3d.primitives.Cube;
-
- import flash.events.Event;
-
- import mx.core.UIComponent;
- import away3d.core.base.Object3D;
- import away3d.loaders.Obj;
- import away3d.loaders.Object3DLoader;
- import away3d.containers.ObjectContainer3D;
- import away3d.loaders.MaterialLibrary;
-
- public class OgoglioView3D extends UIComponent
- {
- private var view:View3D;
-
- private var objLoader:Object3DLoader;
-
- private var janeLoader:Object3DLoader;
-
- public function OgoglioView3D()
- {
- super();
- this.addEventListener(Event.ENTER_FRAME, onFrameEnter);
- }
-
- override protected function createChildren():void
- {
- super.createChildren();
-
- if(!this.view)
- {
- this.view = new View3D();
-
- this.view.camera.moveTo(new Number3D(0, 0, -300));
- this.view.camera.lookAt(new Number3D(0, 0, 0));
- }
- this.addChild(this.view);
-
- if(!this.objLoader){
- this.objLoader = Obj.load("test.obj", { material:new BitmapFileMaterial("body.jpg"), name:"joe", scaling:10 } );
- this.objLoader.rotationY = 180;
- this.objLoader.rotationX = -90;
- }
- this.view.scene.addChild(this.objLoader);
-
- if(!this.janeLoader){
- this.janeLoader = Obj.load("jane.obj", { material:new BitmapFileMaterial("jane.jpg"), name:"jane", scaling:10 } );
- this.janeLoader.rotationY = 180;
- this.janeLoader.rotationX = -90;
- }
- this.view.scene.addChild(this.janeLoader);
-
- }
-
- override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void
- {
- super.updateDisplayList(unscaledWidth, unscaledHeight);
-
- if(this.width / 2 != this.view.x)
- this.view.x = this.width / 2;
- if(this.height / 2 != this.view.y)
- this.view.y = this.height / 2;
- }
-
- private function onFrameEnter(event:Event):void
- {
- if(this.view && this.view.stage)
- {
- this.objLoader.result.transform.tx = -100;
- this.objLoader.result.rotationY += 1;
-
- this.janeLoader.result.rotationY -= 1;
- this.janeLoader.result.transform.tx = 100;
-
- this.view.render();
- }
- }
- }
-}
\ No newline at end of file
Modified: maven/trunk/ogoglio-viewer/build.xml
===================================================================
--- maven/trunk/ogoglio-viewer/build.xml 2008-07-27 03:03:24 UTC (rev 799)
+++ maven/trunk/ogoglio-viewer/build.xml 2008-08-09 01:18:28 UTC (rev 800)
@@ -2,25 +2,29 @@
<project name="ogoglio-viewer" default="wrapper" basedir=".">
- <property name="FLEX_HOME" value="/Users/trevor/Code/flex_sdk_3"/>
- <property name="APP_ROOT" value="/Users/trevor/Code/MavenWorkspace/ogoglio-viewer"/>
+ <property name="FLEX_HOME" value="/Users/nicolas/Dev/flex3sdk"/>
+ <property name="APP_ROOT" value="/Users/nicolas/Dev/workspace-ogoglio/ogoglio-viewer"/>
<taskdef resource="flexTasks.tasks" classpath="${FLEX_HOME}/ant/lib/flexTasks.jar" />
<target name="build">
<mkdir dir="target" />
- <mxmlc file="${APP_ROOT}/Main.mxml" keep-generated-actionscript="true" output="${APP_ROOT}/target/Main.swf">
+ <mxmlc file="${APP_ROOT}/main.mxml" keep-generated-actionscript="true" output="${APP_ROOT}/target/Main.swf">
<load-config filename="${FLEX_HOME}/frameworks/flex-config.xml"/>
<source-path path-element="${FLEX_HOME}/frameworks"/>
</mxmlc>
- </target>
-
- <target name="wrapper" depends="build">
+ </target>
+
+ <!-- You cannot set flashVars with this ant task... kinda lame.
+ So we use it to generate the css and js needed by the wrapper, but dont run
+ the generated HTML - use the provided space.html instead
+ (and edit the flashvars to whatever you need them to be) -->
+ <target name="wrapper" depends="clean, build">
<html-wrapper
- title="ogoglio-viewer"
- file="ogoglio-viewer-index.html"
- height="300"
- width="400"
+ title="html-without-flashvars"
+ file="do-not-use.html"
+ height="768"
+ width="1024"
bgcolor="white"
application="app"
swf="Main"
@@ -29,7 +33,11 @@
version-revision="0"
history="true"
template="express-installation"
- output="${APP_ROOT}/target/"/>
+ output="${APP_ROOT}/target/"/>
+
+ <copy todir="${APP_ROOT}/target">
+ <fileset dir="resources"/>
+ </copy>
</target>
<target name="clean">
Added: maven/trunk/ogoglio-viewer/com/ogoglio/client/CometClient.as
===================================================================
--- maven/trunk/ogoglio-viewer/com/ogoglio/client/CometClient.as (rev 0)
+++ maven/trunk/ogoglio-viewer/com/ogoglio/client/CometClient.as 2008-08-09 01:18:28 UTC (rev 800)
@@ -0,0 +1,235 @@
+package com.ogoglio.client {
+
+import com.adobe.utils.IntUtil;
+import com.ogoglio.util.URLParser;
+import com.ogoglio.client.MessageFactory;
+
+import flash.errors.*;
+import flash.events.*;
+import flash.net.*;
+import flash.utils.ByteArray;
+import flash.utils.Timer;
+
+import mx.rpc.*;
+import mx.rpc.events.*;
+import mx.rpc.http.*;
+import mx.utils.*;
+
+public class CometClient extends Socket
+{
+ private var host:String;
+ private var port:uint;
+ private var path:String;
+ private var spaceID:Number;
+ private var authCookie:String;
+ private var callback:Function;
+
+ private var dollar:RegExp = /\$/;
+
+ private var heartbeatInterval:Number = 5000;
+ private var heartbeatTimer:Timer;
+
+
+ public function CometClient(cometURI:String, spaceID:Number, authCookie:String) {
+ super();
+
+ URLParser.parse(cometURI);
+ this.host = URLParser.host;
+ this.port = parseInt(URLParser.port);
+ this.path = URLParser.path;
+
+ this.spaceID = spaceID;
+ this.authCookie = authCookie;
+
+ this.configureListeners();
+
+ trace("Connection to host: " + host + " at port: " + port);
+ this.connect(host, port);
+ }
+
+ public function set messageHandler(handler:Function):void {
+ this.callback = handler;
+ }
+
+ private function configureListeners():void {
+ addEventListener(Event.CLOSE, closeHandler);
+ addEventListener(Event.CONNECT, connectHandler);
+ addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
+ addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler);
+ addEventListener(ProgressEvent.SOCKET_DATA, initialResponseHandler);
+ }
+
+ private function connectHandler(event:Event):void {
+
+ trace("connectHandler(): sending initial GET");
+
+ writeln("GET "+ path +" HTTP/1.1");
+ writeln("Host: " + host);
+ writeln("Transfer-encoding: chunked");
+ writeln("");
+ }
+
+ private function initialResponseHandler(event:ProgressEvent):void {
+ var response:String = readUTFBytes(bytesAvailable);
+ trace("initialResponseHandler() data:\n" + response);
+
+ if (!response.match("HTTP/1.1 200")) {
+ throw new Error("Problem connecting to server. HTTP Response:" + response);
+ }
+ if (!response.substring(response.length - 8, response.length).match("\r\n\r\n")) {
+ throw new Error("Problem connecting to server, no empty line! HTTP Response:" + response);
+ }
+
+ // If we made contact, switch to main stream processor
+ this.removeEventListener(ProgressEvent.SOCKET_DATA, initialResponseHandler);
+ this.addEventListener(ProgressEvent.SOCKET_DATA, streamProcessor);
+
+ // Fire off an authentication message
+ this.sendMessage(MessageFactory.createAuthenticationMessage(host, port.toString(), spaceID.toString(), authCookie));
+ }
+
+ private function writeln(str:String):void {
+ str += "\r\n";
+ try {
+ writeUTFBytes(str);
+ }
+ catch(e:IOError) {
+ trace("IOError: " + e);
+ }
+ }
+
+ private function sendMessage(message:String):void {
+ var encodedMessage:ByteArray = this.encodeMessage(message);
+ this.sendNetworkMessage(encodedMessage);
+ }
+
+ private function encodeMessage(message:String):ByteArray {
+ // This basically does nothing
+ // It's here as a placeholder for the WireEncoder we had in the former Java implementation
+ var encoded:ByteArray = new ByteArray();
+ encoded.writeUTFBytes(message);
+ return encoded;
+ }
+
+ private function sendNetworkMessage(message:ByteArray):void {
+
+ // Encode the message length into a message header.
+ var messageHeader:ByteArray = this.encodeMessageLength(message.length);
+
+ // Get length of data chunk and encode it.
+ // Note that we add the size of the message header.
+ var dataLength:int = message.length + messageHeader.length;
+ var lengthHexStr:String = IntUtil.toHex(dataLength, true); // careful with BigEndian here...
+ var lengthHexBytes:ByteArray = new ByteArray();
+ lengthHexBytes.writeUTFBytes(lengthHexStr);
+
+ // Now that we know the length of the data length string, start writing to the buffer.
+ // The size is the length of the hex data plus the length of the buffer plus
+ // 4 bytes for the two \r\n pairs plus the size of the message header (which is
+ // redundant but necessary when sending data to a Comet server).
+ var dataBuffer:ByteArray = new ByteArray();
+
+ // Copy in the length string
+ dataBuffer.writeBytes(lengthHexBytes);
+
+ // Insert the first \r\n
+ dataBuffer.writeUTFBytes("\r");
+ dataBuffer.writeUTFBytes("\n");
+
+ // Write in the message size
+ dataBuffer.writeBytes(messageHeader);
+
+ // Copy in the data
+ dataBuffer.writeBytes(message);
+
+ // Add the final \r\n
+ dataBuffer.writeUTFBytes("\r");
+ dataBuffer.writeUTFBytes("\n");
+
+ // Send the message
+ this.writeBytes(dataBuffer);
+ this.flush();
+ }
+
+ private function streamProcessor(event:ProgressEvent):void {
+ var stream:String = readUTFBytes(bytesAvailable);
+ var chunks:Array = stream.split("\r\n");
+ for (var i:int = 0; i < chunks.length; i += 2) {
+ if (chunks[i] == "") {
+ break;
+ }
+ var xmlMessage:XML = this.extractXML(chunks[i], chunks[i+1]);
+
+ if (this.callback != null && xmlMessage != null) {
+ callback(xmlMessage);
+ }
+ }
+ }
+
+ /**
+ * Note that we assume that all messages we get are in XML.
+ * This is in fact the case in the current servlet implementation but makes no provision for
+ * other formats, unlike the more flexible (but more complicated) implementation we had in Java.
+ */
+ private function extractXML(length:String, message:String):XML {
+ // Parse the chunked message length
+ var overallMessageLength:int = parseInt(length, 16);
+
+ // If the chunked message length is 0, we've been disconnected
+ if (overallMessageLength == 0) {
+ trace("EOC received while processing stream");
+ return null;
+ }
+
+ var headerAndBody:Array = message.split(dollar);
+ var internalMessageLength:int = parseInt(headerAndBody[0], 16);
+ var xmlString:String = headerAndBody[1];
+
+ // Check if we agree on size
+ if (xmlString.length != internalMessageLength) {
+ trace("Mismatch between buffered length and actual length of string - content might be corrupted");
+ }
+
+ return new XML(xmlString);
+ }
+
+ /**
+ * Encode the given message length into a hex string followed by a "$"
+ * delimiter, and return the string as a byte array.
+ */
+ private function encodeMessageLength(messageLength:int):ByteArray {
+ var lengthHex:String = IntUtil.toHex(messageLength, true); // Careful, make sure to set BigEndian
+ var encodedLength:ByteArray = new ByteArray();
+ encodedLength.writeUTFBytes(lengthHex + "$");
+ return encodedLength;
+ }
+
+ public function startHeartbeat():void {
+ this.heartbeatTimer = new Timer(this.heartbeatInterval, 0);
+ heartbeatTimer.addEventListener("timer", heartbeatHandler);
+ heartbeatTimer.start();
+
+ // Send a message right away to prevent timeout
+ this.sendMessage(MessageFactory.createHeartbeatMessage(host, port.toString(), spaceID.toString()));
+ }
+
+ private function heartbeatHandler(event:TimerEvent):void {
+ var heartbeatMessage:String = MessageFactory.createHeartbeatMessage(host, port.toString(), spaceID.toString());
+ this.sendMessage(heartbeatMessage);
+ }
+
+ private function closeHandler(event:Event):void {
+ trace("closeHandler(): " + event.toString());
+ }
+
+ private function ioErrorHandler(event:IOErrorEvent):void {
+ trace("IOErrorHandler(): "+ event.toString());
+ }
+
+ private function securityErrorHandler(event:SecurityErrorEvent):void {
+ trace("securityErrorHandler(): " + event.toString());
+ }
+}
+
+}
+
Added: maven/trunk/ogoglio-viewer/com/ogoglio/client/MessageFactory.as
===================================================================
--- maven/trunk/ogoglio-viewer/com/ogoglio/client/MessageFactory.as (rev 0)
+++ maven/trunk/ogoglio-viewer/com/ogoglio/client/MessageFactory.as 2008-08-09 01:18:28 UTC (rev 800)
@@ -0,0 +1,32 @@
+package com.ogoglio.client
+{
+ public class MessageFactory
+ {
+
+ public static function createAuthenticationMessage(host:String, port:String, spaceID:String, authCookie:String):String {
+ var authRequestXML:XML = <Message/>;
+ authRequestXML.@destination="comet://" + host + ":" + port + "/og/comet/proxy";
+ authRequestXML.@origin="comet://UNKNOWN@127.0.0.1:0000/"; // bogus string, server will get data from request
+ authRequestXML.@spaceID=spaceID;
+ authRequestXML.Payload.AuthenticationRequest.@loginCookie=authCookie;
+ authRequestXML.Payload.AuthenticationRequest.@spaceID=spaceID;
+
+ trace("MessageFactory: created:\n" + authRequestXML.toXMLString());
+
+ return authRequestXML.toXMLString();
+ }
+
+ public static function createHeartbeatMessage(host:String, port:String, spaceID:String):String {
+ var heartbeatXML:XML = <Message/>;
+ heartbeatXML.@destination="comet://" + host + ":" + port + "/og/comet/proxy";
+ heartbeatXML.@origin="comet://UNKNOWN@127.0.0.1:0000/"; // bogus string, server will get data from request
+ heartbeatXML.@spaceID=spaceID;
+ heartbeatXML.Payload="";
+ heartbeatXML.Payload.HeartbeatPayload="";
+
+ //trace("MessageFactory: created:\n" + heartbeatXML.toXMLString());
+
+ return heartbeatXML.toXMLString();
+ }
+ }
+}
\ No newline at end of file
Copied: maven/trunk/ogoglio-viewer/com/ogoglio/client/OgoglioView3D.as (from rev 799, maven/trunk/ogoglio-viewer/OgoglioView3D.as)
===================================================================
--- maven/trunk/ogoglio-viewer/com/ogoglio/client/OgoglioView3D.as (rev 0)
+++ maven/trunk/ogoglio-viewer/com/ogoglio/client/OgoglioView3D.as 2008-08-09 01:18:28 UTC (rev 800)
@@ -0,0 +1,82 @@
+package com.ogoglio.client
+{
+ import away3d.containers.View3D;
+ import away3d.core.math.Number3D;
+ import away3d.loaders.Obj;
+ import away3d.loaders.Object3DLoader;
+ import away3d.materials.BitmapFileMaterial;
+
+ import com.ogoglio.client.SpaceClient;
+
+ import flash.events.Event;
+
+ import mx.core.UIComponent;
+
+ public class OgoglioView3D extends UIComponent
+ {
+ private var view:View3D;
+
+ private var objLoader:Object3DLoader;
+
+ private var janeLoader:Object3DLoader;
+
+ public function OgoglioView3D()
+ {
+ super();
+ this.addEventListener(Event.ENTER_FRAME, onFrameEnter);
+ }
+
+ override protected function createChildren():void
+ {
+ super.createChildren();
+
+ if(!this.view)
+ {
+ this.view = new View3D();
+
+ this.view.camera.moveTo(new Number3D(0, 0, -300));
+ this.view.camera.lookAt(new Number3D(0, 0, 0));
+ }
+ this.addChild(this.view);
+
+ if(!this.objLoader){
+ this.objLoader = Obj.load("test.obj", { material:new BitmapFileMaterial("body.jpg"), name:"joe", scaling:10 } );
+ this.objLoader.rotationY = 180;
+ this.objLoader.rotationX = -90;
+ }
+ this.view.scene.addChild(this.objLoader);
+
+ if(!this.janeLoader){
+ this.janeLoader = Obj.load("jane.obj", { material:new BitmapFileMaterial("jane.jpg"), name:"jane", scaling:10 } );
+ this.janeLoader.rotationY = 180;
+ this.janeLoader.rotationX = -90;
+ }
+ this.view.scene.addChild(this.janeLoader);
+
+ }
+
+ override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void
+ {
+ super.updateDisplayList(unscaledWidth, unscaledHeight);
+
+ if(this.width / 2 != this.view.x)
+ this.view.x = this.width / 2;
+ if(this.height / 2 != this.view.y)
+ this.view.y = this.height / 2;
+ }
+
+ private function onFrameEnter(event:Event):void
+ {
+ if(this.view && this.view.stage)
+ {
+ this.objLoader.result.transform.tx = -100;
+ this.objLoader.result.rotationY += 1;
+
+ this.janeLoader.result.rotationY -= 1;
+ this.janeLoader.result.transform.tx = 100;
+
+ this.view.render();
+ }
+ }
+ }
+}
\ No newline at end of file
Property changes on: maven/trunk/ogoglio-viewer/com/ogoglio/client/OgoglioView3D.as
___________________________________________________________________
Added: svn:mergeinfo
+
Added: maven/trunk/ogoglio-viewer/com/ogoglio/client/SpaceClient.as
===================================================================
--- maven/trunk/ogoglio-viewer/com/ogoglio/client/SpaceClient.as (rev 0)
+++ maven/trunk/ogoglio-viewer/com/ogoglio/client/SpaceClient.as 2008-08-09 01:18:28 UTC (rev 800)
@@ -0,0 +1,142 @@
+package com.ogoglio.client
+{
+ import com.ogoglio.util.*;
+
+ import mx.rpc.events.*;
+ import mx.rpc.http.*;
+
+
+ public class SpaceClient {
+
+ private var spaceID:int;
+ private var authCookie:String;
+ private var descriptor:WebAPIDescriptor;
+ private var listener:Function;
+
+ private var username:String;
+ private var cachedAccountDocument:XML;
+ private var spaceDocument:XML;
+
+ private var messageChannel:CometClient;
+
+ public function SpaceClient(spaceID:int, serviceURI:String, authCookie:String, listener:Function) {
+ ArgumentUtils.assertNotNegative(spaceID);
+ this.spaceID = spaceID;
+ ArgumentUtils.assertNotNull(authCookie);
+ this.authCookie = authCookie;
+ ArgumentUtils.assertNotNull(serviceURI);
+ this.descriptor = new WebAPIDescriptor(serviceURI);
+ ArgumentUtils.assertNotNull(listener);
+ this.listener = listener;
+
+ listener(new DebugInfo("* SpaceClient: Started with spaceID: " + spaceID + "; serviceURI: " + serviceURI + "; cookie: " + authCookie));
+
+ listener(new DebugInfo("* SpaceClient: Authenticating..."));
+ // Deal with guests first
+ if (authCookie.match("guest")) {
+ this.cachedAccountDocument = new XML();
+ cachedAccountDocument["username"] = authCookie;
+ this.username = authCookie;
+
+ listener(new DebugInfo(" SpaceClient: Authenticated as guest from cookie: " + this.authCookie));
+
+ listener(new DebugInfo("* SpaceClient: Asking for space document..."));
+ this.getXML(descriptor.getSpaceAndChildrenURI(this.spaceID), spaceDocumentHandler);
+
+ // If not a guest get the account document
+ } else {
+ this.getXML(descriptor.getMeAuthURI(), authDocHandler);
+ }
+ }
+
+ private function authDocHandler(resultEvent:ResultEvent):void {
+ var authDoc:XML = new XML(resultEvent.result);
+
+ if(authDoc == null) {
+ listener(new SpaceClientException("! SpaceClient: Could not authenticate with server."));
+ return;
+ }
+ if (authDoc.attribute("authenticated") != "true") {
+ listener(new SpaceClientException("! SpaceClient: Could not authenticate via cookie."));
+ return;
+ }
+ this.username = authDoc.attribute("username");
+
+ listener(new DebugInfo(" SpaceClient: Authenticated with username: " + this.username));
+
+ listener(new DebugInfo("* SpaceClient: Asking for authentication document..."));
+ this.getXML(descriptor.getAccountURI(username), accountDocHandler);
+ }
+
+ private function accountDocHandler(resultEvent:ResultEvent):void {
+ cachedAccountDocument = new XML(resultEvent.result);
+
+ if(cachedAccountDocument == null) {
+ listener(new SpaceClientException("! SpaceClient: Could not retrieve account document."));
+ return;
+ }
+
+ listener(new DebugInfo(" SpaceClient: Retrieved account document for username: " + cachedAccountDocument.attribute("username")
+ + " - First name: " + cachedAccountDocument.attribute("firstname")
+ + " Last name: " + cachedAccountDocument.attribute("lastname")));
+
+ listener(new DebugInfo("* SpaceClient: Asking for space document..."));
+ this.getXML(descriptor.getSpaceAndChildrenURI(this.spaceID), spaceDocumentHandler);
+ }
+
+ private function spaceDocumentHandler(resultEvent:ResultEvent):void {
+ spaceDocument = new XML(resultEvent.result);
+
+ if(spaceDocument == null) {
+ listener(new SpaceClientException("! SpaceClient: Could not retrieve space document."));
+ return;
+ }
+
+ listener(new DebugInfo(" SpaceClient: Retrieved space document: spaceID: " + spaceDocument.attribute("spaceid")
+ + " Owner username: " + spaceDocument.attribute("ownerusername")
+ + " Display name: " + spaceDocument.attribute("displayname")));
+
+ // TODO: eventually we'll create a space model here
+ // For now we just setup the messaging system
+
+ this.messageChannel = new CometClient(descriptor.getCometProxyURI(), spaceID, authCookie);
+ this.messageChannel.messageHandler = handleMessageFromService;
+ }
+
+ private function getXML(uri:String, resultHandler:Function):void {
+ var connection:HTTPService = new HTTPService();
+ connection.url = uri;
+ connection.method = "get";
+ connection.resultFormat = "e4x";
+ connection.requestTimeout = 5;
+
+ var parameters:Object = new Object();
+ if (authCookie != null) {
+ parameters["Cookie"] = WebConstants.AUTH_COOKIE + "=" + authCookie;
+ }
+
+ connection.addEventListener(ResultEvent.RESULT, resultHandler);
+ connection.addEventListener(FaultEvent.FAULT, failureHandler);
+
+ connection.send(parameters);
+ }
+
+ private function failureHandler(faultEvent:FaultEvent):void {
+ var faultString:String = faultEvent.fault.faultDetail;
+ listener(new SpaceClientException("! SpaceClient: " + faultString));
+ }
+
+ private function handleMessageFromService(message:XML):void {
+ listener(new DebugInfo(" SpaceClient.CometMessageHandler: received\n" + message));
+
+ // Start heartbeat if we authenticated successfully
+ if (message.Payload.AuthenticationSuccess.@username == this.username) {
+ listener(new DebugInfo(" SpaceClient.CometMessageHandler: successful authentication, starting heartbeat"));
+ messageChannel.startHeartbeat();
+ } else {
+ // Lots to do here... move over everything from the original handleMessageFromService
+ listener(message);
+ }
+ }
+ }
+}
\ No newline at end of file
Added: maven/trunk/ogoglio-viewer/com/ogoglio/client/WebAPIDescriptor.as
===================================================================
--- maven/trunk/ogoglio-viewer/com/ogoglio/client/WebAPIDescriptor.as (rev 0)
+++ maven/trunk/ogoglio-viewer/com/ogoglio/client/WebAPIDescriptor.as 2008-08-09 01:18:28 UTC (rev 800)
@@ -0,0 +1,210 @@
+package com.ogoglio.client
+{
+ import com.ogoglio.util.WebConstants;
+ import com.ogoglio.util.ArgumentUtils;
+
+ public class WebAPIDescriptor
+ {
+ private var serviceURI:String = null;
+
+ public function WebAPIDescriptor(serviceURI:String) {
+ ArgumentUtils.assertNotNull(serviceURI);
+ this.serviceURI = serviceURI;
+ }
+
+ public function getSpacesURI():String {
+ return WebAPIUtil.appendToURI(serviceURI, "space/");
+ }
+
+ public function getSpaceSimURIServersOnly():String {
+ return WebAPIUtil.appendToURI(getSpacesURI(), "sim/?serversOnly=true");
+ }
+
+ public function getSpaceSimURI(id:Number):String {
+ return WebAPIUtil.appendToURI(getSpacesURI(), "sim/"+id);
+ }
+
+ public function getSpaceURI(spaceID:Number):String {
+ return WebAPIUtil.appendToURI(serviceURI, "space/" + spaceID);
+ }
+
+ public function getSpaceAndChildrenURI(spaceID:Number):String {
+ return WebAPIUtil.appendToURI(getSpaceURI(spaceID), "?" + WebConstants.SPACE_INCLUDE_CHILDREN_PARAM + "=true");
+ }
+
+ public function getSpaceMemberURI(spaceID:Number):String {
+ return WebAPIUtil.appendToURI(getSpaceURI(spaceID), "member/");
+ }
+
+ public function getSpaceMemberURIForUsername(spaceID:Number, memberUsername:String):String {
+ return WebAPIUtil.appendToURI(getSpaceMemberURI(spaceID), memberUsername + "/");
+ }
+
+ public function getUsersSpaceMembershipsURI(username:String):String {
+ return WebAPIUtil.appendToURI(getAccountURI(username), "membership/");
+ }
+
+ public function getAccountBaseURI():String {
+ return WebAPIUtil.appendToURI(serviceURI, "account/");
+ }
+
+ public function getAccountURI(username:String):String {
+ return WebAPIUtil.appendToURI(getAccountBaseURI(), username + "/");
+ }
+
+ public function getAccountPhotoURI(username:String):String {
+ return WebAPIUtil.appendToURI(getAccountURI(username), "photo/");
+ }
+
+ public function getPossessionsURI(username:String):String {
+ return WebAPIUtil.appendToURI(getAccountURI(username), "possession/");
+ }
+
+ public function getPossessionURI(username:String, possessionID:Number):String {
+ return WebAPIUtil.appendToURI(getPossessionsURI(username), possessionID + "/");
+ }
+
+ public function getMeAuthURI():String {
+ return WebAPIUtil.appendToURI(getAuthURI(), "me/");
+ }
+
+ public function getAuthURI():String {
+ return WebAPIUtil.appendToURI(serviceURI, "auth/");
+ }
+
+ public function getAuthGuestURI():String {
+ return WebAPIUtil.appendToURI(getAuthURI(), "guest/");
+ }
+
+ public function getAccountSpacesURI(username:String):String {
+ return WebAPIUtil.appendToURI(getAccountURI(username), "space/");
+ }
+
+ public function getTemplatesURI(username:String):String {
+ return WebAPIUtil.appendToURI(getAccountURI(username), "template/");
+ }
+
+ public function getTemplateURI(username:String, templateID:Number):String {
+ return WebAPIUtil.appendToURI(getTemplatesURI(username), templateID + "/");
+ }
+
+ public function getAttachmentTemplatesURI():String {
+ return WebAPIUtil.appendToURI(getAccountBaseURI(), "template/attachment/");
+ }
+
+ public function getDoorsURI(spaceID:Number):String {
+ return WebAPIUtil.appendToURI(getSpaceURI(spaceID), "door/");
+ }
+
+ public function getDoorURI(spaceID:Number, doorID:Number):String {
+ return WebAPIUtil.appendToURI(getDoorsURI(spaceID), doorID + "/");
+ }
+
+ public function getThingsURI(spaceID:Number):String {
+ return WebAPIUtil.appendToURI(getSpaceURI(spaceID), "thing/");
+ }
+
+ public function getThingURI(spaceID:Number, thingID:Number):String {
+ return WebAPIUtil.appendToURI(getThingsURI(spaceID), thingID + "/");
+ }
+
+ public function getThingServiceURI(spaceID:Number, thingID:Number):String {
+ return WebAPIUtil.appendToURI(getThingURI(spaceID, thingID), "service/");
+ }
+
+ public function getReloadThingURI(spaceID:Number, thingID:Number):String {
+ return WebAPIUtil.appendToURI(getThingsURI(spaceID), thingID + "/?reload=true");
+ }
+
+ public function getUserURI(spaceID:Number, username:String):String {
+ return WebAPIUtil.appendToURI(getUsersURI(spaceID), username + "/");
+ }
+
+ public function getUsersURI(spaceID:Number):String {
+ return WebAPIUtil.appendToURI(getSpaceURI(spaceID), "user/");
+ }
+
+ public function getBodiesURI():String {
+ return WebAPIUtil.appendToURI(getSpacesURI(), "body/");
+ }
+
+ public function getBodyDataDocumentURI(bodyDataID:String):String {
+ return WebAPIUtil.appendToURI(getBodiesURI(), bodyDataID + "/");
+ }
+
+ public function getBodyDataURI(fileName:String):String {
+ return WebAPIUtil.appendToURI(serviceURI, fileName);
+ }
+
+ public function getBodyConfigurationsURI(username:String):String {
+ return WebAPIUtil.appendToURI(getAccountURI(username), "body/");
+ }
+
+ public function getBodyConfigurationURI(username:String, bodyConfigurationID:Number):String {
+ return WebAPIUtil.appendToURI(getBodyConfigurationsURI(username), bodyConfigurationID + "/");
+ }
+
+ public function getBodyTextureURI(username:String, bodyConfigurationID:Number):String {
+ return WebAPIUtil.appendToURI(getBodyConfigurationURI(username, bodyConfigurationID), "texture");
+ }
+ public function getDefaultBodyConfiguration(username:String):String {
+ return WebAPIUtil.appendToURI(getBodyConfigurationsURI(username), "default/");
+ }
+
+ public function getPagesURI(spaceID:Number, thingID:Number):String {
+ return WebAPIUtil.appendToURI(getThingURI(spaceID, thingID), "page/");
+ }
+
+ public function getPageURI(spaceID:Number, thingID:Number, pageID:Number):String {
+ return WebAPIUtil.appendToURI(getPagesURI(spaceID, thingID), pageID + "/");
+ }
+
+ public function getPageContentsURI(spaceID:Number, thingID:Number, pageID:Number):String {
+ return WebAPIUtil.appendToURI(getPageURI(spaceID, thingID, pageID), "content");
+ }
+
+ public function getSettingsURI(spaceID:Number):String {
+ return WebAPIUtil.appendToURI(getSpaceURI(spaceID), "setting/");
+ }
+
+ public function getSettingURI(spaceID:Number, key:String):String {
+ return WebAPIUtil.appendToURI(getSettingsURI(spaceID), key + "/");
+ }
+
+ public function getTemplateScriptURI(ownerUsername:String, templateID:Number):String {
+ return WebAPIUtil.appendToURI(getTemplateURI(ownerUsername, templateID), "script/");
+ }
+
+ public function getTemplateGeometryURI(ownerUsername:String, templateID:Number, lodIndex:Number):String {
+ return WebAPIUtil.appendToURI(getTemplateURI(ownerUsername, templateID), "geometry/data/" + lodIndex);
+ }
+
+ public function getTemplateResourceURI(ownerUsername:String, templateID:Number, fileName:String):String {
+ return WebAPIUtil.appendToURI(getTemplateURI(ownerUsername, templateID), "geometry/" + fileName);
+ }
+
+ public function getServiceURI():String {
+ return serviceURI;
+ }
+
+ public function getServiceStateURI():String {
+ return WebAPIUtil.appendToURI(getSpacesURI(), "state/");
+ }
+
+ public function getCometProxyURI():String {
+ return WebAPIUtil.appendToURI(serviceURI, "comet/"+getCometProxyPath());
+ }
+
+ public function getCometSimURI():String {
+ return WebAPIUtil.appendToURI(serviceURI, "comet/"+getCometSimPath());
+ }
+
+ public function getCometProxyPath():String {
+ return "proxy";
+ }
+
+ public function getCometSimPath():String {
+ return "sim";
+ }
+ }
+}
\ No newline at end of file
Added: maven/trunk/ogoglio-viewer/com/ogoglio/client/WebAPIUtil.as
===================================================================
--- maven/trunk/ogoglio-viewer/com/ogoglio/client/WebAPIUtil.as (rev 0)
+++ maven/trunk/ogoglio-viewer/com/ogoglio/client/WebAPIUtil.as 2008-08-09 01:18:28 UTC (rev 800)
@@ -0,0 +1,15 @@
+package com.ogoglio.client
+{
+ import com.ogoglio.util.WebConstants;
+
+ public class WebAPIUtil
+ {
+ public static function appendToURI(uri:String, suffix:String):String {
+ if (!uri.charAt(uri.length - 1).match("/")) {
+ uri += "/";
+ }
+ uri += suffix;
+ return uri;
+ }
+ }
+}
\ No newline at end of file
Added: maven/trunk/ogoglio-viewer/com/ogoglio/util/ArgumentUtils.as
===================================================================
--- maven/trunk/ogoglio-viewer/com/ogoglio/util/ArgumentUtils.as (rev 0)
+++ maven/trunk/ogoglio-viewer/com/ogoglio/util/ArgumentUtils.as 2008-08-09 01:18:28 UTC (rev 800)
@@ -0,0 +1,23 @@
+package com.ogoglio.util
+{
+ public class ArgumentUtils
+ {
+ public static function assertNotEmpty(value:String):void {
+ if (value == null) {
+ throw new IllegalArgumentException("String was empty.");
+ }
+ }
+
+ public static function assertNotNull(object:Object):void {
+ if (object == null) {
+ throw new IllegalArgumentException("Argument was null");
+ }
+ }
+
+ public static function assertNotNegative(value:Number):void {
+ if (value < 0) {
+ throw new IllegalArgumentException("Argument was less than zero");
+ }
+ }
+ }
+}
\ No newline at end of file
Added: maven/trunk/ogoglio-viewer/com/ogoglio/util/DebugInfo.as
===================================================================
--- maven/trunk/ogoglio-viewer/com/ogoglio/util/DebugInfo.as (rev 0)
+++ maven/trunk/ogoglio-viewer/com/ogoglio/util/DebugInfo.as 2008-08-09 01:18:28 UTC (rev 800)
@@ -0,0 +1,13 @@
+package com.ogoglio.util
+{
+ public class DebugInfo
+ {
+ public var message:String;
+
+ public function DebugInfo(message:String)
+ {
+ this.message = message;
+ }
+
+ }
+}
\ No newline at end of file
Added: maven/trunk/ogoglio-viewer/com/ogoglio/util/IllegalArgumentException.as
===================================================================
--- maven/trunk/ogoglio-viewer/com/ogoglio/util/IllegalArgumentException.as (rev 0)
+++ maven/trunk/ogoglio-viewer/com/ogoglio/util/IllegalArgumentException.as 2008-08-09 01:18:28 UTC (rev 800)
@@ -0,0 +1,11 @@
+package com.ogoglio.util
+{
+ public class IllegalArgumentException extends Error
+ {
+ public function IllegalArgumentException(message:String = "Illegal argument specified")
+ {
+ super(message);
+ }
+
+ }
+}
\ No newline at end of file
Added: maven/trunk/ogoglio-viewer/com/ogoglio/util/SpaceClientException.as
===================================================================
--- maven/trunk/ogoglio-viewer/com/ogoglio/util/SpaceClientException.as (rev 0)
+++ maven/trunk/ogoglio-viewer/com/ogoglio/util/SpaceClientException.as 2008-08-09 01:18:28 UTC (rev 800)
@@ -0,0 +1,10 @@
+package com.ogoglio.util
+{
+ public class SpaceClientException extends Error
+ {
+ public function SpaceClientException(message:String = "Could not initialize SpaceClient") {
+ super(message);
+ }
+
+ }
+}
\ No newline at end of file
Added: maven/trunk/ogoglio-viewer/com/ogoglio/util/URLParser.as
===================================================================
--- maven/trunk/ogoglio-viewer/com/ogoglio/util/URLParser.as (rev 0)
+++ maven/trunk/ogoglio-viewer/com/ogoglio/util/URLParser.as 2008-08-09 01:18:28 UTC (rev 800)
@@ -0,0 +1,41 @@
+package com.ogoglio.util
+{
+ public class URLParser
+ {
+ public static var url:String;
+ public static var host:String = "";
+ public static var port:String = "";
+ public static var protocol:String = "";
+ public static var path:String = "";
+ public static var parameters:Object;
+
+ public static function parse( url:String ) : void {
+
+ URLParser.url = url;
+ var reg:RegExp = /(?P<protocol>[a-zA-Z]+) : \/\/ (?P<host>[^:\/]*) (:(?P<port>\d+))? ((?P<path>[^?]*))? ((?P<parameters>.*))? /x;
+ var results:Array = reg.exec(url);
+
+ protocol = results.protocol
+ host = results.host;
+ port = results.port;
+ path = results.path;
+
+ var paramsStr:String = results.parameters;
+
+ if(paramsStr!="") {
+ parameters = null;
+ parameters = new Object();
+
+ if(paramsStr.charAt(0) == "?") {
+ paramsStr = paramsStr.substring(1);
+ }
+
+ var params:Array = paramsStr.split("&");
+ for each(var paramStr:String in params) {
+ var param:Array = paramStr.split("=");
+ parameters[param[0]] = param[1];
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
Added: maven/trunk/ogoglio-viewer/com/ogoglio/util/WebConstants.as
===================================================================
--- maven/trunk/ogoglio-viewer/com/ogoglio/util/WebConstants.as (rev 0)
+++ maven/trunk/ogoglio-viewer/com/ogoglio/util/WebConstants.as 2008-08-09 01:18:28 UTC (rev 800)
@@ -0,0 +1,23 @@
+package com.ogoglio.util
+{
+ public class WebConstants
+ {
+ public static const AUTH_USERNAME_PARAM:String = "username";
+
+ public static const AUTH_PASS_PARAM:String = "password";
+
+ public static const AUTH_COOKIE:String = "loginCookie";
+
+ public static const SPACE_INCLUDE_CHILDREN_PARAM:String = "children";
+
+ public static const GUEST_COOKIE_PREFIX:String = "guest";
+
+ public static const REQUESTED_GUEST_NAME_PARAMETER:String = "requestedGuestName";
+
+ public static const GUEST_DISPLAY_NAME_PREFIX:String = "Guest";
+
+ public static const GUEST_BODY_FILE_NAME:String = "ogoglio-body-guest.jar";
+
+ public static const INCOMING_CHAT_SOUND_PATH:String = "incomingChat.wav";
+ }
+}
\ No newline at end of file
Added: maven/trunk/ogoglio-viewer/com/ogoglio/viewer/FlashViewer.as
===================================================================
--- maven/trunk/ogoglio-viewer/com/ogoglio/viewer/FlashViewer.as (rev 0)
+++ maven/trunk/ogoglio-viewer/com/ogoglio/viewer/FlashViewer.as 2008-08-09 01:18:28 UTC (rev 800)
@@ -0,0 +1,94 @@
+package com.ogoglio.viewer
+{
+ import com.ogoglio.client.OgoglioView3D;
+ import com.ogoglio.client.SpaceClient;
+ import com.ogoglio.util.DebugInfo;
+
+ import mx.containers.Panel;
+ import mx.containers.VDividedBox;
+ import mx.controls.TextArea;
+ import mx.core.Application;
+
+
+ public class FlashViewer extends Panel {
+
+ private var mainContainer:VDividedBox;
+ private var debugConsole:TextArea = new TextArea();
+
+ private var authCookie:String;
+ private var spaceID:String;
+ private var serviceURI:String;
+ private var serverIP:String;
+
+ private var spaceClient:SpaceClient;
+
+ private var enableChat:Boolean = false;
+ private var enableDebugConsole:Boolean = true;
+
+ public function FlashViewer(authCookie:String, spaceID:String, serviceURI:String, serverIP:String) {
+
+ this.title = "Ogoglio Flash Viewer";
+ this.authCookie = authCookie;
+ this.spaceID = spaceID;
+ this.serviceURI = serviceURI;
+ this.serverIP = serverIP;
+
+ mainContainer = new VDividedBox();
+ mainContainer.percentWidth = 100;
+ mainContainer.percentHeight = 100;
+ this.addChild(mainContainer);
+
+ if (authCookie == null) {
+ mainContainer.addChild(errorPanel("I can't authenticate. Perhaps you aren't logged in?"));
+ return;
+ }
+
+ if (spaceID == null || serviceURI == null) {
+ mainContainer.addChild(errorPanel("I can't find the space ID and service URI."));
+ return;
+ }
+
+ if (serverIP == null) {
+ mainContainer.addChild(errorPanel("I can't find the server IP."));
+ return;
+ }
+
+ var spaceIDInt:int = parseInt(spaceID);
+ this.spaceClient = new SpaceClient(spaceIDInt, serviceURI, authCookie, spaceClientListener);
+
+ // Eventually we'll create a real viewer here...
+ var viewer:OgoglioView3D = new OgoglioView3D();
+ viewer.percentHeight = 100;
+ viewer.percentWidth = 100;
+ mainContainer.addChild(viewer);
+
+ if (enableDebugConsole) {
+ viewer.percentHeight = 70;
+ debugConsole.percentHeight = 30;
+ debugConsole.percentWidth = 100;
+ debugConsole.text = "Debugging console turned on:\n";
+ mainContainer.addChild(debugConsole);
+ }
+ }
+
+ public function spaceClientListener(callback:Object):void {
+ if (callback is Error) {
+ var error:Error = Error(callback);
+ debugConsole.text += error.message + "\n";
+ } else if (callback is DebugInfo) {
+ var debug:DebugInfo = DebugInfo(callback);
+ debugConsole.text += debug.message + "\n";
+ }
+ }
+
+ private function errorPanel(message:String):TextArea {
+ var errorPanel:TextArea = new TextArea();
+ errorPanel.percentHeight = 100;
+ errorPanel.percentWidth = 100;
+ errorPanel.htmlText = "<b><font size='20'>" + message + "</font></b>";
+ errorPanel.setStyle("textAlign", "center");
+
+ return errorPanel;
+ }
+ }
+}
\ No newline at end of file
Deleted: maven/trunk/ogoglio-viewer/jane.obj
===================================================================
--- maven/trunk/ogoglio-viewer/jane.obj 2008-07-27 03:03:24 UTC (rev 799)
+++ maven/trunk/ogoglio-viewer/jane.obj 2008-08-09 01:18:28 UTC (rev 800)
@@ -1,9308 +0,0 @@
-# Height scale: 0.999856
-# Y Change: -1.2772213
-# created by Ogoglio Obj library: http://ogoglio.com/
-# num vertices: 1750
-# num faces: 3446
-# num groups: 20
-# num smoothing groups: 3
-# num material groups: 0
-v -0.028693866 0.61399424 0.086478546
-v -0.047523156 0.61399424 0.086479545
-v -0.0569368 0.5989244 0.086478546
-v -0.047523156 0.5838556 0.086478546
-v -0.028693866 0.5838556 0.086479545
-v -0.019279223 0.5989244 0.086479545
-v -0.029954687 0.61197865 0.09494833
-v -0.046261337 0.61197865 0.09494833
-v -0.05441416 0.59892845 0.09494833
-v -0.046261337 0.5858784 0.09494833
-v -0.029954687 0.5858784 0.09494833
-v -0.02180186 0.59892845 0.09494833
-v -0.03340119 0.60646033 0.09992461
-v -0.042814836 0.60646033 0.09992461
-v -0.047522157 0.5989264 0.09992461
-v -0.042815834 0.59139144 0.09992461
-v -0.03340119 0.59139144 0.09992461
-v -0.028693866 0.5989264 0.09992461
-v -0.038108513 0.59892845 0.10174634
-v 0.04750016 0.61399424 0.086478546
-v 0.02867087 0.61399424 0.086479545
-v 0.019256227 0.5989244 0.086478546
-v 0.02867087 0.5838556 0.086478546
-v 0.04750016 0.5838556 0.086479545
-v 0.056914803 0.5989244 0.086479545
-v 0.04623834 0.61197865 0.09494833
-v 0.029932689 0.61197865 0.09494833
-v 0.021778863 0.59892845 0.09494833
-v 0.02993169 0.5858784 0.09494833
-v 0.04623834 0.5858784 0.09494833
-v 0.054392166 0.59892845 0.09494833
-v 0.042792838 0.60646033 0.09992461
-v 0.033378195 0.60646033 0.09992461
-v 0.02867087 0.5989264 0.09992461
-v 0.033378195 0.59139144 0.09992461
-v 0.042792838 0.59139144 0.09992461
-v 0.04750016 0.5989264 0.09992461
-v 0.038085517 0.59892845 0.10174634
-v 0.0 0.47002506 0.09726999
-v 0.0 0.50386715 0.11709413
-v 0.0 0.53018534 0.124467075
-v 0.0 0.5120599 0.12098257
-v 0.0 0.48805737 0.12247336
-v 0.0 0.4776219 0.115745336
-v 0.0 0.57006156 0.13850404
-v 0.0 0.56339455 0.14061674
-v 0.0 0.54998446 0.12283231
-v 0.0 0.5162864 0.11918783
-v 0.0 0.525699 0.12498599
-v 0.0 0.519078 0.12098857
-v 0.0 0.53470075 0.121441506
-v 0.0 0.5436684 0.1229343
-v 0.0 0.5549277 0.1339807
-v 0.019081252 0.47336555 0.09612816
-v 0.011234382 0.5037911 0.11669219
-v 0.06971195 0.5241393 0.008369795
-v 0.055462014 0.5343617 -0.05368227
-v 0.084585816 0.56104493 0.008136828
-v 0.064348735 0.5696347 -0.07717788
-v 0.010568478 0.6000873 0.10944723
-v 0.08929214 0.5922904 0.012639179
-v 0.07248756 0.61297846 -0.09068894
-v 0.020126102 0.62373483 0.11642024
-v 0.08968008 0.61848664 0.019487193
-v 0.057520714 0.6575279 -0.09672107
-v 0.025426337 0.6961734 0.0708358
-v 0.080925345 0.664165 -0.0035514885
-v 0.05513206 0.69226706 -0.061813097
-v 0.02632221 0.7130619 0.040310197
-v 0.06432174 0.6962795 -0.0040594153
-v 0.033712145 0.4899192 0.1006625
-v 0.022170808 0.5619458 0.11092803
-v 0.057935655 0.59979737 0.08863223
-v 0.060247324 0.62396383 0.09277164
-v 0.05290838 0.68634796 0.051427595
-v 0.028568886 0.518834 0.106226705
-v 0.07816074 0.53994596 0.009228671
-v 0.02095798 0.52823174 0.11649922
-v 0.023353636 0.51326585 0.11409657
-v 0.011274376 0.47984958 0.113307685
-v 0.01882129 0.55523276 0.113462664
-v 0.0047863107 0.57964325 0.12650578
-v 0.012582188 0.57048965 0.12539594
-v 0.0036004814 0.6042677 0.11077405
-v 0.00784287 0.62098837 0.11889688
-v 0.0043783695 0.5502595 0.121296525
-v 0.0050542722 0.57029057 0.13757119
-v 0.007470924 0.56405044 0.13915396
-v 0.0070079905 0.53235114 0.12617083
-v 0.004865299 0.5204358 0.11747008
-v 0.01985814 0.5575514 0.119289815
-v 0.010037554 0.50983226 0.12169348
-v 0.017622462 0.5661262 0.116165265
-v 0.016914563 0.5193529 0.113379665
-v 0.00840579 0.5179491 0.12114255
-v 0.02172687 0.51769006 0.114736475
-v 0.026423195 0.5195509 0.1076145
-v 0.02117395 0.52486014 0.118065
-v 0.011535338 0.52701175 0.12469304
-v 0.02770001 0.5096803 0.10634568
-v 0.068489134 0.616259 0.07807076
-v 0.011888288 0.6971954 0.07493021
-v 0.014009981 0.7157166 0.034932967
-v 0.014572901 0.48894227 0.12016869
-v 0.05159257 0.5247042 0.081273295
-v 0.06679938 0.56478345 0.081620246
-v 0.07401134 0.58255684 0.06365184
-v 0.0735644 0.6024369 0.06915104
-v 0.06650842 0.67693424 0.03317722
-v 0.021212945 0.59816456 0.10187533
-v 0.053730264 0.59381616 0.09614915
-v 0.028598882 0.59287035 0.10408701
-v 0.04596838 0.59195554 0.10379105
-v 0.054344174 0.6034589 0.09377849
-v 0.031211505 0.6058794 0.10498388
-v 0.045079507 0.6075473 0.10190532
-v 0.042720847 0.62744236 0.11012114
-v 0.039819267 0.6924349 0.062143046
-v 0.016607609 0.5980426 0.10456694
-v 0.026142236 0.5876671 0.108196415
-v 0.044038657 0.58402157 0.10337812
-v 0.05602493 0.58634126 0.09163581
-v 0.062317025 0.595266 0.08000048
-v 0.06022633 0.602528 0.08060039
-v 0.056080922 0.61091876 0.087935336
-v 0.04323677 0.61662495 0.100659505
-v 0.029670727 0.61236846 0.10381105
-v 0.0478971 0.56112194 0.105471805
-v 0.052195482 0.5000347 0.068554126
-v 0.026717152 0.4806435 0.06393979
-v 0.010712457 0.6640581 0.10426798
-v 0.026830135 0.6651869 0.0999986
-v 0.04809707 0.6637981 0.087809354
-v 0.06600549 0.65772593 0.069165036
-v 0.07325745 0.6524478 0.049881812
-v 0.08222216 0.6432171 0.033581164
-v 0.035455894 0.71179616 0.024221512
-v 0.04819606 0.7043663 0.013741021
-v 0.07066082 0.5484437 -0.029196795
-v 0.07613403 0.5763788 -0.035887834
-v 0.08153726 0.6208663 -0.043704703
-v 0.0812533 0.6634021 -0.050644707
-v 0.042852826 0.7122381 -0.01166432
-v 0.017251516 0.72276556 -0.011920284
-v 0.030535603 0.7032974 -0.068113185
-v 0.028503895 0.6636311 -0.10531983
-v 0.03443704 0.61052275 -0.11487945
-v 0.032315347 0.56211376 -0.09958666
-v 0.013972987 0.5514643 0.117016144
-v 0.08175423 0.560557 0.031395476
-v 0.0680012 0.54055583 0.055227045
-v 0.06270397 0.50978327 0.04693624
-v 0.005708178 0.5218705 0.1207676
-v 0.016897565 0.52098465 0.11629325
-v 0.026474187 0.5202228 0.10873734
-v 0.028366916 0.52142763 0.10780247
-v 0.031153513 0.5222975 0.104126
-v 0.03899538 0.5242772 0.09984862
-v 0.039101366 0.51291084 0.09555624
-v 0.031029532 0.51735425 0.10329212
-v 0.0076808934 0.53680634 0.12208242
-v 0.020113103 0.533236 0.111116
-v 0.055866953 0.5998273 0.08739742
-v 0.053273328 0.60297084 0.08739742
-v 0.0541362 0.5941062 0.08739742
-v 0.022100817 0.5981035 0.08727643
-v 0.029246788 0.5933273 0.08739742
-v 0.045587435 0.5924134 0.08739742
-v 0.032045383 0.6053606 0.08720544
-v 0.044771552 0.6067084 0.08724743
-v 0.044345614 0.6112397 0.10318214
-v 0.030395623 0.608976 0.10602473
-v 0.019685166 0.5980426 0.10225427
-v 0.026336208 0.5909016 0.107289545
-v 0.045008518 0.588004 0.1048819
-v 0.056343887 0.5900637 0.09571022
-v 0.060196333 0.5967158 0.08359896
-v 0.05928646 0.6009562 0.084510826
-v 0.055350028 0.6069374 0.09109788
-v 0.017173527 0.5827558 0.11362164
-v 0.012687173 0.58527243 0.1152744
-v 0.0050492724 0.58995676 0.11875489
-v 0.069161035 0.59837854 0.074789226
-v 0.0652516 0.60730326 0.0805364
-v 0.059231468 0.6142303 0.08937713
-v 0.04387968 0.62007344 0.10316614
-v 0.023764577 0.6146722 0.1076235
-v 0.014009981 0.5989274 0.10666664
-v 0.020239085 0.5852884 0.11130897
-v 0.026814139 0.57715666 0.11151994
-v 0.04458258 0.57367814 0.10574477
-v 0.06364284 0.5763937 0.08817729
-v 0.06925302 0.5893619 0.07549613
-v 0.008705746 0.6341394 0.11934681
-v 0.02458546 0.6393876 0.118437946
-v 0.04612636 0.64085245 0.10934925
-v 0.06345886 0.6371609 0.089331135
-v 0.07068782 0.62790024 0.06508463
-v 0.076133035 0.61413825 0.05401822
-v 0.0826901 0.5994464 0.04562543
-v 0.078858644 0.5858073 0.04477455
-v 0.07822473 0.5713285 0.050881673
-v 0.06815618 0.5511594 0.070701815
-v 0.050809685 0.5434544 0.09590618
-v 0.03235234 0.54560614 0.10525884
-v 0.02861088 0.54485834 0.10571877
-v 0.016147673 0.54334736 0.11365263
-v 0.0045043514 0.5440644 0.12238937
-v 0.0058201617 0.5559497 0.13315682
-v 0.011367363 0.56070995 0.13547349
-v 0.008595762 0.57120645 0.1312291
-v 0.029000824 0.4787817 0.10089547
-v 0.040651143 0.48712754 0.07047785
-v 0.050167773 0.49341273 0.040372185
-v 0.006088123 0.553295 0.12275832
-v 0.011826296 0.55860424 0.13183601
-v 0.015426778 0.5569415 0.120435655
-v 0.020601032 0.560374 0.11284775
-v 0.01785243 0.5674989 0.12446108
-v 0.012064262 0.5658512 0.13413069
-v 0.006957998 0.55935216 0.1382031
-v 0.0 0.55724657 0.13806012
-v 0.049935807 0.52114964 -0.02922579
-v 0.028730862 0.5297384 -0.06689837
-v 0.0 0.5806651 0.12642679
-v 0.0 0.5909786 0.11867491
-v 0.0 0.6042677 0.11077405
-v 0.0 0.62098837 0.11889688
-v 0.0 0.6341394 0.11934681
-v 0.0 0.6971954 0.07493021
-v 0.0 0.7157166 0.034932967
-v 0.0 0.6640581 0.10426798
-v 0.0 0.72276556 -0.011920284
-v 0.0 0.7032974 -0.068113185
-v 0.0 0.6636311 -0.10531983
-v 0.0 0.61052275 -0.11487945
-v 0.0 0.56211376 -0.09958666
-v -0.0 0.5295105 -0.06785122
-v 0.0 0.519032 0.11758106
-v -0.0 0.44994688 0.040620152
-v 0.0 0.47673702 0.06481166
-v 0.0 0.50697565 -0.06294293
-v 0.0 0.4741894 -0.06978695
-v 0.0249924 0.5002047 -0.057468724
-v 0.015009838 0.45507312 0.036163792
-v 0.045891393 0.48438096 0.0066620405
-v 0.029453758 0.47164178 0.021286935
-v 0.039893255 0.4922378 -0.028499894
-v 0.05242245 0.49898183 0.012868146
-v 0.037607584 0.48819542 0.037046667
-v 0.03276528 0.4387486 0.025140379
-v 0.04967085 0.4534254 0.005234246
-v 0.055098064 0.46700346 -0.023695588
-v 0.025027396 0.47037804 -0.0652736
-v 0.0 0.46781242 0.050298754
-v 0.017488481 0.47525728 0.040635146
-v 0.015255803 0.4789647 0.06431374
-v -0.019081252 0.47336555 0.09612816
-v -0.011234382 0.5037911 0.11669219
-v -0.06971195 0.5241393 0.008369795
-v -0.055462014 0.5343617 -0.05368227
-v -0.084585816 0.56104493 0.008136828
-v -0.064348735 0.5696347 -0.07717788
-v -0.010568478 0.6000873 0.10944723
-v -0.08929214 0.5922904 0.012639179
-v -0.07248756 0.61297846 -0.09068894
-v -0.020126102 0.62373483 0.11642024
-v -0.08968008 0.61848664 0.019487193
-v -0.057520714 0.6575279 -0.09672107
-v -0.025426337 0.6961734 0.0708358
-v -0.080925345 0.664165 -0.0035514885
-v -0.05513206 0.69226706 -0.061813097
-v -0.02632221 0.7130619 0.040310197
-v -0.06432174 0.6962795 -0.0040594153
-v -0.033712145 0.4899192 0.1006625
-v -0.022170808 0.5619458 0.11092803
-v -0.057935655 0.59979737 0.08863223
-v -0.060247324 0.62396383 0.09277164
-v -0.05290838 0.68634796 0.051427595
-v -0.028568886 0.518834 0.106226705
-v -0.07816074 0.53994596 0.009228671
-v -0.02095798 0.52823174 0.11649922
-v -0.023353636 0.51326585 0.11409657
-v -0.011274376 0.47984958...
[truncated message content] |