Home

Java 3D Scene Engine Ashutosh A. Morwal September 2012

image

Contents

1. 7 2 4 Selecting more than one shape for movement Users should be able to select more than one shape using ctrl key to move them or do any changes to them 7 2 5 Creating models Users should be able to create their own 3D models from this application these mod els could be used as in other scene builder projects or in any other 3D application We can give these models a particular datatype and which can be used only using the loader java file which will be provided in future 7 2 6 More complex shapes A choice of wider complex shapes will be given to the users which can help them build their models A complex shape will be made up of more than one shape and will be treated as one BranchGroup in the program so it can be moved easily 7 2 7 Loading of 3d files in other projects Users will be given a loader file which will help them load 3d files in their own pro ject without doing many efforts So all users have to do is run the loader file through their program and may be passing a 3d file as parameter for the loader constructor This can of course be done using GUI References 1 http jmonkeyengine org wiki doku php sdk scene_composer 2 https wiki brown edu confluence download attachments 3735750 3D_ coordinate syste m gif version 1 amp modificationDate 1 195591779000 3 http download java net media java3d javadoc 1 4 0 javax media j3d doc files ViewModel html 4 http en wikipedia org wiki JMonkey
2. following The idea for detaching the live scene graph and making changes to it was taken from one of the forum discussions on java net 8 The PropManager java class used in loading of external models was taken straight from the book Killer Game Programming in java 6 Many bits in basic3DWorld are based on the WrapCheckers3D java class which was provid ed in the 3D assignment during the second semester of the course The basic scene building components such as the building of Canvas3D in _basic3D World as well as the lightScene method and addBackground method were also part of the 3D assignment The move method in Mover class is based on the doMove method which was given in the 3D assignment Signature Date Acknowledgements This project was not possible without the unduly support of my family friends and my supervisor Dr Bruce Graham During the course of the project I used to meet Dr Graham weekly these meetings helped me improve my project in many ways Also my sister Aishwarya and my dad helped me a lot both of them assisted me with the report and suggested valuable improvements Aishwarya as an architecture student also helped me test few bits of my code Pd also like to thank Dr Simon Jones who helped me with choosing this topic as my dissertation and helped me clear any doubts that I was having in the initial stages of the information gathering The folks at java net were very hel
3. this document follow standard UML 2 0 syntax b3dl _basic3DWorld amp wh _3DWorldHandler actionPerformed Ud _basic3DWorld behave Mover tgList ArrayList _createSceneGraph void addSphere void addBoxvoid addCylindervoid addCone void addExt void clear void undo void deleteObject void mouseClicked void move Point3d shape String rotateXMinus void shapeCount Integer addAxes void rotateXPlus void addBox void rotateYMinus void isMovable boolean addSphere void rotateYPlus void setMovable addCone void rotateZMinus void getlD Integer addCylinder void rotateZPlus void getShape String newProject void makeltBig void saveProject void makeltSmall void loadProject void showSource void addLabel showSource void showShapeSrc void showBasic3DWorld void Figure 9 Class diagam 4 1 1 Class descriptions and responsibilities 4 1 1 1 3DFrame This class takes care of the GUI of the whole project right from displaying all buttons on the main frame to the file edit view and help menus this class handles it all This class is also an entry point to the whole program because home screen is shown to the user in this class This class extends JFrame which uses the BorderLayout supplied by java swing this class also makes use of the GraphicEnvironment class to set the JFrame in maximized state So it does not m
4. adding an object in the scene graph 31 4 2 1 4 Sequence diagram for use case 4 editing the added object cc0005 a2 4 2 1 5 Sequence diagram for use case 4 Undo ccccccccccccccssessccceecceceeeeeeeeeeeeees 33 4 2 1 6 Sequence diagram for use case 6 Reset ecccccccccccccscscsccceeseeeceeeeeeeeeeeeeeeees 34 4 2 1 7 Sequence diagram for use case 7 SHOW SOUICE ccccccccssesessecscceeeeeeeeeeees 34 4 2 1 8 Sequence diagram for use case 8 Save project o on 35 5 plemento NoNe senean me ie rr ee err ee ee ev es eee Me re eee 36 Dol GREOORANa POW sete ce eee ne ee eet acetone ne nue acronis ae une 36 32 Tmplemenine 1S COC sierra a E ETENE EET 37 32i Tie MOMS see i eene a E JF 5 2 2 Adding objects in newly created 3D World cccccccccceeccceceeeeeeeeeeeeeeeeeeeees 38 5 2 3 Editing added object into the 3D World ccc ccc ccccccceceeeeeeeeeeeeeeeeeeeeeeeeeeeeeees 40 IA UNIO e O E EE EE 44 DDD VIEW DOU CS epn a SE a a N N 45 List of Figures PAG Ube l oDC oordinate systemi 2 erin E E EE T eau uaxeoousens T EET 2 Picute zaV D scene Trapi eaa E ncseccaneeaace tame avandia 2 Feme IME scene COMMOS EL Inacio 5 sce soaa recat wiiaca ya sue Seavaliodaceuaaeractalvlsaa ya ina seavatoloceunurecqcueielasausmi teas 7 Fig re 4 Screenshot java DE GitOr sporna aa aaa A aR N i 9 Fiereco Seene aaea aea E t basa thasuiaeresamaunasuaueasarens 10 Pucure 6 Usecasedia ra in ovale sacs e R RRN 13 Pee POO NE A error ernert rr
5. o Move and animate added shapes o Add external 3D models into the scene graph o Move and animate the external models o Create new scene graphs so they can be designed from scratch o Save the scene graphs so they can be used and ported to other applications and websites o Load the scene graphs in the application so they can be edited o Give users a function to undo the last change made in the scene graph o A reset button which will reset the scene graph showing only the axes and no other objects Once the users create the scene graphs they can save it in 3d file and they can use the 3d files in games or on websites using applets To load the scene graphs into their game the users will be provided with a loader which can be used with any java3d program this loader will load the custom project files created from the scene engine 1 3 Achievements The required system has been successfully built and the scene engine can do almost all the things it was expected to do For the purposes of saving the projects we create a custom file format 3D which saves the information about all the objects that are present in the scene graph When we load the 3d files all the objects which are present in the 3d file are added to the scene graph as nodes So every object in the 3d file is treated as a node Along with saving and loading the project can do all of the following things effectively e Undo if some unwanted shapes or texture
6. 1 1 2 Use case 2 open saved 3d file Related requirement 1B Description Whenever user runs the program for the first time an option to open previously saved project might be selected user can also open project from the 3D editor window 3 1 1 3 Use case 3 Adding an object into the scene graph Related requirement 2A 2B Description Once the project has been opened in 3D editor window users may add a 3D object into the scene graph This 3D object can be a primitive shape with an image texture or a 3D model 3 1 1 4 Use case 4 Making changes to the added object Related requirement 3A 3B 3C Description After adding the 3D objects in the 3D editor users may choose to change the characteristics of the object Users can also make changes to the objects which are already present in the scene graph 3 1 1 5 Use case 5 Undo Related requirement 4 Description If user makes some change to an object and the change is not desira ble user can undo that change 3 1 1 6 Use case 6 Reset Related requirement 5 Description Sometimes users may not be happy with whatever they have created in that case users may choose to reset the scene graph 3 1 1 7 Use case 7 Show source Related requirement 6 Description If a user wants to check the source of the current scene graph they can check it using the menu button show source 3 1 1 8 Use case 8 Save project Related requirement 7 Description
7. Scene Builder has implemented all the features that were specified in the requirements the application was tested with few potential users of the system the ap plication was well received with all the users of the system many of the users found the software very interesting and even though initially it was hard to get hold of once users start building scene graphs and manipulating the objects around it was easy to use Many users liked the fact that the application was reliable fast and the scene graph generated is portable and can be used in not only different platforms but also on applets which can be integrated with the browser To use the application very little training is required once users learn the structure of the 3D environment and are used to the 3D world it is very efficient to operate One of the testers for the application was an architect student who felt this application 1s very helpful for architects and with some improvements it can be used for designing purposes by architect students Based on this feedback it was conceded that the Java3D Scene Builder has achieved its primary objectives In the section below the critical evaluation of the software will be made discussing both the strong and weak aspects of the application 7 1 1 GUI GUI of this application could be improved in many ways the GUI uses default JButtons and menus given by java due to the limitations of time they were not changed
8. carried out during the development of the core system The application was tested and improved until the expected result was achieved The important factor in the white box testing was the data flow carried out between the files and the scene graph If the data is not correct then the objects loaded into the scene graph will not be proper and as per the user expectations The data was checked either by printing it on the console or by setting breakpoints and checking the values between different variables taking help of eclipse debug utility This approach was really helpful when the development of selecting an object for movement using mouse was in progress The problem as mentioned in the implementa tion was the picking utility was only detecting the type of shape that was clicked so in order to identify particular shape we had to set userData to it 6 2 Functionality testing After completion of the system the application was given many different and extra ordinary inputs to see how system behaves In one of the testing many shapes and external models were added into the scene graph until the system crashed when the system crashed after overloading of objects JVM gave OutOfMemoryException This is still acceptable as the number of objects that were added in the scene graph were far good greater than practical use of the applica tion 6 2 1 User testing The application was given to users to test they were also given a questionnair
9. dialog box where the name of the new project can be entered When the new project 1s successfully opened the String attribute in 3DWorldHandler called opened stores the name of the new project This attribute is useful in saving of a project because program knows which file to save opened is also used in creating source for the current project a 30 wontd SSS SO mes file edit view Sphere Cylinder Figure 28 Screenshot showing a newly opened project This is how the newly loaded project looks like Z axis is shown in red and axes X and Y are shown in white The axes are nothing but java 3D primitive boxes with a very tiny X Y or Z length The axes or any shape for that matter are added to the scene graph from 3DWorldHandler class 5 2 2 Adding objects in newly created 3D world X Enter coordinates for your component X Coordinate 1 Y Coordinate 4 Z Coordinate 1 X length i Y length Z length lt lt Browse for textures here gt gt OR wo o _ Draw outline Figure 29 Screenshot dialogBox to add a box into scene graph Imagine a scenario where user wants to add a shape onto the scene graph user clicks on box JButton after that 3DWorldHandler will show dialog Box to the user which is achieved using the dialogBox method The data retrieved from the dialog box is sent to _basic3 D World where java3D box is
10. dialog box by 3DWorldHandler class depending upon the shape 3DWorldhandler then calls addShape method from _basic3D World passing the parameters accepted from the user 4 2 1 4 Sequence diagram for use case 4 editing the added object _basic3DWorld 1 editShape 1 2 setMovable true 2 doMove 3 rotate 4 changeScale Figure 21 Sequence diagram 4 Users can select any of the visible objects present in the scene graph and make changes to these objects Whenever user selects any object using mouse following events will take place We check if the object user has clicked on is an external object or java3D primi tive shape using Picking classes supplied by java3D Ifit s a primitive java3D shape then by checking the IDs set to each shape we identify which shape has been clicked and we set the movable property of that shape as true After the shape which is to be moved has been identified we wait for users to change the attributes of the shape as it can be seen from the sequence diagram above users can move shape users can rotate the shape they can change the size of the shape and they can delete the shapes In this version of scene builder we are only going to implement these features considering the limited time we have Other features such as adding animations and changing geometry will be added in the future To see the key associations with every method in this sequence dia
11. in progress and it has few bugs in it The aim behind java3D scene builder was to design user friendly GUI experience similar to MonkeyEngine which will help users build portable scene graphs in java3D API supplied by sun One of the disadvantages of JME is non programmers cannot use it because the users of this software need to know how to code in java and how any java program works The Java3D scene builder can be used both by programmers non programmers as well as the users who want to learn java3d API by sun Programmers and java3D users can see the code which will be modified with every little change that is being made on the scene graph The non programmers can choose to hide the code if they want to All the users of the software will be shown the live scene graph that is being operated so the users will be well aware of the things going on with their 3D world P wl J E D Se lt default conf W t a os Oe Search 34 Projects OO Files Services S SceneComposer Scenes MyScenej3o New Scene Properties d Q MatDefs a Spatial us a Materials G z ertexes b las Models riangles Wo Scenes orid Translation Y town a orid Totation gt a CasaRosa jpg E Yellowhouse jpg orld Scale Local Translation 0 0 0 0 0 0 Local Rotation 0 0 0 0 0 0 1 0 ocal Scale 1 0 1 0 1 0 World Bound in perty gt g casaamarela jpg gt E ciel
12. mul toMove So in the end all we do is set the currently altered Transform3D object t3d to the ob jectTG TransformGroup which changes the location of the object objectTG setTransform t3d 5 2 4 Undo The undo method is defined in _basic3D World class where it retrieves the previous scene graph from the stack maintained by _basic3D World as mentioned earlier every time some object is added to the scene graph the stack contents are also updated To see the undo operation in action look at the figure below it has 4 different shapes added to the scene graph they all will be removed using the undo operation Figure 34 Undo it is all there Now the undo method will be called twice and the two shapes which were added lat est will be removed Figure 35 After calling undo for first time You can see in this image the green sphere which was added has been deleted Upon pressing undo again the next shape which was added will be removed Figure 36 Undo the state of scene graph after performing undo twice 5 2 5 View Source When the requirements of the software specified the idea was to design software which helps user learn how java3D works even though this feature was only intended for programmers it can be used by non programmers to see how the shapes are actual ly added to the scene graph by java3d and what parameters are passed to the methods in _basic3D World Now for the sake of thi
13. please describe shortly Yes No 6 The application allows you to see the source code of the changes you have made to the scene graph was it helpful to you Is the code provided informative enough Yes No 7 How would you rate the GUI Bad 0 1 2 3 4 taf Excellent 8 how would you rate the responsiveness of the applications Bad 0 1 2 3 4 s Excellent 8 Would you recommend this software to anyone if No Yes 9 Any comments Thats gree i ve Your Name Signature f J it zKov 10 Appendix C User Manual 10 1 Installation guide Make sure your computer has java3D and all the classpath have been set Run the 3DSceneBuilder jar file to run the application 10 2 User Manual Java3D Scene Builder is used to create 3D scene graphs which can be used across vari ous platforms and can be used in a browser in the form of applets as well 10 2 1 Adding objects Whenever you will click one of the buttons to add a shape onto the scene graph you will be shown a dialog box which will look something like this Enter coordinates for your component x X Coordinate x Y Coordinate 1 Z Coordinate X length _ Y length Z length lt lt Browse for textures here gt gt OR black v _ Draw outline Figure 45 User Manual dialog box You will have to fill every field that is present in the dialog box with either a float or a number once
14. textures to any shape users have to create their own appearance objects and point them to texture which are linked to physical image on media To save a project in java3d users have to create different java files for which many components of the code may be changed 2 2 Existing systems 2 2 1 jMonkeyEngine jMonekyEngine is a game engine designed in java which uses LWJGL Lightweight Java Game Library as a default renderer It is an open source project designed by the JME Core team First released in 2004 JME team has released three versions since then the latest version j MonekyEngine 3 0 was released in 2011 The jMonkeyEngine has its own 3D APIs known as j MonkeyEngine 3D Scene Graph API so the bottom line here is MonkeyEngine does not use java3D 4 Java3D API has some advantage over MonkeyEngine 3D API like java3D is compatible with OpenGL as well as Direct3D jMonekyEngine is compatible only with OpenGL Threading model of java3D API is much more sophisticated than the JME 3D API 5 iMonkeyEngine SDK SceneComposer One of the component in jMonkeyEngine lets users create a 3D world create a land generate terrains etc This component has many predefined 3D world scenes like a soccer ground garden race track etc which users can use and edit so that they can use these scenes for their game Users can also create their own scenes which can be saved Even though SceneComposer lets you create scenes in 3d it is a work
15. the object can be brought closer to the user in Z axes z positive or away from the user z negative The keys which are used to achieve this are explained be low Right X positive Left X negative Up Y positive Down Y negative Ctrl Z positive closer to user s viewpoint Shift Z negative away from the user Rotate the object The object can be rotated around all the three axes in both the directions so it gives user to turn their object any way they want Figure 15 Rotaion around all three axes The key bindings for rotation are as follows Number pad Key 7 Positive rotation around X axis Number pad Key 8 Negative rotation around X axis Number pad Key 4 Positive rotation around Y axis Number pad Key 5 Negative rotation around Y axis Number pad Key 1 Positive rotation around Z axis Number pad Key 2 Negative rotation around Z axis Scaling object Apart from the regular movement and rotation of the object this class also implements method to scale the object it can either make it small or big users can press key Q to make it big or W to make it small Deleting an object Users can delete any object in the scene graph which is visible in the scene graph by selecting it using mouse and then pressing D key 4 1 1 5 _tg As mentioned in the previous sections tg extends TransformGroup class of java3D every _ tg object has a transform and a 3D object associated with it The 3D
16. the show source menu button shows a JFrame window to the user containing the code generated from the changes made to the 3D editor Pre condition A valid project must be loaded in 3D editor 8 Save current project Related requirement 7 Description Users should be allowed to save every project in the physical media so that the projects can be used later on Main flow When user presses the save button this use case is activated and the scene graph will be saved in the default projects directory Pre condition A valid project must be loaded in 3D editor 9 Appendix B User Questionnaire User Questionnaire Java3D Scene Builder 1 Is the GUI user friendly Yes i No lf no where the improvements could be made Leave comment below 2 When you add objects onto the screen do they appear exactly where you want Did you have to change the location of the object after adding Yes we 3 The ae default textured were they enough Yes J No lf no what other texture should be added Leave comment below 4 Any object added to the scene graph can be edited it can be moved rotated and scaled was it enough Yes r all 5 Did you come across any crashes while using the system If so please describe shortly Yes nT a 6 The application allows you to see the source code of the changes you have made to the scene graph was it helpful to you Is the code provided informative enough Yes
17. Creator is called This method cre ates source depending on the current contents of the scene graph which are rendered on the screen So whenever user adds a shape onto the 3DFrame and click on the view source button the change which was made by latest added shape can be seen 4 2 1 8 Sequence diagram for use case 8 Save project sd save project 3df _3DFrame wh _3DWorldHandler 4 save i Figure 25 Sequence diagram 8 Whenever user selects save from the menu the 3DFrame will call saveProject method from _3DWorldHandler which will scan the whole tgList and put data into already created 3d file 5 Implementation This chapter is about how the implementation of each component has been carried out and how every class contributes to the working of the software as a whole Many screenshots have been included in this chapter which explain more about the working of every component 5 1 Program flow To start with the figure below shows the different states the application will be in and how the different activities in the system will be carried out Homescreen browse 3D Editor show new show opened 3D scene graph 3D scene graph save Figure 26 Program Flow The important states of the software are shown in rectangular shapes the transitions are shown with arrows The following are the states in which software will be when it is up and running e Home screen In thi
18. Figure 41 Out of proportion models The models are just been added without moving them and you can see that they are not in proportion It can also be seen that the texture of the car is not accurate So in order to make the 3d models in proportion with each other we had to perform transformations to the TransformGroup to which the 3d models were added The next screenshot shows us the same models again both the models are scaled and rotated so that they look in proportion with each other Figure 42 Models processed in order to make them proportionate DpRRE Eee D EEE EDEL Eee eee eee eee ee eee eee eee eee eee eee eet eee eee eee eee eee eee eee eee eee eee eee eee eee eee eee eee eee eee eee e eee eee ee ee eee eet eee et eee eee ee eee eee eee eee e eee eee eee eee eet eee eee eee Pee eee eee eee eee eee eee eee Peete eee eee eee eee eee eee eee eee eee eee eee eee eee eee eee eee eee eee Peete eee eee eee Leet eee eee eee eee eee eet e eee eee eee eee eee etre ee eee e rete eee ee tee eee eee ee eee eeteet eee The screenshot below shows the 3D world which was constructed during the testing of the application it contains many 3D models of vehicles and trees the buildings which are seen in the screenshot are the boxes added with textures Figure 43 Screenshot 3D world with external models Every model that you see in the screenshot had to be processed before loading into the scene graph the application will give uses a list of 3
19. Java 3D Scene Engine Ashutosh A Morwal September 2012 Dissertation submitted in partial fulfilment for the degree of Master of Science in Advanced Computing Computing Science and Mathematics University of Stirling Abstract Developing user friendly graphical user interface GUI which will avail developers to create portable scene graphs which can be used in java3D applications or in applets on websites Users should be able to Put primitive shapes given by java3D as well as external models supplied by third parties in to their scene graphs After adding the objects users should be able to move using interactions or animate objects Adding textures objects Delete added objects Save Load scene graphs The method that was adopted for the development of this application was spiral development model throughout the development of the software the source code was revised many times and modified for the improvement the core design of the software was also changed to make the application sub stantially faster than it was at the early stages So far the application performs up to the expectations and requirements which were specified at the beginning Most of the requirements specified have been fulfilled Attestation I understand the nature of plagiarism and I am aware of the University s policy on this I certify that this dissertation reports original work by me during my University project except for the
20. Kote 7 How would you rate the GUI Bad 0 1 2 3 4 5 Excellent 8 how would you rate the responsiveness of the applications Bad 0 i 2 3 4 5 Excellent 8 Would you recommend this software to anyone Yes 7 No 9 Any comments U could use jttle mprovemen Your Name Yosh by Le Signature Jh User Questionnaire Java3D Scene Builder 1 Is the GUI user friendly Yes u No If no where the improvements could be made Leave comment below 2 When you add objects onto the screen do they appear exactly where you want Did you have to change the location of the object after adding Yes Ti No 3 The program provides default textured were they enough Yes No A lf no what other texture should be added Leave comment below 4 Any object added to the scene graph can be edited it can be moved rotated and scaled was it enough Yes No 5 Did you come across any va while using the system If so please describe shortly Yes No 6 The application allows you to see the source code of the changes you have made to the scene graph was it helpful to you Is the code provided informative enough Yes Y No 7 How would you rate the GUI Bad 0 1 2 3 T 5 Excellent 8 how would you rate the responsiveness of the applications Bad 0 1 2 3 4 3 Excellent 8 Would you recommend this software to anyone Yes No 9 Any comments vouvone H mipenty Wor so lai User Questionna
21. Users should be allowed to save every project in the physical media so that the projects can be used later on 3 2 Software prototyping Prototyping of modern software is a practise followed by many standard organizations to get a valuable feedback from the potential users of the software early in the project in the early prototyping stage of software engineering only very few aspects of the systems are considered Sometimes the prototypes of the software are made on the paper just to analyse how the system will look like after being developed This kind of prototype is useful when GUI based software has to be developed Now in software prototyping we will be talking about two different types of prototypes for this application let us have a look at them one by one 3 1 2 GUI Prototyping When it comes to prototyping of software we have different methods we first will start with the GUI prototyping where we will talk about the two GUI designs which were considered during the beginning stages of the project 3 1 2 1 GUI Prototype I In this GUI model we have a separate window JFrame for every feature that we have in the scene engine primitive shapes 3D Editor IDE External Models Figure 7 Prototype I The options to create a new file load existing file or exit is in the 3D Editor window users can use JButtons in the primitive shapes window to add shapes onto the scene graph same with external models The live sce
22. _ Engine 5 http jmonkeyengine org groups development discussion jme2 forum topic java3d vs jme 6 http fivedots coe psu ac th ad jg ch9 index html 7 http cs gmu edu eclab projects mason ncsaporttolio portfolioLicense txt 8 http www java net node 647308 8 Appendix A Use case description 1 New Project Related requirement 1A Description Whenever user runs the program for the first time an option to create a new project might be selected user can create a new project even from the 3D editor window Post condition The user should enter valid name for the new 3d file Main flow This use case begins when user selects an option to create a new 3D project User enters the name of the project system checks if the project of similar name is present if it is present the user is asked to change the name of the project Exceptional flow The 3D file name entered by the user should be a valid name it should not contain any special symbols other than _ The 3d file of the same name should not be pre sent in the current directory 2 Open project Related requirement 1B Description Whenever user runs the program for the first time an option to open previously saved project might be selected user can also open project from the 3D editor window Main flow this user case begins when user want to open saved projects and clicks on open button either from the home screen or from the menu option So from he
23. _nuages 512x512 jpq gt E estrada cruz jpg E estrada jpg gt eh grass jpg Cull Hint Dynamic a gt level meshxml karit lt erthesutters Mm 4 ocal Cull Hint E b main materia Pratesulters re Shadow Mode Off s b y main scene Frameguffers S 2 a M tevtures M 23 ocal Shadow Mode s mg EUME F i Navigator SceneExplorer W OO CNTRE World Light List r F Shadtns MMi F rs S update z New Scene Ts New Scene gt d Scenes town main scene_node 9 DirectionalLight SceneComposer Window 8a Tasks p cursor S cursor E selection grid I zero selection Sa cursor Palette New Scene Tools New Scene Node Mesh create tangent binormals JA Names Miysicene 30 Particle Emitter Spee SI EEE fraa sah Ehara i as Physics create update mesh shape Size O KB Audio Node iis z Picture Point Light Directional Light paca d np se _ Figure 3 JME scene composer in action This is a screen shot taken from j MonkeyEngine scene composer it shows one of the default saved scenes created in JME Even though it looks impressive to load a scene in JME takes a lot of efforts and for beginners and non programmers it is not at all easy to use Just to create a simple town scene that you see in the screenshot above the users have to go through several steps the users are shown as you see a list of all the projects in the right hand column they first have to go to their desired scene This is
24. aph is main tained by tgList in _basic3D World class So in order to retrieve that information _3DWorldHandler class has a method addLabelsFromTG which retrieve every _ tg from the tgList and creates a label and adds a JButton onto the JButton list in SourceCreator addLabelsFromTG method is called every time the viewSource but ton is pressed So the method calls which are shown to the user are always updated As referred earlier when any of these JButtons are pressed users are shown the meth od definition of that call These methods are different from what is actually used in the program The components of the method which are used for working of scene builder are removed and many comments are used for better readability L source Le lela ja public void addBox float xCoor float yCoor float zCoor float xlen float ylen float zlen String color Boolean drawOutline Appearance app if a texture for shape has been selected then load that texture to the appearance if _3DWorldHandler textured true TextureLoader earthTex new TextureLoader _3DWorldHandler f getPath this app new Appearance app setTexture earthTex getTexture else load the solid color else Material mat setMaterial color mat setLightingEnable true app new Appearance app setMaterial mat call the java3D method to create a box Box cc new Box xlen ylen zlen Box GENERATE_NORMALS Bo
25. aphs which are attached to locale so effectively they are attaching an object to the locale One of the special characteristic of the BranchGroup is all its children nodes will acquire that behavior added to it Suppose there is a branch group having four sub graphs a box a sphere a cone and a cylinder and if we add the rotation behavior to the topmost branch group of these nodes then all the four shapes will start rotating This characteristic of java3D is very useful when defining complex animations such as movement of arm in human body or turning of a car Imagine a car has been added to the scene graph controlling a car when user presses a key to turn left the whole car should move not just the tyres of the car hence in this case the turning behavior will be added to the node containing all the branch groups of car 1 2 Scope and Objectives The idea was to design a user friendly Graphical User Interface GUI which will help programmers as well as non programmers in designing scene graphs in java3D world This will not only be used in rapid development of 3D applications but will also help programmers who want to learn java3D To provide the learning functionality this application has provision to show users the code generated from the application highlighting the changes made with every step they take while using the application All the requirements in brief are discussed below o Add primitive shapes into the scene graph
26. atter on what system the application runs it will always be in the full screen Some of the main responsibilities of this class are as follows l Generating GUI for the user 2 Showing home screen to the user 3 Listen to all the user inputs on buttons and menu items Ld _3DFrame b3dk_basicsDWorld wh 3DWorldHandler actionPerformed Figure 10 Use case diagram _3DFrame class is associated with _basic3D World which represents the whole 3D world shown this is then added to _3DFrame 3DFrame extends JFrame Anoth er association in this class in _3DWorldHandler this is mostly used in the actionPerformed method all the calls made by user interactions such as add box add sphere etc are first gone to 3DWorldHandler which in turn calls method from _basic3D World This class contains only a couple of methods and a constructor one of the method is GUIBuilder which does all the work of building the GUI which includes add ing buttons setting their size as well as their location adding ActionListeners to them All these buttons are later on added to a panel and that panel is then added to the JFrame using BorderLayout Another important method of this class actionPerformed which has been de fined because of the interface which we have implemented This method listens to the user interactions not only the buttons but also the menu items An appropriate method from 3DWorldHandler or _basic3 D World is calle
27. ava To kenizer class Depending on what type of node is stored which is indicated by the leftmost column in the file we load data in our scene graph Again the loading logic varies depending upon the shape or object that has been de tected at first token 6 Testing The core architecture of the system was first prepared and implemented it was tested rigorously and then the other components of the system were added to it In order to ensure the bug free execution of the software testing was carried out Through the whole of the project unit testing approach was followed where code was separated from the main program and was tested thoroughly when all the bugs were removed from the separated code it was integrated in the main program The functional testing of the program was carried out after the building of the system as well as during the implementation of the system The application was tested both on windows as well as linux environments the win dows platforms used for the testing were windows XP amp windows 7 and the linux platform used for testing was Ubuntu distributions by Cannonical Throughout the development of the system as well as after the development was fin ished the testing was carried out During the development phases white box testing was mostly used to check if the core system is giving the desired results it is discussed be low 6 1 White box testing The white box testing of the system was
28. ave to clear anything that is currently in the scene graph User is just an actor in this case whenever user interacts with the system newProject method in 3DFrame will be called which clears everything in the scene graph and then newProject method from _3DWorldHandler is called which takes care of taking the file name from the user and creating a new file 4 2 1 2 Sequence diagram for use case 2 loading projects sd openProject 3df _3DFrame wh _3DWorldHandler _basic3DWorld 1 loadProject Figure 19 Sequence diagram 2 Just like in the previous sequence diagram we are calling clear method from _basic3D World class to clear any previous projects that were in the memory Then we show user a JFileChooser where users can select the file they want and then that file name is passed to loadProject method in _3dWorldHandler class which opens the file specified by the user and adds appropriate shape in the scene graph It is to be noted that we do not have any method named addShape in the _basic3D World but we have methods such as addBox addSphere etc we have used addShape in the sequence diagram for the sake of simplicity 4 2 1 3 Sequence diagram for use case 3 adding an object in the scene graph sd addObject 3df _3DFrame wh _3DWorldHandler _basic3DWorld Figure 20 Sequence diagram 3 This use case is straightforward user presses a button to add a shape onto the scene graph Then user is shown a
29. ble to add primitive java shapes as well as third party 3D models into the scene graph e 3B If user chooses 3D objects then there should be a provision to add image textures to the primitive shapes 4 Users should be allowed to make changes to the added objects e 4A In order to make changes to a particular shape in the scene graph the users should be able to select that shape using mouse Java3D has picking libraries which can be used for this purpose We will need to identify which object was clicked e 4B User should be able to move the added objects be it external models or primitive shapes in the scene graph e 4C User should be able to rotate the objects 5 User should be able to revert the latest change they made on the scene graph using undo button this can be easily achieved using the java library java util Stack in this particular case we will save the root scene graph object onto the stack so whatever changes user makes they all will be reflected after doing the undo operation If user loads some project into the scene graph they should be able to remove every object that has been added in the scene graph using undo 6 Reset function to reset the scene graph to which will show default axes Reset can be used to remove all the objects that have been added to the system 7 As stated in the introduction section of this paper this software is mainly useful to student programmers who want to learn ja
30. but instead of using text onto buttons images could have been used which might have helped users improve the user experience of the software Many users also complained that help provided in the form of tooltips and dialog boxes is not enough the application can be improved in this segment GUI is responsive and an action such as deleting of an object or adding of an object movement of objects is done fairly quickly 7 1 2 Objects Once a shape has been added you can move it rotate it and scale it but the color of the shape cannot be changed also users cannot add textures or change textures of the added shape User can add external 3ds models onto scene graph but once added they cannot make any changed to it this is simply because using picking it was not possible to identify dif ferent external 3ds objects One user suggested that the objects added to the scene graph could be moved around us ing mouse instead of using the arrow keys this kind of approach is very fast while interacting with 3d objects in the scene graph 7 1 3 3D Editor One of the good feature of the 3D Editor is users can move around the editor using mouse they can also zoom in and zoom out into the 3D world it helps users to observe where the shapes have been added and they can change it if they want The responsiveness of the application is very good and the shapes are added to the sce ne graph in no time without any lag More guidelines are ne
31. created according to the user spec ification and it is placed onto the user specified location According to the user data that has been received the Booleans in the _3DWorldHandler will be set if the user has selected any image for textures tex tured will be set to true If the user wants to draw an outline for the added object then drawOutline Boolean will be set to true If the user has not selected any textures then the color selected by the user will be applied to the shape Users can also see how each object has been constructed what other shapes have been used to create that object to accomplish that for a particular shape users can choose to draw an outline for an object while adding the object onto scene graph The figure below shows a box with its outline and the same object without its outline file edit view Box Sphere Cylinder Cone Extern f Si Reset undo Figure 30 A box with and without an outline Now if user has selected a texture for an object the scene builder will load that image and put it around the object as a texture In screenshot below you can see a box has been added with dimension 1x 4y 1z with a texture and without a texture file edit view Box AMAIR a sh lly Sphere i M t Cylinder i d i Cone ra t iii E H Extern l i il i fl i i i li TT T fi i ie ae i a a vee T il
32. cts added by the users will be below these nodes and these objects will be affected by both light and the background of the 3D world The information about the background and lights in the scene graph is stored in the locale node which is explained in the introduction an Virtual universe Hi res locale Physical Physical Body Environment Figure 5 Scene graph So to sum up what the system is expected to build is the circled part in the above scene graph Along with this the information of the directional light in the scene graph will also be saved in the 3d file 2 When user starts the system they will be shown a home screen which will have three options new open exit here users can choose to create a completely new project from the scratch e 2A when users will click on new button they should see a black screen with X Y and Z coordinate and a grid which will show the users how much is 1 unit e 2B Users should also be able to open previously saved projects from the projects directory once opened users should be able to make changes to the objects presents in these projects If users open an undesirable project by mistake they should be given a chance to load project which they want to load for this the software should have an open button which will show all the projects that are currently present in the projects directory 3 Adding an object into the scene graph e 3A The users of the system should be a
33. d in file contains the coordinates of the object the size of the object the location of the tex tures if any are applied the colour of the object if textures are not specified and whether or not the object should be outlined How the file is saved will be discussed in the next chapter which is the implementation of the system 4 1 1 4 Mover This class is used by all the _tg class objects throughout the application it extends abstract class Behavior of java 3D API and has to implement the methods processStimulus and initialization The behavior provides a foundation for adding user defined actions on the scene graph objects in the Mover class we have added following behaviours used by every object added into the scene graph move Point3d rotateXMinus void rotateXPlus void rotate Minus void rotateYPlus void rotate Minus void rotate Plus void makeltBig void makeltSmall void Figure 14 Class Diagram 4 Move the object Now as I have stated earlier any object which is visible in the scene graph can be moved just by clicking onto it and using the arrow keys Pro cessKeyEvent method calculates in what direction the object will be moving and this calculated value is passed to move method which does the actual movement of an object on the scene graph using Transform3D One thing to understand here is the object can be moved in six different directions along with regular up down left and right
34. d when one of the user events takes place 4 1 1 2 _basic3DWorld First used in 3DFrame this class is the backbone of the whole project the main activity has to perform is rendering the whole scene graph onto the _3DFrame basic3D World manages all the scene graphs which are being added by the user from 3DFrame public class _basic 3DWorld extends JPanel implements MouseListener So as it can be seen this class extends JPanel and implements MouseListener all the 3D world is rendered onto the JPanel so what 3DFrame shows to the user is this JPanel This class also handles the stack which contains all the changes made by the user and it is used by the undo function to retrieve data and show it onto the screen The main responsibilities of this class are as follows l Create scene graph for user interactions 2 Provide methods to add shapes and external models onto scene graph all these objects are added by modifying the live scene graph 3 Providing methods to undo and clear current scene graph 4 Listen to user mouse inputs for selecting a particular object from the scene graph 5 Deleting an object from the scene graph Ld _basic3DWorld behave Mover tgListArrayList createSceneGraph void addSphere void addBoxvoid addCylindervoid addCone void addExtvoid clearvoid undo void deleteObject void mouseClicked void Figure 11 Class diagam 2 The important attributes used b
35. de behind it at the same time Suppose if user adds a box into the scene graph and user wants to see what change has been made into the code for that they can see it by clicking select view source option from the menu Whenever an object will be added into the scene graph it will be added into the 3D coordinate system every point in 3D coordinate system has three parameters associated with it Suppose there is a point say x 1 2 3 The first number represents the location of the object along the X axis the second number represents location of the object along Y axis and the third number represents location of the object along Z axis These numbers represent where the point will be placed in 3D coordinate system The numbers are generally called as X coordinate Y coordinate and Z coordinate Figure 1 3D Coordinate system 2 Every object which will be added in the scene graph will have these coordinate locations Whenever user chooses to add something in the scene graph user will be asked for these coordinates If the coordinates entered by the user are out of the bounds of the rendering area the user will be notified 1 1 Background and Context Java3D scene engine as the name suggests uses java3D application programming interface developed by Sun The objects that will be added in java3D are systematized in a parent child relationship tree structure which is contained in the java3D scene graph which consists of no
36. des and these nodes are made up of java3D objects Virtual universe Hi res locale IC Physical Physical Body Environment Figure 2 java3D scene graph 3 The figure above depicts how a scene graph with one shape and behavior looks like to begin with every java3D scene graph has two main groups of nodes branching from the locale node A java3D application can contain one or more VirtualUniverse objects these VirtualUniverse objects provide grounding for other scene graphs because in order to be visible in the scene graph objects need to be added to this object The node which is immediately attached to the VirtualUniverse is locale it defines the origin and coordinates for the branch graphs which are attached to it The next big thing after locale node is the BranchGraph node it is single most important node in any scene graph It acts as a root for sub graph which is also known as branch graph The prime reasons why BranchGraph is so important is because only this node can be attached to the locale If user wants to delete any shape from the scene graph then the shape cannot be directly removed from the scene graph the BranchGraph to which the shape has been attached needs to be removed in order to remove the shape As described earlier in order to make anything visible it needs to be added to locale the programmer does not necessarily have to attach it to locale every time they can also attach an object to branch gr
37. ds models which they can add to the scene graph whenever user selects any 3ds model it will first be adjusted and then will get added to the scene graph 5 2 7 Saving and loading a scene graph in 3d file As mentioned in previous chapter the scene graphs are saved in a 3d file format which is internally a text file storing data about the nodes attached to the scene graph The 3d file stores details about the light in the scene graph the location of objects in the scene graph and their coordinates their dimensions and any textures attached to them light 1 0 1 0 1 0 box 1 4 1 0 1 0 0 5 0 5 0 5 red false notext Sphere 1 0 1 0 1 0 0 5 red true notext box 1 0 1 0 1 0 0 5 0 5 0 5 red true notext cylinder 1 0 1 0 1 0 0 5 0 5 red true H j3DEngine addExt textures blue_jeans jpg ext 1 0 1 0 1 0 taxi 3ds Figure 44 3d file example A 3d file with a couple of boxes a sphere a cylinder and an external model looks like this The leftmost column represents the type of object that was added in the scene graph this part will determine what type of data about the object will be stored If it s a sphere we are storing in file we will save its location radius color of the sphere or its texture location etc If a sphere is not textured then notext will be stored in file which is used as an indicator while doing the loading operation While loading we read the whole line from the file and tokenize it using the j
38. e 12 showing pick ray and functioning of Picking If there are more objects behind the currently visible object then the object which 1s visible is picked Users of this application can use mouse to control the viewing po sition of the user and selects the objects which were hidden if they want to 4 1 1 3 _3DWorldHandler All the calls to add any primitive shape onto the scene graph are carried out through this class the main responsibilities of this class are l Taking the input from the user describing the characteristics of the shape by showing a dialog box 2 Manage the GUI responsible for showing the dialog box JTextFields Com boBoxes etc which are shown onto the dialog boxes 3 This class also handles the file handling part of the whole application this class has methods to create a new project open saved project these methods are called from 3DFrame 4 This class adds axes onto the scene graph 5 It converts the current tgList to the labels which are used by SourceCreator class 6 3DWorldHandler is associated with SourceCreator class and calls method from SourceCreator such as addLabel and showSource Lo _3DWorldHandler srcSourceCreator addAxes void addBoxvoid addSpherevoid addConevoid addCylinder void newProject void saveProject void loadProject void showSource void Figure 13 Class diagam 3 Now that we are aware of the activities this class will car
39. e which was used to evaluate the software see appendix 2 for the questionnaire While review ing the questionnaires following issues were brought up by the users Tf the value of the coordinate supplied to an object is more than 10 some times the object is not visible This clearly means that user has added an object and the object is outside bounds of the application To resolve this issue the position of the object en tered by the user can be checked if the position is outside the bounds of the scene graph users should be given some kind of warning One of the user said that when a scene graph is moved to look around using mouse but this movement is little too fast to handle Apparently the system on which the user tested this application had its mouse motion set to very fast which resulted in this issue other users did not find any problem with the mouse Many users complained that when pressing addBox button the dialog box which is shown contains too much information it is not easy to figure out what to put in the fields on the dialog box This can be solved by showing tool tips to the users which will direct them on how to use the software user can be shown a tooltip box as well which will help them on what values to input into the fields in the dialog User can also be shown an example of where the shapes are added on giving different inputs 7 Conclusion 7 1 Summary and Evaluation The Java3D
40. eded to use the 3D editor such as position markers which will help user figure out the location where they have to add the 3D object There should be a provision for users to change the viewing position or the viewing camera either by using keyboard or mouse or by manually entering values to change 7 2 Future work Several extra features could be added to the application to make it more complete we will be discussing the features which can help improve the user experience of the soft ware and also some of functionalities which could make the software usable for more serious things such as creating 3D worlds for games in java 7 2 1 Animation The application only allows movement of objects through user interactions the ability to animate objects has not been added This could be added in future which will help us ers make their scene graph more intuitive Users should be able to add animations to make the objects bigger or smaller or users should be able to rotate the object 7 2 2 Changing background Users should be given an option to change the background of the application not just the colour of the background but also users should be able to add their custom back ground image to the scene graph 7 2 3 Change texture or colour on the go Once the users add an object they cannot change the colour or the texture of the added object this functionality could be added which will improve the usability of the appli cation
41. es Creatine 30 TES a N 13 3 1 1 2 Use case 2 open saved 3d file Related requirement 1B ccccccccccceeeeees 14 3 1 1 3 Use case 3 Adding an object into the scene graph cc cececccccccceeeeeeeees 14 3 1 1 4 Use case 4 Making changes to the added object cc cccccccccceceeeeeeeeees 14 Selle Uee E U ensa E 14 Ido VISE CASC70 REE en a E E aE E EENE 14 3 1 1 7 Use case 7 Show source Related requirement ccccccccccccccccccccccccecceeeeeeeeees 14 3 1 1 8 Use case 8 Save project Related requirement o on 14 Ja SOL Wale DLOlOLY DIINO seis fel cdaurts veaceaway E eee 15 SEx pected BENIVE eee ee eee eee Nee eee nee 18 4 SV Stem eS Om Descriptio serea a E E 19 Ast Static Desio MiOdel sssncs2ssinice senceacereeeesente ee ese E 19 4 1 1 Class descriptions and responsibilities ccccescceceeeceeeeeceeeeeeeeeeeeeeeeeeeees 20 EEE SOOME Srlaaretateansent as EO ES 20 A ede DALEI DONIA nE E E EEA AEA A A E 21 AS SDVordHandi CF asaina aie ogi cosas tay io adaiea eis euale ogi eneta 24 A MMe IVIOVOL EEEE EE ATE E EEEE OEE EEE EN TEE EA ESE 26 AE A We 10 EEE A A D E EE nde E A AE D E A A E E A ote DA AT 28 A decd gt MOULCC VCC LOM r E a a a 29 A 2 Dynamic Desioa Model reirei tet cecal ase 30 4 2 1 1 Sequence diagram for use case l creating A new project cccccceeeeeeeeees 30 4 2 1 2 Sequence diagram for use case 2 loading projects cccccccccsssssesseeseeeees 31 4 2 1 3 Sequence diagram for use case 3
42. es default textured were they enough Yes i Ral If no what other texture should be added Leave comment below 4 Any object added to the scene graph can be edited it can be moved rotated and scaled was it enough Yes No 5 Did you come across any crashes while using the system If so please describe shortly Yes at 6 The application allows you to see the source code of the changes you have made to the scene graph was it helpful to you Is the code provided informative enough Yes No 7 How would you rate the GUI Bad 0 1 2 3 4 6 Excellent 8 how would you rate the responsiveness of the applications Bad 0 1 2 3 D 5 Excellent 8 Would you D y this software to anyone Yes No 9 Any comments to 45 h handle 2 y Your Name Signature A Huj l Att tat User Questionnaire Java3D Scene Builder 1 Is the GUI user friendly Yes A No If no where the improvements could be made Leave comment below 2 When you add objects onto the screen do they appear exactly where you want Did you have to change the location of the object after adding Yes iV No 3 The program provides default textured were they enough Yes No If no what other texture should be added Leave comment below 4 Any object added to the scene graph can be edited it can be moved rotated and scaled was it enough Yes of No 5 Did you come across any crashes while using the system If so
43. evtree eer oimtrr ctr yT PCT a remy ecre ny tnee ae ror rrr et erent Sr 15 Pieire OG UP TOtOLy De Ue crates tates ren tech a a a R E 16 TRV OUEES 9 Class diapa Ants shnce te gad Sesesoe dees siie eaaa aei aeaiee eker ia a iii 19 Feire t0 UsecasedidsiaNi ssassn E a 20 Piene PC lass ia an r T E E A T E E ET 21 Figure 12 showing pick ray and functioning Of PICKING eee cccccccceceeeessseeeeessnnneaeeeeeeeeeeeeeeeeseeeees 24 PIeures 3 Class Cia eam koera incur E E ENEE 25 Figure TAsC lass Diran Aasra a a a e vale adindemsat 26 Figure TS Rotaom around allee AXES a E A RN A echuetinacakednanens A Fene ro ES dap eae n a 28 Fisore tC lass diarani O rerin E lade tae eis kth a deel ta aaccal arc 29 PAG UES Ls S6QUCN CS Warani U8 sicteaserias deat atte E E T Gua taucrtaste EET 30 Paoure 19 Sequence Cia etait 2 sosna a tind ace eens cee ee 31 Piou 20 Se QUCM Ce diar e n E N T EAA 31 Froure 21 Sequence diagram A isanuconunei an a as gels AE 32 PIeute 22 Sdu nce didra Saen a E E A hiace sh aawiteet ged 33 Fiure 2 5 scgacnce diarani Ooenocas ranan n N N ae 34 Femei SCQUCMCe Mia oran S a E yiuoeauaial eon aseeuseanesasteas 34 Figure 2n pcduence CIAL AMO ncrsnipuinu an a a a es 35 PICULC ZO PTO Chali FOW eaa e a S AEE OEE A E 36 Figure 2 7 SCreensmOl HOMES CSCI issnin E a sis 37 Figure 28 Screenshot showing a newly opened project ccccceeesessssssssssssssesesssesesseesseseeeeseeeeeeeees 38 Figure 29 Screenshot dialogBox to add a box in
44. fine for end users who are familiar with the structure of eclipse IDE but for non programmers it s a bit clumsy 2 2 2 Java3D Editor J3D Editor is one more similar type of GUI based application designed in java and uses java3D It is used for automatic generation of code some of its features are highlighted below o 3d models supplied are not enough and not properly processed they are either not in proportion with the other things in 3D world or they are placed on screen without rotating o GUI is not user friendly it does not allow users to move the added shapes In our system we will give users a chance to select any object and move it using keyboard Whenever users add any shape onto the scene graph they are shown a number of dialog boxes one by one which can be a bit irritating at times in our system we can show user only one dialog box users can add all the information onto the dialog box o The users can change the colour of the shape or the textures of the shapes after adding o The users can see what shape has been selected as the selected shape is highlighted o It does not have option to undo or redo the previous changes made onto the scene graph o Users can clone their objects in the scene graph o The code generation of the java3D Editor is a good feature and it lets user generate a java file which can be used in other application o Users can reset the viewing platform of the application i
45. gram please check the appendix for user manual 4 2 1 5 Sequence diagram for use case 4 Undo 3df _3DFrame _basic3DWorld Figure 22 Sequence diagram 5 Users can undo any change they have previously made on the scene graph by press ing undo button on 3DFrame Suppose user adds 3 shapes onto the scene graph and presses undo the shape which was added latest will be removed and so on The undo method in basic3D World pops the top element from the stack the stack stores previous scene graphs which were modified by the user changes The stack does not record changes to the shape 1 e if user rotates a shape or changes the position of the shape those changes cannot be retrieved by pressing undo button 4 2 1 6 Sequence diagram for use case 6 Reset sd clear 3df _3DFrame _basic3DWorld 1 clear Figure 23 Sequence diagram 6 Users can reset the 3DFrame anytime they want this will remove all the object at tached to current scene graph and will clear the screen This method will be called from 3DFrame by user and from 3DFrame the call will passed to basic3 World where the method has been defined 4 2 1 7 Sequence diagram for use case 7 Show source 3df _3DFrame wh _3DWorldHandler 1 viewSource 1 1 showSource 1 1 1 showSource Figure 24 Sequence diagram 7 This method is called from 3DFrame the the call is passed to _3DWorldHandler and then showSource which is defined in Source
46. han one object behind the ob ject user is currently selecting pickClosest returns PickResult object which is stored in result After getting the result we can retrieve what type of object was selected by the user but the problem is that is the only information that can be recovered using java3d picking utility The above two statements show us how getNode method of PickResult can be used to retrieve the information that we need so imagine user clicks on any of the four primitive shapes then p will not be null it will have some value in it we use this in formation to process the selection As I mentioned earlier all that we can recover using picking 1s the type of object which was clicked This is not very helpful especially when there are more than one objects of same type in the scene graph In order to identify the type of object we use one property of Primitive and Shape3D class called userData and we have getter and setter methods provided by these classes for this property So whenever an object is added to the scene graph we set a unique ID as its userData Each time a shape has been added to the scene graph this ID is incremented and so is unique This ID is stored in_ tg class and is used by 3DFrame for identification of added shape Whenever user clicks on any visible object we get an ID of that object and this ID is then checked with every object that has been added to the tgList if a match is sound we se
47. i Hi Se Ge A ne oe eae javier ria so i l N agi CL id Reset undo The following project was created while testing the application and users can create 3D world like these using scene builder What you see in the screenshot are nothing but boxes with different textures Sphere Cylinder Cone Extern Reset undo Figure 31 Example project in scene builder 5 2 3 Editing added object into the 3D World Many changes could be made to the objects added by the user such as changing the position of an object rotating an object deleting an object from the scene graph changing size of the object To accomplish these tasks Mover class which extends Ja va3D behaviour is used Now in order to move an object users first have to select an object users can do this using mouse For the selection of a 3D object we use Picking classes supplied by ja va3D PickCanvas pickCanvas new PickCanvas canvas3D sceneBG In order to use picking you have to create an object of PickCanvas class which is sup plied the canvas used by the application to draw 3D elements and the root branch graph as parameters PickResult result pickCanvas pickClosest Then the PickCanvas object is used in mouseClicked method where it listens to the user clicks We use pickClosest method of PickCanvas to determine the object which is closest to the screen remember there could be more t
48. ies ssaisdccesataieessbyiiseunnigavalelicemusiecsiidemiige 50 Proure 44 23 Tile example senenn E E caneieba udannaasaipeanien 50 Pigure4 5 User Manual didlos WOK si sisss ia ssvictiend cceennieasenseceiaarsdhaaansresacaansiaiensunctbaane theauanesemaanatuaietaeroes 68 1 Introduction Java3D Scene Engine is a GUI application designed in java which enables users to create java3D scene graphs and make changes to it A scene graph 1s used to create virtual universe in java3D API it is made up of different 3D objects such as box sphere etc The scene graph also defines the characteristics of objects such as geometry appearance light In this introductory section there will be four subsections background and context and then the overall scope objective and some of the assumptions that have been made in producing the design of the application and then the things that have been achieved so far with an overview of the dissertation The motivation behind the project came from the fact that to design any java3d game or application a lot of time is consumed in designing of scene graphs This time spent on design is even greater when the developer is new to java3D therefore this project was developed in order to minimize the time that is spent in the designing of a 3D application also giving users a chance to learn how java3D works The users will be shown the live changes that are being made on the scene graph and they can also see the co
49. ire Java3D Scene Builder 1 Is the GUI user friendly Yes 1 No lf no where the improvements could be made Leave comment below 2 When you add objects onto the screen do they appear exactly where you want Did you have to change the location of the object after adding Yes MN No 3 The program provides default textured were they enough Yes No v If no what other texture should be added Leave comment below 4 Any object added to the scene graph can be edited it can be moved rotated and scaled was it enough Yes ai No 5 Did you come across any crashes while using the system If so please describe shortly Yes No 6 The application allows you to see the source code of the changes you have made to the scene graph was it helpful to you Is the code provided informative enough Yes No vT 7 How would you rate the GUI Bad 0 1 2 3 5 Excellent 8 how would you rate the responsiveness of the applications Bad 0 1 2 3 Q 5 Excellent 8 Would you recommend this software to anyone Yes v No 9 Any comments Your Name WAN amp YUANNI Signature val E gt User Questionnaire Java3D Scene Builder 1 Is the GUI user friendly Yes No If no where the improvements could be made Leave comment below 2 When you add objects onto the screen do they appear exactly where you want Did you have to change the location of the object after adding Yes No 3 The program provid
50. ll be redirected to the method definition You can also see how the 3D world creator class has been built and how the lights or the background were added to the scene graph to see that you can click show source button at the bottom of the method definition
51. n select any object they can see on the scene graph and press key D to delete that object from the scene graph How the selection of the object using mouse will be discussed further public void addExt String target float xCoor float yCoor float zCoor Whenever users want to add an external model into the scene graph this method is called it taken the 3ds object to be added from the user and the coordinates of the object This method processes 3ds model in java3d so they are in proportion with the other things in the scene graph String target which is supplied to this method is the name of the 3ds file stored on physical media this method then loads the 3ds model into the scene graph with the help of PropManager java class public void mouseClicked MouseEvent e Even though this method is defined just because this class implements Mouse Liestener this is one of the most valuable methods in this class Whenever user selects any object using mouse this method gets called it helps identify which ob ject has been clicked and accordingly the movable flag for that object is set Picking API supplied by java3d is used in mouseClicked method to identify which object has been clicked Picking is used in such a way that it projects a ray onto the scene graph from user s viewpoint it returns the type of the first object that it intersects cube in the scene mouse power i p rgy Cy user viewpoint Figur
52. n the 3D editor users may choose to change the characteristics of the object Users can also make changes to the objects which are already present in the scene graph Pre condition A valid project with some objects in them should be present and the movable property of the object is set to true This is done by clicking onto the object using mouse Main flow Activated when user selects any object and makes some changes to the object Related requirement 4 Description If user makes some change to an object and the change is not desirable user can undo that change Main flow Activated when undo button is pressed pops the branch graph data from the stack and loads it into the scene graph Pre condition Stack cannot be empty 1 e user should have made at least one change to any one of the scene graph object Because you cannot undo what hasn t been done 6 Reset Related requirement 5 Description Sometimes users may not be happy with whatever they have created in that case users may choose to reset the scene graph Main flow Activated when reset button is pressed deletes every object from the scene graph Exceptional flow Reset should not be performed on a new or empty scene graph 7 Show source Related requirement 6 Description If a user wants to check the source of the current scene graph they can check it using the menu button show source Main flow Activated upon pressing
53. ne graph was shown on the 3D Editor window 3 1 2 2 GUI Prototype I Instead of having different JFrames for every feature this prototype includes all fea tures on different JPanels in one JFrame primitive shapes 3D Editor External Models Figure 8 GUI Prototype II Since there is only one window in this design the scene engine is a lot easier to man age there were many other advantages of prototype II over its predecessor like it s a lot easier 1f you want to run the application in full screen if user want to change the size of the 3D editor window they can do it easily 3 1 3 Architectural prototyping Now from the GUI prototype of the software let us talk about the core architectural design of the application 1 e the actual working of the system While working on the early prototype few issues regarding the architecture of the sys tem were brought up One of the issues was how the user triggered changes made to scene graph like addition of a box to scene graph will be handled by the system The following are the two possible solutions using which this issue could have been solved 3 1 3 1 Compile and load architecture Whenever user adds a box into the scene graph we open the main 3D java file _basic3DWorld java we make changes to that file in the method public void createSceneGraph this change would be nothing but adding an in struction addBox with some parameters de
54. object inherits any transform the tg has Transform3d defines where a particular ob ject will be placed onto the scene graph it also has information regarding the affine transformations that can be performed on the object Internally Transform3D 1s noth ing but a 4x4 floating point matrix with double precision shape String shapeCountInteger e Movable boolean setMovable getlD Integer getShape String Figure 16 Class diagam 5 The two important attributes of tg are shape a string which stores which shape it is and shapeCount which is an integer and acts an ID for every object that is been added This ID is later on used for picking and identifying every shape shapeCount is incremented whenever an object is added into the scene graph Another attribute of tg is movable this is a Boolean and it determines whether or not we can change the location of a particular object at any given time The mova ble property of tg is set from basic3Dworld class precisely when user selects any object using mouse 4 1 1 6 SourceCreator The last but not the least this class is used mostly when user wants to see the source code of the projects they are working on users can select any available project at any time and see the source code for that Ld SourceCreator addLabel showSource void showShapeSrc void showBasic3DWorld void Figure 17 Class diagram 6 Only two methods of this class are public and a
55. outline for the added sphere The most valuable part of this method and all the other methods which add an object onto the scene graph is they all detach the live scene graph add the shape and load the scene graph back again as we add an object directly onto the scene graph the time required to show the object is pretty less The other methods which add shapes onto scene graph are similar and self explanatory public void clear Consider a scenario where user creates a new project adds few objects onto the scene graph and somehow the user is not happy with the project and decides to create a new project in such case all the previous added objects should be removed from the scene graph and a clear scene graph should be shown In such situations this method is called This method is also called when user presses reset button on _3DFrame public void undo Consider one more scenario where user is working on some project and deletes an object by mistake in such situations users can call undo method to recover the previous scene graph that they were working on As mentioned earlier this method uses the stack which saves the root scene graph branch after every change made onto the scene graph public void deleteObject One of the requirements in the problem definition was users should be able to delete any object present in the scene graph and this is the method which provides that functionality to the user Users ca
56. pful while working on the design of the project the idea of implementing live scene graph was actually suggested by one of the member of the site I would also like to show my appreciation to my class mate Sami M chala who supported and motivated me wherever I had any doubts not only with the java bit of the code but also with the report Table of Contents IPAS Use a ent arse A E iota cata uses E iota ATT 1 ARNESANO Geinin a E E tenseenaaaue ii PACK VO WSCC US MS arire sas aac ea acaecd a aa ane vce ee a aac octeneaoe ili TapE Or COMENS rna renter a N A N ene eee re iv ENS CHOW F GUUS aan a a EE AEEA A vi TANTO OU CHOU b eactensisttcnantvt G E EE EE E A OSA l 12 Scope ANG ODJECIVES secano na O 4 ko ACNevemen econ ta ots loca nce A N a ee 4 ld OVENIEW OT Dissertation sxiscotccsacerresseteeabodteoasceinees eericesann asada ON EE 5 2 SUS O UNS SPI e aise eatin ey cone ens uauray course ai ga aenide nawiedl eat nawate OEE 6 21 Esistine components Of Javad Dyas ices Res T E eae le ea eeeeiaee 6 A2 TS ASUIINO SV SUG IIS erinan eine easter a erase a es uuerues 6 22t Monkey EN INE sorana ae teas os ee eeae ae 6 DD VAN a D ke CON ET AE A OE E A E A E E E E ust E E gaan 8 Zid CONCOS aa E 9 3 Requirements Jumping into the 3D World eeeeeeeeeeeeeessssssssssersrrrrrrrrrrrssssssssseren 10 SUP LO ONS Cle NN Ol OM erena a lean ivestuneaseaia eiecenemaincleahiteceemaasea 10 yal ag am Use case F282 ers 80 eee ee eee Ra er or 13 Jkl Lise cas
57. re called from 3DWorldHandler and they are addLabel and showSource So whenever user wants to see the source for the project they can select view source option from the menu they will be shown a JFrame which will contain labels which internally are buttons these labels represent the calls made to the _basic3D World to add a particular object If users want to see the methods upon which the calls are made then they can click on the method call as these are nothing but JButton After clicking on this button the content of this JFrame will be replaced by JTextArea which will display the appropriate method with comments It should be noted that these methods are modified to add comments and are limited only for educational purpose The users can then choose to see the class in which these methods are implemented and how the building blocks of the 3D world are laid out 4 2 Dynamic Design Model The dynamic design model of this system consists of sequence diagrams and state diagrams 4 2 1 Sequence Diagrams Every use case described in problem definition section of this paper has a UML sequence dia gram associated with it 4 2 1 1 Sequence diagram for use case 1 creating a new project sd New Project 3df _3DFrame wh _3DWorldHandler _basic3DWorld Figure 18 Sequence diagram 1 This sequence diagram shows how user interacts with the system to create a new project whenever a new project has to be created we will h
58. re on the user may find the 3d project in the default directory or user can browse the other directories in the physical media 3 Add 3D object Related requirement 2A 2B Description Once the project has been opened in 3D editor window users may add a 3D ob ject into the scene graph This 3D object can be a primitive shape with an image texture or a 3D model Pre condition A valid project should be running Post condition Whenever user clicks on add object button depending on the type of object that user wants to add a dialog box will be shown to the user this dialog box will ask user for things like size and coordinates of the object on X Y Z coordinate system The user should enter valid data for these parameters By valid data we mean the size of object can only be in digits and if user wants to add textures to the object the image selected for the texture should be a valid image accepted by java Main flow Use case activated when user wants to add a button a dialog box is shown in or der to get the data regarding the object If all the data is valid the object is added in scene graph Exceptional flow As mentioned above the exceptions in this use case could be the data entered by the user is not valid in that case we show the dialog box again we do not add the object unless the data is correct 4 Edit object Related requirement 3A 3B 3C Description After adding the 3D objects i
59. ry out let us discuss the methods involved public static void addAxes Whenever users open a new project they are shown three axes which represent the 3D Cartesian system of coordinates This method draws these axes onto the screen public void addBox This method is called from _3DFrame whenever user wants to add a box onto scene graph it shows a dialog box to the user and takes input from them then it calls addBox method from _basic3D World to add a box onto scene graph Other methods to add shapes in this class are similar to this public void newProject This method is called from 3DFrame when a call is made to create a new project it takes a name of the new project from the user and creates a new file in the default projects directory public void loadProject String filename This method is also called from 3DFrame class whenever user presses a button to load previous projects they are shown a JFileChooser in 3DFrame the file name of the user chosen file is then sent to this method loadProject then opens the file and loads the data into the scene graph public void saveProject Saves the opened project into custom 3d file the filename given to these files is the String stored in opened variable This method goes through the tgList ArrayList in _basic3D World which is the list of currently present objects in the scene graph and writes information about these objects into the file The information store
60. s are added to the scene graph users can undo those unwanted changes using this functionality e Reset All the scene graph nodes are removed when this function is used and a blank project is shown to the user with 3D coordinate system and a grid which allow users figure out the coordinate system more effectively e Adding objects Users can add primitive shapes in java as well as the external models into the scene graph While adding these objects users can give their preferences to the object such as colour texture and coordinates of the object or users can choose to add an object with default parameters e Editing objects Users can change the properties of the object such as their position users can rotate the objects around all the three axes users can also change the size of the object using scaling 1 4 Overview of Dissertation The dissertation contains the total of 7 chapters including conclusion In the next chapter state of the art the existing 3d world building system available for java3d will be discussed along with their advantages and disadvantages and we will also talk about how some of the features of these applications could be improved The next chapter will be requirements gathering where the crucial features of the application will be discussed This chapter will also contain the problem definition and the use case diagram for the system The software prototyping used during the design phase
61. s section four shapes will be added to the scene graph and the operation of the view source will be shown source addBox 1 0f 1 0f 1 0f 0 5f 5f 5f white false addSphere 1 0f 1 0f 1 0f 5f white false addBox 1 f 9999999999999999f 1 0f 0 5f 0 5f 0 5f textured false addSphere 1 0f 1 0f 1 0f 0 5f textured false Figure 37 View Source showing methods calls made to _basic3D World for current scene graph As it can be seen the method calls which are shown are nothing but JButton and upon clicking these JButtons the actual method definition is shown onto the Source JFrame If we delete any of the shape that is in the scene graph and click on the view source again the method call made for that shape will be removed from the source JFrame Ley Source addBox 1 f 1 0f 1 0f 0 5f 0 5f 0 5f white false addBox 1 8f 9999999999999999F 1 0f 5f 5f 0 5f textured false textured false addSphere 1 0f 1 0f 1 0f 0 5f Figure 38 Source After one of the sphere has been removed The way this component of the system works is the SourceCreator class maintains a list of JButtons which is updated whenever user presses on viewSource menu item Only those objects are shown to the user which are currently present on the scene graph The information about the objects which are present in the scene gr
62. s state user will be shown a home screen of the application from here user can create a new project or load an existing project or exit from the system If user decides to create a new project then user will be shown a dialog box asking the name for the project Similarly if user chooses to load existing projects user will be shown a dialog box where user can browse and check directories in their computer for 3d files e Select project browse for projects User will be shown the projects in the projects directory here user can also navigate to other directories to search 3d files From this state the users will only be shown the 3D Editor window e Show scene graph Editor window In this screen we show user the default X Y Z coordinates along with the grid or the grid and coordinates with the loaded project depending on user s former actions User will make changes to the scene graph in this screen from this screen users can either close the programs save current project or load another project 5 2 Implementing the code 5 2 1 The home screen New Open Exit Figure 27 Screenshot homescreen Whenever end user runs the application the following home screen is shown which has three choices The home screen is linked to the 3DFrame so if user selects any option from the home screen method from 3DFrame is called If user selects an option to create a new project they are shown a
63. scribing the box after doing the file handling we compile the _basic3 DWorld java file and all other files using this class and we load it into the memory It also involved disposing the cur rent window and creating another JFrame window in order to load the newly created scene graph Even though this method works perfectly and was used in the early prototyping of the software it is a time consuming method after adding any shape into the 3D world it used to take around 5 6 seconds to compile and load the files back into the memory Apart from the fact that it was time consuming the loading of the byte code back in to the memory had its own issues such as the class loader provided by java is buggy sometime it does not load the byte code into the memory for some reason 3 1 3 2 Changing the live scene graph on the GO This method of tackling the above discussed problem is straight forward and less time consuming all we do in this method is remove the main branch graph from the root node make the necessary changes to the scene graph like adding of a shape or un doing previous change and add the branch graph back to the SimpleUniverse object This method was not implemented initially but now the entire software including the loading and saving of projects uses this method to make changes on scene graph 3 3 Expected Flow Before jumping into the object oriented UML diagrams let us discuss how the software is expec
64. ss PropMan ager java This class was provided in the book Killer Game Programming by Andrew Davison The 3D models used by NCSA are stored in 3ds file extension and they can be created using many third party softwares The problem with the 3D models which were pro vided was when the model was added into the scene graph they were out of place they were either too big for the scene graph or they were needed to be rotated in order to make them appear as if they are on ground Also the textures used on these models were not proper Figure 40 3ds Model added is horizontal to X axes As it can be seen in the screenshot the 3ds model added in the scene graph is not in vertical position which it should be as it is not desirable because if a user has added some land in their scene graph and they add 3ds model it will be horizontal to the land which is not something which user wants Also if two different models for example a car and a robot are added to the scene graph they both are not in proportion with each other which is shown in the next screenshot PEPE CPEEPCLCPULECECTUCECLTECTCTCTECECTCTECECECTECICTCTECETT CTE ECTCTECEETCTECEETETECTCT EPEC ECE CTECEEECTECECECTECECECTECECTCTECTCECTECTCPETECTCEETECTCTCTECTCECTECTCECTECTCECTECTCECTECECECTTCTCECTECECECTECECECTECECECTECTCECTECECE CTE TCECTECECECTECTCECTECECECTECTCECTECTCECTECTCECTECECETECECETTECTCETTECTCETECECETECTCETECTCETECTCEETECECETECTCETECECE A A A A A A A a a TE
65. t is useful when the screen is rotated by user using mouse and the users are somehow not able to rotate it back to its original position Figure 4 Screenshot java3DEditor 2 3 Conclusion In Java3D scene builder we will try to improve these entire drawbacks and add many more of our own features such as undo action and redo action We will try to keep the GUI as simple as possible the saving and loading of the program will be very simple Users will also be allowed to open previously save scene and add their own things to it 3 Requirements Jumping into the 3D World This chapter will describe the requirements of the software along with characterization of the boundary of the system This chapter will also include the use case diagram which will be constructed using the requirement stated in section 3 1 3 1 Problem definition The graphical user interface GUI of the application will be designed in java with the java3D API to allow users create a java3D scene graph which will be portable and can be used in java3D applications We have already seen what a scene graph in java3D 1s and how it can be used in various applications in the introduction so we will directly start defining the problem that we have in our hands System Requirements l The fundamental requirement of this application is the ability to construct scene graph every project that user loads in the system will consists of light and a background The obje
66. t the movable property of that tg to true So when user presses any key to change the object in Mover class we move only those tgs whose movable property is true At any given time there is going to be only one _ tg with its movable property true The screenshot below will show how an object can be moved using the arrow keys the screenshot contains the locations of the object initially and the location after it was moved How the moving of an object actually works Below you can see a basic scene graph with a sphere added at location Ox Oy 0z you can see the location of the sphere at the bottom of the screenshot The program is simply printing the location of sphere every time it is changed Xcoordinate Ycoordinate Zcoordinate 0 0 Figure 32 Moving Position 1 of sphere The next screenshot shows the same sphere with a change in its position it can be clearly seen that the object is no more at its default position Ox Oy 0z WKenerdinete Ycoordinate Zcoordinate 9 g 6 1 Xcoordinate 2 Ycoordinate Zcoordinate Xcoordinate 0 30000000000000004 Ycoordinate Zcoordinate 0 0 Xcoordinate 4 Ycoordinate Zcoordinate Xcoordinate 0 5 Ycoordinate Zcoordinate Xcoordinate 6 Ycoordinate Zcoordinate Xcoordinate 7 Ycoordinate Zcoordinate 6 7 Xcoordinate 999999999999999 Ycoordinate oo O00 D NOOO coordinate Figure 33 Mo
67. ted to behave right from when the user starts the application till 1t has been closed When user runs the software for the first time following sequence of events will happen Users are shown a home screen which has options to o Create a new project o Open saved projects o Exit the program Ifuser selects any one of the first two options the 3D Editor window will be shown to the user where most of the time of the software will be spent Here users will be given an option to do following things o Add object o Edit object o Undo last operation o Reset 3D Frame o Open another project o Create another project o Save project o Exit the program 4 System Design Description Now that our use case diagram is ready we can begin with the design phase for our project here we will determine the essential components of our system and how they relate with each other The preceding part of this chapter will be about the static design model which will contain class diagram and dynamic design model which consist of sequence diagrams with their associated use cases and state chart diagrams which will tell us more about the states of the project 4 1 Static Design Model The figure below shows class diagram illustrating the static design model for scene engine system The classes are shown with their attributes and methods along with different relationship cardinalities between the classes It should be noted that all the UML diagrams in
68. to scene graph cccceeeesessseseessesssssseeseessesseeeeens 38 Figure 30 A box with and without an outline cc ccccessssssccceeeeeeeeeeeeeessseeeeeesssnaeeeeeeeeeeeeeeeeeeeneens 39 Figure 21 Example project in secen Ould Fersen aa a E nese ae muss 40 Fieure 32 Moving Position 1 Of SpPNGre wsseiecsasti ete aa E A 42 Figure 33 Moving location of the sphere after being MOVE 2 0 cece cceseeeeeesetteeeeeeeeeeeeeeeeseeeeees 43 Figure ot Undo eis ali o seme nee ee neeneena E manne re TY fe SRT Sreree om RT eye ter ee ee oer 44 Figure 35 After calling undo for first time cc eccccecceessssscceeeeeeeeeeeeeesesseeeeeesnsaeeeeeeeeeeeeeeeeeeeeneees 45 Figure 36 Undo the state of scene graph after performing undo tWICe ccceeeeeeeseeseeeeeeeeseteeens 45 Figure 37 View Source showing methods calls made to _basic3D World for current scene graph 46 Figure 38 Source After one of the sphere has been removed cccceceeseeeeeesssnnteeeeeeeeeeeeeeeeeeeeeees 46 Figure 39 Example of how the code is Shown to the USCL cccccccccccccceceseeseeeeeeesnnnnceeeeeeeeeeeeeeeeeeeeeees 47 Figure 40 3ds Model added is horizontal to X axes cccccssssssccecceeeeeceeeeeseeseeeessssnneeeeeeeeeeeeeeeeeseeeees 48 Figure 4 Outofproporion models resien a 49 Figure 42 Models proccessed in order to make them proportionate Error Bookmark not defined Figure 43 Screenshot 3D world with ex tential models
69. va3D to achieve this bit the software should have a provision to show the code of the live scene graph on demand to the users This code will need to be modified for every little change that is being made on the scene graph 8 The scene graphs will be saved in a physical file on the hard drive they will be saved in the form of text but just to avoid confusion between other text files the file extension given to the scene graphs will be 3d So if we have a scene graph named FirstWorld the physical file for this project on the hard disk drive will be FirstWorld 3d User should be able to save and load the scene graphs in 3d files create new scene graph projects in 3d files 3 1 1 Use case diagram Let us now design a use case diagram for the problem considering the above requirements After doing the abrupt study of the working of the application it was realized that there is going to be only one actor the user of the system in all the use cases hence we are not going to show the actor in the description create new as open 3d file any add object AS Figure 6 Use case diagram Let us now describe each and every use case associating it with its related requirement 3 1 1 1 Use case 1 creating 3d files Related requirement 1A Description Whenever user runs the program for the first time an option to create a new project might be selected user can create a new project even from the 3D editor window 3
70. ving location of the sphere after being moved This screenshot also shows how the location was changed the move method in Mover was called 8 times you can figure that out from the X location of the object it is incremented by 1 and the object is being moved in X positive the number is incre mented To move an object in 3D world mover class has a method called move which is giv en the location of the new position of the object When user presses any key to move an object we first create a Vector3d for that move suppose user wants to go in X positive and then the new Vector3d object that will be generated 1s new Vector3d MOVERATE This Vector3d is then passed to move method where we first check if the object is movable because it is undesirable to move any other object than what user has pressed After that we get the Transform3d object from the TransformGroup object of the current shape Transform3D t3d 3 objectTG getTransform t3d objectTG is the TransformGroup of the current object so we retrieve Transform3D object from objectTG and store it in t3d As discussed previously Transform3D repre sents the current location of a 3D shape and is used for affine transformation Trans form3D has a method mul which multiplies the affine 3D 4x4 matrix internally stored in Transform3D by Vector3d object toMove This toMove object has infor mation about where the object will be relocated t3d
71. will also be discussed and finally we will talk about expected behavior of the application which will explain the typical program flow In the next chapter System Design Description we will discuss the more technical bit of the system with UML diagrams such as class diagrams and sequence diagrams The next chapter Implementation will contain information about how the solution was implemented and the problems that were faced during the development In Testing we will talk about the different testing that was carried out during and after the development 2 State of The Art In this chapter we will discuss the existing system that is the programming model of java3D and then the systems which enable users to create similar 3D worlds will be discussed 2 1 Existing components of java3D If one wishes to design 3D shapes in java3d and add it to the scene graph they have to write a program to do it For this the users should know how to program in java and they will have to learn java3D API and see how the scene graph works in reality Even to rotate an added shape or apply any transformations to shapes users have to define their own behaviour classes which will listen to the user input and implement methods like initialize processStimulus etc which is clumsy as well as time consuming If users want to change or move an object they have to create methods in their behaviour classes to achieve this To add
72. x GENERATE_TEXTURE_COORDS app if the draw outline is selected then call drawOutline method this will simply make the shape hollow and will show how the shape is made e g using polygons cones etc if drawOutline drawOutline cc getShape transform3D defines where the object will be placed onto the 3D coordinate system Transform3D t3d new Transform3D t3d set new Vector3d xCoor yCoor zCoor a _tg shapeCount Show source Figure 39 Example of how the code is shown to the user The above screenshot is an example of how the method definition of any particular object is shown to the users If users are interested in seeing how the scene graph is generated what kind of lighting is necessary or how the background is added to the scene graph they can click on show 3D world class JButton at the bottom this will load the actual basic3DWorld class into the JFrame and users can see the building blocks of java3D 5 2 6 Adding external models For the sake of simplicity and considering the limited time provided for the project only one external model have been included in the application this model is designed by NCSA The models are copyrights of The Board of Trustees of the University of Illinois There are no legal issues in using the models for the academic purposes hence we have included them in the system 7 In order to use these models in the java3D we have been provided a cla
73. y _basic3D World are Mover and tgList we will be discussing those in the next few pages but just to get you started Mover is the behavior which handles moving of any object and _tgList is just an ArrayList of tg class objects tg class extends TransformGroup to add some extra functionality to it The constructor of this class does the job of setting up the JPanel and adding MouseListeners creating scene graphs and initiating user location Besides the constructor this class contains many important methods which are discussed below private void _createSceneGraph This method creates the basic scene graph for the user it contains only the axes as other objects are added later on by the user This method contains call to the addBackground method which is pretty self explanatory it adds a background to the scene graph the next method called is lightScene which adds all the necessary lights to the scene graph after lightscene the scene graph is compiled Scene graph compilation is necessary as it gets rid of all the unnecessary BranchGraphs and TransformGroups if there are any public void addSphere float xCoor float yCoor float zCoor float radius String color boolean cth This method adds a sphere onto the live scene graph for that the arguments provided are as follow xCoor X coordinate of the sphere yCoor Y coordinate of the sphere zCoor Z coordinate of the sphere Cth Tells us whether or not we have to show an
74. you fill all the fields you can either choose to add your own textures to the object or you can select a particular colour for your object Remember you can either select a colour or you can add the textures you cannot add both Once the desired details have been put press OK the object will be added in the scene graph 10 2 2 Editing objects To edit any object added to the scene graph click on the object and move or rotate the object depending on your requirements the keys associated with every function are listed below 10 2 2 1 Movement Right X positive Left X negative Up Y positive Down Y negative Ctrl Z positive closer to user s viewpoint Shift Z negative away from the user 10 2 2 2 Rotation Number pad Key 7 Positive rotation around X axis Number pad Key 8 Negative rotation around X axis Number pad Key 4 Positive rotation around Y axis Number pad Key 5 Negative rotation around Y axis Number pad Key 1 Positive rotation around Z axis Number pad Key 2 Negative rotation around Z axis Delete selected object D Increase size of the object Q Decrease size of the object E 10 2 3 View Source If you want to see how the current scene graph has been created select View Source menu option from the View Menu you will be shown a list of buttons which show how the methods from the 3D world creator class were called To see the method definition you can click on any of the button you want you wi

Download Pdf Manuals

image

Related Search

Related Contents

SCSI アレイコントローラカード GP5-147 ご使用前に  m - Crane Hunter  Samsung SPF-85V Manuel de l'utilisateur  MNK Dauerfettschmierung    Registro  

Copyright © All rights reserved.
Failed to retrieve file