Doors on Buildings (Ekin): Difference between revisions
| Line 54: | Line 54: | ||
So when the module is uploaded to server and run on the client window, it loads the model and waits for right or left clicks. Right clicks enables the user to change door model and sends message to server to tell changing the model. Left clicks triggers script to execute. |
So when the module is uploaded to server and run on the client window, it loads the model and waits for right or left clicks. Right clicks enables the user to change door model and sends message to server to tell changing the model. Left clicks triggers script to execute. |
||
=====Adding new Doors to Module===== |
|||
====Scripting==== |
====Scripting==== |
||
Revision as of 22:40, 18 May 2011
This page is designed to explain Library Model and its subproject VBUDoors in VirtualBU Project.
Project Description
VBUDoors project is a subproject of VirtualBU project. VirtualBU project aims to create photo realistic of 3D environment of Binghamton University campus.This project is one of the crucial sections of VirtualBU project, which illustrates the campus doors which is animated and has different door models. Basically this project is a module that is used in Open Wonderland projects.
Websites
The URL for the websites for the VirtualBU project is
http://vbu.cs.binghamton.edu:8080
http://vbu1.cs.binghamton.edu:8080
http://vbu2.cs.binghamton.edu:8080
The URL for the website for modeling part of my project is
http://www.cs.binghamton.edu/~steflik/wiki/index.php/Library_-_Ekin_Burak_Ozturk
Project Development
Applications Used
Google SketchUp was used to create 3D model of the Library Tower & The Glenn G. Bartle Library.
The reason I used these applications is that in order to develop modules in Open Wonderland Project easily is to use NetBeans environment, since Open Wonderland is developed in Java and uses Apache Ant to compile and build itself, I used NetBeans IDE for development. Another reason that I used it is Apache Ant is embedded into NetBeans 7.0 .
Prerequisites
- Running Open Wonderland Server
- Scripting-component module that uploaded to server Can be downloaded from Open Wonderland Module Warehouse
Development Process
Modeling
Can be found at My Modeling Section
Coding
Module is developed in Java. For my part I created two different modules that have exactly the same idea. When we think of door openings in real life, we can see that there are two types of the which opens to left side or right side. For my project I used this idea and created two different modules that one of them controls doors that opens to left side and another for right side.
Basically my modules are composition of 3 parts which are Java code, 3D models-there are 5 different door models- and Java script part. For my module I embedded both 3D models and scripts into my module.
In Java code side, I created an empty Open Wonderland module template and edited it as my subproject is described. In this part I created handlers that handles the messages between server side and client side. When you run VBUDoors or VBUDoors_right module in client window you will see a door model is comes by default, but if you right click with your mouse you will see a list of different models which are
1. Door 1
2. Door 2
3. Custom 1
4. Custom 2
5. Custom 3
When you click one of them you will see the door model changes. The handlers that I told above handles these changes by notifying server side. I embedded Java Scripts into module that when you left click on model, you will see that the model will open 90 degrees on left side or right side on the very left or very right axis. Calibrating the axis was another difficult part in my project but after making a very deep investigation on open wonderland forums, I found a way to change model axis in models. That is when a model is uploaded to server, server creates a file with .dep extension and this file keeps everything about the model, all scale factors, transformation factors, vertex factors, edges and color information. I manually changed the axis values in this file and fixed the axis information.
The rest of the project depends on scripts. When you click on a model in the world, this click triggers the scripts to execute. Basically scripts rotates the models on the fixed axis 90 degrees and when one door is opened fully it waits 10-15 seconds and then closes automatically.
So when the module is uploaded to server and run on the client window, it loads the model and waits for right or left clicks. Right clicks enables the user to change door model and sends message to server to tell changing the model. Left clicks triggers script to execute.
Adding new Doors to Module
Scripting
Scripting in Open Wonderland modules enables a user to execute simple scripts on objects. With scripting any user can rotate, scale, transform an object or play a sound file in Open Wonderland world, execute an action, start or stop a server, move his/her avatar in any direction, create or delete a file on server content repository and things like that with mouse clicks, keyboard keystrokes and even with .php files. Scripts can be loaded manually after starting a client and adding scripting property to an object or by,like me, embed the script into a module. In my module I used mouse clicks to execute scripts. In order to do that I placed my .js(Java Script) files into client side of the module. My left mouse click script looks exactly like;
print("Hello from VBUDoors Module\r\n");
var v = new java.lang.Runnable()
{
run: function()
{
increment = (Math.PI/2)/90;
for(i = 0; i <= 90; i++)
{
MyClass.rotateObject(0, 1, 0, increment, 0);
MyClass.mySleep(10);
}
MyClass.mySleep(5000);
for(i = 0; i<= 90; i++)
{
MyClass.rotateObject(0, 1, 0, -increment, 0);
MyClass.mySleep(10);
}
}
}
t = new java.lang.Thread(v);
t.start();
As it can be seen from my script, it rotates the model on y axis 90 degrees waits a little and rotates back to its initial position. Further information can be found here Scripting Component Documents
How to run VBUDoors Module
After uploading the VBUDoors.jar and VBUDoors_right.jar files on the server, you need to restart running wonderland server. Then after opening a client window, you need to insert the desired module. You can do it by clicking Insert menu on top side of client window and then click component, this will pop-up a new window that shows modules you can run on the server.
References
2. Open Wonderland Documentation
By Ekin Burak Ozturk