Doors on Buildings (Ekin): Difference between revisions
No edit summary (change visibility) |
|||
| (13 intermediate revisions by the same user not shown) | |||
| Line 23: | Line 23: | ||
*[http://www.netbeans.org/ NetBeans 7.0] |
*[http://www.netbeans.org/ NetBeans 7.0] |
||
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 '''[http://ant.apache.org/ 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 |
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 '''[http://ant.apache.org/ 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 [http://openwonderland.org/download/modules/doc_details/224-link-to-scripting-component-modulejar?cat=add_ons&Itemid=87/ Open Wonderland Module Warehouse] |
|||
====Development Process==== |
====Development Process==== |
||
=====Modeling===== |
|||
To start with, in order to generate 3D model, approximately two hundred photos which explain all of details of Library Tower and The Glenn G. Bartle Library Buildings were taken. And also by using hand cam, some videos were recorded to illustrate more realistic views of buildings. |
|||
Can be found at [http://www.cs.binghamton.edu/~steflik/wiki/index.php/Library_-_Ekin_Burak_Ozturk 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 [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== |
|||
1. [http://openwonderland.org Open Wonderland Page] |
|||
2. [http://code.google.com/p/openwonderland/wiki/OpenWonderland Open Wonderland Documentation] |
|||
3. [http://groups.google.com/group/open-wonderland-scripting?pli=1 Open Wonderland Scripting] |
|||
4. [http://cs.binghamton.edu/~steflik/wiki/index.php/VirtualBU VirtualBU web page] |
|||
By Ekin Burak Ozturk |
|||
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