|
From: <tre...@us...> - 2007-11-01 13:16:36
|
Revision: 550
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=550&view=rev
Author: trevorolio
Date: 2007-11-01 06:16:40 -0700 (Thu, 01 Nov 2007)
Log Message:
-----------
Updated the template editor UI to provide for script FILE upload in addition to inline editing.
This is handy for those of us who edit scripts in populate template directories using reasonable IDEs.
Added space.getOwnerUsername() to the script api so scripts can give owners more actions.
Modified Paths:
--------------
maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/script/ScriptQuaternion.java
maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/script/ScriptSpace.java
maven/trunk/ogoglio-server/src/main/resources/siteTemplates/templateEditor.html
Modified: maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/script/ScriptQuaternion.java
===================================================================
--- maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/script/ScriptQuaternion.java 2007-10-31 13:50:49 UTC (rev 549)
+++ maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/script/ScriptQuaternion.java 2007-11-01 13:16:40 UTC (rev 550)
@@ -15,6 +15,7 @@
package com.ogoglio.sim.script;
import javax.media.j3d.Transform3D;
+import javax.vecmath.Point3d;
import javax.vecmath.Quat4d;
import javax.vecmath.Vector3d;
@@ -97,6 +98,9 @@
}
public void jsFunction_rotate(double x, double y, double z) {
+ if(Double.isNaN(x) || Double.isNaN(y) || Double.isNaN(z)){
+ throw new IllegalArgumentException("Can't rotate with NaN: " + x + ", " + y + ", " + z);
+ }
Transform3D rotTransform = new Transform3D();
rotTransform.setEuler(new Vector3d(x, y, z));
@@ -110,6 +114,16 @@
setQuat(quat);
}
+ public void jsFunction_rotatePoint(ScriptPoint pointOfRotation, ScriptPoint pointToRotate){
+ Vector3d vectorOfRot = new Vector3d(); //new Vector3d(pointOfRotation.jsGet_x(), pointOfRotation.jsGet_y(), pointOfRotation.jsGet_z());
+ Transform3D rotTransform = new Transform3D(new Quat4d(x, y, z, w), vectorOfRot, 1);
+ Point3d workingPoint = new Point3d(pointToRotate.jsGet_x(), pointToRotate.jsGet_y(), pointToRotate.jsGet_z());
+ rotTransform.transform(workingPoint);
+ pointToRotate.jsSet_x(workingPoint.x);
+ pointToRotate.jsSet_y(workingPoint.y);
+ pointToRotate.jsSet_z(workingPoint.z);
+ }
+
public void jsFunction_set(double w, double x, double y, double z) {
this.w = w;
this.x = w;
Modified: maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/script/ScriptSpace.java
===================================================================
--- maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/script/ScriptSpace.java 2007-10-31 13:50:49 UTC (rev 549)
+++ maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/script/ScriptSpace.java 2007-11-01 13:16:40 UTC (rev 550)
@@ -84,6 +84,10 @@
return spaceSimulator.getSpaceID();
}
+ public String jsGet_ownerUsername(){
+ return spaceSimulator.getSpace().getOwnerUsername();
+ }
+
public long jsGet_time() {
return System.currentTimeMillis();
}
@@ -171,6 +175,14 @@
return result;
}
+ public double jsFunction_getThingTemplateID(double thingID){
+ Thing thing = spaceSimulator.getSpace().getThing((long) thingID);
+ if (thing == null) {
+ return -1;
+ }
+ return thing.getTemplate().getTemplateID();
+ }
+
public ScriptPoint jsFunction_getThingPosition(double thingID) {
Thing thing = spaceSimulator.getSpace().getThing((long) thingID);
if (thing == null) {
Modified: maven/trunk/ogoglio-server/src/main/resources/siteTemplates/templateEditor.html
===================================================================
--- maven/trunk/ogoglio-server/src/main/resources/siteTemplates/templateEditor.html 2007-10-31 13:50:49 UTC (rev 549)
+++ maven/trunk/ogoglio-server/src/main/resources/siteTemplates/templateEditor.html 2007-11-01 13:16:40 UTC (rev 550)
@@ -61,7 +61,7 @@
var objMessage = null;
var seatCheckbox = null;
var seatPositionForm = null;
-
+var scriptFileForm = null;
var scriptEditor = null;
var templateDoc = null;
@@ -89,10 +89,12 @@
titleElement.innerHTML = "Template: " + escapeHTML(templateDoc.getAttribute('displayname')) + " <input id='titleFormGoButton' type='submit' value='rename' onclick='titleFormGo(); return false;' />";
+
var templatePath = appPath + "/account/" + authedUsername + "/template/" + templateID;
obj0Form.action = templatePath + "/geometry/data/0";
obj0Form.onsubmit = submitObj0;
-
+ scriptFileForm.action = templatePath + "/script/";
+
var geometryMessage = "does not exist";
var resourceHTML = "";
@@ -157,6 +159,10 @@
return AIM.submit(resourceForm, {'onStart' : startedTemplateForm, 'onComplete' : completedTemplateForm});
}
+function scriptFileFormGo(){
+ return AIM.submit(scriptFileForm, {'onStart' : startedScriptFileForm, 'onComplete' : completedScriptFileForm});
+}
+
function titleFormGo(){
var goButton = document.getElementById("titleFormGoButton");
if(goButton.value == "rename"){
@@ -174,6 +180,17 @@
}
}
+function scriptFileFormGo(){
+ return AIM.submit(scriptFileForm, {'onStart' : startedScriptFileForm, 'onComplete' : completedScriptFileForm});
+}
+
+function startedScriptFileForm(){
+}
+
+function completedScriptFileForm(response){
+ requestTemplateScript(authedUsername, templateID, handleScript);
+}
+
function scriptFormGo(scriptForm){
var newScript = trim(scriptForm.scriptTextArea.value);
updateTemplateScript(authedUsername, templateID, newScript, handleScriptUpdate);
@@ -248,7 +265,8 @@
objMessage = document.getElementById("objMessage");
seatCheckbox = document.getElementById("seatCheckbox");
seatPositionForm = document.getElementById("seatPositionForm");
-
+ scriptFileForm = document.getElementById("scriptFileForm");
+
scriptEditor = document.getElementById('scriptEditor');
if(templateID == null){
@@ -324,8 +342,18 @@
<br clear="all"/>
<div class="section">
+ <h3>Upload script:</h3>
+ <form id="scriptFileForm" onsubmit="scriptFileFormGo();" target="scriptFileTarget" action="" enctype="multipart/form-data" method="post">
+ <input type="file" name="scriptFile" />
+ <input type="submit" value="upload script" />
+ </form>
+ <iframe id="scriptFileTarget" name="scriptFileTarget" style="width: 1px; height: 1px;"></iframe>
+ </div>
+ <br clear="all"/>
+
+ <div class="section">
<div style="float: right;" class="navLink"><a href="http://ogoglio.wiki.sourceforge.net/ServerManualJavascriptAPI">Script API »</a></div>
- <h3>Script:</h3>
+ <h3>Edit script:</h3>
<div id="scriptEditor">
</div>
</div>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|