|
From: <tre...@us...> - 2007-09-17 23:35:34
|
Revision: 412
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=412&view=rev
Author: trevorolio
Date: 2007-09-17 16:35:38 -0700 (Mon, 17 Sep 2007)
Log Message:
-----------
Refactored the way user animations are referenced so as to reduce duplicate code and allow for easy addition.
Now avatars can /wave /clap /point and /laugh in addition to the usual standing and walking animations.
Modified Paths:
--------------
maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/SpaceSimulator.java
Modified: maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/SpaceSimulator.java
===================================================================
--- maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/SpaceSimulator.java 2007-09-17 23:35:33 UTC (rev 411)
+++ maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/SpaceSimulator.java 2007-09-17 23:35:38 UTC (rev 412)
@@ -164,14 +164,7 @@
}
public InputStream getUserAnimationStream(String username, long animationID) throws IOException {
- if (animationID == 1) {
- return UIConstants.getResource("avatar/avatar.bvh");
- } else if (animationID == 2) {
- return UIConstants.getResource("avatar/avatar-walk.bvh");
- } else if (animationID == 3) {
- return UIConstants.getResource("avatar/avatar-wave.bvh");
- }
- return null;
+ return UIConstants.getUserAnimation((int) animationID);
}
public InputStream getUserSkinMapStream(String username) throws IOException {
@@ -371,20 +364,24 @@
String chatMessage = event.getStringProperty(SpaceEvent.TSE_MESSAGE);
- // this is a hack to play pre-baked animations in demos
+ // this is a hack to play pre-baked animations
// TODO create a user animation record and a method to dl and play them
- if ("/wave".equals(chatMessage)) {
- SpaceEvent waveEvent = new SpaceEvent(SpaceEvent.PLAY_ANIMATION_EVENT);
- waveEvent.setProperty(SpaceEvent.USERNAME, user.getUsername());
- waveEvent.setProperty(SpaceEvent.ANIMATION_ID, new Long(3));
- listener.generatedSpaceEvent(waveEvent, SpaceSimulator.this);
- continue;
- } else if ("/point".equals(chatMessage)) {
- SpaceEvent waveEvent = new SpaceEvent(SpaceEvent.PLAY_ANIMATION_EVENT);
- waveEvent.setProperty(SpaceEvent.USERNAME, user.getUsername());
- waveEvent.setProperty(SpaceEvent.ANIMATION_ID, new Long(4));
- listener.generatedSpaceEvent(waveEvent, SpaceSimulator.this);
- continue;
+ if(chatMessage.startsWith("/") && chatMessage.length() > 1){
+ String command = chatMessage.substring(1);
+ boolean sentAnimation = false;
+ for (int i = 0; i < UIConstants.USER_ANIMATION_COMMANDS.length; i++) {
+ if(UIConstants.USER_ANIMATION_COMMANDS[i].equals(command)){
+ SpaceEvent playAnimationEvent = new SpaceEvent(SpaceEvent.PLAY_ANIMATION_EVENT);
+ playAnimationEvent.setProperty(SpaceEvent.USERNAME, user.getUsername());
+ playAnimationEvent.setProperty(SpaceEvent.ANIMATION_ID, new Long(i));
+ listener.generatedSpaceEvent(playAnimationEvent, SpaceSimulator.this);
+ sentAnimation = true;
+ break;
+ }
+ }
+ if(sentAnimation){
+ continue;
+ }
}
chatMessage = markdownChatMessage(chatMessage);
@@ -981,7 +978,7 @@
public ScriptHTTPResponse callThingHTTPService(long thingID, String method, Map parameterMap) {
Thing thing = space.getThing(thingID);
- if(thing == null){
+ if (thing == null) {
ScriptHTTPResponse response = new ScriptHTTPResponse();
response.jsConstructor(404, null, null);
return response;
@@ -1037,7 +1034,7 @@
}
public InputStream getSubGeometryStream(String name) throws IOException {
- if("loading.mtl".equals(name)){
+ if ("loading.mtl".equals(name)) {
return UIConstants.getResource("templates/loading.mtl");
}
return null;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|