Doors on Buildings (Ekin): Difference between revisions
No edit summary (change visibility) |
|||
| (11 intermediate revisions by the same user not shown) | |||
| Line 35: | Line 35: | ||
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. |
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- |
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. |
||
==The idea of Module in Open Wonderland== |
|||
A Wonderland world consists of: |
|||
*Cells, that represent visible objects |
|||
*Components, attached to cells, that add specific features to cells |
|||
*Cell renderers, that use the graphics engine API to make cells visible on-screen |
|||
*Art and other resources |
|||
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 |
|||
Once these have all been created, they need to be packaged in some way for easy upload to the server. This is done using a Wonderland MODULE. A module is basically a wrapper file that contains all the Wonderland building blocks according to a specific structure. This structure lets the server know where all the different building blocks are. A module is actually a Java jar file. |
|||
'''Server and Client Programs''' |
|||
1. ''Door 1'' |
|||
If lots of people are visiting the same virtual world, we have to make sure that everything in the world is the same for everyone. |
|||
For example, if you're playing a game inside Open Wonderland and your friend tells you to pick up a health pack, you both have to be able to see the same health pack, at the same time, in the same location. And if someone else comes along and takes the pack, everyone else in the game has to know that the pack is no longer available. So, Wonderland has to keep track of all the objects in the world. This is very difficult – but Open Wonderland has been designed to make it easy. |
|||
2. ''Door 2'' |
|||
Wonderland is an example of a client-server application. To see what this means, we'll look at some of the main requirements for a virtual word. |
|||
*Every user in the virtual world must see the same things as everyone else. |
|||
3. ''Custom 1'' |
|||
If Nicole and Jon are in a room together, and Nicole sees a book in the room, then Jon must see the same book in the same location. |
|||
• If anything changes, everyone should be kept up to date. If Nicole picks up the book, Jon should see that it is now no longer on the shelf, but is being |
|||
4. ''Custom 2'' |
|||
held by Nicole. |
|||
• Users should be able to connect at any time and see the current state of the world. If Jon has to leave the world for some reason, and while he is gone |
|||
5. ''Custom 3'' |
|||
Nicole puts the book on a table, when Jon visits the room again, he should see the book on the table (assuming it hasn't moved since then). |
|||
• Users do not need to know anything about the physical location of any other user in the real world. Nicole does not need to know that Jon is really in |
|||
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. |
|||
San Francisco or that another user is in Singapore, nor do they need to know that Nicole is in Massachusetts. They do not need to communicate directly with |
|||
each other in the real world. Their computers also do not need to communicate with each other directly. |
|||
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. |
|||
Wonderland is split into two parts, a server program, and a client program (we say that Wonderland has a client-server architecture): |
|||
Server |
|||
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. |
|||
• The virtual world is stored on a computer at a particular IP address. The actual address is defined as a URL. |
|||
=====Adding new Doors to Module===== |
|||
• The server knows everything about the virtual world: it stores all the objects that will be displayed, controls how different parts of the Wonderland |
|||
Before adding new doors type into module there one important modification to make. This modification is about editing the axis of the new model. The problem about axes is explained in previous sections. |
|||
system communicate with each other, and knows which users are inside the virtual world. |
|||
After finishing the modeling phase of a new door, a user need to user Open Wonderland client window to prepare his/her model to use it in a module. The very first thing is, after connection to an Open Wonderland server (after login to a server) user needs to use '''Inset''' menu button to insert the prepared model which is a '''COLLADA''' file (''.dae'' extension). When model is inserted user needs to save the model as a module. The ''save as a module'' option will be seen on the ''insert model'' window. After the module is saved, user needs to extract the ''Art'' directory from saved module (this is '''.jar''' file). When he/she enters the art directory, there will be ''moduleName.dae'' directory and in this directory there will be three files which are; |
|||
Client |
|||
• The client is on another computer, at a different IP address. |
|||
1. moduleName.dae.gz file |
|||
• The client must log into the server to join a virtual world. |
|||
• After the client logs on, the server sends a copy of the virtual world to the client. (Actually, the client can cache data locally, but on entering a new |
|||
2. moduleName.dae.gz.ldr file |
|||
virtual world, the data is sent to the client by the server.) |
|||
• Note that there can be lots of different clients, each running on a different computer. There can also be more than one server, though this is rather complex. |
|||
3. moduleName.dae.gz.dep file |
|||
Your computer is the client, asking the Wonderland server to send you all the data you need to display and interact with the virtual world. |
|||
• The client is the program that you run on your computer – a Wonderland client. |
|||
The only file needed to be modified is ''moduleName.dae.gz.dep'' file. It can be opened with any text editor and the following lines need to be set to following values; |
|||
• The server is the program that runs on the other computer – a Wonderland server. |
|||
If another person (say, Jon) wants to join you in the virtual world, they must log on to the same server as you, and request their own copy of all the virtual world data. Now, you both have the same virtual world displayed on your computer. If you change something about the world, e.g. move a book, Jon needs to know what happened (or he'll get confused). So, when you pick up the book, four things are done: |
|||
<modelBGTranslation> |
|||
• your client sends the new position of the book object to the Wonderland server |
|||
<x>0.0</x> |
|||
• the server updates its own copy of the book object |
|||
<y>0.0</y> |
|||
• the server then sends the new position of the book to Jon's client program |
|||
<z>0.0</z> |
|||
• Jon's client updates its own copy of the book object, and displays it in its new location |
|||
</modelBGTranslation> |
|||
Now everyone is up-to-date. All this communication is handled by Wonderland. But we must still write code to plug our own cells into the Wonderland communication system. This is also packaged inside a module, along with everything else. |
|||
since the default values will be the origin of the model. The reason we are changing these values are we need the models to rotate from the very left or right corner of itself otherwise the model will draw an circle. After making these changes we can add the model into '''../art''' directory of the module. |
|||
The next we need to tell the module that we have another door model that can be selected. In order to that we need to add a couple lines of code into '''VBUDoorsCellRenderer.java''' file. |
|||
''public VBUDoorsType[] doorType = new VBUDoorstType[5 '''this needs to be increased by 1'''];'' |
|||
public VBUDoorsCellRenderer(Cell cell) { |
|||
super(cell); |
|||
//init door data |
|||
doorType[0] = new VBUDoorsType("Door 1", "wla://VBUDoorst/door_right.dae/models/door_right.dae.gz", |
|||
0.045f, new Vector3f(0,-0.5f,0), |
|||
new Quaternion().fromAngleAxis(1.571f, Vector3f.UNIT_X.negate())); |
|||
doorType[1] = new VBUDoorsType("Door 2", "wla://VBUDoorst/door_right_union.dae/models/door_right_union.dae.gz", |
|||
0.045f, new Vector3f(0,-0.5f,0), |
|||
new Quaternion().fromAngleAxis(1.571f, Vector3f.UNIT_X.negate())); |
|||
doorType[2] = new VBUDoorsType("Custom 1", "wla://VBUDoors/custom_right_1.dae/models/custom_right_1.dae.gz", |
|||
0.045f, new Vector3f(0,-0.5f,0), |
|||
new Quaternion().fromAngleAxis(1.571f, Vector3f.UNIT_X.negate())); |
|||
doorType[3] = new VBUDoorsType("Custom 2", "wla://VBUDoors/custom_right_2.dae/models/custom_right_2.dae.gz", |
|||
0.045f, new Vector3f(0,-0.5f,0), |
|||
new Quaternion().fromAngleAxis(1.571f, Vector3f.UNIT_X.negate())); |
|||
doorType[4] = new VBUDoorsType("Custom 3", "wla://VBUDoors/custom_right_3.dae/models/custom_right_3.dae.gz", |
|||
0.045f, new Vector3f(0,-0.5f,0), |
|||
new Quaternion().fromAngleAxis(1.571f, Vector3f.UNIT_X.negate())); |
|||
and the new model needs to be added as |
|||
''doorType[5] = new VBUDoorsType("Custom 4", "wla://VBUDoors/''moduleName.dae''/models/''moduleName''.dae.gz",0.045f, new Vector3f(0,-0.5f,0), new Quaternion().fromAngleAxis(1.571f, Vector3f.UNIT_X.negate())); |
|||
with this we are setting its name to '''Custom 4''' , its place that server will get it to '''wla:VBUDoors//moduleName.dae/models/moduleName.da.gz''' , setting its scale to '''0.045f''' , setting its transformation to '''new Vector3f(0,-0.5f,0)''' and its quaternion to '''new Quaternion().fromAngleAxis(1.571f,Vector3f.UNIT_X.negate())'''. |
|||
====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 [https://sites.google.com/site/openwonderland/tutorials/scripting/ 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== |
==References== |
||
Latest revision as of 23:19, 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
Before adding new doors type into module there one important modification to make. This modification is about editing the axis of the new model. The problem about axes is explained in previous sections. After finishing the modeling phase of a new door, a user need to user Open Wonderland client window to prepare his/her model to use it in a module. The very first thing is, after connection to an Open Wonderland server (after login to a server) user needs to use Inset menu button to insert the prepared model which is a COLLADA file (.dae extension). When model is inserted user needs to save the model as a module. The save as a module option will be seen on the insert model window. After the module is saved, user needs to extract the Art directory from saved module (this is .jar file). When he/she enters the art directory, there will be moduleName.dae directory and in this directory there will be three files which are;
1. moduleName.dae.gz file
2. moduleName.dae.gz.ldr file
3. moduleName.dae.gz.dep file
The only file needed to be modified is moduleName.dae.gz.dep file. It can be opened with any text editor and the following lines need to be set to following values;
<modelBGTranslation>
<x>0.0</x>
<y>0.0</y>
<z>0.0</z>
</modelBGTranslation>
since the default values will be the origin of the model. The reason we are changing these values are we need the models to rotate from the very left or right corner of itself otherwise the model will draw an circle. After making these changes we can add the model into ../art directory of the module.
The next we need to tell the module that we have another door model that can be selected. In order to that we need to add a couple lines of code into VBUDoorsCellRenderer.java file.
public VBUDoorsType[] doorType = new VBUDoorstType[5 this needs to be increased by 1];
public VBUDoorsCellRenderer(Cell cell) {
super(cell);
//init door data
doorType[0] = new VBUDoorsType("Door 1", "wla://VBUDoorst/door_right.dae/models/door_right.dae.gz",
0.045f, new Vector3f(0,-0.5f,0),
new Quaternion().fromAngleAxis(1.571f, Vector3f.UNIT_X.negate()));
doorType[1] = new VBUDoorsType("Door 2", "wla://VBUDoorst/door_right_union.dae/models/door_right_union.dae.gz",
0.045f, new Vector3f(0,-0.5f,0),
new Quaternion().fromAngleAxis(1.571f, Vector3f.UNIT_X.negate()));
doorType[2] = new VBUDoorsType("Custom 1", "wla://VBUDoors/custom_right_1.dae/models/custom_right_1.dae.gz",
0.045f, new Vector3f(0,-0.5f,0),
new Quaternion().fromAngleAxis(1.571f, Vector3f.UNIT_X.negate()));
doorType[3] = new VBUDoorsType("Custom 2", "wla://VBUDoors/custom_right_2.dae/models/custom_right_2.dae.gz",
0.045f, new Vector3f(0,-0.5f,0),
new Quaternion().fromAngleAxis(1.571f, Vector3f.UNIT_X.negate()));
doorType[4] = new VBUDoorsType("Custom 3", "wla://VBUDoors/custom_right_3.dae/models/custom_right_3.dae.gz",
0.045f, new Vector3f(0,-0.5f,0),
new Quaternion().fromAngleAxis(1.571f, Vector3f.UNIT_X.negate()));
and the new model needs to be added as
doorType[5] = new VBUDoorsType("Custom 4", "wla://VBUDoors/moduleName.dae/models/moduleName.dae.gz",0.045f, new Vector3f(0,-0.5f,0), new Quaternion().fromAngleAxis(1.571f, Vector3f.UNIT_X.negate()));
with this we are setting its name to Custom 4 , its place that server will get it to wla:VBUDoors//moduleName.dae/models/moduleName.da.gz , setting its scale to 0.045f , setting its transformation to new Vector3f(0,-0.5f,0) and its quaternion to new Quaternion().fromAngleAxis(1.571f,Vector3f.UNIT_X.negate()).
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