Академический Документы
Профессиональный Документы
Культура Документы
User Guide
Adobe Atmosphere
User Guide
2003 Adobe Systems Incorporated. All rights reserved. Adobe Atmosphere User Guide for Windows If this guide is distributed with software that includes an end user agreement, this guide, as well as the software described in it, is furnished under license and may be used or copied only in accordance with the terms of such license. Except as permitted by any such license, no part of this guide may be reproduced, stored in a retrieval system, or transmitted, in any form or by any means, electronic, mechanical, recording, or otherwise, without the prior written permission of Adobe Systems Incorporated. Please note that the content in this guide is protected under copyright law even if it is not distributed with software that includes an end user license agreement. The content of this guide is furnished for informational use only, is subject to change without notice, and should not be construed as a commitment by Adobe Systems Incorporated. Adobe Systems Incorporated assumes no responsibility or liability for any errors or inaccuracies that may appear in the informational content contained in this guide. Please remember that existing artwork or images that you may want to include in your project may be protected under copyright law. The unauthorized incorporation of such material into your new work could be a violation of the rights of the copyright owner. Please be sure to obtain any permission required from the copyright owner. Any references to company names in sample templates are for demonstration purposes only and are not intended to refer to any actual organization. Adobe, the Adobe logo, Acrobat, Adobe Reader, GoLive, Illustrator, InDesign, Photoshop, Minion, and Myriad are either registered trademarks or trademarks of Adobe Systems Incorporated in the United States and/or other countries. Microsoft, DirectX, Direct3D, Windows, and Windows NT are registered trademarks of Microsoft Corporation in the U.S and/or other countries. Apple, Macintosh, and QuickTime are trademarks of Apple Computer, Inc. registered in the U.S. and other countries. QuickTime and the QuickTime logo are trademarks used under license. Pentium is a registered trademark of Intel Corporation. 3ds max is a registered trademark of Autodesk Corporation. Maya is a registered trademark of Alias Systems. SoftImage is a registered trademark of Avid Technology. LightWave is a registered trademark of NewTek. Bryce is a registered trademark of Corel Corporation. Poser and Avatar Lab are registered trademarks of Curious Labs and EGISYS AG. TrueSpace is a registered trademark of Caligari Corporation. GeForce and Quadro are either registered trademarks or trademarks NVIDIA Corporation. Radeon, Mobility, and All-In-Wonder are either registered trademarks or trademarks ATI Technologies. Macromedia and Flash are trademarks or registered trademarks of Macromedia, Inc. in the United States and/ or other countries. All other trademarks are the property of their respective owners. Contains an implementation of the LZW algorithm licensed under various patents. Adobe Systems Incorporated, 345 Park Avenue, San Jose, California 95110, USA. Notice to U.S. Government End Users. The Software and Documentation are Commercial Items, as that term is dened at 48 C.F.R. 2.101, consisting of Commercial Computer Software and Commercial Computer Software Documentation, as such terms are used in 48 C.F.R. 12.212 or 48 C.F.R. 227.7202, as applicable. Consistent with 48 C.F.R. 12.212 or 48 C.F.R. 227.7202-1 through 227.7202-4, as applicable, the Commercial Computer Software and Commercial Computer Software Documentation are being licensed to U.S. Government end users (a) only as Commercial Items and (b) with only those rights as are granted to all other end users pursuant to the terms and conditions herein. Unpublished-rights reserved under the copyright laws of the United States. Adobe Systems Incorporated, 345 Park Avenue, San Jose, CA 95110-2704, USA. For U.S. Government End Users, Adobe agrees to comply with all applicable equal opportunity laws including, if appropriate, the provisions of Executive Order 11246, as amended, Section 402 of the Vietnam Era Veterans Readjustment Assistance Act of 1974 (38 USC 4212), and Section 503 of the Rehabilitation Act of 1973, as amended, and the regulations at 41 CFR Parts 601 through 60-60, 60-250, and 60-741. The afrmative action clause and regulations contained in the preceding sentence shall be incorporated by reference. Part Number: 90047303 (11/03)
Contents
Chapter 1: The Atmosphere Platform
Platform Features. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1 The Atmosphere Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1 Why 3-D?. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5
ii
CONTENTS
Learning the Toolbars. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46 Working with Palettes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49 Tutorial: Maximizing Screen Space by Docking. . . . . . . . . . . . . . . . . . . . . . . . 50 Tutorial: Positioning and Combining Palettes . . . . . . . . . . . . . . . . . . . . . . . . . 56 Using context menus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56 Using Undo and Redo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57 Customizing Atmosphere . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
Chapter 7: Views
Introduction to Views . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71 Working with the View Windows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72 Working with the Actor Object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74 Using the Reference Point Object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75 Working with Views. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76 Controlling the View . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80 Zooming to t Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82 Tutorial: Viewing a Characters Good Side . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82
Tutorial: Adding a Viewpoint Object to a Scene . . . . . . . . . . . . . . . . . . . . . . . 87 Tutorial: Adding a Viewpoint Object from the Object Presets palette. . . 88 Tutorial: Scaling a Viewpoint Object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89 Converting 3-D Files for Import into Atmosphere . . . . . . . . . . . . . . . . . . . . . 91 Converting Viewpoint Objects to Surface Objects. . . . . . . . . . . . . . . . . . . . . 91 Creating Avatars . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93 Creating a Portal. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94 Positioning an Entry Point. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95 Using Anchors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96 Naming Scene Objects. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96 Locking Scene Objects. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96 Setting Visibility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
iv
CONTENTS
vi
CONTENTS
Textures Set 2. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 223 Objects Set 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 227 Objects Set 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 229 Objects Set 3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 231 Scripts - Set 1 - Basic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 232 Scripts - Set 2 - Intermediate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233 Scripts - Set 3 - Advanced . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 234
OverlapEventHandler . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 275 Scene Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 277 Actor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 277 Anchor. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 285 Camera . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 286 EntryPoint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 290 PhysicalModel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 291 ReferencePoint. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 302 SceneGroup. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 303 Script . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 312 SolidObject . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 315 SurfaceObject. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 321 ViewpointObject . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 325 Solid Object Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 330 Face . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 330 Primitive . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 332 Materials . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 336 SurfaceTexture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 336 Texture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 337 Viewpoint Object Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 339 MTSBaseObject . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 339 MTSImageStream . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 340 MTSScene. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 341 MTSGeometry. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 343 MTSInstance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 343 MTSTexture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 346 MTSInstance2d. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 347 MTSMaterial . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 350 MTSTimeElem. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 351 MTSTimeElemSWFView . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 353 Physics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 355 FastConstraintSolver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 355 AngularDashpot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 359 Actions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 360 DragAction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 360 FluidAction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 361 MagneticAction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 362 MotorAction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 364
viii
CONTENTS
SingleDragAction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 365 SimpleRigidWindAction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 366 Constraints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 367 BreakableConstraint. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 367 HingeConstraint. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 368 PointToPointConstraint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 369 PrismaticConstraint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 370 StiffSpringConstraint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 371 WheelConstraint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 373
Colophon
What is Atmosphere?
The Adobe Atmosphere platform is a completely integrated end-to-end solution for creating 3-D interactive environments, delivering them over the web or within PDF documents, and allowing users to collaborate within them. The Atmosphere embedded multimedia type gives the web or document designer the ability to present a rich variety of interactive content, including three-dimensional objects, directional sound, streaming audio and video, SWF animations, and physical behaviors, all within the context of a live theater performance. Viewers of Atmosphere environments can move and interact freely within these spaces, and collaborate with each other. Atmosphere is different from other multimedia authoring tools in that it provides all of the tools and capabilities needed to author and play back realistic, immersive experiences within a 3-D stage set.
Platform Features
The Atmosphere platform integrates many features into a single application:
Immersion Create environments with dramatic lighting, animated 3-D objects, real-time behavior, video and audio in small les embedded in a PDF or HTML doucment. Interactivity Atmosphere users can easily create realisitc enivronments and behavior thanks to the built-in JavaScript API and integrated physics engine. Users can interact realistically with environments, objects and avatars that can behave independently or under user control. Multimedia Atmosphere supports directional sounds, streaming video and audio, SWF animations and high
3-D objects, light, sound, images, textures, video and other multimedia; attach scripted behaviors to objects and environments; and securely publish these environments to the Web or PDF.
CHAPTER 1
Atmosphere Player A web browser plug-in that allows users to interactively view and navigate Atmosphere
environments embedded in web pages. Atmosphere Player for Adobe Reader enables users to access Atmosphere environments embedded in PDF documents.
Atmosphere Collaboration Server A publicly available server, which allows messaging, object synchronization and interactivity between users of Atmosphere environments.
Atmosphere Player
The Adobe Atmosphere Player is a free application that allows users to view, interact, and collaborate with others in environments created with Atmosphere and published online or within PDF documents.
Atmosphere environments can be viewed within a web page using the Player plug-in.
Web Page Integration Atmosphere Player supports communication between web page HTML, Java and JavaScript
allowing web designers full control of user experience using the Players JavaScript API.
A Multimedia Experience The Atmosphere Player offers the user a rich and interactive multimedia experience without
requiring a high-bandwidth connection (56K normally sufces). Atmosphere environments can also be viewed in PDF documents using Atmosphere Player for Adobe Reader.
Intel Pentium II or faster processor Microsoft Windows 98SE, Windows ME, Windows 2000, Windows XP Home or Pro 64 MB of available RAM (128 MB recommended) 14 MB of available hard-disk space 16-bit color (32-Bit Color recommended) 56K modem or faster Internet connection Microsoft Internet Explorer 5.00.2614.3500 and above. Graphic Card Support: Radeon 7500 or higher, GeForce 2 or higher
Atmosphere
Adobe Atmosphere is a professional authoring tool for assembling and creating 3-D interactive environments. This new embedded multimedia type offers a unique way to present a rich variety of interactive content, including three-dimensional objects, sound, streaming audio and video, SWF animations, and physical behaviors. Atmosphere enables the designer to easily and quickly create content using intuitive tools. Users can import objects created with other 3-D authoring applications, add texture, media, interactivity and lighting and then publish the environment for use on the web or in PDF documents.
CHAPTER 1
via the Viewpoint media format (MTX, MTZ). Atmosphere also supports wide range of standard graphics and multimedia formats.
Scene Modeling Create objects and combine them with imported assets to build a seamless environment. Apply
global appearance properties such as lighting. Texture and fog using intuitive tools.
Interactivity Add interactive elements to the environment using JavaScript and a real-world physics simulation
engine.
Publishing Output the resulting environment in a form that can be embedded in either a web page or a PDF document. Published worlds cannot be re-opened in Atmosphere, thus securing the authors intellectual property. Atmosphere System Requirements Atmosphere, like the Atmosphere Player, can run well on a minimal system conguration, but more powerful systems will improve the authoring experience. System requirements for Atmosphere are:
128 MB of available RAM (256 MB recommended) 50 MB of available hard-disk space 1,024x768 screen resolution 16-bit color (32-Bit Color recommended) Graphic Card Support: Radeon 7500 or higher, GeForce 2 or higher
Why 3-D?
The Atmosphere platform is designed to make the power of immersive media rich environments available to a much wider audience than has been previously possible. The web is a very popular way for individuals and organizations to present information, but until now, it has largely been limited to the same kinds of 2-D information that can be presented on a printed page. People are accustomed to a world that has height, width and depth. Technologies like the telephone, television and the web offer only a limited lower number of dimensions. Consider the difference in trying to learn to navigate an unfamiliar place like an airport: directions given over a telephone (1-D), via a map (2-D) or by means of a video ythrough (3-D) represent successively easier ways to learn an unfamiliar space. By making it possible to easily create 3-D environments that can be navigated online, Atmosphere extends a powerful medium to a much wider audience and range of applications.
CHAPTER 1
The Atmosphere Player features support for hardware acceleration. If the Player detects a supported video card, it will enable hardware acceleration automatically.
This animated spinning globe icon and a progress bar will appear as the Atmosphere environment is loading.
When the spinning globe icon disappears, the geometry for the environment has completed loading and will be displayed. Textures and multimedia les will continue to download.
CHAPTER 2
Atmosphere environments can be viewed from within a web page. Above is an environment built using Atmosphere and showcased on the Adobe site.
10
CHAPTER 2
The Atmosphere web pages at http://www.adobe.com/products/atmosphere/ include an example PDF of Lewis Carrolls classic Alice in Wonderland that includes Atmosphere environments.
2 Scroll the document until you locate a Atmosphere environment and click on it 3 The Atmosphere environment will load within the document.
The Mad Haters Tea Party Atmosphere environments within a PDF document.
Before you can navigate an Atmosphere environment, the environment must be the focus of the web page. You can give the environment focus by clicking on it.
12
CHAPTER 2
Holding down the Ctrl key while dragging the mouse forward will tilt the view perspective up towards the ceiling or sky, while dragging backwards will tilt down.
Using the Ctrl key to tilt the view will not change your horizontal or vertical movements. For example, if you rst hold down Ctrl and drag the mouse backwards so that you are looking at the ground and then, releasing the Ctrl key, drag the mouse forward, you will still move in a forward direction even though youre looking at the ground. You will not move closer to the ground.
There is one other movement associated with the Shift key. Holding down the Shift key and moving the mouse to the side will shufe your view horizontally. This movement is called a strafe and it allows you to move linearly to either side. The strafe movements is very useful if you want to look at pictures, like those in a gallery, that are lined up on a wall side by side. These are all the movements possible within the Player. With a little practice, you will nd that you can combine movements to navigate wherever you wish to go within an environment.
To practice navigating within Atmosphere Player, follow these steps. 1 Load an Atmosphere environment, one can be found in the Help\Tutorials\Gallery folder under the directory where Atmosphere was installed. It should be a path similar to c:\Program Files\Adobe\Atmosphere\Help\Tutorials\ Gallery. After navigating to your folder in the open dialog, select the le Gallery.html and press Open. 2 Click on the Atmosphere environment to active it, then hold down the up arrow to move forward into the environment.
The scene changes after moving forward into the environment. 3 Return to your starting point by holding down the down arrow to move backwards through the environment. 4 Next hold down the left arrow key and youll spin around in the environment to the left. The right arrow key will do the opposite. 5 If youd like some elevation, hold down the Shift key while pressing the up arrow and youll ascend in the environment. When you release the up arrow, youll descend again if gravity is enabled.
14
CHAPTER 2
6 Holding down the Ctrl key while pressing the up arrow will tip your view up towards the ceiling. Holding the Ctrl key while pressing the down arrow will tip your view down towards the ground. 7 The last move to practice is a strafe. Hold down the Shift key and press the left arrow key. This will move you sideways to the left. Try it with the right arrow key to return to the original location.
Atmosphere Player Toolbar Buttons Icon Name Collide toggle Gravity toggle Show My Avatar toggle Chat Controls Preferences Users Avatars Bookmarks Description Enables collision detection in the environment Enables gravity in the world Shows your avatar in the environment Enables chat mode and opens the Chat palette Opens the Controls palette which may include custom controls Opens the Preferences palette for setting Player preferences Opens the Users palette which lists the other users in the current environment Opens the Avatar palette where you can change the current avatar Opens the Bookmarks palette which stores bookmarks of favorite sites
Detecting Collisions
You may notice as you move through Atmosphere environments, that you cannot move through solid objects such as walls and pillars. This is because the Collide option is enabled. The Collide button allows you to toggle this feature, enabling movement through solid objects when turned off. If you have trouble navigating a particular environment, you can disable the Collide button to m ake it easier to move around.
Setting Gravity
Another physical constraint in Atmosphere environments is gravity. If the Gravity toggle button is enabled while you are higher than the oor of the environment, then you, and avatar - if turned on, will descend until you come to rest on a solid object.
You wont descend unless both the Gravity and Collide button are enabled.
If there is no solid object underneath you, then you will continue to descend until the entire environment is out of site. If the Gravity toggle button is disabled, then you will hang in the air after releasing the mouse. If you ever nd yourself falling off the edge of environment, you can right click on the environment and select Navigation > Reenter World from the pop-up menu to restore yourself to the Entry Point location.
16
CHAPTER 2
Disabling Gravity and Collisions lets you easily ascend high above an environment.
You can also share Bookmarked environments with others during a Chat session. Sharing bookmarks is covered in Chapter 3, Interacting with an Atmosphere Environment.
18
CHAPTER 2
An environment with the default avatar visible. Click the Show My Avatar button on the toolbar to see the avatar.
Avatars, like bookmarks, can be shared with other users in an environment during a Chat session. Chapter 3, Interacting with an Atmosphere Environment, explains how to do this.
To change your avatar, simply select one from the library in My Avatars and drag it to the Current Avatar box. Atmosphere will load the new character and present it in the Atmosphere window. You can delete an avatar by selecting it in the My Avatars sections and pressing the Delete key. If you right-click in the My Avatars section, a Contextual menu will let you change the thumbnail size to Small, Medium or Large. If you delete one of the default avatars from the My Avatars section there is no way to recover it unless you reinstall Atmosphere.
20
CHAPTER 2
General Preferences
The General tab of the Preferences palette includes settings for the avatar Nickname and URL under the Personal Defaults heading. The Nickname will appear in the Chat palette along with any message you type when youre in Chat mode. It will also identify you in the Users palette to other visitors in the environment. To load a new avatar, simply enter the avatars URL into the Avatar URL eld and the avatar will show up as the Current Avatar in the Avatar palette. From here you can drag it into the My Avatars section. There is also a Show My Avatar option to make your avatar visible in the Atmosphere Player, which works the same way as the Show My Avatar button in the toolbar.
22
CHAPTER 2
The Preferences panel includes controls for dening Player behaviors. You can enable Collisions and Gravity and set values for Acceleration and Maximum Velocity under the Navigation heading. These options work the same as their respective toolbar buttons. The Acceleration value determines how quickly your avatar begins to move. A low Acceleration value will cause your avatar to start moving slowly and pick up speed the longer the arrow key is held down. A high Acceleration value will cause the avatar to move with Maximum Velocity as soon as one of the arrow keys is pressed.
The Acceleration and Maximum Velocity values are only used when navigating with the keyboard.
The Maximum Velocity value is the fastest speed that the avatar will move, regardless of how long the arrow key is held down. Both Acceleration and Maximum Velocity can range from 1 to 100. Dont be tempted to set the Acceleration and Maximum Velocity to their maximum value. Unless you are navigating a very large environment, maximizing these values will make the avatar motion difcult to manage.
Display Preferences
The Display tab of the Preferences palette lists and lets you choose your Preferred Renderer. Options include Hardware (Direct3D) and Software. If your computer system has a video card that supports hardware rendering, then you will see better performance and image quality by selecting the Hardware (Direct3D) option as the Preferred Renderer. Software rendering, although slower, will always work regardless of your system.
Even if you select the Hardware (Direct3D) option, hardware rendering may be unavailable if Atmosphere is unable to recognize your video card. Appendix A, Installing and Conguring Atmosphere, includes information on conguring Atmosphere to recognize your video card as well as a list of supported video cards.
The Display tab of the Preferences panel lets you choose to activate hardware rendering. The General Rendering Options let you select to Throttle When Not Active. This option will lower the frame rate of the Atmosphere environment when it is not the active window. By enabling this option, you are allowing your video card to perform other tasks when it is not being used to render the Atmosphere environment. The Use 24-bit Textures options allows higher resolution textures that support photo-realistic color. If disabled, the Atmosphere Player will use lower resolution images. This reduces image quality, but results in an environment that is rendered more quickly, which may be necessary on older systems with slower processors. This option requires that you restart Atmosphere. If you are viewing Atmosphere environments on an older system like a Pentium II, then the frame rate for the Player may be slow. There are several options in the Display tab of the Preferences palette that can help speed up Atmosphere. For the Software Rendering Options section, you can select to Use and/or Smooth Textures and Light Maps. Disabling these options will make the environment render more quickly, but will sacrice image quality.
i i
These options have no effect if the Hardware (Direct3D) option is enabled. Disabling textures will not cause the environment to load any faster. Even if textures are disabled, they will still be downloaded. The performance increase that comes by disabling textures is an increase in frame rate as you navigate the environment.
24
CHAPTER 2
To further speed the Players performance, you can also disable Light Maps. The Smooth Textures and Smooth Light Maps options will cause Player to anti-alias textures and light maps. To see the impact of smoothing textures, zoom in close to a texture.
By enabling the Smooth Textures option, the pixels in the textures are smoothly blended.
With the Smooth Textures option disabled, the Player performance is increased, but the textures will appear jagged.
26
CHAPTER 2
Chat Preferences
The Chat tab of the Preferences palette, includes options to Enable Chat, Enable Chat Logging, Print URLs of Shared Links and Enable Bookmarks. At times, you may wish to turn off some of these options to maintain privacy. Note that by right-clicking in an environment, a Chat item appears in the pop-down menu. You can control the behavior of the Chat window whether it appears at the bottom of the environment window or as a detached, oating window by toggling this option. Chat features are covered more completely in Chapter 3, Interacting with Atmosphere Environments.
The Chat tab of the Preferences panel includes options for controlling the Chat features.
Portals offer a way to link to other Atmosphere environments. You can select to move back and forward between linked environments using the Navigation > Back and Forward right-click pop-up menu commands. If a Portals squares are lying at, then it is not active. This could be due to an broken link or a server that is ofine.
28
Chapter 3
The Chat palette displays the text of online messages as users communicate with one another. You can also place the Chat window at the bottom of the Atmosphere environment by right-clicking and selecting Chat from the Contextual menu.
30
Chapter 3
The Chat palette can also be opened at the bottom of the Atmosphere Player interface.
Identifying Users
The Users palette lists all the current visitors in the environment. The names that are displayed are specied in the Nickname eld in the General tab of the Preferences palette. The Whisper option can be used to limit the Chat features to selected users. To have a private conversation with a specic user, check the Whisper box next to the user.
32
Chapter 3
Atmosphere environments can be controlled using standard web page controls. Above is a Cathedral environment that is integrated into a web page. The web page includes several controls that communicate with the Atmosphere environment. The Start Guided Tour button, for instance, will maneuver the visitor about the environment following preset paths.
An example of an environment that uses scripted interactive objects. This environment lets you click on objects that are oating in the scene.
Physics simulation
Atmospheres physics simulation engine and JavaScript API support physical simulations like gravity, collisions, magnetism, friction and wind. Figure 3-8 shows a realistic catapult that also interacts with the web page to allow users to load and launch a sphere towards a wall of blocks. When the sphere strikes the wall of blocks, the blocks fall naturally thanks to the physics engine.
34
Chapter 3
An example of magnetic attraction controlled by using the strength and falloff controls in the Controls palette. The Controls palette lets user change physical properties for objects in the scene.
36
Chapter 3
Workow
Asset Creation and Acquisition
Atmosphere scenes are composed of multiple assets. These assets can come from a variety of places. They can be created directly in Atmosphere, loaded from a library of pre-built objects, imported from other 2D and 3D design applications, or created at run-time using the Atmosphere Players JavaScript API (Application Programming Interface). Assets of an Atmosphere scene can contain geometric, appearance, animation, and interaction information. Some of the assets that make up an Atmosphere scene are:
2D Text Created at run-time 2D Sprites Loaded at run-time Props 3D Objects which are created in an external design application and either imported into a scene using
exported and loaded at run-time Script Objects - Imported into a scene using Atmosphere This phase of the Atmosphere workow includes asset creation (Solid Objects), asset import (Props, Surface Objects, Solid Objects, Script Objects), and asset import and conversion (Surface Objects). Atmosphere can import 3-D models, including animations, saved in the standard Viewpoint Media format (MTX and MTZ). 3-D objects created in Atmosphere can be wrapped with textures, which can be still or video images. Atmosphere supports video in AVI, WMV, MPEG and MOV (QuickTime) formats and still images in GIF, JPEG and PNG formats. Applications like Adobe Photoshop and Image Ready and Adobe Premiere can be used to prepare still images and video for use in Atmosphere.
38
CHAPTER 4
Scene Modeling
In this phase of the workow, you combine scene assets geometrically, modify their appearance, and specify the appearance of the scene as a whole. This is the process of building a spatially and visually coherent 3D environment or stage set. Geometric combination includes positioning 3D assets and possibly scaling them in relationship to each other. Appearance editing includes applying color and textures to 3D object surfaces, and editing imported surface properties. Textures can include local or streamed video content in popular formats. Finally, global illumination computation can be used to make all the assets in the scene work together visually in a more realistic way.
Interaction Modeling
In this phase, interaction is added to the scene and to the objects within it. This is done by attaching scripts to the scene and its individual objects and by wiring Script Objects to other Scene Objects and to each other.
Publishing
In this phase, the esulting environment is ouput in a form that can be immediately embedded in either a web site or a PDF document. All assets known to Atmosphere are combined in a single directory, URL references are made relative and resolved to the moved assets, and a Web browser with the Atmosphere Player is brought up to preview the published content, if desired. The published folder can then be copied intact to a Web server or embedded in a PDF document for nal publication.
New Concepts
Before diving into learning the specics of Atmosphere, it will be helpful to understand some basic concepts.
Preparing Content
Successful projects depend on good planning, and Atmosphere projects are no exception. Paper sketches and a rough plan can save wasted effort later on.
3-D geometries are manipulated using the wireframe views. The Player View is used to apply colors, textures, and lighting. The wireframe views can be changed to show different perspectives such as Top, Front, Right and Perspective. The shaded view is also called the Player View and it shows the environment as it will appear in the Player.
Although the Player View shows textures and lighting, it does not preview scripted behaviors. To make it easy to fully test environments, including behaviors, Atmosphere offers one-click publishing, which publishes the environment and immediately launches it in a Web browser window hosting the Atmosphere Player.
Atmosphere uses editors to change content specic to the two view types. The wireframe views shows the skeletal underpinnings of the 3-D environment, while the shaded Player View shows the scene as it will actually appear to users. There are three editors in Atmosphere the Scene Editor, the Solid Object Editor, and the Appearance Editor. The Scene Editor and Solid Object Editor are related and work in the wireframe views, while the Appearance Editor works in the Player View. The actions you can perform depend on the editor that you are using in the currently active view. For example, colors, textures, and lighting can only be applied using the Appearance Editor. The Scene Editor manipulates the entire environment. All of the objects are treated as a single scene, like a theatre set, where you, the director, make the action unfold by placing props and actors for greatest effect. The Solid Object Editor is used to create and modify individual Solid Objects, which can be used as assets in the scene. For example, you could use the Solid Object Editor to assemble a chair from simple geometric shapes called primitives, and then toggle back to Scene Editor mode to place the chair with other objects. You might also use the Solid Object Editor to create rooms, and use the Scene Editor to combine these rooms into a complete building. The Appearance Editor allows you to apply sophisticated lighting effects to scenes, and colors and textures to the surfaces of objects. Finally, the Scene Editor is used to apply interaction to scene elements. Changing editors can be accomplished in a number of ways. To enter the Solid Object Editor, double-click the object that you wish to edit. To enter Scene Editor, double click on the background away from any objects. The wire frame view background color changes to distinguish the modes a blue tint indicates the Solid Object Editor is active.
40
CHAPTER 4
The window title bar also changes to indicate which editor is active. Using these editors is covered in more detail in Chapter 8, Using Scene Objects, and Chapter 9, Assembling Solid Objects.
This Hierarchy palette shows an organized view of all the objects that make up the current Solid Object. Objects in Hierarchies can be grouped. For example, a house scene can include a door object, which includes a doorknob group, which includes a lock object.
Presets
Another concept in Atmosphere is the Preset. Presets are Atmosphere resources, like textures, that are organized in a library that makes it easy to view and select the right object. For example, textures in the Paint Presets can be applied by selecting them and clicking on objects. Presets, contained in the Paint and Object Presets palettes can include colors, textures, Viewpoint Objects, models and scripts.
Presets are references to resources that are accessed via palettes like the Paint Presets palette.
Presets appear as thumbnails or icons in the Presets palette. Since these thumbnails are only references to the actual resources, deleting a texture preset doesnt delete the texture le, only the reference to the le. When an environment is published, Atmosphere reads the reference to copy the resource le to the published le. Presets can be saved into different sets using a Manage Sets dialog box which allows you to create and manage sets via a Set drop-down list at the top of the Presets palette. For example, texture sets could include metal, wood, roong, grass, etc. allowing you to quickly navigate large libraries of resources.
Script Objects
One of the most powerful aspects of Atmosphere is the ability to associate scripts with objects or scenes. Atmosphere ships with a library of pre-built Script Object Presets (like Fog and Rotation) that allow even those who are new to scripting to associate behaviors with objects or scenes. Drag a script preset to the Scene view and the Inspector palette will display properties for controlling the behavior of the script. Changing these properties will change the scripted behavior. Atmospheres JavaScript API includes support for the built-in Havok physics engine. This engine includes realistic simulation of many physical behaviors including collisions, springs, wheels, wind and uids. Chapter 14, Adding Interactivity with Scripts, covers using Script Object Presets.
42
CHAPTER 4
Solid Objects
This is a geometric object type that is built directly in Atmosphere. You can create and edit these objects using the Solid Object Editor. Solid Objects, are constructed by combining a small set of primitives such as Box, Cylinder and Cone into arbitrarily complex constructs using boolean operations (sometimes called Constructive Solid Geometry, or CSG). Solid Objects can be lit and textured in the Appearance Editor. Solid Object creation is covered in Chapter 9, Assembling Solid Objects.
Viewpoint Objects
Viewpoint Objects are 3-D models created in other applications and imported into Atmosphere using the Viewpoint Media format (MTX, MTZ). Viewpoint Objects carry their own lighting and textures and cannot be globally lit by Atmosphere. They can contain animations that can be controlled by the JavaScript API at run-time. Currently, Viewpoint Objects directly loaded into an Atmosphere scene act as the props in that scene. Viewpoint Objects are covered in Chapter 8, Using Scene Objects.
Surface Objects
Surface Objects are 3D mesh objects in a format native to the Atmosphere platform. They provide a way in which users can import external 3D scene components (including geometry, UV coordinates, and texture properties), and use them as full citizens of an Atmosphere scene. In this way, parts of an environment can be constructed as Solid Objects using Atmosphere, and parts can be created in external design applications and imported into Atmosphere. External formats must be converted into Viewpoint format in order to be imported and converted to native Surface Objects. Once imported as Viewpoint Objects, they are then converted into Surface Objects using Atmospheres Object > Convert to Surface menu command. Surface Objects are included in global illumination processing and will cast and receive soft shadows within the scene. Surface objects can also be textured in Atmosphere, or the textures that were imported with them can be edited. The basic form of Surface Objects cannot be edited using Atmosphere and the conversion process loses any animations that were associated with the original Viewpoint Objects that were imported and converted. Surface Objects are covered in Chapter 8, Using Scene Objects.
The Atmosphere interface includes menus, tabbed panes, palettes, toolbars, and view windows.
Many features can be accessed in several different ways. For example, you can create a new view using the Views menu, the context menu or a keyboard shortcut. All three methods perform the same function.
44
CHAPTER 5
Menus offer visual clues for keyboard shortcuts, dialog boxes and submenus. Some menu commands, such as File > Save As, have an ellipsis (three dots in a row) next to the menu command. This indicates that the menu command will open a dialog box. Some menus items appear in light gray type, indicating that they are not available. An example of this is the Objects > Ungroup command isnt enabled unless a grouped object is selected. To the right of some menu items, a keyboard shortcut is listed, allowing these commands to be triggered from the keyboard. Ctrl+S means hold down the Control key while typing S this is the keyboard shortcut for the File > Save command. A complete list of keyboard shortcuts can be found in Appendix B, Atmosphere Keyboard Shortcuts. All menus can be accessed using the keyboard by holding down the Alt key and pressing the letter that is underlined on the main menu. For example, pressing Alt+F will select the File menu. Once a menu item is selected you can use the arrow keys to move up and down the current menu or the left and right arrow keys to move to adjacent menus. Pressing the Enter key will execute the selected menu option.
of the File menu is a list of recently opened les. Selecting one of these choices will re-open the selected le. The File menu commands are covered in more detail in Chapter 6, Working with Files.
Keyboard shortcuts are useful for working efciently in Atmosphere and are included in parentheses in the manual text.
46
CHAPTER 5
Atmospheres main window with two toolbars that have been docked to the top of the window, the options toolbar docked to the bottom, and two that are left oating. Drag or Double-click on the toolbar title bar to dock it to the top or bottom edge of the window. As an aid to learning and remembering the tools, a tooltip a text box containing the name of the tool appears when you position the mouse cursor over the tool. The tooltip also lists the keyboard shortcut if one if available, e.g. the tooltip for the rst icon in the Tools panel reads Selection Tool (V) meaning Ctrl+V is the keyboard shortcut for this tool.
Tools
The Tools toolbar includes tools to select, manipulate, zoom and navigate:
General Toolbar Tools Icon Name Selection Tool (V) Direct Selection Tool (A) Rotate Tool (R) Scale Tool (S) Orbit Camera Tool (C) Hand Tool (H) Dynamic Zoom Tool (D) Zoom Tool (Z) Navigate Tool (N) Description Used to select objects Used to select objects and/or connectors Used to rotate objects Used to scale objects Used to spin the camera along its center axis Used to pan the current view Used to zoom by clicking and dragging Used to zoom by dragging an area in the view Used in the Player View to navigate
Scene Tools
The Scene Tools are used for placing scene objects. These tools are only available when the Scene Editor is active.
48
CHAPTER 5
Scene Toolbar Tools Icon Name Place Scene Object Preset Place Empty Solid Object Script Portal Entry Point Anchor Description Places the currently selected Scene Object Preset in the scene Places an Empty Solid Object in the scene Places an Script in the scene Places a Portal in the scene Places an Entry Point in the scene Places an Anchor point in the scene
Texture Tools
The Texture Tools toolbar is used to apply, edit and remove textures from objects. These tools will only be available when an Appearance Editor window (also called a Player View) is selected.
Texture Toolbar Tools Icon Name Edit Texture Tool Remove Texture Tool Sample Texture Tool Apply Texture Tool Description Selects textures and displays texture properties in the Inspector palette Removes texture from the object Loads texture properties in the Inspector palette Applies texture to the object or face
The Options toolbar offers an easy way to position items precisely. The Options toolbar ts nicely along the bottom edge of the interface.
Palettes can include several tabbed panes. Palettes can have a menu, accessed by clicking on the triangular arrow icon in the upper-right corner, that includes additional commands. If the palette has no menu, the icon button is disabled. Clicking on the red X in the upper-right corner will close the palette. You can reopen a palette using the Window menu. Just like toolbars, palettes can be docked. To dock a palette, drag it to the menu bar or the edge of the atmosphere window and release the mouse. You can open a docked palette by clicking on its tab. Clicking a second time on the tab will retract the palette. This provides easy access to palettes without consuming screen real estate. Be aware that if you dock a palette you will not be able to access its palette menu. However, you will be able to access all the palette menu commands from the palettes right-click menu.
50
CHAPTER 5
The interface with all toolbars and palettes docked, congured to maximize screen space.
History palette
The History palette includes a list of all the actions done in the Scene Editor and the Solid Object Editor. Selecting an item in the History palette will return the state of the active view to reect the actions up to that point, just as if youd repeatedly used the Edit > Undo (Ctrl+Z) menu command. If you select an action in the History palette and then perform another action, all actions that follow the selected action will be deleted.
52
CHAPTER 5
The History palette enables you to undo several commands at once. The History palette includes a pop-up menu with two options Options and Clear. The Options menu command will open a dialog box where you can specify the number of Maximum States to keep in the history. The Clear command will remove all items from the current History palette without changing the scene. This also makes the Undo command unavailable. Using the History palette is covered later in this chapter.
Inspector palette
The Inspector palette displays properties and options available for the currently selected object, tool or preset. For example, when the Cone Object tool is selected, the Inspector palette includes settings for the number of Faces and the size of the Top and Bottom Radius for the cone. The Inspector palette shows tabbed panes that change depending on what is being inspected. For tools and objects in the Scene and Solid Object Editors, the General and Scripting tabs are available. In Player View, the Surface and Light Map tabs are available for inspecting colors and the Surface, Light Map, Texture and Movie tabs are available for inspecting textures.
General tab When a single object or a group is selected in the Solid Object or the Scene Editor, the General tab will be available. It includes a eld for entering an object Name. It also includes options for making the object Locked, hiding the object in the wireframe or Player views, and, for the Solid Object Editor, making it Subtractive. It also includes any additional parameter values for the selected object. Scripting tab The Scripting tab includes a text eld in which to enter or edit the URL for a JavaScript script that can
be attached to the object, primitive, or group. The Edit button will open the script for editing in a Text Editor. You can learn more about working with scripts in Chapter 14, Adding Interactivity with Scripts.
For colors and textures, the Inspector palette offers this set of tabbed panes. The Light Map tab has a control that turns the Light Map on or off. You can also specify Light Map Brightness and Sampling Density. More information on Light Maps can be found in Chapter 13 Working with Lights. For Textures, two additional tabs appear Texture and Movie. The Texture tab includes a Scaling Type, which can be set to Pixel, Tile, Parametric or Projective. There is also an option to constrain proportions when scaling. The Size and Offset values control how big the image is and where the upper left corner of the image is located. The Rotation value will rotate the texture about its center, counterclockwise for positive values and clockwise for negative values. The Texture URL eld lets you select the location of the texture image le.
54
CHAPTER 5
The Movie tab lets you set the number of times the movie loops and the volume of the movies sound. The details of editing textures are covered in Chapter 12, Manipulating Textures.
Hierarchy palettes
Atmosphere has two hierarchy palettes: Scene Objects Hierarchy and Solid Objects Hierarchy. The palettes are similar, but they contain very different sets of information. The Object Hierarchy palette includes a complete hierarchical list of all the objects or primitives contained in a Solid Object. Each item is listed on a separate row with easy access to settings for enabling and disabling visibility, locking, subtraction and scripts associated with the object.
The Object Hierarchy palette shows all the objects that make up a Solid Object.
The Scene Hierarchy palette shows all of the Scene Objects in the current documents scene in a hierarchical list. It also includes columns for enabling and disabling visibility, locking and scripts. Both palettes provide an easy way to select, rename and move objects into and out of groups.
Presets alettes
There are two Presets palettes. The Paint Presets palette holds presets for colors and textures (which can include movies) and the Object Presets palette holds presets for models, Script Objects, and Viewpoint Objects. Colors in the Paint Presets palette have a separate paint bucket icon indicating the selected color, and textures are shown as image thumbnails. Selecting these icons and thumbnails lets you apply colors and textures to objects surfaces in the Appearance Editors Player View window.
The Paint Presets palette holds colors and textures. The Objects Presets palette holds all imported scene objects. These objects can be Atmosphere models, Viewpoint objects, or Script Objects. Scene objects imported into this palette can be placed in a Scene Editor view.
56
CHAPTER 5
The Object Presets palette holds imported models, scripts and Viewpoint objects.
The History palette doesnt keep track of actions performed in the Appearance Editor (Player View). If you perform a new action after jumping back in the History list, the former subsequent actions are lost.
The total number of commands that are remembered in the History palette can be set in the the Maximum States value in the Options dialog box accessed in the yout menu of the History palette.
Customizing Atmosphere
There are several ways to customize Atmosphere by setting preferences. These options are found in the Preferences (Ctrl+K) dialog box, opened with the Edit > Preferences menu command. Additionally, Atmosphere, like other Adobe products, remembers the interface changes that youve made and will return to the same layout the next time you launch Atmosphere. The Preferences dialog includes sections for dening how Atmosphere les are saved, how the grid is used during editing, and the displayed colors.
58
CHAPTER 5
Output Settings
To make Atmosphere les smaller, you can enable the Save in Compressed Format option. Compressed les take up less disk space and download faster, but they need to be uncompressed before they can be used. This is a one-time action that happens when the environment is rst loaded. The Launch Web Browser on Publish option will open a specied web browser once the Publish command is used. You can select the web page to load when the browser is launched by typing in a URL.
Display
The second section of the Preferences dialog box includes controls that affect the Display including options that apply to the wireframe views including Grid, Snap to Grid, Guidelines and Shadows. You can also set the grid Spacing and Subdivisions. The default is set to 10. Units can be set to be Feet, Meters, Inches, Yards, Centimeters, Millimeters, Miles, or Kilometers.
All scripting values refer to units in feet regardless of Display Preferences settings.
Colors
Atmosphere uses colors to indicate states. For example, a selected object is displayed in red. If you prefer to display selected objects as yellow, click on the color next to Selection and use the color picker to change it to yellow. Henceforth all selected objects will appear yellow instead of red. The Reset Colors to Defaults button will reset colors to the factory defaults.
60
CHAPTER 5
62
CHAPTER 6
The File > Open menu command will open a Windows File dialog box from which you canselect a le to open. This is a standard Windows le dialog box. Using the buttons to the left, you can choose other directories. There are also icon buttons that will let you Go Up a Directory, Create a New Folder and View the les in the current directory as Thumbnails, Tiles, Icons, List, and Details. With a le selected in the le dialog box, you can open it by double clicking on the lename or by selecting it and pressing the Open button. You can also drag an ATMO le from Windows Explorer and drop it into Atmosphere to open it.
Saving Environments
One of the most important menu commands is the File > Save (Ctrl+S) menu command, which saves the current environment. The File > Save As (Shift+Ctrl+S) menu command will open another File dialog box in which you can give the current le a different name and/or location to be saved. The name given to the environment in the le dialog box will be displayed in the title bar of each of the views. The Preferences dialog box (Ctrl+K) includes an option to Save Files in Compressed Format. If this option is enabled, then the les will be compressed before saving. This can greatly reduce the le size the example le reduces from 743 kb to 115 kb with the Compressed Format option enabled.
Compressed Atmosphere les will have the same AER le extension as uncompressed les. The Atmosphere Player knows whether the le is compressed or uncompressed by data stored in its header.
Closing Environments
The File > Close (Ctrl+W) menu command will close the currently open document. If the le has not been saved since the last change to it, a dialog box will ask if you wish to save your changes. The Close menu command will not exit the application. You can also close the le by clicking the red X close buttons at the top of all currently open view windows. However, you will then have to reestablish your preferred Views setup after opening the next Atmosphere document.
Importing Files
The File > Import menu includes several different options Models, Scripts, and Viewpoint Objects. Each of these options will import a different le format. In the le dialog box, you can select multiple les to be imported by holding down the Ctrl key and clicking individually on the les to select or by holding down the Shift key and selecting the rst and last items in a range of les. All selected les will be imported at one time.
Importing Models
When the File > Import > Models menu command is selected, you can import an existing Atmosphere project le into the current scene. This menu command is only available when a wireframe view is selected. These les must have the ATMO le extension. Imported models will appear in the scene in the same location as that to which they were saved. Imported models will be listed in the Scene Hierarchy as <Model>. You may wish to save objects you create in Atmosphere to a Models or other directory so that they can be imported and reused as needed.
64
CHAPTER 6
Importing Scripts
Scripts are used to control the behavior of objects and environments. The Import menu will open JavaScript (JS) les. Scripts are Scene Objects and can only be imported when the Scene Editor is active. Imported Script Objects will appear at the origin of the current scene. Scripts are covered in more detail in Chapter 14, Adding Interactivity with Scripts, and Appendix C, JavaScript API Documentation.
66
CHAPTER 6
Imported textures will be displayed in the Paint Presets palette as thumbnails. If you move the mouse cursor over the top of the thumbnails, the path to the texture image will be displayed as a tooltip. You can learn more about colors and textures in Chapter 11, Applying Colors and Textures.
Imported textures appear as thumbnails in the Paint Presets palette. If a source texture image le is moved after it has been imported, its thumbnail in the Paint Presets palette will show a red URL? icon to indicate that the image le can no longer be located.
Missing texture les are marked with this icon in the Paint Presets palette.
While holding down the shift key, click on the wood16.jpg le. Click the Open button.
The Object Presets palette can hold models, scripts and Viewpoint Objects.
68
CHAPTER 6
The Manage Preset Sets dialog box lets you create and manage sets of objects and textures. Once a new set is created, you can add presets to it using the Add Presets menu commands found in the Object and Paint Presets palettes. The new presets will then be added to the selected set. If you look in the directories where presets are stored, you will nd Atmosphere has created le names such as Material001.amt, Model001.asc and ScriptObject001.ajs. These small les hold parameter information for the preset. The preset le type can be identied by its extension; amt for textures, amc for colors, asc for models, ajs for scripts and avp for Viewpoint Objects. Atmosphere uses the operating systems native le system as an integral part of its presets management system. A Preset Set is simply a named directory on your disk. When switching to a Preset Set, all presets of the appropriate type (Paint or Object) will be read from the specied directory and loaded into the Presets palette. You can rename a Preset Set at any time, and also change the directory on your disk that it points to. You can use the operating system, independently of Atmosphere, to reorganize presets across various directories by simply moving, copying, or deleting preset les.
Exporting Objects
The File > Export menu includes a single command - Model. This command is available in the Scene and Solid Object editors is enabled when an appropriate subset of objects is selected in either the Scene Hierarchy palette or the Objects Hierarchy palette. An exported model is saved as an ATMO le. Selected objects are exported with their positions relative to their active coordinates. When exported models are imported into other scenes, the objects will be placed at the origin of the current scene and the parts of the object will be placed relative to the origin. For example, lets say you create a Solid Object icon in the Scene view at 10ft on the X-axis and place a Box object belonging to the Solid Object at 25ft on the X-axis. If you select and export the Box object, it will appear at 15ft on the X-axis when imported into a new scene.
You can export as a model an entire subset of the current scene, including a collection of interlinked Scene Objects and Script Objects. In this way, you can create a library model that includes both objects and their behaviors. When importing such a library model back into a new scene, all of the objects, with their behaviors, will be loaded and reconnected together.
The World Settings dialog box includes environment settings such as name and URL. The File > World Settings (Alt+Ctrl+S) menu command will open a dialog box in which you can give the entire environment a name and specify where it will be located on the web. You specify the environments home server and path in the Reference URL eld. The Server URL eld species the location of the server used to enable chat and synchronization features. The Topic eld is used to identify the type of environment and can be a descriptive keyword or two. For example, a product storefront scene could have the Topic set to commerce.
Publishing
Publishing is the nal process that compiles all of the your projects geometry, lighting, texture, media types and behavior into an AER le, and places it on a server (or locally for testing). The process is initiated using the File > Publish > World (Ctrl+P) or File > Publish > Model menu commands. Publishing a model will only save the selected
70
CHAPTER 6
object as an AER le. Publishing a world will launch a web browser and display the Atmosphere environment in all its glory. You can learn more about publishing in Chapter 15, Publishing Atmosphere Scenes.
Publishing a scene opens it in a web browser, but publishing a model does not.
Chapter 7: Views
Since computer monitors are 2-D devices, content creators have to switch views frequently to check the dimensions and position of the 3-D objects they create. This might not be immediately apparent to people used to 2-D authoring applications. Atmosphere displays projects in two types of views. Wireframe views show just the lines at the edges of objects and are used for geometric creation and editing tasks, while the Player View is a preview of nal visual results and performance, with textures and lighting (global illumination) applied. Experienced Atmosphere designers often keep several views of the same scene open so that they can check the size and placement of objects in all three dimensions. Atmosphere has commands that will automatically open multiple views in three or four windows placed for easy object viewing.
Introduction to Views
Atmospheres three editors display scene contents in either wireframe views or the Player View. The Solid Object Editor and the Scene Editor display objects using wireframe views and the Appearance Editor displays objects in the Player View. Wireframe views show the lines that make up edges of objects and are commonly used in 3-D applications to create and modify the geometry of objects. In Atmosphere, wireframes are used to create and edit the geometry of objects and to compose scenes by applying geometric transformations to these objects. The Player View is a preview of the scene including lighting, and textures. The Player View shows the scene as it will appear in the Atmosphere Player. Scripted behaviors, run-time interaction and loaded models, sound, video, physics (with the exception of Player navigation), and dynamic lighting will not appear in the Player View. In order to test the full experience of an Atmosphere environment, the user must publish the scene and view it in a copy of the Atmosphere Player, usually within a Web browser. The Publish feature of Atmosphere will do this automatically for you. Wireframe views can be switched to eight preset positions by right-clicking in a Solid Object or Scene Editor window and selecting the Preset Position menu item. The Preset Positions are grouped in two sets in the menu: Top (F5), Front (F6), Right (F7) and Perspective (F8) in one group, and Bottom (Shift+F5), Back (Shift+F6), Left (Shift+F7) and Isometric (Shift+F8) in the second. Note that the Shift key toggles the reverse perspective for the Top, Front and Right positions. F5 shows Top view while Shift+F5 shows bottom view etc. The Player View position is independent from the wireframe views and is controlled by the Navigate tool in the Tools toolbar.
72
CHAPTER 7
The Solid Object Editor is used to compose primitives into more complex objects like this fountain.
Scene Editor
The Scene Editor is used to place scene objects and also has eight wireframe positional presets. When the Scene Editor is active, the Scene Tools toolbar is active.
Notice that the background color changes when selecting Solid Object and Scene Editor. By default the Solid Object Editors background is a dark blue and the Scene Editors background is a dark gray.
The same water fountain viewed in perspective in the Scene Editor. The Scene Editor is used to work with scene objects. You can switch between The Scene Editor and Solid Object Editor by selecting a Solid Object and choosing the Object > Edit Selected Object menu command (or by double clicking on the Solid Object in the Scene view). You can switch from Solid Object Editor to Scene Editor by double-clicking in the background away from any objects.
74
CHAPTER 7
The fountain once again in the Player View. The Appearance Editors Player View lets you see objects as they will appear in the Atmosphere Player.
When the Entry Point object is selected, the Inspector displays buttons that allow you to sync the locations of the Actor and Entry Point objects.
76
CHAPTER 7
The Reference Point object displays the orientation of the X, Y and Z axes.
Selecting a Layout
With more than one view window open, it can become difcult to nd a specic view. The View > Layout menu offers commands to organize and select windows. Cascade Views will align all view windows so the title bar for each window is just below and offset from the one above it.
78
CHAPTER 7
Cascading views are positioned so you can see the title bar of each view. The View > Layout > Tile Views menu option will place all view windows side by side, lling the screen with equalsized windows.
Tile Views places equal-sized windows side-by-side. Note that each wireframe window has a different view. The View > Layout > Mosaic Views menu option will open the current view in a large window and place other views in small windows to the right.
80
CHAPTER 7
The Mosaic Views option maximizes the active window and places the other views off to the side. The View > Layout menu offers window layout options consisting of one to four view windows. Selecting View > Layout > one View will open a single Top view window. Selecting View > Layout > 2 Views will open Top and Front cascading views. The View > Layout > 3 Views option will show a Top, Front and Player View windows with the Top view being the largest. Finally, the 4 Views option will open Top, Front and Right views along with a Player window.
Panning a View
When a new wireframe view appears, the center of the grid is located in the center of the window. You can pan the view to a different location using the Hand tool (H) . With the Hand tool selected, click and drag to move the scene in the window.
You can also grab and pan the current wireframe view using the spacebar. Holding the spacebar down will change the cursor to the Hand icon, allowing you to drag the scene with the mouse.
Zooming a View
To zoom in or out of a scene in wireframe view, use the Zoom tool (Z) or the Dynamic Zoom (D) tool.
The Zoom tool will zoom in with each left-click of the mouse. Holding down the Ctrl key causes the + sign in the magnifying glass icon to change to a and left-clicking will zoom out. You can also click and drag a rectangle around an area, and the area will zoom to ll the window when the mouse button is released. The Dynamic Zoom tool lets you zoom continuously using the left mouse button and dragging forward to zoom in and backward to zoom out. Both tools support a mouse equipped with a scroll wheel. Forward scroll zooms in, and backward scroll zooms out. Another way to zoom in and out of the view in steps is by using the View > Zoom In (Ctrl++) and View > Zoom Out (Ctrl+-) menu commands.
Rotating a View
The Orbit Camera Tool (C) lets you rotate a view about its center point by dragging in the view.
You can also rotate the view using the View > Rotate Clockwise 90 degrees and View > Rotate Counterclockwise 90 degrees menu commands. With the Orbit Camera Tool (C) selected, hold down the Ctrl key to rotate the view about any axis.
Resetting a View
Its easy to get lost in wireframe views, especially if you are new to editing in three dimensions. You can reset the view to place the grid origin in the center of the window with the View > Reset Views (Shift+Ctrl+R) menu command.
82
CHAPTER 7
Zooming to t Objects
The View menu includes two useful commands that zoom the current view to t all the current objects or just the selected object. View > Fit All (Ctrl+0) ts the whole scene to the current window. View > Fit Selected (Shift+Ctrl+0) ts just the selected objects. The Fit All and Fit Selected features can also be used in the Player View.
The Fit All command will zoom and pan the current view so all objects are visible.
3 To see the objects in the scene, select View > Fit All (Ctrl+0). This will zoom and pan the window so all objects are visible in the Top view. 4 Select View > New View (Shift+Ctrl+N) to open a new view window. This new view window will also be a Top view. 5 With the new view window active, select View > Preset Position > Front (or press the F6 key). Use the View > Fit All (Ctrl+0) command to see all the objects in this view. 6 Select View > Player View (F4) to open a Player View window to see a shaded version of the scene. 7 Select View > Layout > 4 Views to open four view windows. This will add a Right view. 8 Select each view and use the View > Fit All (Ctrl+0) command to t the objects in the view.
The nal layout has four views with the object tted to each view.
84
CHAPTER 7
All Scene Objects presets are identied with this icon and a title.
86
CHAPTER 8
When you click on an object in the Objects Presets palette, the Scene Object button in the Scene Tools toolbar will be selected automatically. By holding down the Shift button while placing an object in the Scene Editor, you can create multiple copies of the object.
Atmosphere native Surface Object type, Viewpoint Objects are considered props. That is, they do not participate in global illumination calculated by Atmosphere, nor can they be edited in most ways in Atmosphere (they can be positioned, scaled, and rotated as a whole, however). The advantage of props is that they do continue to retain most of the characteristics they had when exported from the design application in which they were originally authored (including key-frame animations, special surface properties, and so on), and they can be controlled at run-time through the JavaScript API. Use props for dynamic objects within the scene. When importing a Viewpoint Object to be used as a full-edged citizen of the scene (part of the environment), import the Viewpoint Object and then use Atmosphere to convert it to a Surface Object. Large, complex Viewpoint Objects with thousands of polygons can cause Atmosphere to perform sluggishly. Before saving a 3-D model to be used in Atmosphere, optimize the model by reducing it to the smallest number of polygons possible. Viewpoint Objects can be imported using the File > Import > Viewpoint Object menu command or from a preset loaded into the Object Presets palette. Viewpoint Objects that are imported will initially be placed at the Scenes origin, while Viewpoint Objects added from the Object Presets palette can be placed anywhere in the Scene by clicking at that point. Select the object icon in the Object Presets palette, then click in the Scene at the point where you wish to position the object. Holding down the Shift key allows placing multiple copies of the Viewpoint Object.
Viewpoint Objects can also include animation sequences which are controlled by the JavaScript API at run-time See chapter 14, Adding Interactivity with Scripts.
With the Scene Editor active, select File > Import > Viewpoint Object. Select a Viewpoint Object to add to the scene, then click the Open button (Viewpoint Object les must have the MTX, MTZ or XML le extension). The Viewpoint Object will appear at the origin of the Scene view.
88
CHAPTER 8
Select and drag the Viewpoint Object to the position you wish. You may need to use several different views to correctly position the Viewpoint Object.
3 To reposition the Viewpoint Object, select it and drag it to a new location. Presets make it easy to add multiple copies of an object to a Scene.
Other Scene Objects like Solid Objects can also be moved and scaled in the Scene Editor that same way as Viewpoint Objects.
90
CHAPTER 8
The export path to Viewpoint format from major 3-D software packages Software package 3ds max Maya LightWave SoftImage Bryce Poser Carrara TrueSpace Viewpoint exporter? Yes Yes Yes No Yes Yes Yes Yes obj Export rst to...
92
CHAPTER 8
An imported Viewpoint Object of a robot standing next to a grandfather clock, a Solid Object created in Atmosphere. Note that the grandfather clock casts a shadow after Atmosphere has computed global illumination for the scene, but the robot does not. You can convert Viewpoint objects into native Atmosphere Surface Objects with the Object > Convert to Surfaces menu command. Using this command will convert the Viewpoint Object into a Surface Object.
Atmosphere will not let you convert a Viewpoint Object to a Surface Object until the project le has been saved.
Surface Objects are included in Atmospheres Radiosity lighting calculations and can be textured in Atmosphere. Surface Objects lose any animated sequences that they may have contained before conversion.
After being converted to a Surface Object, the robot can be lit and textured in Atmosphere. When Viewpoint Objects are converted to Surface Objects, the applied textures are saved as PNG les.
Creating Avatars
Atmosphere can also be used to create avatars. In fact, many of the existing preset avatars were created using Atmospheres primitives, including the default blue man. Atmosphere avatars must be sized and positioned carefully, if they are to appear in the environment correctly. If you create an avatar in Atmosphere, position the avatar so its eye is at the scenes origin point. This is where the virtual camera will look out from the model when the Avatar is loaded with the Player.
94
CHAPTER 8
An avatars eye level must be aligned with the scenes origin to appear correctly in the Player.
Creating a Portal
Portals link Atmosphere environments. When a user enters a Portal in the Atmosphere Player, a new environment is loaded and the viewer nds themselves in a new place. Portals are represented in Player by glowing red, blue and green panes which rotate in space just above eye level. Portals are created and positioned using the Scene Editor. With the Scene Editor active, select the fourth icon from the left on the Scene toolbar. Click on this tool, then click at the position where you wish to add the Portal. With the Portal object selected, the Inspector palette includes a Target URL parameter. Enter the URL of the environment to which you wish to link.
A Portal will connect to the environment entered in the Target URL box.
The Actor is represented by a small person icon in wireframe views. As you navigate in Player View, the Actor will move in sync in the wireframe view.
96
CHAPTER 8
The Inspector palette for the Entry Point object includes buttons to change the Entry Points location. The Inspector palette also allows you to give the Entry Point a Name (if its not the default) and a Title. An Atmosphere scene can have several Entry Points.
Using Anchors
Anchors are used to mark positions in space. With an Anchor object dened, you can script actions based on the Anchors position. For example, you could position several Anchors that dene a path and then use a script to move visitors along that path, from Anchor to Anchor.
Anchors are also available in the Solid Object Editor. Anchors that are created as part of a Solid Object will move along with the other primitives in the Solid Object Group that contains them. An Anchor created in the Scene Editor (a Scene Anchor, versus a Solid Object Anchor) will move along with the other Scene Objects in the Scene Group that contains them.
Be aware that even though a scene Solid Object is locked, components of Solid Objects selected by double-clicking in the Scene Hierarchy can be edited in the Solid Object Editor.
Setting Visibility
You can set objects to be Visible in Wireframe Views and/or Visible in Player View using the options found in the Inspector palette. You can also turn wireframe visibility on and off using the Visibility column in the Scene Hierarchy palette. When a Scene Object is designated to be visible in the Wireframe views, an eye icon will appear in the objects row in the Scene Hierarchy palette. The Visible in Player View option is not shown in the Scene Hierarchy palette. This option is not available for the Script and Portal scene objects. Making objects temporarily invisible in the Player will come in handy as you work with lighting.
98
CHAPTER 8
Adding Primitives
To place a primitive object in the Solid Object Editor, click an icon in the Solid Object toolbar, then click in the Solid Object Editor window at the location where you wish to place the object. If you hold down the mouse button when placing an object, you can drag the object around to a new position.
The Solid Objects toolbar holds all the primitive objects. To create another identical object, either select the icon in the toolbar again or use the Edit > Duplicate (Ctrl+D) menu command. Once an object is created, the Selection Tool (V) is automatically selected again. By holding down the Shift key while creating a primitive, you can create multiple copies of the selected primitive without having to click in the Solid Object Tools toolbar again. When you have nished adding primitives to the Solid Object, double-click anywhere in the background to re-enter the Scene Editor in which the entire Solid Object can be moved, scaled, and rotated together as a single unit. Doubleclicking in the Solid Object will return to the Solid Object Editor.
100
CHAPTER 9
performed in order to generate this top-level Solid Object. In the Scene Editor, Solid Objects appear as rigid bodies which can be moved around, rotated, and scaled as a whole.
102
CHAPTER 9
Naming Objects
Once an object is created (a Primitive or a Group), it will appear in the Object Hierarchy palette with its type listed in brackets. To name the object, select it and type a name in the Inspector palettes Name eld. Alternately, select the primitive in the Object Hierarchy palette and click on the name. The eld will become editable and you can change the name. Note that the object type will still appear next to the name in brackets. Any object in the Object Hierarchy can be named in this manner, including Solid Object Groups. Objects in the Object Hierarchy palette are always listed in alphabetical order. When you rename an object, it moves to the appropriate position in the alphabetized list. This sometimes causes objects to disappear from the visible part of the Hierarchy (you may need to scroll down or up to locate it).
Primitive objects appear in the Object Hierarchy palette beneath the Solid Object they belong to. Clicking the arrow to the left of a Solid Object alternately shows and hides member objects.
4 Enter the Solid Object Editor by double-clicking on the Solid Object icon in the Scene Editor window. You can also double-click the Solid Object icon in the Object Hierarchy list. 5 Right-click in the window and select Preset Positions > Perspective (or type F8) to bring up Perspective view. Click on the Floor icon in the Solid Object Tools toolbar and click anywhere in the Perspective view window. A slab-shaped oor will appear. 6 Select the Column icon in the Solid Object Tools toolbar and hold down the Shift key and click four times in the Perspective view to create four Column objects, one at each corner of the Floor object. 7 Select each Column object and change its Radius value in the Inspector palette to one foot. 8 Select the Floor object and switch to the Front view (type F6 or right-click and choose Preset Position > Top). Then drag the Floor object to align it with the Column tops.
A simple table created from primitive objects, in the Perspective view (F8)
104
CHAPTER 9
Box
The Box primitive is a simple rectangular box with eight corners. Its default size is a cube with edges two feet long. Dragging its connectorsthe white squares that appear when it is selected will let you resize it as needed. The Box primitive has no extra parameters in the Inspector palette.
Box objects are a common primitive. Note that selected objects appear in red, with small white connectors that allow resizing.
Column
The Column primitive resembles a cylinder. The Column primitive defaults to 10 feet tall and two feet in radius, and includes two connectors, one at each end. These connectors can be used to adjust the height of the Column primitive. Columns also have two parameters adjustable in the Inspector palette. The Faces value sets the number of edges that
comprise the circular cross-section. This value can range from three to 64, with larger numbers resulting in a more nearly circular Column. The Radius value is the radius of the circular cross-section.
Cone
The Cone primitive is similar to the Column primitive, except that the radius is different at either end of the cone. Its Inspector parameters include Faces, Top Radius and Bottom Radius.
106
CHAPTER 9
Triangular Slab
The Triangular Slab primitive defaults to two edges 10 feet long joined at a right angle. It has three connectors, one at each corner. The Triangle Slab has one Inspector parameter, Thickness.
Stairs
The Stairs primitive creates a set of stairs with a connector at each corner. The Stairs primitive is the smartest solid primitive currently available in Atmosphere. An entire ight of stairs can be constructed as a single Stairs primitive, by dening the position of only four Connectors. Basically, the Stairs primitive is constrained so that the height of a single stair is always the same, the number of stairs increases or decreases to match the height between the top two and the bottom two Connectors, and the top and bottom stairs encompass the distance between the two Connectors that dene each of them. If you drop a Stairs primitive into the Solid Object Editor and start moving its Connectors around (try this from both a Top view and a Front view), this will become more apparent.
108
CHAPTER 9
Wall and Floor objects are slabs with different orientations. Although the primitive objects are simple, only your imagination limits the ways they can be combined into complicated objects.
110
CHAPTER 9
An environment containing A cottage created using only Atmospheres Solid Object primitives.
Deleting Objects
Objects can be deleted by selecting the object and using the Edit > Clear menu command or by pressing the Delete key. The Edit > Undo (Ctrl+Z) command will undelete a deleted object. You can also select and delete an object in the Object Hierarchy palette.
Duplicating Objects
The Edit > Duplicate (Ctrl+D) menu command will create a copy of the selected object. The duplicated object will have the same parameters as the original and will be placed a little distance away from the original. The Duplicate command makes it easy to create large populations of identical objects.
Grouping Objects
The easiest way to move several objects at once in the Solid Object Editor is to collect them into a group. Groups of objects are moved, scaled and rotated together. Grouping is particularly useful in crowded assemblies. A group can consist of one of more objects. To create a group, select all the objects to include in the group and select the Object > Group (Ctrl+G) menu command. When a group is selected, all objects in the group are selected together.
Grouped objects can be moved together in Scene Editor view. Object groups are identied in the Object Hierarchy palette with the name, Group and the number of items contained within the group. Groups, like Hierarchy objects, can be given a name by clicking on the selected group name and typing a new name. All objects that are members of a group will appear as sub members of the group. Clicking on the arrow icon to the left of the group name will cause all objects to roll up in the hierarchy under the group name. Groups can contain other groups, called nested groups.
112
CHAPTER 9
Groups appear in the Object Hierarchy palette as either a folder or a folder with its child objects visible. Clicking the arrow icon by the folder expands or collapses the hierarchy at that point. Another way to create a group is by using the Object > New Group menu command. This command will create a new group in the Object Hierarchy palette. The new group will have no items. You can add objects to a group by dragging and dropping them on the group in the Object Hierarchy palette.
Group options
Like Solid Objects, Groups of objects can be made subtractive in the Inspector palette. Groups have the additional option to form the Boolean Intersection of the grouped objects.
Even though a group is marked as subtractive, the individual objects in the group will not be marked as subtractive.
114
CHAPTER 9
An entire group of objects can be marked as subtractive. Above are Two Floor objects that are each overlapped with a grouped array of Box objects. The group on the right is marked as subtractive.
Creating Boolean intersections The Boolean Intersect Contents of Group option for groups is used to create an
assembly from the contents of the group whose skin is formed only from the overlapping portions of the areas enclosed by the objects. All non-overlapping portions will not be visible. For example, consider c. The grouped objects and the Floor can be added, subtracted, or subtracted with the Boolean Intersection option.
A Box object grouped with an overlapping Column object placed through the center of a Floor object.
116
CHAPTER 9
Subtraction of the grouped object from the Floor object with the Boolean Intersect option selected. The Boolean Intersect Contents of Group option will only work on groups that have overlapping objects. If no objects in the group overlap, the entire group will be invisible.
Ungrouping Objects
A group of objects can be ungrouped using the Object > Ungroup (Shift+Ctrl+G) menu command. This will eliminate the group from the Object Hierarchy and the sub member objects will become separate objects.
Locking Objects
There are two options that prevent objects or groups from being accidentally selected locking and hiding. Locked objects will still be visible in the scene, but they cannot be selected. This is convenient if you need to see the object, but dont want it to inadvertently edit it.
118
CHAPTER 9
To lock an object, select it and choose the Object > Lock > Selection (Ctrl+L) menu command. Clicking on a locked object with the Selection Tool will do nothing. Locked objects have a small lock icon in the Object Hierarchy palette.
Locking a group will automatically lock all the objects contained within the group also.
Locked objects are easily identied in the Object Hierarchy palette. The Object > Lock > Others command locks all objects except those that are selected. This is useful if you want to work on a single object without selecting the rest. Object > Lock > All (Alt+Ctrl+L) locks all objects in the scene. Object > Unlock All (Shift+Ctrl+L) unlocks all objects in the scene.
Hiding Objects
Another option is to hide objects. Hidden objects will still be available in the Object Hierarchy palette, but they will not be visible in the scene. To hide an object, select it and choose the Object > Hide > Selection (Ctrl+H) menu command. Hidden objects will not have a small eye icon appear in the Object Hierarchy palette.
Hidden objects do not have the eye icon visible. Object > Hide > Others hides all objects except those that are selected. Object > Hide > All (Alt+Ctrl+H) hides all objects in the scene. The Object > Show All (Shift+Ctrl+H) unhides all objects in the scene.
120
CHAPTER 9
Selecting Objects
Atmosphere offers a number of ways to select objects, both with the mouse and from the keyboard, allowing users to choose their most comfortable and productive personal style.
Selecting by clicking
The easiest way to select an object is to click on it with the mouse cursor. In the Solid Object Editor with the Direct Select Tool (A) active, a selected object will appear red with white handles. For example, when a single Box object is selected, the box will turn red and two connectors will appear at opposite corners.
122
CHAPTER 10
The red wireframe lines denote a selected object in the Solid Object Editor with the Direct Selection Tool (A) active.
You can select objects in the Scene Hierarchy palette in the same way.
124
CHAPTER 10
When multiple objects are selected, they are all highlighted in red in the Solid Object Editor with the Direct Selection Tool (A) active.
Moving Objects
With the Direct Selection Tool (A) active, you can move objects by clicking in them and dragging them to a new position. In Perspective or Isometric view, the object will move in the horizontal plane on which it rests only. You can move the object vertically by clicking on it, moving it in the plane and then dragging it with the Shift key held down. Holding down the Ctrl key while dragging will constrain the object to move along a single axis. In Top, Bottom, Left, Right, Front and Back view the object can be moved vertically without holding down Shift. Vertically moving objects in Perspective or Isometric view is just a little tricky. To move vertically, click on the object and move it within its current plane before holding down the Shift keyat which point you can move vertically. If you hold down the Shift key before clicking the object, nothing will happen. You can also move objects vertically by opening a New View (F4) and selecting Preset Position > Front from the Contextual Menu and then moving the object in that view.
If the Snap to Grid option is enabled in the Preferences dialog box, then the Guideline values will be integers. If the Snap to Grid option is disabled, then the displayed values will include values computed to several decimal places.
Guidelines show the distance from the X, Y and Z axes while Shadows locate an object on the grid..
126
CHAPTER 10
Selecting connectors
You can select connectors with the Direct Selection Tool (A). First click on and object in the Solid Object Editor. It will turn red with white connectors. Click on a connectorit will turn red and the object will turn white. By holding down the Shift key while clicking on connectors of selected objects, you can select multiple connectors. Another way to access to connectors is to select Connectors in the Select drop-down list in the Options toolbar. This will display the connectors for all objects in the Solid Object Editor.
With all connectors visible, you can easily select multiple connectors.
Scaling Objects
Scaling or resizing is accomplished by dragging on an objects connectors with the Direct Access Tool (A) active in the Solid Object Editor. When you grab and drag a connector, only the attached corner of the object moves. This will increase the size of objects like a Box. Columns and Cones will be elongated and Slabs and Stairs will be stretched. You can scale objects in different dimensions by switching to appropriate views like Top, Right and Front.
128
CHAPTER 10
Skewing Objects
In Perspective view, you can drag a connector in two directions at once: the effect is to skew the object.
Welding Connectors
At the right end of the Options toolbar is a Weld Connectors option and a Weld Distance value. When this option is enabled, you can weld two connectors together. Welded connectors will move together when any of their objects are moved. The Weld Distance value determines how close the connectors need to be to each other before they are welded together. The Weld Distance is displayed in the view as a light gray transparent circle. This circle marks the weld inuence distances and is helpful in aligning connectors so they weld together. The weld distance circle will turn yellow when a nearby connector is close enough to weld.
A gray transparent circle indicates the connector weld distance. Once two connectors are welded together, you can move one of the objects and the welded connector on the other object will follow.
130
CHAPTER 10
Moving an object automatically drags all welded connectors with it. Above is a simple table with the connectors of the table legs welded to the table top. As the Slab object is moved, the Columns top connectors follow, but the bottom connectors do not, so that, in this case, the table is skewed.
Snapping to a Grid
The Snap to Grid feature, accessed via the Contextual menu causes an objects corners to align with the grid corners automatically. Values displayed in the Options toolbar will be integer values when Snap to Grid is active.
Creating a Grid
Grids are shown by default: you can change the spacing or turn them off using the Grid option in the Display tab of the Preferences (Ctrl+K) dialog box.
The grid feature in Atmosphere zooms with the view to provides grid lines at any scale.
Grids can be enabled and spacing set in the Preferences dialog box.
132
CHAPTER 10
7 Drag an outline over both Floor objects to select them both and move them to the lower left corner of the Top view. 8 With both Floor objects selected, select the Edit > Duplicate (Ctrl+D) menu command to duplicate both objects. Drag the duplicated objects until their bottom connectors align with the top connectors of the original objects. 9 Continue to duplicate and drag the Floor objects until an 8x8 array of Floor objects is complete. The chess board is a versatile model that has many uses in 3-D constructs. Because all the connectors are welded, dragging a single connector up or down relative to the plane will deform the adjacent object. By dragging various connectors up and down you can create a rough terrain.
Rotating Objects
Objects can be rotated using the Rotate tool (R) . Select an object, click the Rotate (R) tool and then drag anywhere around the object. The object will rotate around its center. If you rst click on a point, and then drag, the object will rotate around that point. The rotation anchor is marked with a blue target. Dragging an outline around the object will cause the rotation center to return to the center of the object. If guidelines are enabled, the value of the rotation in degrees will be displayed next to the center point.
134
CHAPTER 10
10 Select all objects with Edit > Select All (Ctrl+A) and group them with the Object > Group (Ctrl+G) menu command. In the Scene Hierarchy palette, name the Solid Object Top. 11 Press the F6 key to see the Front view. Click on the Rotate Tool (R) and drag in the view to rotate the top about 15 degrees from its center pointenough to show a slight tilt.
Clearing Transformations
Mistakes happen: if your rotation center was misplaced or you drag accidentally, the topor any 3-D objectcould end up lost in 3-D space. If this happens, you can quickly recover with the Edit > Clear Transformation (Shift+Ctrl+T) command. This returns the object to its last location prior to the transformation. The Clear Transformation command will work for any transform tool that has a center anchor including Scale and Rotate. It also keeps track of multiple actions and will undo all transforms with the exception of moves. For example, if you placed an object at the origin, rotated it 20 degrees, scaled it and moved it 5 ft along the X-axis, then the Clean Transformation command would remove the rotation and scaling, but leave the object 5 ft along the X-axis.
Subtracting Objects
You can subtract primitive objects from other objects to create new shapes. If the Subtractive option is selected in the Inspector or in the Object Hierarchy palettes, the object will not be visible in the Player view. Instead it will remove
136
CHAPTER 10
its volume from objects that overlaps. For example, if you place a Cylinder so that it passes through a Box, making the Cylinder subtractive will cause a circular hole to appear in the Box in the Player view.
5 Select the duplicated Triangular Slab and the Floor objects and enable the Subtractive option for each in the Inspector palette. Also set the Thickness value to 1.0. This will insure that the objects cut through the rst Triangular Slab. 6 For the B and C letters, create ve Floor objects and move their connectors so that they form the letters. Then select the Subtractive option for objects that are within the outer letter objects and increase their Thickness values as you did in Step 5.
138
CHAPTER 10
Use the View > Fit All (Ctrl+0) menu command to quickly frame the environment in the Player view window.
Adding Color
When the Appearance Editor is selected, the icon buttons on the Texture Tools toolbar become active. These tools let you apply, remove, sample and edit colors and textures.
140
CHAPTER 11
Removing Colors
You can remove colors from an object or face using the Remove Texture Tool (E) . If an object has had several colors applied to it, the Remove Texture Tool will remove only the last color that was applied. Clicking multiple times on an object with the Remove Texture Tool will remove all previously applied colors one by one.
Changing Colors
The color in the Inspector palette is selected by changing the Red, Green and Blue color values. You can type in new values, or click the arrow next to each value to use a slider control. You can also change the color by clicking on the color swatch, which brings up the Color palette.
Using the Color Sliders
Each Red, Green and Blue color slider ranges from 0 to 255, with 0 representing no color and 255 representing full color. The specied amount of red, green and blue is mixed together to produce the color. For example, a Red value of 255 produces pure red if Green and Blue are set to 0. Setting Red to 0 and Green and Blue to 255 produces yellow.
Keep in mind that colors on the computer screen are additive higher color values are brighter. This stands in contrast to media like paint and inks where larger amounts of color produce darker results known as subtractive color.
Using the Color Palette The Color palette makes it easy to choose colors. Access it by clicking the color swatch in the
The Color palette is accessed by clicking the Inspector color swatch. The Color palette allows selection of preset colors displayed in the Basic colors section. You can also select any RGB color by dragging the crosshairs in the palette to the right and clicking to select a color. The current color is shown in the Color/Solid swatch. The selected colors Red, Green and Blue values are displayed, as well as its Hue Saturation and Luminance values. The Red, Green and Blue values are the same as those entered in the Inspector palette. You can enter numerical color values into the text elds to create colors from recipes. Clicking the Add to Custom Colors button adds the current Color/Solid swatch to the bank of Custom Colors. When you click the OK button, the color in the Color/Solid swatch will be transferred to the Inspector palette.
Using the Pop-up Color Selectors You can also right-click on the Inspector color swatch to open a contextual menu
consisting of a mini palette of color swatches. When a color is selected in this mini palette, its hexadecimal value is displayed at the bottom of the palette. Hexadecimal values are commonly used to specify color on web pages.
142
CHAPTER 11
Right-click the Inspector color swatch for this mini palette. Right-click on the color swatch with the Alt key held down to see a mini-palette of standard web safe colors.
Alt-right-click on the Inspector color swatch brings up the web color palette.
The completed chessboard with colored pieces.. Colors can be applied to objects using the Apply Texture Tool (K).
144
CHAPTER 11
The color preset icon identies colors in the Paint Presets palette. When a color preset is selected in the Paint Presets palette, the gray paint bucket is highlighted with color and a red border. When selected, you can change the presets color value in the Inspector.
Selected color presets can be set using the Inspector. You can store all your projects colors in the Paint Presets palette. The color and values for each color are displayed at the bottom of each preset icon.
It is easier to manage large collections of colors and textures by using the Manage Sets dialog box to create sets. See Chapter 8, Using Scene Objects.
The Paint Presets palette holds preset colors that can be applied to objects. You can delete a selected preset using the Remove Preset command in the palette menu. To remove all presets, choose Remove All Presets from the palette menu. Once a paint bucket icon is selected in the Paint Presets palette, you can apply the selected color to an object (or object face) by selecting the Apply Texture Tool from the Texture Tools toolbar and clicking on an object in the Appearance Editor.
Texture Formats
Textures are image les that can be wrapped around or tiled over the surface of an object. The le formats supported for textures are GIF, JPEG and PNG. Each of these formats is commonly found on the web. Imported textures appear as thumbnails in the Paint Presets palette.
GIF
The Graphics Interchange Format (GIF) supports only 256 colors but offers lossless compression which preserves image quality better than JPG or PNG. GIF is a good format for textures that contain text, logos and drawings. File sizes are usually small and load quickly. Atmosphere doesnt support transparency, interlacing or animation in GIF les.
JPEG
The JPEG (JPG) format supports a photo-realistic 16.7 million colors. JPEG compression is lossy but adjustable to trade image quality for le size. JPEG is good for photographs and images with gradients. Files are normally the smallest.
PNG
The Portable Network Graphics (PNG) can contain 256 or 16.7 million colors and offers both lossy and lossless compression. PNG les are usually larger than JPG, but offer good quality.
Applying Textures
Textures are applied to objects in the Appearance Editor using the Apple Texture Tool (K). The method is the same except that textures must be imported into the Paint Presets palette before use with the Add Texture Preset command from the Paint Presets palette menu. Imported textures appear as thumbnails in the Paint Presets palette. Select a texture, then use the Apply texture Tool (K) to apply to an object or face. You can import multiple textures at the same time by Shft- or Ctrl-selecting multiple le names in the le dialog box before clicking Open.
146
CHAPTER 11
The Paint Presets palette displays thumbnails of imported textures. When a texture preset is selected in the Paint Presets palette, several option for controlling the size and orientation of the texture appear in the Texture tab of the Inspector palette. These settings will be covered in Chapter 12, Manipulating Textures.
Although colors can be applied to the sky, you cannot apply a texture to the sky background.
148
CHAPTER 11
MPEG Windows Media Files (WMV) All of these formats can be opened using the le dialog that appears from the Add Texture Preset menu command on the Paint Presets palette menu. Video les normally appear with the poster frame as a thumbnail.
Movie options
Once a movie le has been applied to a face in the scene, a Movie tab appears in the Inspector palette. This tab includes options to make the movie Loop and set the Volume of the movie sound.
Movies applied to an object face will play automatically when the scene is loaded. Notice how the movie is rotated incorrectly and tiled. The next chapter will explain how to x these problems.
Removing Textures
The Remove Texture Tool (E) removes color, texture and video from objects. Select the tool and click on the object or face to remove the color or texture.
150
CHAPTER 11
Editing Textures
Once a texture is applied to an object (see chapter 11, Applying Colors and Textures), its properties can be edited in the Inspector palette. Choose the Edit Texture Tool in the Appearance Editor and click in the Player view on the texture that you wish to edit. Its parameters will appear in the Inspector palette. For textures, the Inspector palette includes four tabbed panes Surface, Texture, Light Map and Movie.
Surface Tab
The Surface tab lets you select whether the texture is applied to a single Face or to every side of the object. The Surface panel also includes an option to specify whether or not the object Emits Light. If it emits light, you can specify the Brightness value and a Self-Illumination Factor. You can learn more about lighting in Chapter 13, Lighting a Scene.
The Surface tab lets you apply texture to whole objects or an individual face.
Texture Tab
The Texture tab controls how the texture image is sized and oriented on the object. You can wrap the texture, and set an offset, rotation and other parameters that affect how the texture is applied to an object.
152
CHAPTER 12
The Texture panel lets you manipulate the placement of the texture.
Scaling Textures
The U and V Size values in the Texture tab determine the size of the texture image. The U Size value scales in the horizontal direction and the V Size value in the vertical direction. The check box by the chain link locks image size U and V scaling in tandem if checked and separately if unchecked. The Size values depend on the Scaling Type that is selected. The four Scaling Type options are Pixel, Tile, Parametric and Projective, explained below.
i i
If the Size values are different before the link checkbox is enabled, the relative difference between the U and V values will be maintained, they will not be set equal. The maximum Texture size that can be used in Atmosphere is 2000 x 2000 pixels.
154
CHAPTER 12
A scaled texture applied to three Wall primitives.The texture appearance is controlled by changing the Size values and Scaling Type.
If a texture is offset without Wrap enabled, the edge of the texture will be smeared into the offset space.
Offset values are measured from the upper left corner of the object face.
156
CHAPTER 12
Pixel Scaling With Pixel Scaling selected, the Size value expresses the size of an individual pixel of the texture given
in feet. For example, a U-Size of 1 means that each pixel in the texture will be one foot across. Pixel and Tile Scaling behave similarly, except that the Size values are different.
Tile Scaling Tile Scaling makes it easy to size the texture as a tile that ts perfectly across the object face. Size expresses the size of the entire image in feet. A U-Size of 1 means that the image is 1 foot across independent of the number of pixels in the image, and will t exactly across faces that are 1, 2 and 3 feet wide, etc. Parametric Scaling Parametric Scaling stretches a texture image so that it exactly ts the object face. U and V Size
values of 1 will t the selected face exactly regardless of the actual dimensions of the face. If the Size values are changed to 2, then only half of the texture is tted to the surface and a value of 0.5 will make texture images t twice across the surface. Changing the size of the face will cause the texture to automatically scale to t. Note that the Size values in this case express a ratio rather than a dimension like feet.
Projective Scaling The Projective Scaling applies the texture image to an object as if it were cast from a lm projector.
This provides a way to apply textures to oddly shaped objects or apply interesting distortions to applied textures. The Size values for Projective Scaling express the size of the projected image in feet. The location of the texture projector relative to the object is set by the Elevation and Azimuth values, and are similar to those used by the sun direction in lighting (see Chapter 13 Lighting a Scene).
Wrapping Textures
The Wrap options cause the texture image to be placed end to end across the face of the surface like tiles on a oor. If the Wrap options are selected for both the U and V directions, then the texture image will be tiled across the entire face of the object. The grass eld of this soccer stadium was created by wrapping a small grass texture horizontally and vertically. If you look closely you can see the repeating pattern. You can use the Scaling Type and Size parameters to make the texture t the face exactly. A little experimentation will also help you nd the most pleasing visual effect.
158
CHAPTER 12
Textures like the grass in this soccer stadium can be tiled to cover the entire surface. Here is a texture that is tiled across the surface using the Wrap options.
Rotating Textures
The Rotation value rotates the texture image counterclockwise. The origin point is the upper left corner of the texture image.
160
CHAPTER 12
Seamless textures will tile end to end with minimally noticeable seams.
Creating Billboards
Billboards are a special type of texture that always face the viewer. These are convenient for objects such as trees where a single billboard object will present the illusion of a tree without including the complex mesh required to model an actual tree.
Trees are often modeled as billboard objects. 1 Obtain a high-resolution photo of a tree, with a normal viewing angle and lighting and no overlapping objects. 2 In Adobe Photoshop, or another image editor, cut the tree out from its background, leaving white where you want transparency.
162
CHAPTER 12
First step is to crop the tree from the picture. 3 Using this image as a template, make a second image, in which the tree is black on a white background. This will be your images alpha map. Superimposing the two images makes it easier to remove any mistakes. You may also wish to smooth the edges. Save the two images as identically-sized, non-progressive, 24-bit JPEG les.
The alpha map of the tree. 4 To process the images in Viewpoint Scene Builder, apply both to a VP primitive plane. Use settings that will not render a visible edge around the plane or light it unrealistically. Save the object as an MTX le. 5 Import the Viewpoint MTX le into your Atmosphere environment and copy the MTS le to the folder where you publish your environment.
A billboard tree object as part of an Atmosphere environment. Billboard objects always face the viewer.
164
CHAPTER 12
166
CHAPTER 13
Understanding Lighting
Atmosphere uses advanced Radiosity lighting algorithms that produce realistic lighting effects. Radiosity takes into account the way light behaves in the real world. There are two kinds of lighting in Atmosphere pre-computed lighting and dynamic lighting. Pre-computed lighting is calculated before the environment is viewed in the Player. When you click the Start button in the Lighting Control, lighting information is calculated and saved with the scene. Dynamic lighting is applied in real-time as the user interacts with the environment.
The Emits Light option turns any object into a light. Brightness is controlled by the Emitted Brightness value, which determines how much light radiates outward and can range in value from 0 to 100. The Self-Illumination Factor determines how bright the object itself is and can range from 0 to 1. For indoor lights, try setting the Emitted Brightness value to 100 and the Self-Illumination Factor to 1. This will cause a bright light to be added to the scene.
168
CHAPTER 13
Any Solid Object or Surface Object in the scene can be an emissive surface. The uorescent lights on the ceiling are cylinders set to be emissive surfaces.
Pre-Computed Lighting
Computers calculate light by tracing the path of light rays from each light source to objects in the scene and back to the observer. The angle of incidence, the reective properties of the object and dozens of other properties must be considered and calculated to show lighting that appears realistic to the human eye. Atmosphere uses advanced Radiosity lighting algorithms that produce cinematic lighting quality by calculating the myriad ways that real light bounces through a scene. This is a huge computing job, even for the most powerful modern PC, and can take hours or even days for complex scenes. Since that wouldnt be practical for a real-time experiences, the work-around is to compute the lighting and then save the information in les called Light Maps that are savedwith the scene. This process is referred to as precomputed lighting, and is distinct from real-time or dynamic lighting. Light maps have the advantage that they can quickly be read during scene playback. Atmosphere uses the Lighting Controls palette to set parameters that affect the lighting.
Lights can be made from existing scene objects. Above is a recessed ceiling light, made from a cylinder with Surfaces set to 6, that adds light to the scene when set as an emissive object.
170
CHAPTER 13
You cannot edit Solid Objects while the lighting is being calculated. Attempting to do so will present a warning dialog box. You can stop the lighting solution at any time using the Stop button.
The Lighting Control palette includes Start and Stop buttons The lighting process can require many minutes or even hours depending on the complexity of the Scene. Once lighting is done, the information is saved in the Light Maps. Atmosphere preserves Light Maps so they dont normally need to be redone once a scene has been lighted. Just above the progress bars is a Status label which shows the current task: Initializing Light Maps: allocates and clears memory for lighting calculations. Gathering Light for Faces: collects all light from background and the Sun sources as well as emissive surfaces Distributing Light: calculates the light bouncing from non-emissive surfaces that were illuminated by the previous step. Done: displayed when lighting calculations are complete.
The progress bars track the Percent of Light Remaining, the Percent of Surfaces Remaining and the Percent of Current Surface Remaining and are meant to help you judge how long the lighting will take. During lighting and once a scene has been lit, you can alter the Scene Brightness using the Scene Brightness control at the bottom of the Lighting Controls palette. You cannot alter the Scene Brightness setting after closing and reopening the project le exiting without rst recalculating lighting..
Lighting Settings
Under the Settings tab you can select which light sources are used to calculate shadows. Multiple light sources will make shadows appear softer. If you are creating an indoor scene such as the interior of a building, be sure to disable Calculate Light for Sun and Background. This will speed up the computation. The Lighting Threshold value determines a threshold below which light energy will no longer be distributed. For example, a Lighting Threshold of 20 will stop computing bounced light after 80 percent of the light has been distributed.
The Settings tab of the Lighting Control palette lets you choose which lighting sources to include. You can continue to navigate in the Player view even though lighting computations are in process. The Update Frequency setting in the Lighting Control palette will determine how many surfaces are calculated before the Player View is updated.
If the Player view isnt active, the refresh rate is set to 1 frame per second. This will speed up the lighting calculations.
172
CHAPTER 13
A setting of 10 will give the user immediate feedback in the Player View while taking longer to complete the lighting and a setting of 80 will speed lighting at the expense of less frequent Player View updates. An Update Frequency value of 0 will cause the Player view to update only after the entire lighting solution is calculated.
The Quality tab of the Lighting Control palette determines the accuracy of the lighting. At the top of the Quality tabbed pane are three buttons Draft, Preview and Final. Clicking these buttons changes the value settings. These buttons are the same as those found at the top of the Controls tab. The Sampling Densities values for the Background and Sun dene the number of rays (actually the square root of the total number of light rays) that come from the Background and the Sun respectively. Increasing the Sampling Densities will improve the accuracy of the lighting and the smoothness of soft shadows. However, higher sampling densities take longer to compute. Lighting is computed by dividing a surface into samples, and computing the light for each sample. More samples make the lighting more accurate, but take longer to compute. Light Map Sample Size controls the resolution of the light map for the corresponding surface. Measured in feet, the sample size determines the linear size of each pixel in the light map. The default setting is for light to be calculated at points on a regular grid each one foot apart. Decreasing the value will lessen the distance between sample points thus increasing the number of samples for the surface. This means that the calculation of the light map will be more accurate, although it will make them take more time and increases the amount of light map data that is saved in the le. More accurate light maps result in crisper shadows and smoother gradients. The Sample Size values can be specied for Solid Objects and Surface Objects that are designated as emissive surfaces. You can also set Sample Size Minimum and Maximum values for Light Maps. Emissive Surface Sample Size values
can range from 0.01 to 100 and Light Map Sample Size values can range from 0.1 to 5. The Minimum and Maximum settings clamp the per-surface Sample Size to these values.
Quality Presets Values Setting Background Sampling Density Sun Sampling Density Solid Object Emissive Surface Sample Size Surface Object Emissive Surface Sample Size Light Map Sample Size Minimum Light Map Sample Size Maximum Draft Quality 2 1 8 4 1 5 Final Quality 4 4 4 2 1 5 Preview Quality 16 8 2 1 0.1 5
174
CHAPTER 13
The same scene with its Scene Brightness set to 5. Darker regions are brightened but lighter regions may lose contrast.
Using Sunlight
In addition to emissive surfaces, you can also specify a distant light source known in Atmosphere (and in the real world) as the Sun. The Suns settings are found in the Sun tab of the Lighting Control palette and include: Elevation and Azimuth settings to describe its position in the sky, Cone Angle and Brightness to describe its intensity and Red, Green and Blue to describe its color.
Azimuth describes the angle between the X-axis and a line drawn to the Sun. Values can range from 360 to 360 degress. Elevation and Azimuth values at sunrise would be 0 and 0. At high noon, the Elevation would be 90 and the Azimuth would be 90. At sundown, the Elevation would again be 0, but the Azimuth value would be 180.
176
CHAPTER 13
The Color section in the Sun tab of the Lighting Control palette will let you specify a color for the light coming from the sun. You can change the color by clicking on the color swatch and picking a new color from the Color palette or by dragging the Red, Green or Blue sliders.
Color swatches in Atmosphere have 3 palettes. Clicking brings up the Color palette, Ctrl-clicking brings up a mini palette, and Alt-clicking brings up the web standard colors palette.
A scene with a the Sun color set to white. The default Sun color is pure white. Changing the Suns color dramatically alters the scene. This is the same scene with a blue Sun color.
Textures cannot be applied to the background, but you can place a texture using an object known as a Sky Dome or a Sky Cone.
Because sky cones can block lighting from the background and the sun it is usually best to import them after lighting the rest of the scene or load them as a model with a script. Sky cones should have their Light Maps disabled in order to reduce le size.
178
CHAPTER 13
Sky cones can be textured to show the surrounding environment. The distant plain, hills and sky are textures on the sky cone.
The Light Map tab of the Inspector palette lets you enable Light Maps and set their Brightness and Sampling Density. In the Light Map tab, you can also set the Brightness and Sampling Density for each color and texture.
Dynamic lighting is computed in the Player as users and objects move about the scene. Dynamic and static lighting are added together in the Player. For object that will move and rotate, it is best to light them just with background light and the to use a dynamic light in the Player to represent the sun.
180
CHAPTER 13
For Surface Objects precomputed lighting is stored at the vertices of the mesh. To increase the lighting quality, subdivide the mesh prior to importing it into Atmosphere.
Above is a texture before brightening with this technique, and the same texture after the levels have been changed. Texture images are pre-lit and become darker when applied to a lighted scene. Brightening dark textures causes them to appear correctly in a lighted scene. Below are two cubes with identical lighting with the two different textures applied.
This chapter covers the basics of using scripts in Atmosphere. A more detailed tutorial is included in Appendix D, JavaScript API Documentation, and Appendix E, JavaScript API Table of Modules.
Loading Scripts
Scripts can be imported into Atmosphere using the File > Import > Scripts menu command. You can also place scripts in the Object Presets palette using the Add Script Preset command in the palette menu. Both of these options will open a le dialog box to locate and load the Script les which typically have a JS extension. Imported presets appear as Script icons in the Object Presets palette. You can load several script presets at once by Shift- or Control-selecting scripts in the Open File dialog box.
182
CHAPTER 14
Placing Scripts
Scripts that are loaded using the File > Import > Script command appear at the origin of a Scene. Scripts in the Object Presets palette are placed using the Scene Editor which allows scripts to be placed anywhere. To place a script, click on its icon in the Object Presets palette, then click in the Scene.
Some scripts will use the position of the Script icon in the Scene view as a parameter to control its function. For example, the rotateContinuous.js script uses the Scripts position to dene the point about which an object rotates.
The script name and its path are displayed in the Scene Hierarchy palette. When a script is selected, the Inspector palette displays the Scripting tab where the scripts properties Names and Values are shown.
The Scripting tab of the Inspector palette appears when a script is selected in the scene.
Some effects such as fog will not be visible until the environment is published and loaded in the Player plug-in.
To add fog to your scene, follow these steps. 1 Locate the Help\Tutorials\Bridge folder under the directory where Atmosphere was installed. It should be a path similar to c:\Program Files\Adobe\Atmosphere\Help\Tutorials\Bridge. After navigating to your folder in the open dialog, select the le bridge.atmo and press Open. 2 Select the Add Script Preset menu command in the palette menu of the Object Presets palette. This will open a le dialog box. 3 In the le dialog box, locate and select the fog.js script in the Extras\Scripts\Set_1_Basic directory where Atmosphere was installed. Click the Open button to open the script preset. 4 Select the fog script in the Object Presets palette and click in the Scene Editor to place the script icon anywhere in the scene. 5 Select File > Publish > World (Ctrl+P) to see the fog in the environment.
184
CHAPTER 14
An Atmosphere environment with the fog script applied. The amount of fog can be set by adjusting the scripts properties in the Inspector. Fog can be enabled in the scene simply by adding the fog.js script.
Editing Scripts
The Inspector palette includes a eld that holds the path to the imported script. You can set the scripts path by clicking the Browse for JavaScript File button to the right of the JavaScript URL. Clicking the Edit button will open this script in a text editor. The text editor has no menu bar options, but you can use the right-click Contextual menu to Cut, Copy, Paste and Delete selections of text and bring up the Save and Save As dialogs. To learn more about editing scripts, see Appendix D, JavaScript API Documentation.
The scripts that ship with Atmosphere include a comment at the top of the script that explains what the script does and how to use it. When you create your own scripts, its a very good idea to include comments that will help you remember what the script does.
Clicking the Edit button will open the script in a text editor.
The two slash marks (//) at the beginning of the line mark a line of code as a comment that will not be processed.
The properties dened in this section are displayed in the Inspector palette. When the user saves their project, the values in the palette elds are written into the project le. Additionally, when the user publishes the project, these values are written into the published AER le as well.
186
CHAPTER 14
This approach allows developers to protect their script work, since AER les only open in the Player and cant be opened in Atmosphere.
The script below this top section is the part processed in the Atmosphere Player using the custom values for properties that were set in the Inspector.
Atmosphere supports positional sound, meaning that the sound will get louder as you navigate closer to it and softer as you move away.
The play and stop properties can be controlled by other scripts to start and stop the sound. The repeats property denes the number of times the sound will play. If the repeats value is set to 0, then sound will loop indenitely. The runOnStartup value will cause the sound to begin when the environment loads. The URL property denes the path to the sound le to play. Atmosphere supports sound in the WAV and MP3 le formats. The volume property controls how loudly the sound plays.
5 In the Inspector palette, click on the URL property to select it. Then right click on the Value eld and select Sounds from the pop-up menu. In the le dialog box that opens, locate and select the background sound that you wish to use. 6 Select File > Publish > World (Ctrl+P) to hear the background sound being played.
The sound.js script opened in a text editor. Script properties can be altered to change the function of the script. Above is the Inspector palette after the url property has been changed.
188
CHAPTER 14
The New Script Property dialog box lets you dene custom properties. The number types include Number, String, Boolean, Vector, Color, Object, Action and Rotation. You can learn about each of these number types in Appendix D, JavaScript API Documentation. You can also select options that allow the value to be referenced, modied and whether it is an array or not. Selected properties can be deleted using the Delete Selected Script Property icon button, also located at the bottom of the Inspector palette.
The Script Whip tool will draw a line from the tool to the target object. You can also drag the Script Whip tool to the objects in the Scene or Object Hierarchy palettes.
Because script objects can only be selected in the Scene Editor, you cannot whip to a Solid Object sub-part. You can, however, whip to a Solid Object part using the Object Hierarchy palette.
If you expand a script object in the Scene Hierarchy palette, all of its properties that are listed in the Scripting tab of the Inspector palette are visible. Double clicking on any of these properties will open the script in a text editor.
190
CHAPTER 14
6 Select File > Publish > World (Ctrl+P) to see the car object rotating in the scene.
By changing the axis and rpm properties, you can control the axis about which the object rotates and its speed.
192
CHAPTER 14
1 Locate the Help\Tutorials\Soccer folder under the directory where Atmosphere was installed. It should be a path similar to c:\Program Files\Adobe\Atmosphere\Help\Tutorials\Soccer. After navigating to your folder in the open dialog, select the project le Soccer.atmo and press Open. 2 In the Scene Editor, create a new Solid Object that is separate from other Solid objects in the environment. 3 Select the Add Script Preset menu command in the palette menu of the Object Presets palette. This will open a le dialog box. 4 In the le dialog box, locate and select the createPhysicalModel.js script in the Extras\Scripts\Set_1_Basic directory where Atmosphere is installed. Click the Open button to open the script preset. 5 Select the script and place it in the Scene view. Then locate and select the target property in the Scripting tag of the Inspector palette. 6 Drag from the Whip tool to the Solid Object that includes the soccer ball object. The Solid Objects name will appear as the value for the target property. 8 Select File > Publish > World (Ctrl+P) to see the car object rotating about the scene.
A soccer eld with a ball that is a PhysicalModel. If you collide with the ball it will be pushed forward in the scene, (but only if the Collide option is enabled in the Player).
194
CHAPTER 14
The windmill environment after linking the rotate script to the onClick script. Linking scripts to scripts let you control actions based on events that the user initiates.
Locating Errors
Experienced Atmosphere developers are familiar with some of the bugs that are common to online 3-D worlds, and make a point of checking for them. Atmosphere is perhaps the easiest-to-use 3-D package ever, but 3-D worlds are complex places, and bugs have a way of sneaking up on the most careful developer.
Inactive Portals
If a Portal references a URL that cannot be located, then the normally spinning red, green and blue squares will lay at. Flat Portal panels mean you should double check the URL listed for the Portal.
Leaking Light
If you create a room and the walls dont quite meet or align correctly with the ceiling, then light from the sun or background may leak in causing unwanted lighting in the scene. This is easy to check in the Player view. If you dont need it for anything else, turn off the Suns light and shadows in the Settings tab of the Lighting Control palette before lighting the environment.
Missing Textures
If you imported Viewpoint Objects and converted them to Surface Objects that now seem to be missing their textures, then you may have forgotten to move the texture map saved as a PNG le to the server. The Publishing process will move textures applied to Solid Objects, but textures from converted Viewpoint Objects need to be moved by hand after being converted.
Scripting Errors
If your environment generates scripting errors, they will be displayed in the Chat palette when the world is loaded in the Player. These errors will give the line number of the script and an error message that are helpful for debugging.
196
CHAPTER 15
If the environment loads, but the oor seems to be missing, the problem could be that your Entry Point object is contained within the Floor object. Another problem occurs when Entry Points are positioned outside of the environment: when the scene loads in the Player with Gravity enabled, the user falls away from the environment. In both cases, go into the Scene Editor and reposition the Entry Point. See Chapter 8, Working with Scene Objects.
The World Settings dialog box lets you name your scene and specify where it is located online. In this dialog box, you can name the environment and enter a Reference URL, which is the location of the HTTP server where the environment will be posted. If the Reference URL is left blank, the environment will be loaded locally when published. The Server URL denes the location of the Collaboration Server if you wish to enable chat and object synchronization. If the Server URL is left blank, it will automatically be set to use Adobes default Collaboration Server. The Topic eld is for keywords that describe your project.
If you wish to specify Adobes Collaboration Server, simply enter wac://atmosphere.adobe.com in the Server URL eld.
198
CHAPTER 15
Publishing Preferences
The Preferences dialog offers an option to Launch Web Browser on Publish. This option will cause a web browser to launch and display your le when you Publish an Atmosphere environment-this is handy for debugging and previewing your environments. There is also an option to include a Web Page URL. This URL will be loaded in the browser when the environment is published. If the Web Page URL eld is left blank, then the HTML le created by Atmosphere will be loaded in the web browser. However, if a Web Page URL is included, then the specied URL will be loaded. If the Web Page URL points to a web page that does not include an embed tag for the Atmosphere environment, the published environment will not be visible.
The Add Movie dialog box lets you add Atmosphere scenes to PDF documents. 3 Once the Atmosphere scene has been added to your document, you can select the Hand tool and click on the scene to browse the Atmosphere environment. 4 Clicking on the Select Object Tool will enable you to edit the scenes setting and appearance.
200
CHAPTER 15
With Atmosphere scenes make PDF documents a richer experience. Above is a PDF version of Alice in Wonderland that includes several Atmosphere scenes.
Optimization Techniques
If you intend to place your Atmosphere environment on the web, you may wish to optimize the le before publishing. Optimized les will be smaller and download faster. Optimized les embedded in PDF documents can help keep them smaller, too.. Optimizing usually means some tradeoffs between quality and le size, so its best to frequently check your work to make sure youre not sacricing too much quality. Several techniques can help keep your le sizes manageable, including: Reduce the size of textures. Use compressed JPEG images wherever you can. Use low polygon meshes where possible.
Split complex environments up into smaller environments linked using Portals. Enable the Save Files in Compressed Format option in the Preferences dialog box.
Apply textures only to visible faces instead of entire objects where you can. Avoid using a large number of faces in a single object. Avoid using 2 or more dynamic lights in a single environment. Be judicious in using physical models objects that are scripted to obey physics. Too many physics calculations will slow the entire environment. Offer a smaller environment with a lower screen resolution for users that must use software rendering. Avoid using a large number of Viewpoint Objects. Use Billboards for complex objects such as trees that are difcult to include as geometry models.
202
CHAPTER 15
Installing Atmosphere
Insert the Atmosphere installer CD and follow the on-screen instructions. You can also launch the Adobe Atmosphere Setup wizard by clicking its icon on the CD. For more detailed information, see the Installation ReadMe on the CD. Be sure to have your serial number handy - the installer will not proceed without a valid serial number.
204
APPENDIX A
Hardware Rendering will improve the performance and the appearance of Atmosphere environments.
Even if you have a newer video card, the Active Renderer may still be set to Software. If this is the case, then the video card in your system is not supported. A complete list of supported video cards is included later in this chapter.
A scene shows transparent windows and crisp shadows with hardware rendering.
206
APPENDIX A
[1002] - ATI Technologies chipsets This line, for example, identies a video chipset containing a chipset manufactured by ATI. If the line starts with two slashes it is disabled, otherwise it is enabled. 3 Try to locate your video chipset in the le (if you do not know what chipset you have, see the next paragraph). If there is a line for your chipset, but it is disabled, remove the two slashes, save the le and relaunch Atmosphere. If there is no entry for your chipset, then you will have to add a line. 4 Atmosphere recognizes your chipset from two numbers, the Vendor ID and the Device ID. If you do not see your video chipset in the list, you will have to look up the numbers for your chipset and enter them in the conguration le. 5 Download the DirectX Caps Viewer from http://www.microsoft.com/, unzip it and run it. 6 In the DirectX Caps Viewer, there is a tree view on the left. The name of your video chipset appears under the heading DirectX Graphics Adapters. Try to nd this name in the AtmoHWCong.txt le. If it is present but disabled, remove the two slashes, save the le and relaunch Atmosphere.
7 If the chipset is not listed, click on the video chipset name that appears under DirectX Graphics Adapters. In the right pane, you will see see two items, VendorId and DeviceId among others. 8 Note the characters of the VendorId eld that appear after the 0x and leading zeroes: for example, its 1002 for a VendorID of 0x00001002. 9 Note the characters of the DeviceId eld that appear after the 0x and leading zeroes: for example, its 10d for a DeviceId of 0x0000010d. 10 Check the AtmoHWCong.txt le for a line that lists your vendor. If your vendor is there, add a line like this under the vendor name: (tab)xxxx description Where (tab) means press the tab key once, xxxx is the last digits of the DeviceId and description is any text that helps you remember the entryAtmosphere ignores the description. Save the le and relaunch Atmosphere. 11 If your vendor is not listed, add two lines to the end of the le AtmoHWCong.txt le like this:
208
APPENDIX A
[xxxx] vendor description (tab)xxxx chipset description In the rst line [xxxx] is the last digits of the VendorId surrounded by square brackets and vendor description is any text that helps you remember the vendor. In the second line, (tab) means press the tab key once, xxxx is the last digits of the DeviceId and chipset description is any text that helps you remember the entryAtmosphere ignores the description text. Save the le and relaunch Atmosphere. If Atmosphere still doesnt recognize your chipset, check to make sure that you made the entries correctly, saved the le and relaunched Atmosphere. If all is correct, then it may be that your chipset, even though listed in the AtmoHWCong.txt le, is not supported by Atmosphere. This may occur because Atmosphere interrogates the chipset to nd out if it supports certain minimum capabilities. If it nds that it does not, it will automatically switch back to software rendering mode. Please be aware that Adobe has tested Atmosphere against only the chipsets explicitly listed (and not commented out) in the AtmoHWCong.txt le that came with the Player installation. If you choose to add an untested chipset, you may experience problems running the Player, crashes, or bad looking results. You may also nd that hardware rendering is slower than software rendering in certain cases. As Adobe tests more chipsets, it will add them to subsequent versions of the released Player.
210
APPENDIX B
Command View > New View View > Preview View > Top View > Front View > Right View > Perspective View > Bottom View > Back View > Left View > Isometric View > Zoom In View > Zoom Out View > Fit All View > Fit Selected View > Grid View > Snap to Grid View > Guidelines View > Shadows View > Reset Views Help > Atmosphere Help Help > Javascript API Documentation Help > Lighting Overview
Shortcut Shift+Ctrl+N F4 F5 F6 F7 F8 Shift+F5 Shift+F6 Shift+F7 Shift+F8 Ctrl++ Ctrl+Ctrl+0 Shift+Ctrl+0 Ctrl+ Shift+Ctrl+ Ctrl+; Shift+Ctrl+; Shift+Ctrl+R F1 F2 F3
Toolbar Keyboard Shortcuts Command Selection Tool Direct Selection Tool Rotate Tool Scale Tool Orbit Camera Tool Hand Tool Dynamic Zoom Tool Zoom Tool Navigate Tool Remove Texture Tool Sample Texture Tool Apply Texture Tool Misc Keyboard Shortcuts Command Access File menu Access Edit menu Access Object menu Access View menu Access Window menu Access Help menu Move to next menu Move to previous menu Move up menu list Move down menu list Execute selected menu command Move focus to next palette control Move focus to previous palette control Simulate click on button with focus Shortcut Alt+F Alt+E Alt+O Alt+V Alt+W Alt+H Right arrow Left arrow Up arrow Down arrow Enter Tab Shift+Tab Enter Shortcut V A R S C H or spacebar D Z N E I K
212
APPENDIX B
Player Navigation Keyboard Shortcuts Command Move forward Move backward Turn to right Turn to left Move upward Move downward (with Gravity disabled) Tilt view upward Tilt view downward Strafe right Strafe left Shortcut Up arrow Down arrow Right arrow Left arrow Shift+up arrow Shift+down arrow Ctrl+up arrow Ctrl+down arrow Shift+right arrow Shift+left arrow
214
APPENDIX C
Textures Set 1
216
APPENDIX C
218
APPENDIX C
220
APPENDIX C
222
APPENDIX C
Textures Set 2
224
APPENDIX C
226
APPENDIX C
Objects Set 1
228
APPENDIX C
Objects Set 2
230
APPENDIX C
Objects Set 3
232
APPENDIX C
glareEffect
controller-door
controller-motor
onClick
onCollide
onMouseOver
onProximityOfActorToAnchor
onProximityOfActorToScript
playMovie
234
APPENDIX C
pointToPointConstraint
This script sets up a point to point constraint between the target object and the reference object. The script will create a physical model for the target object, so make sure you dont use the target object with another script that wants to do so. The script also needs the reference object to have a physical model, however it wont make one for it. Make sure the reference object has one by checking the Fixed Physical Model checkbox in the object inspector window in the builder. This script allows you to swap one or all of the textures on a primitive object with another texture. The guide above tells you how to set up the script to swap all textures on the target object. This is the default behavior when you leave the baseTexture property empty. You can also set the baseTexture property to the lename of one of the textures you put on the primitive. In that case the script will only swap that texture with the swap texture, and leave all other textures alone. You can swap between the base textures and the swap texture with the swap action. If you want to make sure that the base textures are on, use the useBaseTexture action. Similarly, if you want to make sure that the swap texture is on, use the useSwapTexture action.
swapTexture
windController
This script allows you to affect an object with wind. You dene the direction the wind blows in by placing the anchor linked to the windOriginAnchor property. The wind blows from that anchor towards the script. The strength of the wind is set with the windStrength property, where 0 is no wind at all and 100 is a storm.
signalRamp
signalRampContinuous
SceneGraph Overview
The objects available within the JavaScript API are organized in hierarchies. Two main hierarchies exist: the scene hierarchy, which contains the scene geometry, and the user interface, with the application at its root.
236
APPENDIX D
The scene hierarchy is rather like a folder hierarchy in the operating system. Objects may be thought to be contained within nested folders. However, in addition to storing an object, the scene hierarchy also affects the 3D position of objects displayed in the scene. Moving a parent object will also move the child objects if they are attached to parent (true by default), and the position of objects will be in parent relative coordinates. If the objects are not attached to parent (by setting to false in the API), then their position is in absolute world space coordinates. To aid the positioning of objects in the API, there are properties on objects that give the world space position directly for an object independent of where it is in the scene hierarchy. By default in the Atmosphere application, all objects are attached to parent.
The World
At the top of a scene hierarchy is the world which is a container of type SceneGroup that has listed within it child objects that are other scene objects. The World is accessed within the JavaScript API using the global variable theWorld. The world will contain the globals theActor and theStage.
The Actor
The actor (the global theActor) represents the local user of the application. It has various properties that represent the motion of the Actor as he or she moves through the 3-D world. There is a built-in standard navigation scheme that may be partially or fully disabled and replaced with a motion that is determined by a JavaScript. (The control of the Actor motion and view of ones avatar are discussed in more detail in a later section.)
The Stage
The stage is a container for all content loaded from les when interacting with a world (excluding the actor and remote actors). The stage may directly contain solid objects, surface objects, Viewpoint objects, etc., as well as other scene groups with their own nested content. When a model is added to the world using a script to open an .AER le, it is added to the stage by default.
Solid Objects
A solid object is a scene element that contains a hierarchy of primitives that include boxes, cones, walls, oors, anchor points, entry points and groups that contain other primitives. In the Atmosphere application the primitives may be edited and moved relative to each other. In the Player application, the primitives will have been combined together into a single xed shape. This shape, the solid object, may be animated and used to do physics, but the primitives will be xed in their position relative to the solid object. The tree of primitives is accessed using the rootPrimitive property, and may be searched using the nd function. Alternatively, you may nd a named object within a solid object using the getPrimitive function.
Primitives
A primitive is an object that represents a single geometrical entity in the Builder, such as a cone, box, oor or wall. Other primitives include anchors and entry points that may be used to specify positions and orientations to a script. Primitives that have geometry contain an array of face objects which correspond to the planar polygons of the primitive. Primitives may also have on-click methods attached to them to enable interaction.
Faces
A face object of a primitive represents a single planar region of that primitive, and may have an associated surface texture.
Surface Textures
A surface texture is an object that contains the mapping between a face and a texture map. This mapping includes the rotation angle, size and position of the texture relative to the surface. It also contains a reference to the texture object which stores the actual image.
Textures
A texture is an object that stores an image, and which is used by a surface texture to be mapped onto a primitive.
Viewpoint Objects
A Viewpoint object is an element in the scene hierarchy which contains an imported object specied by a Viewpoint MTX le (which may have an associated MTS le). A Viewpoint object contains a single MTSScene object, which is the root of the Viewpoint scene hierarchy. A Viewpoint scene contains a hierarchy of instances. An instance contains a transformation and reference to a piece of Viewpoint geometry (a polygon mesh) as well as an array of child instances. Viewpoint instances also contain an array of MTSMaterial objects that describe how a piece of geometry is textured and rendered. Viewpoint surfaces may be textured using static images (MTSTexture) or SWF animations. Viewpoint objects may have rich materials including bump mapping and environment mapping, but do not take part in static lighting computations in the Atmosphere application. Viewpoint objects do not receive dynamic shadows in the Player.
238
APPENDIX D
Surface Objects
A surface object is an element in the scene hierarchy which contains one or more surfaces. These are currently authored by converting from Viewpoint objects. The advantage of surface objects is that they may be included in static lighting computations in the Atmosphere application and can receive dynamic shadows in the Player.
The Application object, available as the global application, is the object that represents the user interface and input peripherals. These include the state of keys in the keyboard and the mouse button. The application also has an array of view objects, one for each window into the current 3-D world. (In this version of Atmosphere there is only one such view.) The application also has some control over the chat window and can send JavaScript commands to external objects on the web page of the plug-in allowing back-end processing.
View Objects
A view object represents the 2-D window within which the world may be seen. A view knows its size in pixels and the X/Y position of the mouse when the cursor is over the rendered window. A view also has an array of cameras representing different 3-D projections of the world. (In the current release there is one camera per view.)
Camera Objects
A camera object has a 3-D position and orientation along with variables to control the eld of view. A camera also has some utility functions to enable 2-D pixel coordinates to be converted into 3-D ray directions and vice versa. This is useful when implementing interactive scripts that need to re rays into a scene.
Physical Simulation
One of the powerful features of Atmosphere is the ability to create physically-realistic animation using the built-in physics engine. A physics engine may be thought of as a process that updates the position and orientation of certain objects every frame in accordance with the laws of physics. Without a physics engine, objects can pass through each other without collisions and do not experience forces such as gravity. In addition, physics engines allow the specication of physical constraints which restrict the motion in a way that is consistent with the presence of things like hinges, slide rails or pivot points. Using combinations of physically animated objects and constraints, it is possible to construct elaborate mechanisms (such as vehicles) that interact with the world and with each other in a realistic manner.
Physical Models
An object will only be animated using physics when a physical model has been created to control it. Each frame, the physical model updates the position and orientation of the object for which it was created. Physical models have position, orientation, velocity, angular velocity, and acceleration. They also have ags that determine whether they are xed in space, and whether they will collide with other physical models. Collisions may be disabled between pairs of physical models as needed to permit intersections which are part of the design. For reasons of efciency, there are two kinds of physical models convex and concave. Convex physical models are approximated using the convex hull of their geometry and they simulate collisions efciently. Concave physical models are slower, but allow objects to enter within the convex hull of each other to compute more accurate collisions. An exception to this rule occurs when a physical model is created with a mass of zero. In such a case, the physical model is locked to the world, and a concave physical model is just as efcient as a convex. This is especially useful when using a Viewpoint object to represent a terrain surface or part of a xed structure (such as a slide). Making a terrain object convex would prevent other physical models from moving into the valleys. Making it concave is still efcient, since the physical model has zero mass and so is locked in place. To create a physical model, a function such as createPhysicalModel(mass, inertiaScale) is called, and may be used with a scene group, a Viewpoint object, a Viewpoint instance, a surface object or a solid object. When createPhys icalModel(mass, inertiaScale) is called for a scene group, any Viewpoint objects, surface objects and solid objects contained within the scene group are unioned together into one physical entity (note that this does not include child scene groups). There is a ag which prevents the union with a parent scene groups physical model, and this ag is automatically set to true if an object within the scene group has already been used to create a physical model. Child scene groups will be kinematically placed relative to the parent every frame, but will not interact physically. The user interface for the Adobe Atmosphere Player application includes check boxes for Collisions and Gravity. Note that these settings actually only control whether the Actor experiences gravity and collisions. To enable gravity for a physical model, the physical model must have its vertical acceleration set to a Vector (such as Vector( 0, -32, 0 ) for Earths gravity at sea level). This enables gravity to be controlled independently for different objects. A hot air balloon, for example, might have the acceleration for its canopy set to point upwards, simulating lift.
Physical Constraints
A constraint object, in the physics engine, is a way to restrict the motion of two physical objects in such a way that there appears to be a type of mechanism connecting them. For instance, a point-to-point constraint requires that a point on one physical object remain in the same position as a second point on a second physical object, no matter how one or both of them moves. In this way the effect of a spherical joint may be added to the simulation. Hinges (using a hinge constraint) and rails (a prismatic constraint) may also be created. Constraints need to be solved or enforced, using a fast constraint solver object. One of these objects is created in the script, and the constraints are set using a specied solver. Angular Dashpots are not constraints as such, but may be used as damped angular springs to encourage the relative orientation of one object to another, such as a spring-loaded door.
240
APPENDIX D
Scope
As you browse worlds using the Adobe Atmosphere Player, a separate instance of the interpreter is created for each world that you visit. Additionally, any loaded scene groups or avatars that have JavaScripts attached to them will also have their own separate interpreter. This is done in order to prevent name collisions between sets of world scripts and those scripts running on loaded scene groups. All scripts present in an Atmosphere world will share the same JavaScript interpreter. For example, a world which contains entries into the JavaScript URL eld on the Inspector Palette for both a solid object and a scene object will both share the share the same interpreter. Global variables declared in either of these scripts will be available to both scripts. Stated another way, if two scripts both dene a global variable named distance, the last value set for distance will be used by both scripts. If not intentional, this will likely produce unpredictable results during processing. However, global variable sharing may also be exploited to allow the sharing of state between scripts in a convenient fashion. To prevent unwanted name collisions, avoid global variables, and instead use variables attached to the this variable, such as in this.mass = 1.0;. Such an approach will limit the scope of the variables to the script object itself.
For Viewpoint objects and script-loaded scene groups, it is possible for the object to exist before all of its elements (such as geometry) have been fully loaded. Attempting to use such elements prematurely will cause an error. (One such example is using the object to create a physical model from geometry that has not loaded yet.) It is important, therefore, to wait until the objects have fully loaded before proceeding further. Whenever a script is told to run, and the script does not return within a specied duration, the script will time out, that is be permanently stopped. Scripts are prevented from looping continuously in this way to avoid hanging the system. This requires that scripts do not loop continuously waiting for an object to load. Instead a call-back is needed in the script to check the status of objects. There are two possibilities: one is to dene a timestep function, called back every frame and within which the loaded ag is tested until true; a second approach is to dene an onLoad function, that will be called back once when the object nishes loading. In either case, the object must be added to the list of objects which will receive callbacks via the addAnimator function.
Many of the Preset scripts included with Atmosphere initiate a timestep which tests to see if the target object is loaded prior to performing any action on it. See the code in these scripts for an example of best practices on testing whether something is loaded.
Script Context
JavaScripts attached to objects may be run in three different situations or contexts. Atmosphere creates three global variables to aid in this distinction:
worldContext this global variable will be true anytime that a script is not attached to an avatar in any manner (that is, not used by an AER le which is loaded as an avatar). localAvatarContext this global variable will be true for the owner of an avatar only. In other words, when a script is
attached to an AER le which is then loaded as an avatar, this variable will be true only for the person who is using the AER le as their avatar.
remoteAvatarContext this global variable will be true for your avatar script when it is being run on a remote users
computer. This distinction allows an avatar owner to process events differently depending upon the context of the avatar. For example, an avatar may contain animations which are triggered by buttons on the control panel. The avatar owner may wish to only create the buttons on their local control panel, and not those of the remote users. In addition, these global variables may also be used in conjunction with the chat.lter() method to send silent messages to their remote avatar, triggering the animations on the remote users computer.
242
APPENDIX D
Utility Functions
animators
The list of all registered animators. Some entries may be the value false. Animators are used each timestep to callback a timestep function(now, deltaTime) if one has been dened for the animator. Animators are also called back once with the onLoad(now) function, if it is dened. This happens after all scripts for the world have been run and the animators loaded ag has transitioned from false to true.
chat.print (There are (at most) + animators.size + animators.);
context
244
APPENDIX E
else if (context == RemoteAvatarContext) { chat.print(This is a REMOTE avatar script.); } else { chat.print(This is not an avatar script.); }
localAvatarContext
the value of the context global in an Avatar script which is running on the client that owns the Avatar.
remoteAvatarContext
the value of the context global in an Avatar script which is running on another users client.
worldContext
Global Methods
addAnimator(object)
Adds the given object to the list of animators. Once every frame, each animators timestep(t, deltaT) callback is called, where t is the current time in seconds since the world was entered, and deltaT is the time in seconds since the last timestep. Additionally, each animators onLoad() callback is called when the last and nal javascript le associated with the world has been successfully loaded and executed.
foo = new Object; foo.timestep = function(t, deltaT) { chat.print(This timestep is at + t + seconds.); chat.print(Last timestep was at + (t - deltaT) + seconds.); } addAnimator(foo);
removeAnimator(object)
Removes the given object from the list of animators. If the object is in the animators list more than once, only one instance of it is removed.
removeAnimator(foo);
dump(object)
dir(object)
Displays a hierarchical list of the objects children in the chat output window.
obj = theStage.getSolidObject(0); prim = obj.rootPrimitive; dir(prim);
path(object)
PluginCommand(stringCommand, 0, 0)
This method allows Webpage Javascript to communicate with Atmosphere Javascripts. Any Javascript code that Atmosphere can process can also be triggered from an Webpage script. Functions can be called, properties changed, and variables updated. In the Webpage, the Atmosphere Player is loaded using the <object> tag, which also allows for an id value in the tag. (If you are using the AtmosphereInterface.js provided by Adobe, the id value will automatically be assigned to MetaCtl0.) Once the page has been processed and Atmosphere is loaded, you may reference the Atmosphere object using the document object SceneGroup (DOM) in HTML. The PluginCommand described here becomes a method of the Atmosphere object, and is called in this manner: document.all.MetaCtl0.PluginCommand(stringCommand, 0, 0); To send a command to from the Webpage javascript to Atmosphere Javascript, embed the identical Atmosphere command into a string as the stringCommand argument. Because the command is sent as a string, pay careful attention to how embedded strings within your command are represented, since it is possible that they may incorrectly terminate the command. As a reminder, there are two methods in Javascript for ensuring that multiple string quotations do not cancel each other out. The rst is easier to visualize for syntax compliance, but as your command string gets longer the second method will become useful. First Method: alternate the use of quotation types, as in . Heres an example of a short command which is easy to recognize as having correct syntax, and easy to send: document.all.MetaCtl0.PluginCommand(chat.print(Hello Atmosphere User!);, 0, 0); Second Method: use the backslash character \ prior to the embedded quotations. Using the backslash character will instruct Javascript that the next character in line should be processed as part of the string, and not a control character. The example shown here uses the same command example as above, but with different formatting to help clarify the backslash use: document.all.MetaCtl0.PluginCommand(chat.print(\Hello Atmosphere User!\);, 0, 0); Both examples above will produce the same result in the Atmosphere Chat window (a string message). Again, depending upon the length of your command, both methods will be useful, with longer command strings being more easily created with the second method.
246
APPENDIX E
Finally, it is possible to concatenate Webpage variable values into your command string sent to Atmosphere. Once understood, this process is not difcult and is very useful to induce Atmosphere actions and changes based upon events in the Webpage. * See the examples elsewhere on the Atmosphere website to demonstrate this behavior in more detail. The example can be downloaded and examined or customized for your particular application. * Note: when modifying properties in in Atmosphere, its necessary to wrap the command in an eval() method, as shown below. This requirement may be removed in the future.
//automatically hide the Atmosphere Chat pane document.all.MetaCtl0.PluginCommand(eval(application.chatPaneVisible = false);, 0, 0); //move a world object using a variable value from the webpage document.all.MetaCtl0.PluginCommand(eval(box.position = Vector(box.position[0], + pageValue + , box.position[2] ) );, 0, 0);
sendJS(stringCommand)
This method allows Atmosphere world Javascripts to communicate with the Webpage Javascript. Any Javascript code that the Webpage can process can also be triggered from an Atmosphere script. The entire document object SceneGroup (DOM) can be addressed, functions can be called, properties changed, variables updated. To accomplish any of these tasks, simply embed the identical Webpage call into a string within the sendJS(stringCommand) method. Because the command is sent as a string, pay careful attention to how embedded strings within your command are represented, since it is possible that they may incorrectly terminate the command. As a reminder, there are two methods in Javascript for ensuring that multiple string quotations do not cancel each other out. The rst is easier to visualize for syntax compliance, but as your command string gets longer, the second method will become useful. First Method: alternate the use of quotation types, as in . Heres an example of a short command which is easy to recognize as having correct syntax, and easy to send:
sendJS(alert(Hello, World.););
Second Method: use the backslash character \ prior to the embedded quotations. Using the backslash character will instruct Javascript that the next character in line should be processed as part of the string, and not a control character. The example shown here uses the same command example as above, but with different formatting to help clarify the backslash use:
sendJS(alert(\Hello World.\););
Both examples above will produce the same result in the Browser window (which is an alert dialog showing the Hello World. text). Again, depending upon the length of your command, both methods will be useful, with longer command strings being more easily created with the second method. Finally, it is possible to concatenate Atmosphere variable values into your command string sent to the webpage. Once understood, this process is not difcult and is very useful to induce webpage actions and changes based upon events in the Atmosphere world.
* See the examples elsewhere on the Atmosphere website to demonstrate this behavior in more detail. The example can be downloaded and examined or customized for your particular application.
// Open the URL in a browser window sendJS(window.open (http://www.adobe.com, , );); // Pop up a JavaScript alert window sendJS(alert(\Hello World!\);); // Update a webpage form checkbox with the Atmosphere current state sendJS(document.forms[myForm].chatPaneVis.checked = + application.chatPaneVisible);
$.gc()
This global method will force JavaScript memory garbage collection. More clearly, at regular intervals, the Atmosphere JavaScript processor performs memory reset and update for variables and objects which have been deleted in the JavaScript code. When large amounts of processing occurs using objects and variables of *identical* names, the objects or variables may be recreated prior to being deleted by the normal Javascript cleanup routine. If you experience errors under these conditions, you may insert this garbage collection method into your routine to ensure that the reused objects and variables were properly deleted prior to being reused.
//delete and recreate a new array of box SceneGroups function deleteBoxes() { //delete the rst group of boxes for ( i=0; i<50; i++ ) { delete boxes[i].SceneGroup; } //force memory clean up $.gc(); //recreate a new box array for ( i=0; i<50; i++ ) { boxes[i].SceneGroup = SceneGroup(./box.aer); } }
Callbacks
timestep(t, deltaT)
This function is called each frame with the current time in seconds that has elapsed since the world was entered. In worldInit.js the list of animators is traversed by this callback which in turn calls the timestep functions for each of the animators. Use custom timesteps to accomplish animated behavior, such as moving an object from one location to another over a specied duration. Creating custom timesteps require an object as a reference. For in-depth examples on
248
APPENDIX E
the use of the timestep method, follow the Javascript Workshops link at the Adobe Atmosphere website. (Please also note that there is a default function present for the timestep(t, deltaT) method in the worldinit.js le, and it is not recommended that you change this behavior).
box = SceneGroup(./box.aer).add(); box.timestep = function(t, deltaT) { box.orientation = Rotation(y, t); } addAnimator(box);
onLoad()
This function is called after the last and nal JavaScript le associated with the world has been loaded and run. In worldInit.js this event is used to wait for scripts to be loaded before testing whether animators need to have their onLoad methods called. This is done when their loaded ag transitions from false to true. The onLoad() method can be used to initialize objects as they load. Creating a custom onLoad() callback requires an object as an animator. Note: the addAnimator function must be used in order to enable the onLoad callback function. (Please also note that there is a default function present for the global function onLoad() in the worldinit.js le, and it is not recommended that you use this as a global function name in a script.)
box = SceneGroup(./box.aer).add(); box.onLoad = function(now) { chat.print(onLoad called at: + now); } addAnimator(box);
Application
Application
The Application module is is used to communicate with elements of the user interface. These include the keyboard and mouse buttons, which may be read. There are also ags that control the visibility of the chat pane and the toolbar, both of which appear in the Player window. The Application module also maintains an array of View objects that each represent a 3-D rendered view of the current world. (Currently there is exactly one such view.) Global Properties
application
This global variable stores a reference to the object that represents the application.
// Print out properties associated with application dump(application);
Properties
type
controlKeyDown
shiftKeyDown
leftArrowKeyDown
rightArrowKeyDown
upArrowKeyDown
downArrowKeyDown
mouseButtonDown
chatPaneVisible
splitPercentage
Species the percentage of the Player window area which should be occupied by the chat pane.
application.splitPercentage = 20; // set to 20 percent
250
APPENDIX E
toolbarVisible
Controls the display of the toolbar which appears at the lower edge of the Player area.
application.toolbarVisible = false; //turn it off for maximum viewable area
Methods
getView(index)
Returns the View object selected by the value of index. Currently the only valid value for index is 0.
view = application.getView(0); dump(view);
getViewCount()
Returns the number of views in the application. Currently will always return 1.
numViews = application.getViewCount(); chat.print(There is/are + numViews + view(s).);
View
The View module is an object that represents a 2-D rendered window that is being used to image a 3-D world. The module properties include the size of the rendered area and the current mouse coordinates relative to the view. The View module also contains an array of cameras that are being used to image the world onto the 2-D view plane (Currently there is exactly one camera per view.) Properties
type
imageWidth
imageHeight
mouseX
The X coordinate of the pixel that the mouse cursor is over in the rendered view. 0 represents the left side of the screen, with the value increasing as the cursor goes to the right.
view = application.getView(0);
mouseY
The Y coordinate of the pixel that the mouse cursor is over in the rendered view. 0 represents the top of the screen, with the value increasing as the cursor goes down the screen.
view = application.getView(0); stageModel.getSolidObject(0).rootPrimitive.onClick = function() { chat.print(You clicked down at Y-coordinate: + view.mouseY); }
mouseInitialized
This is a boolean property which will return true when the mouse is over the render view area.
view = application.getView(0); if (view.mouseInitialized) { /* ready to track mouse */ }
Methods
getCamera(index)
Function that returns a reference to the camera for given numerical index
camera = view.getCamera(0);
getCameraCount()
Function that returns the number of cameras associated with rendering this view. (Currently exactly one.)
numCameras = view.getCameraCount();
triggerRedisplay()
Forces the view to be fully redrawn during the next time step. This may be necessary when changing the appearance of Viewpoint objects.
view = application.getView(0); view.triggerRedisplay();
Button
The Button module enables a script to add buttons and toggles to the browsers Controls panel. Once created, the buttons and toggles may be added and removed from the panel freely (so that they may be made visible when they are relevant). The script may also change their labels and states at any time. The script may query the state, or may be notied of changes (typically when the user clicks on the button or toggle, but also when the script changes the state) via the onClick() callback.
252
APPENDIX E
Global Methods
Button(label)
creates a Button with the specied label (optional). The Button will not be added to the Control Panel until you call add().
takePicture = Button(Say Cheese);
Toggle(label)
creates a Toggle with the specied label (optional). The Toggle will not be added to the Control Panel until you call add().
fogToggle = Toggle(Fog Enabled);
Properties
state
enabled
label
Methods
add()
adds the button or toggle to the control panel associated with the current world. The toggle itself is returned as a convenience.
fogToggle = Toggle(Fog Enabled).add();
remove()
removes the button or toggle from whatever control panel it is currently in.
fogToggle.remove();
Callbacks
onClick(state)
is called when the button is pressed or when the toggle state changes (either due to the user clicking on it, or if toggle.state is changed by JavaScript code).
Slider
The Slider module enables a script to add sliders and progress bars to the browsers Controls panel. Once created, the sliders may be added and removed from the panel (so they may be, for instance, only made visible when they are relevant). The script may also change their labels and values at any time. The script may query a sliders value, or may be notied when it changes (typically when the user slides the tab or types a new value, but also when the script sets the value directly) via the onChange() callback. Global Methods
Slider(label)
Creates a Slider with the specied label (optional). The Slider will not be added to the control panel until you call add().
fogNearSlider = Slider(Fog Near);
Progress(label)
Creates a Progress Bar with the specied label (optional). The Progress Bar will not be added to the control panel until you call add().
lifeProgress = Progress(Life Force Left);
Properties
enabled
If set to false, greys the slider and makes it unavailable for use. (default = true)
fogNearSlider.enabled = false;
integersOnly
If true, the slider will accept and generate only integer values. False by default. (For progress bars do not set integersOnly to false in the current release.)
// Drop-off expects only integers. fogDropOffSlider.integersOnly = true;
label
range
254
APPENDIX E
value
Methods
add()
Adds the slider or progress bar to the control panel associated with the current world. The slider itself is returned as a convenience.
fogNearSlider = Slider(Fog Near).add();
remove()
Callbacks
onChange(value)
Is called when the sliders value changes (either because the user moves it or if slider.value is changed by the script).
fogNearSlider.onChange = function(value) { fog.near = value; }
Lastly, successful synchronization requires that a consecutive series of steps be followed for establishing shared object names and their conditions. The Atmosphere website shows an example of this technology, and will aid greatly in creating your own solution. *(Note that Adobe provides a limited quantity of default server power for handling avatar, chat, and object synchronization. See documentation elsewhere regarding). Global Properties
chat
Properties
avatarID
A GUID for your avatar in the current world. This property will allow you to send messages to your remote avatar more easily. Note that it is not possible to obtain the GUID of another avatar.
myCurrentAvatarID = avatarID;
isConnected
This property will return true once a connection with the server has been established.
if (isConnected) { ... }
worldID
Methods
input(a, b, c, ...)
Concatenates the parameters together into a single string and enters it as if the user had typed it in. Note that the string will not be displayed in your local chat window. This method is presently only available for the chat device, and only for Local Avatar scripts.
chat.input(Hello Everybody!);
print(a, b, c, ...)
Prints the specied strings or values. Note that this method is not available for your Remote Avatar script.
status.print(All is well.);
createSharedObject(str objectName)
Creates a JavaScript object of the given name on the chat server, and which is shared by all visitors. This function will trigger the callback onSharedPropertyChange(sName, sProp, sValue) for the sender only. Note that both sProp and sValue will be empty strings for this rst callback.
256
APPENDIX E
This method is a local check of the property value; it does not communicate with the server
chat.getSharedProperty(myGlobe,isSpinning);
Notice that only a request method exists; there is no method to create a shared property. This prevents new visitors from forcibly (accidentally) resetting the value of the shared property when they arrive. When this method is called, it will trigger the onSharedPropertyChange(sName, sProp, sValue) callback for the sender only. If the property already exists, the callback will return the property and current value. If it does not exist, the property will be created, and the value will be an empty string upon return.
chat.requestSharedProperty(myGlobe,isSpinning);
Use this method to set the shared property value. This method must be called only after objectName and propertyName are known to exist.
chat.setSharedProperty(myGlobe,isSpinning, true);
Callbacks
lterInput(textInput)
When you type text into the local chat line and then press the Enter key, the string from the chat line is rst passed through this method (if present) before being sent to the chat server. This method can be present in a script attached to your Avatar, or be present in a script which is attached to a world you created. Used in the latter manner, as the world designer you can lter out words for everyone who is visiting your world. It must return true if the input has been captured, and false if the input should be passed on to the chat server.
chat.lterInput = function(msg) { if (msg.match(/^PING!/)) { chat.print(PONG!); return true; //Dont send the PING! on to the server. } else { return false; //Otherwise, let the message pass. } }
lterOutput(textOutput)
This method is used by your Remote Avatar, which is running on someone elses computer. When you type a message into your chat line and press Enter, the message is sent to the server, and the server in turn sends the message to all the visitors in the world (including you, the original sender). Before your message is placed into the chat window on someone elses computer, it is passed through this chat.lterOutput method, which is running for your Avatar on their computer. The returned string is what will actually be printed to their chat window, or no message will be printed at all if the return value is an empty string or false.
chat.lterOutput = function(msg) { // If the message string contains MyCoolWave, trigger my // remote avatar to wave, and strip the MyCoolWave text // out of the message before sending it to the chat if (msg.match(/MyCoolWave/)) { doWave(); // Run my wave msg = msg.replace(/MyCoolWave/, ); // Strip out MyCoolWave } return msg; }
onConnect( )
A callback which is processed when server connection is established. Call createSharedObject() in this function to establish the objects that will be synchronized. Note that timing limitations exit for script processing, and attempting to induce extensive server callbacks may fail.
chat.onConnect = function() { chat.createSharedObject(myGlobe); }
This is the main callback which occurs when any visitor updates a property value for any shared object.
chat.onSharedPropertyChange = function(objName, objProp, objValue) { ... }
Math
Rotation
A Rotation object encodes an arbitrary relative geometric rotation. Most objects use a Rotation to specify their orientation (a rotation relative to the parent or world coordinate frame). A number of methods are provided to make combining and manipulating Rotations simpler, without regard to their underlying implementation. (Rotations are
258
APPENDIX E
equivalent to orthonormal 3x3 matrices and are stored internally as quaternions. This allows them to be smoothly interpolated or blended to give intermediate rotations.) For objects in the scene, a pivot point is assigned at object creation which is used for rotation purposes. This point is not revealed in the interface currently, and will vary based upon numerous variables such as the use of scale and translate tools. Therefore, do not rely on the object pivot being in a known location. Instead, use an anchor in world space to act as the pivot. An example of this approach can be seen in the rotateContinous preset script included with the Atmosphere application. Lastly, rotation measured for objects in an Atmosphere scene are in the units of Radians (where a complete circle = pi * 2). Global Methods
Rotation(various...)
Creates a new Rotation(rotational transformation object). The following parameter styles are understood: Rotation() - The identity Rotation(no rotation at all) Rotation(X, .7) - Rotate by .7 radians around X. Rotation(Y, .3) - Rotate by .3 radians around Y. Rotation(Z, .9) - Rotate by .9 radians around Z. Rotation(XZY, .7, .9, .3) - Rotate around Y by .3, Z by .9, then X by .7 (Rotations are processed from right to left.) Rotation(vec, angle) - Rotate around Vector vec by angle radians. Rotation(r1, r2) - Rotate by Rotation r2, then by Rotation r1 (think r1 of r2) Rotation(X, .7, r2) - Rotate by Rotation r2, then around X by .7 Rotation(r1.toString()) - decoding from an encoded string. Rotation(r1, r2.toString(), X, .7, ...) - Any number of concatenations are allowed.
critter.orientation = Rotation(Y, critter.yRotation);
Properties
inverse
type
Methods
blend(b, fraction)
Returns a rotation that is the interpolation between a and b according to the specied fraction (0..1)
// 10% of the way from a to b c = a.blend(b, .1);
map(vec)
mapAxis(axis)
power(pow)
toString()
Returns the Rotation encoded as a string. This provides a way in which rotation information can be sent over the chat line to another visitor in the same world. The receiving visitor can then decode the rotation using this approach: box.rotation = Rotation(newRotation.toString())
newRotation = currentRotation.toString()
Transform
A Transform is a geometric transformation composed of an arbitrary rotation followed by a translation. Most objects use a Transform to specify their location and orientation. Various methods are provided to make manipulation of Transforms straightforward, without regard to the underlying representation. (A Transform is equivalent to a constrained 3x4 linear transformation matrix with an orthonormal 3x3 rotational sub-matrix. It is actually stored internally as a quaternion and a translation. Due to this, its useful to note that using chat.print(transform) for debugging purposes will return an array of 6 values. This format, however, cannot be used for setting a Transform, but is useful only for observing the results of an operation.) Global Methods
Transform(various...)
Creates a new Transform(spatial transformation object). The following parameter styles are understood: Transform() - The identity transformation (no rotation or translation) Transform(translateVec) - Translate by the given Vector
260
APPENDIX E
Transform(rotor) - Rotate by the given Rotation Transform(translateVec, rotor) - a translation of a rotation Transform(tfm1, tfm2) - tfm1 of tfm2 (apply tfm2, then tfm1) Transform(trans1, tfm2, rot3, tfm4, ...) - Any number of concatenations are allowed. In this manner, multiple iterations of transforms are not in absolute coordinates, but are added relatively Transform(t1.toString()) - decoding from an encoded string.
critter.transform = Transform(critterSpot, Rotation(Y, critter.yRotation));
Properties
inverse
rotation
translation
Methods
blend(Transform b, oat fraction)
map(vec)
power(pow)
toString()
Returns the Transform encoded as a string. This provides a way in which transform information can be sent over the chat line to another visitor in the same world. The receiving visitor can then decode the transform using this
Vector
Vectors specify geometric x, y, z offsets. Most objects use Vectors to specify their location (relative to the origin <0, 0, 0>). Many methods are provided for combining and manipulating Vectors without the need to refer to the x, y, z components directly. Global Methods
Vector(various...)
Creates a new Vector (direction or position object). The following parameter styles are understood: Vector() - The zero vector <0.0, 0.0, 0.0> Vector(x, y, z) - The vector <x,y,z> Vector([x, y, z]) - The vector <x, y, z> Vector(v.toString()) - decoding from a string-encoded Vector Also note that anywhere a Vector is accepted as a parameter, an Array of three numbers, [x, y, z] or [r, g, b], will generally also be understood. (The exception is that you cannot dispatch Vector methods this way, so v = Vector(1, 2, 3).add([4, 5, 6]); is valid, but v = [1, 2, 3].add([4, 5, 6]); is not.)
critter.position = Vector(5.0, oorHeight, 17.0);
Properties
[n]
x, y, z
r, g, b
length
262
APPENDIX E
negated
normalized
Methods
add(B)
subtract(Vector)
change(index, value)
Returns a new vector with the specied element (0 < index <= 2) changed. It is not possible to modify a component directly except using this method.
// Set y = oorHeight. shadowPlace = position.change(1, oorHeight);
scale(s)
same(B)
dot(B)
Returns the dot product of this Vector with Vector B. (The dot product of vectors A and B is by denition the cosine of the angle between A and B, times the lengths of both A and B.)
aimQuality = aimVec.dot(targetPosition.subtract(myPosition).normalize())
cross(B)
Returns the cross product of this Vector with Vector B. (The cross product of vectors A and B is by denition a new vector, C, perpendicular to both A and B, whos length is the sine of the angle between A and B, times the
lengths of both A and B. The direction of C can be determined by the right hand rule: curl the ngers of your right hand in the direction from A to B, then your thumb points in the direction of C.)
upVec = rightVec.cross(forwardVec);
addScaled(B, scale)
blend(B, fraction)
Returns a Vector interpolated the specied fraction from this Vector to Vector B.
// 50% blend gives average. midPoint = minPoint.blend(maxPoint, .5);
Returns the Vector encoded as a string. This provides a way in which vector information can be sent over the chat line to another visitor in the same world. The receiving visitor can then decode the vector using this approach: tempVector = Vector(newVector.toString())
newVector = currentVector.toString()
Effects
Fog
The fog effect causes your world to be lled with a mist that obscures objects based on their distance from the user. The near and far properties determine the range of this transition and the dropOff property controls the rate of change within that range. For highly complex large worlds, using fog will improve rendering performance, since geometry beyond the far fog distance is efciently culled from the rendering process. An alternative use of fog is to approximate the appearance of localized lighting around the user, by using a fog color of black. Global Properties
fog
Properties
active
264
APPENDIX E
fog.active = true;
color
dropOff
far
near
Glare
The glare effect creates a diffuse glow over and around an object in the Explorer view if the object was marked with emits light in the Builder. It creates the impression that the light sources are very bright, causing optical effects within the virtual camera that approximate lens are or glare in a real-world camera. This will work for constant color and texture mapped light sources. Global Properties
glareEffect
Properties
active
brightness
Controls the visible brightness of the glare, which also reects the color of the glare and the color of the light object. The default brightness value is 1.0, with a range limitation of 0.0 to 2.0. Changing the brightness value does not slow down rendering, allowing for animated brightness effects such as pulsating glare.
color
An array of three oats representing the scales of the color of the glare in RGB values. The default color scale is a [1.0, 1.0, 1.0]. Please note that changing the color values every frame (such as in a timestep function) is not recommended. Changing the color causes the recomputation of internal data, and slows down rendering performance. However, changing values once at initial load time (or changing it based upon an event) is reasonable.
glareEffect.color = [0.5, 0.7, 1.0];
nonlinearity
The degree of non-linear remapping of the color values. Nonlinearity determines how the glare is combined with the rendered background. A very small value produces a linear response, but can too easily reach the maximum pixel level with a bright background. A high value of non-linearity tends to make the glare more smoothly varying without obvious clamping. The default value is 0.5. Please note that changing the value of nonlinearity every frame (such as in a timestep function) is not recommended. Changing the nonlinearity causes the recomputation of internal data, and slows down rendering performance. However, changing the value once at initial load time (or changing it based upon an event) is reasonable.
glareEffect.nonlinearity = 0.5;
radius
Glare size in screen pixels. The available range for radius is 16 to 64. The current implementation only works accurately for radius values that are multiples of 8.
glareEffect.radius = 16;
Sound
The Sound module enables a script to add sounds to the world. The sounds can be positional (localized), or ambient (uniformly everywhere). They can be started or stopped at any time, and may be set to play once, some number of successive repetitions, or to loop indenitely. Presently, the le formats supported for sound are: WAV, MP3, and CEL) When you use a script to specify a sound le, the Atmosphere application will keep track of the les for you. During publish, any referenced les in your script will be copied and included with the world le, and the le reference will be updated to match the sound le location. Global Methods
Sound(url)
Creates a new Sound in the current world from the specied URL (but does not start playing the sound).
windSound = Sound(http://myDomain.com/myHomePage/wind.wav);
266
APPENDIX E
Properties
active
far
near
The distance within which the sound will always be at maximum value. For each additional multiple of minDistance, the sound loudness will decrease by half.
windSound.near = 2.5;
position
The absolute position vector of the sound in the world or null if the sound is ambient. When switching from ambient to positional or vice versa, you must call play() to restart the sound in the new mode.
// Wind sounds coming from outside windSound.position = window.position;
repeats
How many times should the sound repeats (0 = forever). Cannot be changed while the sound is playing.
// knockSound.play() plays knock knock knock! knockSound.repeat = 3;
URL
The URL from which the sound was created (translated to an absolute URL).
chat.print(Now playing: + windSound.URL);
volume
Methods
play()
stop()
Event Handlers
CollisionEventHandler
A CollisionEventHandler is an object that can be used to specify what happens when two or more physical objects collide with each other. Numerous CollisionEventHandlers can be created, each specifying results for a limited scope of events, set by the ltering methods shown below. A CollisionEventHandler has an onCollision method, which is where the actions are dened forthe results of an event (what you want to do when a collision happens). By default, a CollisionEventHandler handles all events in a world. Use the local lter methods shown below to limit event handling to specic physical models. [Note: The Player object itself should not be specied as one of the physical models when ltering events. This is because the Player object is changed during initial world load, and will also be changed if the user changes avatars. To lter for Player events only, see the code example below for the rst property.] Global Methods
CollisionEventHandler()
Local Callbacks
onCollision(PhysicalModelA, PhysicalModelB, normalRelativeVelocity)
A method which denes what will happen when a collision occurs. The two physical models involved in the collision are returned, as well as the normalized relative velocity between the SceneGroups. The velocity may be used to provide scale for actions, such as changing the volume of a sound.
boxEvents.onCollision = function(physicalModelA, physicalModelB, normalRelativeVelocity) { if ( (physicalModelA.getParent() == player) || (physicalModelB.getParent() == player) ) { chat.print(This collision involved the Player!); } }
Local Methods
setFilterNoPhysicalModel()
Species that the collision event handler should respond to all collisions between all physical models (that is, do not limit the event handler to any specic SceneGroups).
268
APPENDIX E
boxEvents.setFilterNoPhysicalModel();
setFilterPhysicalModel(PhysicalModel)
Species that the collision event handler should respond to all collisions for a single physical model.
boxEvents.setFilterPhysicalModel(boxPhysicalModel);
setFilterPhysicalModels(PhysicalModel, PhysicalModel)
Species that the collision event handler should be limited to collisions between two physical models.
boxEvents.setFilterPhysicalModel(boxPhysicalModel, conePhysicalModel);
KeyEventHandler
A KeyEventHandler allows the developer to specify a response when the user presses a key while the focus is on the rendered window. The recognized key events include keyDown, keyUp, and a catch-all lter which recognizes all key events. The KeyEventHandler object is more simplied than the MouseEventHandler. Three ltering methods exist which specify the type of event to which the handler should respond, and the lters do not require that you pass an object to the method. The setFilterOnKeyDown() method will cause the handler to respond only when a key is pressed, and setFilterOnKeyUp() will cause a response only when a key is released. The setFilterEvent() method will respond to all key events. When a key event occurs, Atmosphere searches the list of user created KeyEventHandlers(with their Filtering Methods) to determine if the .OnEvent(keyEvent) callback should be triggered. If triggered, the event object which is returned possesses numerous properties about the key event. Two likely approaches may be used to respond to key events: Create two event handlers, one which uses the setFilterOnKeyDown() method and the other which uses setFilterOnKeyUp(). When the user presses a key, you may respond differently depending upon which key was pressed or released. Check the keyEvent returned to determine which key caused the event. A table is provided below which shows the conversion of key codes to common key names. Create only a one event handler which uses the setFilterEvent() method, and test event in the same manner as above to determine the key used. Your specic application will determine the best approach for you. Global Methods
KeyEventHandler()
Creates a new KeyEventHandler which may be set to process all key events(default), or be limited to down or up events only.
// create a new handler myEventHandler = KeyEventHandler();
Local Callbacks
onEvent(keyEvent)
A method which denes what will happen when a key event occurs. A KeyEvent object is returned which possesses the key code for the key pressed, as well as several other properties.
myEventHandler = KeyEventHandler(); myEventHandler.setFilterOnKeyDown(); myEventHandler.onEvent = function(keyEvent) { chat.print(Key Code = + keyEvent.keyCode); }
See the description for KeyEvent below for more details. Local Methods By default, a KeyEventHandler responds to all key events. Filtering Methods are therefore provided below to limit the scope of key events and allow customized responses.
setFilterEvent()
setFilterOnKeyDown()
setFilterOnKeyUp()
270
APPENDIX E
KeyEvent
A KeyEvent is not an object that you can modify. Rather, it is an object that is returned in the KeyEventHandler. onEvent(KeyEvent, what) callback. When you create a new KeyEventHandler(), you assign a ltering method to specify the events to which the handler should respond. For example, MyKeyEventHandler.setFilterOnKeyDown() instructs this handler to respond only when the user presses a key while the focus is on the rendered window. Following the click, the handler responds by triggering the MyKeyEventHandler.onEvent(KeyEvent) callback function, and processes the code you have written for this function. The KeyEvent described below is returned as an object, and possesses possesses the key code for the key pressed, as well as several other properties. Properties
keycode
true if SHIFT key was also held down during key event
metaKey2Down
true if CTRL key was also held down during key event
metaKey3Down
Key Code Table The key code returned by the KeyEvent object is identical to what is returned by Internet Explorer. If you are familiar with key codes and their matching common names for Internet Explorer, the response by Atmosphere will more easily understood. It should be noted that both Atmosphere and Internet Explorer have a limitation when returning key codes: upper and lower case are not differentiated. Therefore, the key code returned for any key will be the same regardless of whether the shift key is also held down. Due to this, shift key position must be also be tested if it is desirable to take case into account. For your convenience, the table below shows key codes matched to the common key names when your regional settings are set to English (United States).
Code 8 9 13 16 17 18 19 20 27 32 33 34 35 36 37 38 39 40 45 46 48 49 50 51 52 53 54 55 56 57 Name Backspace Tab Return Shift Control Alt Pause Caps Lock Esc Space Bar Page Up Page Down End Home Left Arrow Up Arrow Right Arrow Down Arrow Insert Delete 0 1 2 3 4 5 6 7 8 9 Code 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 Name A B C D E F G H I J K L M N O P Q R S T U V W X Y Z Left Window Key Right Window Key Code 96 97 98 99 100 101 102 103 104 105 106 107 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 135 Name Num Pad 0 Num Pad 1 Num Pad 2 Num Pad 3 Num Pad 4 Num Pad 5 Num Pad 6 Num Pad 7 Num Pad 8 Num Pad 9 Num Pad Multiply * Num Pad Add + Num Pad Subtract Num Pad Decimal . Num Pad Divide / F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F24 Code 144 145 186 187 188 189 190 191 192 219 220 221 222 Name Num Lock Scroll Lock Semicolon ; Equal = Comma , Hyphen Period . Slash \ Left Quote ` Left Bracket [ Virgule / Right Bracket ] Single Quote
272
APPENDIX E
MouseEventHandler
A MouseEventHandler allows the developer to specify a response when the user performs a mouse event in the rendered window. The recognized mouse events include Click, Over, Out, and Move (which can be combined to also create mouse Drag). A new MouseEventHandler() object should be created for each type of mouse event to which you desire to respond. The event responses are separated by designating different Filtering Methods as their names indicate (shown below). The Filtering Methods are also used to specify or limit the scope of world objects which will trigger the MouseEventHandler response. When a mouse event occurs, Atmosphere searches the list of user created MouseEventHandlers(with their Filtering Methods) to determine if the .OnEvent(event, what) callback should be triggered. If triggered, the event object which is returned as the rst argument possesses numerous properties about the mouse event. The second argument what contains a reference to the world object that was under the mouse during the event. Two likely approaches may be used to respond to mouse events: Create only a few event handlers(one for each type), and test the what object that is returned to customize the response based upon the object clicked. A switch - case statement would be useful for this type of approach. Create many custom event handlers with a single object specied in the Filtering Method. Both of these approaches have their advantages, and your specic application will determine whats best for you. Lastly, information on how various world objects respond to mouse events is shown below in the Local Methods section. Global Methods
MouseEventHandler()
Creates a new MouseEventHandler which may be set to process all mouse events(default), or be limited to a specic primitive, viewpoint object, or physical model.
// specify that the main world geometry, or stage will receive click events myEventHandler = MouseEventHandler(); myEventHandler.setFilterOnClick(stageModel.getSolidObject(0)); myEventHandler.onEvent = function(mouseEvent, what) { chat.print(Object = + what); }
Local Callbacks
onEvent(mouseEvent, what)
A method which denes what will happen when a mouse event occurs. A mouseEvent object is returned which possesses numerous properties, and the object under the mouse is returned as the second argument what.
myEventHandler = MouseEventHandler(); myEventHandler.setFilterOnClick(stageModel.getSolidObject(0));
If the above onEvent function is called as shown, a dump of the mouseEvent will return the following properties, which can in turn be used to control other logic for the event:
buttonLeftDown buttonMiddleDown buttonRightDown clickDown clickEvent clickUp metaKey1Down metaKey2Down metaKey3Down metaKey4Down x y // // // // // // // // // // true or false state of the left mouse button true or false state of the middle mouse button (currently always false) true for mouse down event, and false for mouse up acts as a type identier, and returns true for all click events true for mouse up event, and false for mouse down true if Shift key was also held down during click event true if Ctrl key was also held down during click event (currently not used) (currently not used)
// the x-axis pixel position of the mouse during the click event // the y-axis pixel position of the mouse during the click event
Local Methods By default, a MouseEventHandler responds to all mouse events. While this seems advantageous initially, all mouse move events are processed and can quickly become cumbersome. Filtering Methods are therefore provided below to limit the scope of mouse events and allow customized responses. The methods require that an object be specied, and this object will be used to determine if the OnEvent() callback should be triggered. Shown here is a list of object types and their scope during mouse event processing: All world geometry will respond to mouse events. Primitives should be named in the Builder application so that customized responses can be created. The stageModel represents the parent geometry in the world, and will respond to all mouse events if it specied as the lter object. Note that the sky does not respond to mouse events when the stageModel is used as the object. Any portion of a loaded SceneGroup will respond to mouse events, if the top level SceneGroup is referenced as the lter object. The scope can be reduced further by naming primitives in the loaded SceneGroup. Viewpoint objects which are imported into the stage or which are loaded as part of a submodel will respond to mouse events. The entire Viewpoint object is used, and cannot be limited to specic instance components.
setFilterOnClick(object)
Causes the specied object (Primitive, Viewpoint Object, or SceneGroup) to return an OnClick mouse event.
chair = theStage.getPrimitive(chair); myEventHandler.setFilterOnClick(chair);
274
APPENDIX E
setFilterOnMouseOver(object)
Causes the specied object (Primitive, Viewpoint Object, or SceneGroup) to return an OnMouseOver mouse event.
chair = theStage.getPrimitive(chair); myEventHandler.setFilterOnMouseOver(chair);
setFilterOnMouseMove(object)
Causes the specied object (Primitive, Viewpoint Object, or SceneGroup) to return an OnMouseMove mouse event.
chair = theStage.getPrimitive(chair); myEventHandler.setFilterOnMouseMove(chair);
setFilterOnMouseOut(object)
Causes the specied object (Primitive, Viewpoint Object, or SceneGroup) to return an OnMouseOut mouse event.
chair = theStage.getPrimitive(chair); myEventHandler.setFilterOnMouseOut(chair);
setFilterEvent()
Species that no events should be ltered, and all user mouse events (click, over, out, move) should return the event object inclusive with all its properties. Note that using this method will cause the second argument of the onEvent callback to return undened.
myEventHandler.setFilterEvent();
MouseEvent
A MouseEvent is not an object that you can modify. Rather, it is an object that is returned as the rst argument of the MouseEventHandler.onEvent(mouseEvent, what) callback. When you create a new MouseEventHandler(), you assign a ltering method to specify the events to which the handler should respond. For example, MyMouseEventHandler.setFilterOnClick(box) instructs this handler to respond only when the user clicks on the box (a world object, found in Javascript, and assigned the variable name box). Following the click, the handler responds by triggering the MyMouseEventHandler.onEvent(mouseEvent, what) callback function, and processes the code you have written for this function. The mouseEvent described below is returned as the rst argument of this function, and the object under the mouse during the event is returned as the second argument, what.
Local Callbacks
onEvent(mouseEvent, what)
A method which denes what will happen when the mouse event occurs. An event object is returned which possesses numerous properties, and the object under the mouse is returned as the second argument.
myEventHandler = MouseEventHandler(); myEventHandler.setFilterOnClick(stageModel); myEventHandler.onEvent = function(mouseEvent, what) { chat.print(Object = + what); dump(mouseEvent); }
If the above onEvent function is called as shown, a dump of the mouseEvent will return the following properties, which can in turn be used to control other logic for the event:
buttonLeftDown buttonMiddleDown buttonRightDown clickDown clickEvent clickUp metaKey1Down metaKey2Down metaKey3Down metaKey4Down x y // // // // // // // // // // true or false state of the left mouse button true or false state of the middle mouse button (currently always false) true for mouse down event, and false for mouse up acts as a type identier, and returns true for all click events true for mouse up event, and false for mouse down true if Shift key was also held down during click event true if Ctrl key was also held down during click event (currently not used) (currently not used)
// the x-axis pixel position of the mouse during the click event // the y-axis pixel position of the mouse during the click event
OverlapEventHandler
An OverlapEventHandler is an object that can be used to specify what happens when two or more physical objects overlap each other. Numerous OverlapEventHandlers can be created, each specifying results for a limited scope of events (set by the ltering methods shown below). An OverlapEventHandler has onEnter and onLeave methods, which is where the actions are dened forthe results of either event. By default, an OverlapEventHandler handles all events in a world. Use the local lter methods shown below tolimit event handling to specic physical models. Note: Enabling an OverlapEventHandler() for a specic physical model will also disable collision with that physical model; the two are mutually exclusive. It is not possible to collide with and object and also intersect with it at the same time. Global Methods
OverlapEventHandler()
Creates a new OverlapEventHandler (which possesses onEnter, onLeave, and ltering methods).
276
APPENDIX E
buildingOverlap = OverlapEventHandler();
Local Callbacks
onEnter(PhysicalModelA, PhysicalModelB)
A method which denes what will happen when an overlap initially occurs. The two physical models involved in the overlap are also returned. These values can be tested for parent or type, and customized actions performed based upon the results.
buildingOverlap.onEnter = function(physicalModelA, physicalModelB) { if ( physicalModelA.getParent().type == Player || physicalModelB.getParent().type == Player ) { chat.print(The Player has entered the building.); } }
onLeave(PhysicalModelA, PhysicalModelB)
Similar to above, a method which denes what will happen when an overlap is discontinued. The two physical models that were involved in the overlap are also returned. These values can be tested for parent or type, and customized actions performed based upon the results.
buildingOverlap.onLeave = function(physicalModelA, physicalModelB) { if ( physicalModelA.getParent().type == Player || physicalModelB.getParent().type == Player ) { chat.print(The Player has left the building.); } }
Local Methods
setFilterNoPhysicalModel()
Species that the overlap event handler should respond to all overlaps between all physical models (that is, do not limit the event handler to any specic SceneGroups).
buildingOverlap.setFilterNoPhysicalModel();
setFilterPhysicalModel(PhysicalModel)
Species that the overlap event handler should respond to all overlaps for a single physical model.
buildingOverlap.setFilterPhysicalModel(boxPhysicalModel);
setFilterPhysicalModels(PhysicalModel, PhysicalModel)
Species that the overlap event handler should be limited to overlaps between two physical models.
buildingOverlap.setFilterPhysicalModel(boxPhysicalModel, conePhysicalModel);
Scene Objects
Actor
The Actor module is used to represent the user of the application as they navigate the 3-D world. It has a position and orientation that is changed as the user moves. It corresponds the position of the users avatar as seen by other people (and by the user in third person view). The actor also includes properties that control the motion of the user. These include world-relative and screen-relative velocities, ags for enabling and disabling gravity and collisions, ags to disable the default navigation scheme and functions for setting and retrieving the orientation of the user. The user orientation is unusual in that it consists of two parts, a body orientation, which is contrained to only rotate about the Y axis, and the head orientation that includes rotation angles at the neck. The default user interface controls both. The body orientation is used to control rotations about Y, and to rotate the displayed avatar, while the head orientation determines the orientation of the camera in rst person view. See the Camera module for more information. If you desire to move the Actor for any purpose, it is best to use the function setPositionAvoidingCollisions(Ve ctor). This function will account for other objects present at the desired location, and cause the physics engine to momentarily turn off collisions while the function attempts to move the Actor to the desired position. These precautions prevent erratic behavior due to unforseen collisions which may be present. Note that if the Avatar is bigger than the available space at the destination, the avatar may fall through the oor (and continue falling if gravity is on). Be sure to leave sufcient height for large Avatars under these conditions. Global Properties
theActor
Properties
type
avatarURL
The URL of the Actors current actual avatar. Note that if the user selects a new avatar, theActor.avatarURL will not update until the new avatar is actually loaded and in use. Similarly, when a user rst enters a world or launches the Browser, theActor.avatarURL will remain undened until their avatar has loaded. This value is readonly.
278
APPENDIX E
showAvatar
position
transform
worldSpacePosition
worldSpaceTransform
facing
worldSpaceFacing
a Vector pointing the direction the Actor is facing, in world space coordinates.
function moveActorForward(direction, distance) { actor.position = theActor.position.addScaled(actor.worldSpaceFacing, dist); }
bodyYaw
headPitch
velocity
acceleration
worldSpaceVelocity
worldSpaceAcceleration
An acceleration vector which is applied to the Actor (in world space coordinates).
// Apply an acceleration in the X direction (continuous). theActor.worldSpaceAcceleration = Vector(20, 0, 0);
bodySpaceVelocity
A vector that represents the velocity of the actor relative to the world.
if (theActor.bodySpaceVelocity.length > 20) { chat.print(The actor is moving fast.); }
targetVelocity
A velocity that the actor tries to match when at rest. This may be set to non-zero when trying to track a moving object.
theActor.targetVelocity = Vector(0.0, 0.0, 1.0);
targetWorldSpaceVelocity
A velocity that the actor tries to match when at rest, in world space coordinates. This may be set to non-zero when trying to track a moving object.
theActor.targetWorldSpaceVelocity = Vector(0.0, 0.0, 1.0);
forwardSpeed
the Actors forward velocity, facing the Actors current direction for this rendered frame
theActor.forwardSpeed += 20; // Jump straight forward
lateralSpeed
the Actors lateral velocity, facing the Actors current direction for this rendered frame
theActor.lateralSpeed += 20; // Jump straight to the right
280
APPENDIX E
verticalSpeed
the Actors vertical velocity, facing the Actors current direction for this rendered frame
theActor.verticalSpeed += 20; // Jump straight up
enableVerticalThrusters
If enableVerticalThrusters is set to true, then holding down the shift key while using the up-arrow key reverses the direction of gravity. If gravity is off then the up and down arrows affect the actors vertical velocity.
theActor.enableVerticalThrusters = true;
gravity
Gravity for theActor is now exposed as a single scalar acceleration value in feet per second, per second (default = 32). This acceleration is applied in the Y direction of world space coordinates. Gravity will not be applied if the user has disabled gravity in the user preferences (located on the right-click context menu). Lastly, gravity may be forced on for your world using the boolean properties described further below.
// Reduce gravity for this particular world. theActor.gravity = 16;
forcedCollideSetting
If ignoreCollidePreference is set to true, the value of forcedCollideSetting determines whether collisions are enabled
// To force collisions to be on, // independent of the control panel setting: theActor.ignoreCollidePreference = true; theActor.forcedCollideSetting = true; // To force collisions to be off // independent of the control panel setting: theActor.ignoreCollidePreference = true; theActor.forcedCollideSetting = false;
ignoreCollidePreference
If set true, this overrides the users collide preference and enables collisions based on the value of forcedCollideSetting.
// To use the collide preference from the control panel: theActor.ignoreCollidePreference = false; // To force collisions to be on, // independent of the control panel setting: theActor.ignoreCollidePreference = true; theActor.forcedCollideSetting = true; // To force collisions to be off, // independent of the control panel setting: theActor.ignoreCollidePreference = true; theActor.forcedCollideSetting = false;
forcedGravitySetting
If ignoreGravityPreference is set to true, the value of forcedGravitySetting determines whether gravity is enabled
// To force gravity to be on, // independent of the control panel setting: theActor.ignoreGravityPreference = true; theActor.forcedGravitySetting = true; // To force gravity to be off, // independent of the control panel setting: theActor.ignoreGravityPreference = true; theActor.forcedGravitySetting = false;
ignoreGravityPreference
If set true, this overrides the users gravity preference and enables gravity based on the value of forcedGravitySetting
// To use the gravity preference from the control panel: theActor.ignoreGravityPreference = false; // To force gravity to be on, independent of the control panel setting: theActor.ignoreGravityPreference = true; theActor.forcedGravitySetting = true; // To force gravity to be off, independent of the control panel setting: theActor.ignoreGravityPreference = true; theActor.forcedGravitySetting = false;
keyLeftRightMovesEnabled
A ag that determines whether to use the built in navigation scheme for shift+left-arrow or shift right-arrow.
// We wish to prevent such motion theActor.keyLeftRightMovesEnabled = false;
keyUpDownMovesEnabled
A ag that determines whether to use the built in navigation scheme for shift+up-arrow or shift down-arrow.
// We wish to prevent such motion theActor.keyUpDownMovesEnabled = false;
keyForwardBackwardMovesEnabled
A ag that determines whether to use the built in navigation scheme for up-arrow or down-arrow.
// We wish to prevent such motion theActor.keyUpForwardBackwardMovesEnabled = false;
keyLeftRightTurnsEnabled
A ag that determines whether to use the built in navigation scheme for left-arrow or right-arrow.
// We wish to prevent such motion theActor.keyLeftRightTurnsEnabled = false;
282
APPENDIX E
keyUpDownTurnsEnabled
A ag that determines whether to use the built in navigation scheme for ctrl+up-arrow or ctrl down-arrow.
// We wish to prevent such motion theActor.keyUpDownTurnsEnabled = false;
mouseLeftRightMovesEnabled
A ag that determines whether to use the built in navigation scheme for shift+left-arrow or shift right-arrow.
// We wish to prevent such motion theActor.mouseLeftRightMovesEnabled = false;
mouseUpDownMovesEnabled
A ag that determines whether to use the built in navigation scheme for shift+mouse-up or shift mouse-down.
// We wish to prevent such motion theActor.mouseUpDownMovesEnabled = false;
mouseForwardBackwardMovesEnabled
A ag that determines whether to use the built in navigation scheme for mouse-up or mouse-down.
// We wish to prevent such motion theActor.mouseForwardBackwardMovesEnabled = false;
mouseLeftRightTurnsEnabled
A ag that determines whether to use the built in navigation scheme for mouse-left or mouse-right or ctrl mouse-left or ctrl mouse-right.
// We wish to prevent such motion theActor.mouseLeftRightTurnsEnabled = false;
mouseUpDownTurnsEnabled
A ag that determines whether to use the built in navigation scheme for ctrl+ mouse-up or ctrl+mouse-down.
// We wish to prevent such motion theActor.mouseUpDownTurnsEnabled = false;
keyMoveInsteadOfTurn
A ag that determines whether to move instead of turn the theActor when the left-arrow or right-arrow is pressed. Default is false.
// Make the actor strafe theActor.keyMoveInsteadOfTurn = true;
Methods
dist(position)
Returns the distance between the Actor and the provided position Vector.
if (theActor.dist(frog.position) < frog.fearRadius) {
moveTo(Vector position)
This method schedules an update to the position property using a smooth interpolation over the next time step period. This smooth kinematic motion is more stable when other objects collide with the current object. By the next time step the velocity and acceleration will be set to zero.
target = stageModel.getPrimitive(Target); theActor.moveTo(target.position);
transformTo(transform)
This method schedules an update to the actors orientation and position properties using a smooth interpolation over the next time step period. This smooth kinematic motion is more stable when other objects collide with the current object. By the next time step, the velocity, acceleration, angular velocity, and angular acceleration will be set to zero.
anchor = stageModel.getPrimitive(anchor); theActor.transformTo(anchor.transform);
alignHeadAndBodyTo(Rotation)
Given the Rotation, aligns the body subject to the constraint that it can only rotate around the y-axis, and aligns the head subject to the constraint that it can only rotate around a horizontal axis relative to the body.
// Given a subject, align the actor to look at it deltaPos = theActor.position.subtract(subject.position); actorRange = Math.sqrt(deltaPos.x*deltaPos.x + deltaPos.y*deltaPos.y + deltaPos.z*deltaPos.z); actorRangeXZ = Math.sqrt(deltaPos.x*deltaPos.x + deltaPos.z*deltaPos.z); actorPitch = Math.atan2(-deltaPos.y, actorRangeXZ); actorYaw = Math.atan2(deltaPos.x, deltaPos.z); targetOrientation = Rotation(YX, actorYaw, actorPitch); theActor.alignHeadAndBodyTo(targetOrientation);
getBodyOrientation()
Returns the Transform representing the actors body orientation. Note that the actors body does not tilt up and down, only rotates around the worlds y-axis.
// Calculate the actors bodys yaw bodyOrientation = theActor.getBodyOrientation().map(Vector(0,0,1)); bodyYaw = Math.atan2(bodyOrientation.z, bodyOrientation.x);
getHeadOrientation()
284
APPENDIX E
// Places the camera six feet behind the actor offset = Vector(0.0, 0.0, 6.0); bodyRelativeOffset = theActor.getHeadOrientation().map(offset); camera.position = theActor.position.add(bodyRelativeOffset); camera.orientation = theActor.getHeadOrientation();
setPosition(Vector or x,y,z)
Places the eye position of the actor at the specied position, giving no consideration to collisions with other objects.
// Place the actor at the exact location specied. target = Vector(10.0, 0.0, 6.0); theActor.setPosition(target); // or theActor.setPosition(target.x, target.y, target.z);
getPositionAvoidingCollisions(Vector or x,y,z)
Returns a position which is as close to the desiredlocation as possible, taking into consideration the size of the current actor avatar. Modies the passed position (a vector) in the minimum x/y/z direction necessary to place the actor avatar in a location which does not collide with other objects. This call would be useful in smoothing the path of a guided tour, for example. Since avatar sizes differ, attempting to force an unknown avatar along a given path may cause numerous collisions, which in turn are constantly corrected by the collision processor, causing jitters. Using this callto customize path locations will eliminate the collisions, smoothing the experience for all.
// Find a location as close to specied target as possible, // while avoiding collisions with the oor, etc. target = anchor7.position; theActor.getPositionAvoidingCollisions(target); // or theActor.getPositionAvoidingCollisions(target.x, target.y, target.z);
setPositionAvoidingCollisions(Vector or x,y,z)
Places the eye position of the actor as close to the specied position as possible while avoiding collisions with other objects. This is useful when teleporting within a world.
// Places the actor as close to specied target as possible, // while avoiding collisions with the oor etc. target = Vector(10.0, 0.0, 6.0); theActor.setPositionAvoidingCollisions(target); // or theActor.setPositionAvoidingCollisions(target.x, target.y, target.z);
getSolidObjectCount()
Returns the solid object count for the Actors SceneGroup currently in use. This is useful for modifying avatar properties, such as dynamic lighting.
//get the actor SceneGroup geometry, and enable dynamic lighting for (i = 0; i < theActor.getSolidObjectCount(); i++)
getSolidObject(index)
Returns the SolidObject at the given index that is contained by the actors SceneGroup.
//print actor height compared to the world currentHeight = ( theActor.getSolidObject(0).position[1] - stageModel.getSolidObject(0).position[1] ); chat.print(Your avatar is currently this high: + currentHeight);
getViewpointObjectCount()
Returns the Viewpoint object count for the Actors SceneGroup currently in use. This is useful for modifying avatar properties, such as dynamic lighting.
for (i = 0; i < theActor.getViewpointObjectCount(); i++) { theActor.getViewpointObject(i).useDynamicLighting = true; theActor.getViewpointObject(i).addDynamicHighlights = true; }
getViewpointObject(index)
Returns the Viewpoint object specied for the actor avatar currently in use.
chat.print(actor Viewpoint object (0) name = + theActor.getViewpointObject(0).name );
Anchor
The Anchor scene element is a useful object for holding a desired position and orientation, which can then be accessed and used at a later time in the browsing experience. An Anchor has no geometric volume, which places its pivot point at the exact origin. This is useful for using an anchor to specify an axis of rotation. A series of numbered Anchors is useful for designating points along a path for use in such things as a guided tour, or to load and place an array of objects in pre-determined positions. Local Properties
type
name
loaded
286
APPENDIX E
if (myObject.loaded) { ... }
parent
position
orientation
transform
worldSpacePosition
worldSpaceOrientation
worldSpaceTransform
Camera
The Camera module represents virtual cameras that are used to render a 2-D view from a 3-D SceneGroup. It has properties that control the projection of the camera, such as eld of view, position and orientation. There is a ag that may be used to lock the camera to the rst person view from the actor, and a ag that determines whether the avatar is visible in the image generated by the camera. (This is useful when implementing third person camera controllers.)
Functions are also supplied for converting pixel coordinates to rays, to ease the creation of ray-test queries. Finally, the 2D center of projection may be shifted relative to the image plane for special effects and unusual projections.
Important Note: A Javascript (PlayerInit.js) which is included with the Player product is currently modifying ve of
these properties: position, orientation, transform, lockToActor, and showAvatar. Since this Javascript provides camera control by default, and since there is currently just one camera, it may not be possible to modify these ve properties with any dependable results. Properties
type
orientation
position
transform
The Transform object representing the combined position and orientation of the camera.
// Smoothly animate between EntryPoints ep1 and ep2 // (including their orientations) over 100 frames: camera = application.getView(0).getCamera(0); camera.n = 0; camera.timestep = function() { this.transform = ep1.transform.blend(ep2.transform, this.n++/100); } addAnimator(camera);
eldOfView
The eld of view of the camera in degrees. Can range from 0 to 180, default is 80.
camera = application.getView(0).getCamera(0); camera.eldOfView = 100;
288
APPENDIX E
lockToActor
When true the cameras position and orientation are copied from the actors position and head orientation every time step.
// Make the camera track the actors position // and head orientation camera = application.getView(0).getCamera(0); camera.lockToActor = true;
preferenceShowMyAvatar
Returns the current state of the checkbox in the Actor preferences Show My Avatar, as well as the toggle on the toolbar. This property is read only.
if (application.preferenceShowMyAvatar) { ... }
showAvatar
Controls the third person view of the user avatar in the Actor window.
application.showAvatar = true;
Methods
dist(Vector)
Returns the distance between the supplied position and the cameras position.
camera = application.getView(0).getCamera(0); radialDistance = camera.dist(actor.position);
setPosition(Vector)
getPixelXCoordFromRayDirection(Vector rayDirection)
Returns the pixel x coordinate in the image plane for a given ray direction from the camera.
camera = application.getView(0).getCamera(0); direction = Vector(1.0, 0.0, 0.0); xValue = = camera.getPixelXCoordFromRayDirection(direction);
getPixelYCoordFromRayDirection(Vector rayDirection)
Returns the pixel y coordinate in the image plane for a given ray direction from the camera.
camera = application.getView(0).getCamera(0); direction = Vector(1.0, 0.0, 0.0); yValue = = camera.getPixelYCoordFromRayDirection(direction);
getRayDirectionFromPixelCoords(x, y)
setOffsetsFromRayDirectionAndPixelCoords(Vector rayDirection, x, y)
Changes the xOffset and yOffset so that the given ray direction and pixel coordinates correspond in the image plane.
camera = application.getView(0).getCamera(0); direction = Vector(1, 0, 0); camera.setOffsetsFromRayDirectionAndPixelCoords(direction, 50, 60);DistantLight
DistantLight is a module that controls a distant light source for solid objects that have dynamic lighting enabled. Dynamic lighting is added to lightmaps that were computed for radiosity. Distant lights shine parallel light from innity and have a brightness and colour. The central direction for where the light comes from is determined by the direction property, whereas the cone angle determines the spread of rays around that direction. (In real life, the sun and moon, for instance, have a cone angle of approximately half a degree. Area lights may be approximated using larger cone angles.) Large cone angles illuminate more than half of a sphere, leading to softer-looking illumination. Properties
type
worldSpaceDirection
coneAngle
The angle subtended by the distant light, valid values range from 0 to 360 degrees.
// Set the cone angle to 45 degrees stageModel.getDistantLight(0).coneAngle = 45;
brightness
The scale value of the distant light. Reasonable values range between 1-100, and appropriate initial settings are dependant upon the light map brightness of the objects to be illuminated. Experimentation with the initial value is necessary for obtaining desired results.
// Set the lights brightness to 10 stageModel.getDistantLight(0).brightness = 10;
290
APPENDIX E
castShadows
In worlds where dynamic lighting is enabled, controls whether the DistantLight will cause dynamically lit objects to cast shadows. Note that a dynamically lit object will only require processing (thereby reducing performance) when it moves. Moving your avatar around in the world and changing views does not require an update to the dynamic light, and therefore should not affect performance.
// Enable the lights ability to cast shadows stageModel.getDistantLight(0).castShadows = true;
color
The color of the light as an Array or Vector of three values ordered as (red, green, and blue).
// make the light red stageModel.getDistantLight(0).color = [1, 0, 0]; // make the light green stageModel.getDistantLight(0).color = [0, 1, 0]; // make the light blue stageModel.getDistantLight(0).color = [0, 0, 1];
EntryPoint
The EntryPoint scene element represents the starting position (and orientation) when a visitor enters your world. Identifying the EntryPoint in JavaScript might be useful if you desire to return the visitor to the starting location for any given reason. Multiple entrypoints can be created and used when specifying the URL of the Atmosphere world in your webpage, and are referenced by appending the pound sign followed by the Entrypoint name (example: ./ myFileName.aer#entryPosition2. see more details about EntryPoints in the Atmosphere Application Help). Local Properties
type
name
loaded
parent
position
orientation
transform
worldSpacePosition
worldSpaceOrientation
worldSpaceTransform
PhysicalModel
The PhysicalModel module enables JavaScript to apply physically accurate motions to SceneGroups, solid objects, surface objects, and Viewpoint objects. Once a physical model has been created from a object, it will respond to real world dynamics as you assign them including collisions, external forces and constraints. The physics processing engine attempts to be efcient when calculating the movement of many objects. As a act of efciency, a physical model will become deactivated if its velocity stays at a low level for a signicant length of time. Therefore, just prior to forcibly setting a velocity or acceleration for a physical model, you should set the active property to true to begin processing of the object once again in the event that it has come to rest. Another alternative is to call the method disableDeactivation() for the object, which will cause it processed at all times. Be aware that calling this method for many objects may reduce performance.
292
APPENDIX E
When positioning a physical model, you are actually specifying the location of its center of mass. This may be different than the position dened for the position of the SceneGroup from which the physical model may have been made. When rst created the physical model will be in the same visual location as the SceneGroup or Viewpoint object from which it was made. The offset between the physical model and the SceneGroup or ojbect position may be computed at that time. The importance of the distinction is apparent when using moveTo or transformTo for the physical model. It should be noted that for any of the physics based constraints or actions, it is necessary to assign reasonable mass values when creating the physical models so that physics processing does not become unstable (driven out of scope). The guidelines for mass and inertia are decribed in the method createPhysicalModel(). If you plan to control the movement of a physical model but want it xed for the moment, set a reasonable mass value when creating it, and also set the xed ag to true. This will prevent angular and lateral motion, but still enable collisions. When moving the object, it is preferable to use moveTo / transformTo / rotateTo so that collisions are properly considered along the move path and nal destination. Properties
type
worldSpacePosition
the position of the object used to create the PhysicalModel, in world space coordinates (as a Vector).
myPhysicalModelCreatorObject.worldSpacePosition = myAnchor3.worldSpacePosition;
worldSpaceOrientation
the rotational orientation of the object used to create the PhysicalModel, in world space coordinates (as a Rotation). Note that Atmosphere uses the units of Radians for rotations (where a full circle = pi * 2).
myPhysicalModelCreatorObject.worldSpaceOrientation = myAnchor3.worldSpaceOrientation;
worldSpaceTransform
the Transform object (representing the combined position and orientation) of the object used to create the PhysicalModel, in world space coordinates.
myPhysicalModelCreatorObject.worldSpaceTransform = myAnchor3.worldSpaceTransform;
rigidBodyWorldSpacePosition
the position of the center of mass for the PhysicalModel, in world space coordinates (as a Vector).
myPhysicalModel.rigidBodyWorldSpacePosition = myAnchor3.worldSpacePosition;
rigidBodyWorldSpaceTransform
the Transform (representing the combined position and orientation) of the center of mass for the PhysicalModel, in world space coordinates.
myPhysicalModel.rigidBodyWorldSpaceTransform = myAnchor3.worldSpaceTransform;
worldSpaceVelocity
the velocity of the object in world space coordinates (as a Vector). Just prior to setting the velocity for an object, you should set the active property to true in case the object has come to rest. (For more information, see the overview at the top of page.)
myPhysicalModel.active = true; myPhysicalModel.worldSpaceVelocity = Vector(0, 5, -25);
worldSpaceAcceleration
the acceleration of the object in world space coordinates (as a Vector). The acceleration applies a force to the center of mass that is proportional to the mass. This approach allows you to simulate a uniform gravitational eld to all objects, such as the acceleration due to gravity. So, acceleration is an input to force generation, rather than a measure of the velocity derivative. (For Earths gravity at sea-level, set acceleration to (0.0, -32.0, 0.0) ). Just prior to setting the acceleration for an object, you should set the active property to true in case the object has come to rest. (For more information, see the overview at the top of page.)
myPhysicalModel.active = true; myPhysicalModel.acceleration = Vector(10, 5, -25);
worldSpaceAngularVelocity
the angular velocity of the object in world space coordinates (as a Vector). Just prior to setting the angularVelocity for an object, you should set the active property to true in case the object has come to rest. (For more information, see the overview at the top of page.) Atmosphere angularVelocity is in the scale of Radians per second.
myPhysicalModel.active = true; myPhysicalModel.angularVelocity = Vector(10, 5, -25);
mass
the mass of the physical model as specied during creation. This property may be modied at any time. Since you can read the volume of the physical model, you could set its mass to reect the density of a given substance such as water. Be sure that the density value you use is in the same units system as the mass units / volume units (volume units are feet cubed).
physicalModel.mass = physicalModel.volume * density;
volume
the volume of the physical model computed from the geometry of the physical model. Note that if you created a convex physical model, it will return the volume of the convex hull, not the original surface. Volume units are feet cubed.
volumeForFloating = myBoat.physicalModel.volume;
active
A ag specifying whether this physical model should be processed by the physics engine at the current moment(default = true). This property is very useful in establishing a more elegant base state for a physics enabled scene. For example, suppose you load an array of bowling pins to be used as physical objects in a bowling game. At initial load, the pins may wiggle somewhat as they experience gravity, and settle to the oor.
294
APPENDIX E
This unnecessary settling can be eliminated by setting the active state to false. The objects will automatically resume physics behavior at the next collision with another object, and this ag will automatically be returned to true. This property should also be set to true prior to specifying an acceleration or velocity of an object, since an object at rest may be in a deactivated state. (see comments regarding deactivation elsewhere on this page.)
for ( i=0 ; i<9 ; i++ ) { bowlingPins[i].physicalModel.active = false; }
collide
Determines if and how this SceneGroup collides with the world and other SceneGroups. If collide is true, collisions with the world and other collidable SceneGroups are taken into account when calling moveTo() (i.e., the world and other objects can affect our position).
// Set the initial position without collisions ball.position = startPosition; // Henceforth, dont let the ball pass through things. ball.collide = true; // Schedule a move with collisions ball.moveTo(endPosition);
xed
A boolean that xes an object in place to prevent physical motion. This ag speeds up collision detection for other objects relative to just setting the velocity and acceleration to zero. If xed is false then the object will move according to its velocity, acceleration, angular velocity and angular accerelation taking collisions into account depending on the value the of the collide property.
box = SceneGroup(./box.aer).add(); box.timestep = function() { if (this.loaded) { this.physicalModel = this.createPhysicalModel(10); this.physicalModel.xed = true; this.physicalModel.friction = .5; this.physicalModel.inertiaScale = 1.5; this.physicalModel.restitution = .6; removeAnimator(this); } } addAnimator(box);
friction
The coefcient of friction for the physical model. Higher values of friction allow physical models to sit on slopes without sliding. Typical values are in the range of 0.0 to 1.0, although higher values are allowed - negative values are not. The denition of friction is the ratio between the normal force and the largest allowed lateral friction force that may result. Coefcients of friction are combined for two physical models to come up with a single value for interactions between them.
// See xed code sample above for example
intertiaScale
This value scales the moment of inertia of the physical model as it is created. The default value is 1.0. Values larger than 1.0 may be required to aid the stability of long chains of physical models linked together by constraints.
// See xed code sample above for example
restitution
This coefcient affects the degree of bounce of an object. Allowed values are between 0.0 (no bounce) and 1.0 (perfect bounce). It is dened as the ratio of velocities before and after a normal collision to a surface. Coefcients of restitution are combined for colliding physical objects to come up with a single value for interactions between them.
// See xed code sample above for example
useForOverlaps
A ag specifying whether this physical model should be considered when processing an OverlapEventHandler().
box1.physicalModel.useForOverlaps = true;
Methods
applyAngularImpulse(Vector impulse)
This function increments the angular momentum of the physical model by a specied amount. The direction of the impulse vector denes the rotation axis, and the magnitude of the vector determines the amount of angular momentum applied. A torque impulse may be thought of as a large torque applied for a short time, with the magnitude of the torque being multiplied by the duration to get the amount of angular momentum change.
box = SceneGroup(./box.aer).add(); box.timestep = function() { if (this.loaded) { this.physicalModel = this.createPhysicalModel(10); this.physicalModel.collide = true; this.root = this.getSolidObject(0).rootPrimitive; this.root.onClick = function() {
296
APPENDIX E
This function increments the linear momentum of the physical model by a specied amount, and also updates the angular momentum, in a way that is consistent with the impulse being applied to a given position within the physical model. The direction of the impulse vector denes the direction of applied force, and the magnitude of the vector determines the amount of linear momentum applied. A linear impulse may be thought of as a large force applied for a short time, with the magnitude of the force being multiplied by the duration to get the amount of linear momentum change. A classic use of an impulse is to simulate the effect of a bullet hitting an object at a specied location. Since the impulse is not calculated to be at the center of mass, the object might start to spin as well. Lastly, An impulse is measured in units of force times time, or momentum. So, to get an object from rest up to a velocity of 1 foot per second, you would need to apply an impulse equal to the mass of the object.
box = SceneGroup(./box.aer).add(); box.timestep = function() { if(this.loaded) { this.physicalModel = this.createPhysicalModel(10); this.physicalModel.collide = true; this.root = this.getSolidObject(0).rootPrimitive; this.root.onClick = function() { mouseX = application.getView(0).mouseX; mouseY = application.getView(0).mouseY; camera = application.getView(0).getCamera(0); rayOrigin rayDir distance = camera.position; = camera.getRayDirectionFromPixelCoords(mouseX, mouseY); = stageModel.rayIntersectionDistance(rayOrigin, rayDir);
intersection = Vector(rayOrigin.x + rayDir.x * distance, rayOrigin.y + rayDir.y * distance, rayOrigin.z + rayDir.z * distance); impulse = rayDir.scale(10); // Push the box at the point where it is clicked on box.physicalModel.applyImpulse(impulse, intersection);
applyImpulseToCenterOfMass(Vector impulse)
This function increments the linear momentum of the physical model by a specied amount, and also updates the angular momentum, in a way that is consistent with the impulse being applied to a given position within the physical model. The direction of the impulse vector denes the direction of applied force, and the magnitude of the vector determines the amount of linear momentum applied. A linear impulse may be thought of as a large force applied for a short time, with the magnitude of the force being multiplied by the duration to get the amount of linear momentum change.
box = SceneGroup(./resources/box.aer).add(); box.timestep = function() { if (this.loaded) { this.physicalModel = this.createPhysicalModel(10); this.physicalModel.collide = true; this.root = this.getSolidObject(0).rootPrimitive; this.solidObject.onClick = function() { camera = application.getView(0).getCamera(0); direction = box.position.subtract(camera.position); impulse = direction.normalized.scale(10); // Push the box directly away when it is clicked on box.physicalModel.applyImpulseToCenterOfMass(impulse); } removeAnimator(this); } } addAnimator(box);
disableCollisionsWith(PhysicalModel)
This function allows one physical model to avoid colliding with another physical model. This pair of objects is kept in a list and any collisions detected between the physical models will be ignored. This feature is useful when making mechanisms using constraints and it is necessary to avoid collisions between two objects that are joined together.
box1 = SceneGroup(./resources/box.aer).add(); box2 = SceneGroup(./resources/box.aer).add();
298
APPENDIX E
loader = new Object(); loader.timestep = function() { if(box1.loaded && box2.loaded) { box1.physicalModel = this.createPhysicalModel(2); box2.physicalModel = this.createPhysicalModel(5); box1.physicalModel.disableCollisionsWith(box2.physicalModel); removeAnimator(this); } } addAnimator(loader);
enableCollisionsWith(PhysicalModel)
This function undoes the effect of disableCollisionsWith(physicalModel). It removes the pair of collisions that are currently being ignored from the list, so that collisions between these two objects will no longer be ignored.
box1.physicalModel.enableCollisionsWith(box2.physicalModel);
disableDeactivation()
Prevents the physical model from being deactivated when it comes to rest. For SceneGroups being modied with moveTo and transformTo, the call to disableDeactivation must be made once to prevent the object from being disabled by the automatic deactivation criteria.
box1.physicalModel.disableDeactivation();
enableDeactivation()
For use following the above method, will allow the physical model to once again be deactivated when it comes to rest.
box1.physicalModel.enableDeactivation();
moveTo(Vector position)
This method schedules an update to the position property using a smooth interpolation over the next time step period. This smooth kinematic motion is more stable when other objects collide with the current object. By the next time step the velocity and acceleration will be set to zero. Note that it is not recommended that you set this value in a timestep, meaning to set a new value every frame. The most dependable method for moving a Physical Model (apart from using constraints or the collision with another object) is to use the ApplyImpulse() methods.
anchorA = stageModel.getPrimitive(A); anchorB = stageModel.getPrimitive(B); box = SceneGroup(./box.aer).add(); box.timestep = function() { if (this.loaded) { this.physicalModel = this.createPhysicalModel(10);
rotateTo(orientation)
This method schedules an update to the orientation property using a smooth interpolation over the next time step period. This smooth kinematic motion is more stable when other objects collide with the current object. By the next time step the angular velocity and angular acceleration will be set to zero.Note that it is not recommended that you set this value in a timestep, meaning to set a new value every frame. The most dependable method for moving a Physical Model (apart from using constraints or the collision with another object) is to use the ApplyImpulse() methods. Note that rotations in Atmosphere are in the units of Radians (a full circle = pi * 2).
anchorA = stageModel.getPrimitive(A); anchorB = stageModel.getPrimitive(B); box = SceneGroup(./box.aer).add(); box.timestep = function() { if(this.loaded) { this.physicalModel = this.createPhysicalModel(10); this.physicalModel.transform = anchorA.transform; this.physicalModel.collide = true; this.button = Button(RotateTo Anchor B).add(); this.button.onClick = function() { box.physicalModel.rotateTo(anchorB.orientation); } removeAnimator(this); } } addAnimator(box);
transformTo(transform)
This method schedules an update to the orientation and position properties using a smooth interpolation over the next time step period. This smooth kinematic motion is more stable when other objects collide with the current object. By the next time step the velocity, acceleration, angular velocity and angular acceleration will
300
APPENDIX E
be set to zero. Note that it is not recommended that you set this value in a timestep, meaning to set a new value every frame. The most dependable method for moving a Physical Model (apart from using constraints or the collision with another object) is to use the ApplyImpulse() methods.
anchorA = stageModel.getPrimitive(A); anchorB = stageModel.getPrimitive(B); box = SceneGroup(./box.aer).add(); box.timestep = function() { if (this.loaded) { this.physicalModel = this.createPhysicalModel(10); this.physicalModel.orienation = anchorA.orienation; this.physicalModel.collide = true; this.button = Button(TransformTo Anchor B).add(); this.button.onClick = function() { box.physicalModel.transformTo(anchorB.transform); } removeAnimator(this); } } addAnimator(box);
getParent()
Returns a reference to the object that was used to create the physical model.
box1Parent = box1.physicalModel.getParent();
Portal
The Portal scene element is used to automatically transport your visitor to another Atmosphere world (or different entrypoint in the current world) when they overlap the Portal area. The Portal is identied by three vertical square planes which are rotating and circling about the overlap area (the planes are colored red, blue, green). It is possible to dynamically specify the URL of the portal in JavaScript, enabling the designer to transport the visitor to different locations based upon the outcome of some logic / condition. Local Properties
type
name
loaded
parent
position
orientation
transform
worldSpacePosition
worldSpaceOrientation
worldSpaceTransform
url
A new URL for the portal object, which may be any valid URL (relative or absolute) and which may also include an alternate Atmosphere entrypoint (see details on EntryPoints elsewhere in these documents).
302
APPENDIX E
// specify a new URL if the user answers the question correctly if (userAnswer = true) { customPortal3.url = ./myFileName.aer#entryPosition2; }
ReferencePoint
The ReferencePoint scene element is similar in use the Anchor object. Since all Atmosphere worlds contain at least one ReferencePoint, it may be a useful way to specify a common location as you design your worlds. (Note that the primary usage for ReferencePoint is found in the Atmosphere authoring application, where it is used to specify the placement of any new objects or primitives during construction. Note also that the ReferencePoint has no name property, as it cannot be named in the Authoring Appliation.) Local Properties
type
loaded
parent
position
orientation
transform
worldSpacePosition
worldSpaceOrientation
worldSpaceTransform
SceneGroup
The SceneGroup module is used to represent a single SceneGroup in the scene graph. A SceneGroup contains a transformation that affects the location of everything contained within the SceneGroup. A SceneGroup includes an array of solid objects, an array of Viewpoint objects and an array of child SceneGroups. The SceneGroup may be in coordinates relative to its parent SceneGroup, or in world coordinates. This is determined by the value of the ag attachedToParentModel. When the value of this ag is changed, the position coordinates are updated to maintain the same location in world space. Any Atmosphere world saved from the Builder may be loaded as a SceneGroup. Avatars are also examples of SceneGroups. When positioning a SceneGroup, you are actually specifying the location of the pivot point of the SceneGroup within the parent SceneGroup. The origin of the coordinate frame of a SceneGroup is coincident with the location and orientation of the EntryPoint with title Pivot or Eye if one is present. (Eye is prefered for avatars and Pivot for scene SceneGroups.) If neither is present the pivot point is the origin of the coordinate system for the SceneGroup as specied in the Builder. To allow a SceneGroup to exhibit physically-realistic motion, a function is used to create a physical model. This then updates the orientation and position of the SceneGroup every time step. Note: Any SceneGroup methods that access or perform operations on the geometry or elements within a SceneGroup can only be done once the SceneGroup has fully loaded. Examples of this are createPhysicalModel, crea teConvexPhysicalModel, getSolidObjectCount, getSolidObject, getViewpointObjectCount, getViewpointObject, and getDistantLightCount, getDistantLight. Global Properties
mySceneGroup
Loaded SceneGroups can have attached scripts, use mySceneGroup to access the SceneGroup from within its script. In the case of avatar scripts, it refers to the avatars SceneGroup.
mySceneGroup.getSolidObject(0).useDynamicLighting = false;
304
APPENDIX E
theStage
The loaded worlds SceneGroup. Provides access to all objects and elements in the base scene. Note that it is not possible to set an object property to be theStage. You must use the theStage global if you need to access theStage in a script.
numSolidObjects = theStage.getSolidObjectCount(); numViewpointObjects = theStage.getViewpointObjectCount(); chat.print((numSolidObject + numViewpointObject) + objects in the world.)
theWorld
The top level SceneGroup containing all objects in the current Atmosphere instance, including theActor. Provides access to all objects and elements in the scene.
myCoolObject = theWorld.getChild(coolObjectName);
Global Methods
SceneGroup(url)
The SceneGroup constructor, it loads an Atmosphere world le from the given URL and returns it as an object. Just like Web links, SceneGroup URLs can be either relative or absolute. Note that the SceneGroup is not visible (rendered) until you use the local add() method shown below.
// Absolute URL spider = SceneGroup(http://www.myDomain.com/myHomePage/spider.aer); // Relative URLs y1 = SceneGroup(./y.aer); y2 = SceneGroup(../y.aer); y3 = SceneGroup(../../y.aer); y4 = SceneGroup(./bugs/y.aer); y5 = SceneGroup(/y.aer);
// // // // //
current folder up one folder up two folders in the folder called bugs in the root folder
Properties
type
loaded
This ag is true once the SceneGroup has nished loading. Note that if a SceneGroup contains ViewpointObjects, the SceneGroup.loaded ag will properly wait for the ViewpointObject.loaded ags to become true only under the following conditions: The SceneGroup is in the rst level directly under the stage in the Scene Hierarchy. The SceneGroup was added to the scene by a Javascript calling the .add() function.
box = SceneGroup(./box.aer); box.timestep = function()
parent
orientation
position
transform
worldSpacePosition
worldSpaceOrientation
306
APPENDIX E
worldSpaceTransform
bounds
The min and max extent of the SceneGroup in local coordinates, relative to the SceneGroups Eye position and orientation, expressed as an array of two Vectors [min, max].
spider = SceneGroup(./spider.aer); // Make spiders feet just touch the oor height = oorHeight - spider.bounds[0].y; spider.position = Vector(spider.position.x, height, spider.position.z);
visible
Allows the SceneGroup to be visibly removed from the rendered scene. Note that the SceneGroup geometry will still be present; this would be useful for creating an object which causes collisions, but which is invisible.
box = SceneGroup(./box.aer); box.visible = false;
attachedToParent
A ag that is set to true when a SceneGroup is attached to another SceneGroup using the addTo() method. A SceneGroup that is attached to its parent will be transformed with the parent. If this ag is then set to false the child SceneGroup will act as an independant SceneGroup.
box1 = SceneGroup(./box.aer); box2 = SceneGroup(./box.aer); loader = new Object() loader.timestep = function() { if (!box1.loaded && !box2.loaded) { return; } box1.add(); box2.addTo(box1); box1.physicalModel = box2.createPhysicalModel(5); box2.physicalModel = box2.createPhysicalModel(10); box2.attachedToParent = false; removeAnimator(this); } addAnimator(loader);
Methods
add()
Adds the SceneGroup to the top-level World. Returns a reference to the SceneGroup as a convenience.
// Load the spider and add it to the world spider = SceneGroup(./spider.aer).add();
addTo(parent)
Adds the SceneGroup as a child to the specied SceneGroup. Returns the SceneGroup as a convenience.
// Load the hat and add it to my avatar myHat = SceneGroup(./hat.aer).addTo(mySceneGroup);
remove()
Removes the SceneGroup from the top-level World. Note that the SceneGroup is still present in memory, but is no longer processed by the rendering engine(and therefore not visible). This understanding may be useful for performance improvement when many dynamic SceneGroups are present in the world. Using remove(), it is not necessary to create and load the SceneGroups again, but simply to add() them back into the scene. It is also now possible to remove SceneGroups from memory, if desired. To accomplish this, rst remove the SceneGroup from the rendered world using remove() as shown below, then use the global JavaScript delete method to remove the SceneGroup from memory.
// Remove the spider from the world spider.remove(); // Also remove the SceneGroup from memory, if desired delete spider;
getPrimitive(name)
Returns the rst Primitive with the given name from the SceneGroups array of SolidObjects.
thePrimitive = theStage.getPrimitive(Lamp);
createDistantLight()
All worlds have one DistantLight by default. Additional DistantLights can be created with this method. Note that light coordinate systems (X,Y,Z) are local to the SceneGroup from which they were created. (See the documentation on DistantLight for a description of appearance and behavior.)
anotherLight = theStage.createDistantLight();
getDistantLight(index)
getDistantLightCount()
308
APPENDIX E
mapLocalPositionToWorldPosition(Vector)
Given a position Vector in local coordinates returns the corresponding position Vector in world-relative coordinates.
// Find the local space position of the wheel axle in the SceneGroup anchor = car.getPrimitive(wheel1); desiredOffset = anchor.position; // Place the wheel SceneGroup in world space wheel.position = car.mapLocalPositionToWorldPosition(desiredOffset);
mapLocalTransformToWorldTransform(Transform)
Given a Transform in local coordinates returns the corresponding Transform in world-relative coordinates.
carRelativeTransform = Transform(Vector(0, 4, 6), Rotation(Z, 0.0)); box.transform = car.mapLocalTransformToWorldTransform(carRelativeTransform);
setPosition(x, y, z)
Sets the absolute position of the SceneGroup within its parent World (if any) ignoring the collision ag. The velocity and acceleration are unaffected.
mySceneGroup.setPosition(10,0,15);
getParent()
Returns the parent SceneGroup; will return NULL if the given SceneGroup is the World.
theParent = SceneGroup.getParent();
getChild(index or name)
Returns the corresponding child object at the given index or name that is contained by the SceneGroup.
theChild = SceneGroup.getChild(0);
getChildCount()
getSceneGroup(index or name)
Returns the corresponding SceneGroup at the given index or name that is contained by the SceneGroup.
theChildSceneGroup = SceneGroup.getSceneGroup(0);
getSceneGroupCount()
getSolidObject(index or name)
Returns the corresponding SolidObject at the given index or name that is contained by the SceneGroup.
theSolidObject = theStage.getSolidObject(0);
getSolidObjectCount()
getSurfaceObject(index or name)
Returns the corresponding SurfaceObject at the given index or name that is contained by the SceneGroup.
theSurfaceObject = theStage.getSurfaceObject(0);
getSurfaceObjectCount()
getViewpointObject(index or name)
Returns the corresponding ViewpointObject at the given index or name that is contained by the SceneGroup.
viewpointObject1 = theStage.getViewpointObject(0); viewpointObject2 = theStage.getViewpointObject(sphere);
getViewpointObjectCount()
createPhysicalModel(mass, inertiaScale)
A function that takes the SceneGroups geometry and creates a PhysicalModel with the given mass. This is done for all the pieces of the SceneGroup that dont already have PhysicalModels. Once created, the physical model will modify the tranform of the SceneGroup as it experiences external forces, collisions and constraints. For this version of the function, the physical model uses the full geometry of the SceneGroup, which may slow down the physics simulation if done for many complex objects. The one exception is if the physical model is created with a mass of 0, in which case it will be xed in place, and will allow for more efcient collision computations with other objects. Mass is a relative scale, and a density index of 1 per square foot of geometric volume is a reasonable starting point. For example, a box with thedimensions of [1x1x1] would be assigned a mass of 1. A box which is [2x2x2] would be assigned amass of 8, since the volume of the box is 8 square feet. It should be noted that for any of the physics based constraints or actions, there are conditions under which the physics processing may become unstable. Exerting very large forces on very lightobjects may cause the calculations to be driven out of scope(to innity). These conditions can beavoided by assigning reasonable mass values when creating the physical models, as described above. The designer should experiment with mass values and forces applied to insure that physics and javascript processing are not brought to a halt. The inertia scale may be used to scale the moment of inertia of the object. Sometimes constraints may be made more stable by scaling up the moments of inertia of the physical models that they affect.
box = SceneGroup(./box.aer).add(); box.timestep = function()
310
APPENDIX E
createConvexPhysicalModel(mass, inertiaScale)
Same as the method createPhysicalModel, though in this version the function, the physical model uses the convex hull of the SceneGroup, which allows collisions to be much more efciently computed by the physics engine. Settings for mass and inertia should adhere to the same guidelines also described above. Again, note that setting the mass to 0 will cause the physical model to be xed in place, and will also produce more efcient(faster) collision computation.
star = SceneGroup(./star.aer).add(); star.timestep = function() { if (this.loaded) { physicalModel = this.createConvexPhysicalModel(5); removeAnimator(this); } } addAnimator(box);
getPhysicalModel()
deletePhysicalModel()
Deletes the PhysicalModel created by the above methods, and all associated physics processing.
//delete the physical model already created from a loaded SceneGroup star.deletePhysicalModel();
Given an origin and direction shoots a ray and returns the distance between the origin and the point on the surface the ray intersects. Note: the vectors must be normalized or the result will be unpredictable.
camera mouseX mouseY rayOrigin rayDir = application.getView(0).getCamera(0); = application.getView(0).mouseX; = application.getView(0).mouseY = player.position; = camera.getRayDirectionFromPixelCoords(mouseX, mouseY);
Given an origin and direction shoots a ray and returns the normal vector of the surface the ray intersects.
camera mouseX mouseY rayOrigin rayDir = application.getView(0).getCamera(0); = application.getView(0).mouseX; = application.getView(0).mouseY = player.position; = camera.getRayDirectionFromPixelCoords(mouseX, mouseY);
// Calculates the normal vector of the surface // clicked on by the mouse normal = theStage.rayIntersectionNormal(rayOrigin, rayDir);
Given an origin and direction shoots a ray and returns the side vector of the surface the ray intersects.
camera mouseX mouseY rayOrigin rayDir = application.getView(0).getCamera(0); = application.getView(0).mouseX; = application.getView(0).mouseY = player.position; = camera.getRayDirectionFromPixelCoords(mouseX, mouseY);
// Calculates the side vector of the surface // clicked on by the mouse sideVector = theStage.rayIntersectionUTangent(rayOrigin, rayDir);
Given an origin and direction shoots a ray and returns the up vector of the surface the ray intersects.
camera mouseX mouseY rayOrigin rayDir = application.getView(0).getCamera(0); = application.getView(0).mouseX; = application.getView(0).mouseY = player.position; = camera.getRayDirectionFromPixelCoords(mouseX, mouseY);
// Calculates the up vector of the surface // clicked on by the mouse upVector = theStage.rayIntersectionVTangent(rayOrigin, rayDir);
312
APPENDIX E
Callbacks
suggestLocation(loc)
A SceneGroup scripts mySceneGroup.suggestLocation(loc) is called to notify the SceneGroup that it should move to a new location (position and orientation, represented as a single Transform object). A default (prototype) implementation of suggestLocation is provided which performs a simple linear interpolation between the old location and the new. Avatars are moved via mySceneGroup.suggestLocation, so overriding this with your own function allows you to provide your own method of interpolation. (The frequency with which suggestLocation will be called for avatar motion is undened, as it depends on network and other unpredictable factors.) World scripts which create SceneGroups may also call suggestLocation on those SceneGroups. Any such external calls are passed into the SceneGroups own script as a call to mySceneGroup.suggestLocation(loc), which by default will envoke the prototype linear interpolation or may be overridden by the SceneGroups script.
// Save the default version which does linear interpolation: mySceneGroup.interpolateTo = mySceneGroup.suggestLocation; // Override with our own method which prints the // target location for our information and then // invokes the default linear interpolation: mySceneGroup.suggestLocation = function(location) { chat.print(Avatar has been asked to move to: + location); this.interpolateTo(location); }
Script
The Script scene element is a powerful object to causing dynamic activity in an Atmosphere world, and the purpose for which these documents were written! The Script object itself is now exposed in the Atmosphere API, which enables it to use its own properties of position, orientation, and transform when performing object movement and other vector math. A Script also has no geometric volume, which places its pivot point at the exact origin. This is useful for using a Script to specify an axis of rotation. A very powerful new aspect of Atmosphere JavaScripts is the ability to divide the script into two sections; a top section which is processed when the script is loaded in the Authoring Application, and a bottom section which is processed when the script is run in the Atmosphere Player. Many scripts are included with the Atmosphere Authoring application, and observing their code content will help greatly in understanding how the scripts are used. To aid further, an explanation of the script workow is as follows: A top section of the script is rst dened by two custom comment lines: //BEGIN_AUTHORING_PROPERTIES //END_AUTHORING_PROPERTIES Any Javascript within this top section is read and processed only when the script is added to a world, or when a saved world is reloaded into the authoring application.
Within this top section, the script writer uses the deneCustomPropertyValue method shown below to create properties (variables and functions) which can be seen by the user in the Inspector Palette. During use of the Authoring Application, the default values for these properties can be modied by the user. Also during Application use, functions (called actions) can be linked to other objects or script properties. This allows the output of a function from one script (for example, onClick) to trigger the function from another script (such as playSound). The user modied values are stored in both the .atmo project le and the .aer published le (which is used for viewing in the webpage). When the .aer published le is opened in the Atmosphere Player, the rest of the script is read and processed (again, the top section is ignored). In this bottom section, the script designer retrieves the custom user values using the get CustomPropertyValue(name) methods shown below. The script designer then performs the script driven tasks and activity using the custom values retrieved. Final comments: If default values are specied when the properties are created in the top section of the script, these default values will be saved even if the user doesnt modify them. In this manner it may possible for the script to accomplish much with very little input from the user. Its wise to use the keyword this when retrieving the custom property values. If you tie all the properties to the this object, then variable names from one script will not collide with another script in the world. (example: this.target = this.getCustomPropertyValue(target); ) Lastly, its useful to put instructions for how to use your script into comment lines at the top of the script. Once a user loads your script into the world, the instructions can be viewed by simply clicking the Edit button on the Inspector palette when your script is selected. The Atmosphere development team recommends designating your instruction section with the lines //BEGIN_ INSTRUCTIONS and //END_INSTRUCTIONS. This will aid the casual user of the script in knowing where the instructions are dened, but Atmosphere may also add functionality in the future to show these instructions in a different manner, making it easier to reference your guidelines as they work with the script during world design. Local Properties
type
name
loaded
314
APPENDIX E
parent
position
orientation
transform
worldSpacePosition
worldSpaceOrientation
worldSpaceTransform
Local Methods
deneCustomPropertyValue(type, name, value, ref, mod)
For use in the top section of the script to create the custom properties which will be exposed in the Authoring Application Inspector Palette. The Authoring Application user may modify the default values (if you allow), and link properties from one script to another. This method should only be used to create the custom properties, and again, only in the authoring section of the script. A description of the arguments for this call are shown below in the code example.
// The target object which will be moved. this.deneCustomPropertyValue(
getCustomPropertyCount()
Returns the count of the custom properties and actions created in the top section of the script (between the key comment lines //BEGIN_AUTHORING_PROPERTIES and //END_AUTHORING_PROPERTIES).
for ( i = 0; i < this.getCustomPropertyCount(); i++ ) { ... //do task for each property }
getCustomPropertyName(index)
Returns the custom property name at the index specied in the array of custom properties.
this.Name2 = this.getCustomPropertyName(2);
getCustomPropertyValue(name)
Likely the most common of the methods to be used. Retrieves the value for the property of known name. If the user has modied the default value using the Inspector Palette, the modied value will be returned (its stored in both the .atmo project le and the .aer published le).
this.target = this.getCustomPropertyValue(target);
setCustomPropertyValue(name, value)
Its also possible to set the local variable for custom properties using this call.
this.setCustomPropertyValue(volume, 0.7);
callCustomPropertyValue(name)
SolidObject
A SolidObject is used to represent the surface that results from combining a number of primitives specied in the Builder. These can include subtractive and additive primitives, allowing for holes etc. The primitives within a solid object are held rigidly relative to each other. However, the entire solid object may be manipulated using its orientation
316
APPENDIX E
and position. Primitives may be accessed via the root primitive, which is the top of the tree of primitives for the solid object. Objects within this tree may be accessed using the nd method of Primitive. By default, a solid object will be rendered using the light map computed in the Builder to modulate the surface texture, if present. By setting the ag useDynamicLighting to true, the rendering will scale the surface light map by the value of lightMapBrightness, and will add the contribution of any dynamic lights in the scene. For the current release, only a single DistantLight is supported, and that is owned by the stage SceneGroup. The ambient color is added to the diffuse color times the light contribution. These are then both added to the scaled light map color. In this way it is possible to have realistic diffuse lighting effects on objects that are being animated using a script or using a physical model. For objects that will be rotated in a world, it is best to light it in the Builder using only the background light and not the sun. The effect of the sun can then be approximated using a distant light in the script. Note that SolidObjects are not solid, and the description is not based on whether they have a physical model. A solid object is dened by a geometry which has an enclosed volumes (allowing boolean operations such as subtractions). Surface objects, in contrast may have open surfaces, and do not support boolean operations. Properties
type
name
loaded
parent
root
rootPrimitive
position
orientation
transform
worldSpacePosition
worldSpaceOrientation
worldSpaceTransform
bounds
The min and max extent of the SolidObject in local coordinates, relative to the SolidObjects Eye position and orientation, expressed as an array of two Vectors [min, max].
318
APPENDIX E
// Make the spiders feet just touch the oor spider.y = oorHeight-spider.bounds[0].y;
opacity
The percentage value of opaqueness of the SolidObject. Valid values range from 0 to 1. (0.0, 0.125, 0.25, 0.375, 0.5, 0.625, 0.75, 0.875, 1.0)
// A ghost spider spider.opacity = .5;
transparentParity
useDynamicLighting
A boolean ag that when set to true enables the DistantLight dened in the script to modulate the lighting on the SolidObject.
// Dynamically light the spider spider.useDynamicLighting = true;
visible
ambientBrightness
ambientColor
A Vector representing the color of the ambient term. Default is Vector(1, 1, 1).
sphere = SceneGroup (./sphere.aer); solidObject = spheres[i].getSolidObject(0); solidObject.ambientColor = Vector (.25, .25, .28);
diffuseBrightness
The scale value that modulates the brightness of the lighting from Distant Light sources. Default is 0.75.
sphere = SceneGroup (./sphere.aer); solidObject = spheres[i].getSolidObject(0); solidObject.diffuseBrightness = .6;
diffuseColor
A Vector representing the color to modulate the light coming from Distant Light sources. Default is Vector(1, 1, 1).
sphere = SceneGroup (./sphere.aer); solidObject = spheres[i].getSolidObject(0); solidObject.diffuseColor = Vector (1, 1, .98);
lightMapBrightness
The scale value that modulates the brightness of the objects light map. Default is 0.25.
sphere = SceneGroup (./sphere.aer); solidObject = spheres[i].getSolidObject(0); solidObject.lightMapBrightness = .35;
lightMapColor
A Vector representing the color to modulate the objects light map with. Default is Vector(1, 1, 1).
sphere = SceneGroup (./sphere.aer); solidObject = spheres[i].getSolidObject(0); solidObject.lightMapColor = Vector (1, 1, 1);
castShadowsOntoOthers
A boolean value that species whether this object will cast a shadow onto other objects in the scene. This property requires that dynamic lighting is enabled for the scene, and that this object and the shadow receiving object specify the property useDynamicLighting at true. The receiving object must also specify receiveShadows as true. Since dynamic lighting is very costly in regards to processing requirements, numerous lighting properties have been made available so that the world designer can tailor dynamic lighting behavior for their particular purposes.
solidObject.castShadowsOntoOthers = true;
castShadowsOntoSelf
A boolean value that species whether this object will cast a shadow onto itself. This property requires that dynamic lighting is enabled for the scene, and that the property useDynamicLighting is also set to true. Since dynamic lighting is very costly in regards to processing requirements, numerous lighting properties have been made available so that the world designer can tailor dynamic lighting behavior for their particular purposes.
solidObject.castShadowsOntoSelf = true;
receiveShadows
A boolean value that species whether this object will receive shadows. This property requires that dynamic lighting is enabled for the scene, and that the property useDynamicLighting is set to true. Since dynamic lighting is very costly in regards to processing requirements, numerous lighting properties have been made available so that the world designer can tailor dynamic lighting behavior for their particular purposes.
320
APPENDIX E
solidObject.receiveShadows = true;
Methods
createPhysicalModel(mass, inertiaScale)
A function that takes the current SolidObject geometry and creates a physical model with the given mass. Once created, the physical model will modify the tranform of the SolidObject object as it experiences external forces, collisions and constraints. For this version of the function, the physical model uses the full geometry of the SolidObject, which may slow down the physics simulation if done for many complex objects. The one exception is if the physical model is created with a mass of zero, in which case it will be xed in place, and will allow for efcient collision computations with other objects. Mass is a relative scale, and a density index of 1 per square foot of geometric volume is a reasonable starting point. For example, a box with thedimensions of [1x1x1] would be assigned a mass of 1. A box which is [2x2x2] would be assigned amass of 8, since the volume of the box is 8 square feet. It should be noted that for any of the physics based constraints or actions, there are conditions under which the physics processing may become unstable. Exerting very large forces on very lightobjects may cause the calculations to be driven out of scope(to innity). These conditions can be avoided by assigning reasonable mass values when creating the physical models, as described above. The designer should experiment with mass values and forces applied to insure that physics and javascript processing are not brought to a halt. The inertia scale may be used to scale the moment of inertia of the object. Sometimes constraints may be made more stable by scaling up the moments of inertia of the physical models that they affect.
boxPhysicalModel = boxSolidObject.createPhysicalModel(1, 1);
createConvexPhysicalModel(mass, inertiaScale)
A function that takes the current SolidObject geometry and creates a physical model with the given mass. The inertia scale may be used to scale the moment of inertia of the object. Sometimes constraints may be made more stable by scaling up the moments of inertia of the physical models that they affect. Once created, the physical model will modify the tranform of the SolidObject object as it experiences external forces, collisions and constraints. For this version of the function, the physical model uses the convex hull of the SolidObject object, which allows collisions to be much more efciently computed by the physics engine. Care should be given to following the guidelines for mass and inertia values as described in createPhysicalModel() above.
boxPhysicalModel = boxSolidObject.createConvexPhysicalModel(1, 1);
getPhysicalModel()
deletePhysicalModel()
Deletes the PhysicalModel created by the above methods, and removes all associated physics processing.
getParent()
Returns the parent SceneGroup; will return NULL if the given SceneGroup is the World.
theParent = SceneGroup.getParent();
getPrimitive(name)
Returns the rst Primitive with the given name from the SolidObjects array of primitives. Functionally equivalent to solidObject.rootPrimitive.nd(name).
myLongBox = mySolidObject.getPrimitive(LongBox);
mapLocalPositionToWorldPosition(Vector position)
Given a position Vector in local coordinates returns the corresponding position Vector in world-relative coordinates.
// Find the local space position of the wheel axle in the SceneGroup anchor = car.getPrimtive(wheel1); desiredOffset = anchor.position; // Place the wheel SceneGroup in world space wheel.position = car.getSolidObject(0).mapLocalPositionToWorldPosition(desiredOffset);
mapLocalTransformToWorldTransform(Transform)
Given a Transform in local coordinates returns the corresponding Transform in world-relative coordinates.
carRelativeTransform = Transform(Vector(0, 4, 6), Rotation(Z, 0.0)); theCarSolid = car.getSolidObject(0); box.transform = theCarSolid.mapLocalTransformToWorldTransform(carRelativeTransform);
SurfaceObject
A SurfaceObject is generated when a Viewpoint object is imported, and then Convert to Surface is selected from the Object menu in the Atmosphere authoring application. Converting a Viewpoint object to a SurfaceObject is useful in that the object can now recieve its lighting from the Atmoshpere lighting process (direction, brightness, etc.). Additionally, the object textures can also now be modied from within Atmosphere. Properties
type
name
322
APPENDIX E
loaded
parent
attachedToParent
A ag that is set to true when a SurfaceObject is attached to a SceneGroup using the addTo() method. A SurfaceObject that is attached to its parent will be transformed with the parent. If this ag is then set to false, the child SurfaceObject will act as an independant SceneGroup.
box1 = SceneGroup(./box.aer); box2 = theWorld.getSurfaceObject(mySurfaceObject); loader = new Object() loader.timestep = function() { if (!box1.loaded && !box2.loaded) { return; } box1.add(); box2.addTo(box1); box1.physicalModel = box1.createPhysicalModel(5); box2.physicalModel = box2.createPhysicalModel(10); box2.attachedToParent = false; removeAnimator(this); } addAnimator(loader);
position
orientation
transform
worldSpacePosition
worldSpaceOrientation
worldSpaceTransform
bounds
The min and max extent of the SurfaceObject in local coordinates, expressed as an array of two Vectors [min, max].
// Make the spiders feet just touch the oor spider.y = oorHeight-spider.bounds[0].y;
includeInParentRigidBody
When the parent SceneGroup containing the SurfaceObject is used to create a physical model, this ag species whether the SurfaceObject should be included. If set to false, the SurfaceObject will not experience collisions, but will still be attached to the parent SceneGroup.
SurfaceObject.includeInModelRigidBody = false; newPM = parent.createConvexPhysicalModel(1.0);
useDynamicLighting
A boolean ag that when set to true enables the DistantLight dened in the script to modulate the lighting on the SurfaceObject.
// Dynamically light the spider spider.useDynamicLighting = true;
324
APPENDIX E
receiveShadows
A boolean value that species whether this object will receive shadows. This property requires that dynamic lighting is enabled for the scene, and that the property useDynamicLighting is set to true.
SurfaceObject.receiveShadows = true;
visible
Methods
createPhysicalModel(mass, inertiaScale)
A function that takes the current SurfaceObject geometry and creates a physical model with the given mass. Once created, the physical model will modify the tranform of the SurfaceObject object as it experiences external forces, collisions and constraints. For this version of the function, the physical model uses the full geometry of the SurfaceObject, which may slow down the physics simulation if done for many complex objects. The one exception is if the physical model is created with a mass of zero, in which case it will be xed in place, and will allow for efcient collision computations with other objects. Mass is a relative scale, and a density index of 1 per cubic foot of geometric volume is a reasonable starting point. For example, a box with thedimensions of [1x1x1] would be assigned a mass of 1. A box which is [2x2x2] would be assigned a mass of 8, since the volume of the box is 8 cubic feet. It should be noted that for any of the physics based constraints or actions, there are conditions under which the physics processing may become unstable. Exerting very large forces on very lightobjects may cause the calculations to be driven out of scope(to innity). These conditions can be avoided by assigning reasonable mass values when creating the physical models, as described above. The designer should experiment with mass values and forces applied to insure that physics and javascript processing are not brought to a halt. The inertia scale may be used to scale the moment of inertia of the object. Sometimes constraints may be made more stable by scaling up the moments of inertia of the physical models that they affect.
boxPhysicalModel = boxSurfaceObject.createPhysicalModel(1, 1);
createConvexPhysicalModel(mass, inertiaScale)
A function that takes the current SurfaceObject geometry and creates a physical model with the given mass. The inertia scale may be used to scale the moment of inertia of the object. Sometimes constraints may be made more stable by scaling up the moments of inertia of the physical models that they affect. Once created, the physical model will modify the tranform of the SurfaceObject object as it experiences external forces, collisions and constraints. For this version of the function, the physical model uses the convex hull of the SurfaceObject object, which allows collisions to be much more efciently computed by the physics engine. Care should be given to following the guidelines for mass and inertia values as described in createPhysicalModel() above.
getPhysicalModel()
deletePhysicalModel()
Deletes the PhysicalModel created by the above methods, and removes all associated physics processing.
boxObject.deletePhysicalModel();
getParent()
Returns the parent SceneGroup; will return NULL if the given SceneGroup is the World.
theParent = SceneGroup.getParent();
mapLocalPositionToWorldPosition(Vector position)
Given a position Vector in local coordinates returns the corresponding position Vector in world-relative coordinates.
// Find the local space position of the wheel axle in the SceneGroup anchor = car.getPrimtive(whee1); desiredOffset = anchor.position; // Place the wheel SceneGroup in world space wheel.position = car.getSurfaceObject(0).mapLocalPositionToWorldPosition(desiredOffset);
mapLocalTransformToWorldTransform(Transform)
Given a Transform in local coordinates returns the corresponding Transform in world-relative coordinates.
carRelativeTransform = Transform(Vector(0, 4, 6), Rotation(Z, 0.0)); theCarSurface = car.getSurfaceObject(0); box.transform = theCarSurface.mapLocalTransformToWorldTransform(carRelativeTransform);
ViewpointObject
A ViewpointObject is a SceneGroup which is imported into the Atmosphere Builder from an MTX le (and optional associated MTS le). It contains a reference to the full MTSScene which is described in both the MTX and MTS les (if present). The scene may contain geometries, transformations, textures, materials, time elements (animations), text objects, SWF movies, and other related XML properties. The Viewpoint object has a transform that positions it relative to its parent SceneGroup (or world space if attachedToParentModel is set to false). Methods are also available to dene a physical model which will cause the Viewpoint object to experience physical interaction with other objects. (Note that the current physical model will not alter its shape when animations are run in the ViewpointObject.)
326
APPENDIX E
Note that within a Viewpoint scene, the Z coordinate is reversed for position. Therefore, if a Viewpoint scene contains multiple instances, moving those instances relative to each other will require using an inverted Z value as compared to the normal Atmosphere coordinate system. Properties
type
position
orientation
transform
The object transform representing the combined position and orientation values.
// Set by creating a Transform explicitly viewpointObject.transform = Transform([8.0, 8.0, -20.0], Rotation(XYZ, 1.57, 1.57, 1.57)); // Set equal to another Transform viewpointObject.transform = anchorPoint1.Transform;
worldSpacePosition
worldSpaceOrientation
worldSpaceTransform
attachedToParent
Specied whether the Viewpoint object is attached to the parent SceneGroup. If the parent SceneGroup also contains a physical model, setting this ag to false will also remove the physical model of the Viewpoint object, and it will become as separate object.
viewpointObject.attachedToParent = false;
bounds
The bounds of the object in world coordinates, as an array of two Vectors [min, max].
// Hang the spider from the ceiling spider.y = room.bounds[0].y - 2;
includeInParentRigidBody
When the parent SceneGroup containing the Viewpoint object is used to create a physical model, this ag species whether the Viewpoint object should be included. If set to false,the Viewpoint object will not experience collisions, but will still be attached to the parent SceneGroup.
viewpointObject.includeInModelRigidBody = false; newPM = parent.createConvexPhysicalModel(1.0);
loaded
Returns true once the Viewpoint object (MTX and MTS data) has nished loading.
if (myObject.loaded) { ... }
name
parent
scene
Contains a reference to the entire scenegraph of the Viewpoint object. Returns an object of type MTSScene.
handInstance = viewpointObject.scene.getInstance(hand);
receivesMouseEvents
A ag specifying whether mouse events are to be handled by the interactors of the Viewpoint object. Default is true.
//Mouse events will not trigger the Viewpoint object viewpointObject.receivesMouseEvents = false;
addDynamicHighlights
328
APPENDIX E
useDynamicLighting
A ag specifying whether dynamic lighting should be enabled for this Viewpoint object.
viewpointObject.useDynamicLighting = true;
visible
Methods
createPhysicalModel(mass, inertiaScale)
A function that takes the current Viewpoint geometry and creates a physical model with the given mass.Once created, the physical model will modify the tranform of the Viewpoint object as it experiences external forces, collisions and constraints. For this version of the function, the physical model uses the full geometry of the SceneGroup, which may slow down the physics simulation if done for many complex objects. The one exception is if the physical model is created with a mass of zero, in which case it will be xed in place, and will allow for efcient collision computations with other objects. Mass is a relative scale, and a density index of 1 per square foot of geometric volume is a reasonable starting point. For example, a box with thedimensions of [1x1x1] would be assigned a mass of 1. A box which is [2x2x2] would be assigned amass of 8, since the volume of the box is 8 square feet. It should be noted that for any of the physics based constraints or actions, there are conditions under which the physics processing may become unstable. Exerting very large forces on very lightobjects may cause the calculations to be driven out of scope(to innity). These conditions can be avoided by assigning reasonable mass values when creating the physical models, as described above. The designer should experiment with mass values and forces applied to insure that physics and javascript processing are not brought to a halt. The inertia scale may be used to scale the moment of inertia of the object. Sometimes constraints may be made more stable by scaling up the moments of inertia of the physical models that they affect.
boxPhysicalModel = boxViewPointObject.createPhysicalModel(1, 1);
createPhysicalModelForMTSInstance(mass, inertiaScale)
A function similar to above, but which can be used at the instance level (more specic). For example, in a viewpoint scene which contains a number of instances, thismethod can be applied to just one of those instances. In doing so, the physical model created and the instance itself will now be rendered and processed as a separate object. Care should be given to following the guidelines for mass and inertia values as described in createPhysicalModel() above.
boxPhysicalModel = boxInstance.createPhysicalModelForMTSInstance(1, 1);
createConvexPhysicalModel(mass, inertiaScale)
A function that takes the current Viewpoint geometry and creates a physical model with the given mass. The inertia scale may be used to scale the moment of inertia of the object. Sometimes constraints may be made
more stable by scaling up the moments of inertia of the physical models that they affect. Once created, the physical model will modfy the tranform of the Viewpoint object as it experiences external forces, collisions and constraints. For this version of the function, the physical model uses the convex hull of the Viewpoint object, which allows collisions to be much more efciently computed by the physics engine. Care should be given to following the guidelines for mass and inertia values as described in createPhysicalModel() above.
boxPhysicalModel = boxViewPointObject.createConvexPhysicalModel(1, 1);
createConvexPhysicalModelForMTSInstance(mass, inertiaScale)
A function similar to above, but which can be used at the instance level (more specic). For example, in a viewpoint scene which contains a number of instances, thismethod can be applied to just one of those instances. In doing so, the physical model created and the instance itself will now be rendered and processed as a separate object. Care should be given to following the guidelines for mass and inertia values as described in createPhysicalModel() above.
boxPhysicalModel = boxInstance.createConvexPhysicalModelForMTSInstance(1, 1);
toString()
Returns the name of the object (assigned in the Builder) as a string. If a name was not assigned,the type is returned.
objectName = ViewPointObject.toString();
getPhysicalModel()
deletePhysicalModel()
Deletes the PhysicalModel created by the above methods, and removes all associated physics processing.
boxObject.deletePhysicalModel();
getParent()
Returns the parent SceneGroup; will return NULL if the given SceneGroup is the World.
theParent = SceneGroup.getParent();
Callbacks
onClick(what, mods)
This function is called when the user clicks on the Viewpoint object. what is the lowest-level geometry that was hit. mods is an integer bitmask indicating modier keys (e.g., shift, control, etc..) which were down during the click event.
box.onClick = function(what, mods) { if (what.name == lid)
330
APPENDIX E
{ chat.print(You clicked on the boxs lid!); } else { chat.print(You clicked on the box!); } }
onMouseOver()
This function is called when the cursor rst hovers over the Viewpoint object.
viewpointObject.onMouseOver = function() { // get the objects border theBorder = viewpointObject.scene.getMaterial(border) // set the borders color to white theBorder.diffuseColor = [ 1.0, 1.0, 1.0 ]; }
onMouseOut()
This function is called when the cursor stops hovering over the Viewpoint object.
viewpointObject.onMouseOut = function() { // get the objects border theBorder = viewpointObject.scene.getMaterial(border) // set the borders color to dark grey theBorder.diffuseColor = [ 0.3, 0.3, 0.3 ]; }
normal
objectFaceNo
The origin of the faces light map as a Vector. This value is read-only.
lightMapUTangent
The tangent to the light maps U-axis as a Vector. This value is read-only.
lightMapVTangent
The tangent to the light maps V-axis as a Vector. This value is read-only.
textureOrigin
The tangent to the textures V-axis as a Vector. This value is read-only. Methods
getSurfaceTexture()
removeAnimator(this); }
332
APPENDIX E
} addAnimator(loader);
Primitive
A Primitive is a module used to represent a Builder group, anchor, entrypoint or geometric primitive. Every solid object has a rootPrimitive which is the top level group from the Builder le for that solid object. (Currently there is only one solid object per SceneGroup.) This root primitive may be searched by name to nd other primitives using the nd function. Anchors are a form of primitive often used to pass locations and orientations to scripts from the Builder. Other primitives will be actual geometry which will contain faces. Global Properties
rootPrimitive
Properties
type
subType
The primitives type. I.e. the type of solid it is in the Builder: Column, Box, Cone, etc.
if (foo.subYype == Column) { ... }
loaded
Boolean ag that is set to true when the Primitives owner SceneGroup is fully loaded and ready.
foo.timestep = function() { if (!this.loaded) { return; } // loaded, now do something } addAnimator(foo);
orientation
The orientation of the Primitive as set in the Builder, expressed as a Rotation. Presently this only applies to Entrypoints and Anchors.
root = stageModel.getSolidObject(0).rootPrimitive; anchor = root.nd(.../anchorPoint);
position
The position (or min of bounds) of the Primitive in the world, expressed as a Vector.
anchor = stageModel.getPrimitive(anchorPoint); box = SceneGroup(./box.aer); box.position = anchor.position;
transform
The Transform of the Primitive representing the combined position and orientation. Presently this only applies to Entrypoints and Anchors.
anchor = stageModel.getPrimitive(anchorPoint); box = SceneGroup(./box.aer); box.transform = anchor.transform;
name
visibleInActorView
The boolean ag that mirrors the checkbox in the Builder Visible in Actor View.
if (foo.visibleInActorView) { chat.print(Primitive is visible); }
subtractive
bounds
The min and max extent of the Primitive in local coordinates, relative to the Primitives SceneGroups Eye position and orientation, expressed as an array of two Vectors [min, max].
min = foo.bounds[0]; max = foo.bounds[1];
334
APPENDIX E
volume = (max.x - min.x) * (max.y - min.y) * (max.z - min.z); chat.print(Primitives bounding-box volume is + volume);
children
An array of Primitives that are children to the given Primitive in the Builder object hierarcy. If children is undened the Primitive has no children.
if (foo.children == undened) { chat.print(Primitive has no children); } else { chat.print(First childs name is + foo.children[0].name); }
parent
The Primitives parent. If parent is undened then it is the rootPrimitive of the SolidObject.
if (foo.parent == undened) { chat.print(Primitive has no parent); } else { chat.print(Parents name is + foo.parent.name); }
Methods
nd(path)
Returns the rst descendant of this object which matches the specied path. The path is similar to a le path, where / separates each element, and where each element is one of: A name refers to the child with that name . refers to the current Primitive .. refers to the parent of the current Primitive ... refers to any number of elements (other than ..) * refers to any one element (other than ..)
root = stageModel.getSolidObject(0).rootPrimitive; rstTorch = root.nd(.../torch);
Similar to the method nd but returns an array of all the matching Primitives.
root = stageModel.getSolidObject(0).rootPrimitive; torches = root.ndAll (.../torch);
getFace(index)
getFaceCount()
getParentSceneObject()
Returns the parent SceneObject for this primitive. Currently, this object will be of type SolidObject only. (Future updates may enable many types of objects to have primitives.)
myPrimitiveParent = myPrimitive.getParentSceneObject();
toString()
Returns the name of the object (assigned in the Builder) as a string. If a name was not assigned, the type is returned.
for ( i=0 ; i < stageModel.getSolidObject(0).rootPrimitive.children.length ; i++ ) { chat.print( stageModel.getSolidObject(0).rootPrimitive.children[i].toString() ); }
Callbacks
onClick(string what, mods)
Called when the user clicks on the associated Primitive. what is the lowest-level WorldObject that was hit, which may differ from this if this is, e.g., a Group which contains a number of child Primitives. mods is an integer bitmask indicating modier keys (e.g., shift, control, etc..) which were down during the click event, and may contain other ags as well. The exact interpretation of mods is presently still under development and subject to change.
stageModel.getSolidObject(0).rootPrimitive.onClick = function(what) { if (what.name != null) { chat.print(You clicked on + what.name); } }
336
APPENDIX E
Materials
SurfaceTexture
A SurfaceTexture is a module used to represent the mapping between a texture image and a surface. It contains a reference to a Texture module, that contains the image, along with parameters that control the location, size and rotation angle of the texture relative to the surface. Texture swapping is enabled by changing the texture property to reference to a different texture object. A form of texture animation may be achieved by referencing a different texture object each time step. Properties
type
hasTexture
A boolean ag that is true when the SurfaceTexture has an attached texture, and false if the surface uses a texture color only. If there is no texture or surface color specied in the Builder application, the SurfaceTexture object will be undened, and this property will not be useful. Additionally, this property should not be used as a test for the presence of a texture object. Instead, test to see if getFace(n).getSurfaceTexture() is dened.
surfaceTextureType
The type of texturing scheme used on a particular face, either Texture or AnchoredTexture.
texture
Methods
getTexture()
if (theSurfaceTexture.hasTexture) { chat.print(The SurfaceTexture has a texture.); chat.print(Its type is + theSurfaceTexture.surfaceTextureType); } theSurfaceTexture.sizeU = 2.0; theSurfaceTexture.sizeV = 2.0; theSurfaceTexture.offsetU = .25; theSurfaceTexture.offsetU = .75; theSurfaceTexture.rotationAngleInDegrees = 45; theSurfaceTexture.texture = aTexture; theTexture = theSurfaceTexture.getTexture(); removeAnimator(this); } } addAnimator(loader);
Texture
A Texture module is used to represent the image loaded to be used as a texture on a surface. The actual mapping is controlled using a SurfaceTexture module. The a string property (URLString) controls the source of the image le and another property (cached) controls whether the image is cached locally.
338
APPENDIX E
Global Methods
Texture()
Properties
type
cached
A boolean ag that determines if the image le loaded by a Texture object should be cached by the Player application. By default this is set to true.
tex = Texture(); tex.cached = true;
URL
The URL path of an image le to be loaded as a texture. Supports .PNG, .JPG, and .GIF graphic le formats. Note that the URL for a given texture can only be set once; attempting to change the URL will cause a JavaScript error. If it is desired to swap textures for a Surface Texture, create numerous texture objects with unique URLs, and then change the SurfaceTexture.texture property to reference any of the texture objects.
// texture object with absolute URL tex1 = Texture(); tex1.URL = http://myDomain.com/myHomePage/grass.gif; // texture object with relative URL tex2 = Texture(); tex2.URL = ./grid.jpg;
Methods
restartTextureLoad()
Returns an integer that describes the Viewpoint type of the objects base class.
if ( a.baseMetatype() != b.baseMetatype() ) { chat.print(Not the same base type); }
getBaseMetatypeName()
getMetatype()
getMetatypeName()
Returns a string that contains the Viewpoint type of the object as a 4-character string.
chat.print( Object type = + a.metatypeName() );
getName()
getProperty(index or name)
Returns the value of a Viewpoint internal property either by index or via the 4-character name returned by getPropertyName(); below.
scale = object.getProperty(scl_); // - or scale = object.getProperty(2);
getPropertyCount()
340
APPENDIX E
numProps = object.getPropertyCount();
getPropertyName(index)
Returns the 4-character name for the property for that index value.
propName = object.getPropertyName(2);
getPropertyType(index)
Returns the data type for the property for that index value as a long integer.
if ( a.getPropertyType(1) == a.getPropertyType(2) ) { chat.print (Same type); }
getPropertyTypeName(index)
Returns the data type for the property for that index value as a 4-character string.
chat.print( Type = + a.getPropertyTypeName() );
hasProperty(name)
Returns whether an object has the property with the 4-character string name.
hasScale = a.hasProperty(scl_);
setProperty(name, value)
MTSImageStream
An MTSImageStream object is used to represent a Viewpoint time element of type MTSImageStream. These time elements are typically used to load an image for a texture (MTSTexture). Using these methods, you can change the image based upon any given event without needing to reload the world, or the object. Properties
aolArt
America Online performs further compression on GIF and JPG images to aid in reducing download time. Atmosphere has the capacity to decompress these les. This boolean ag species whether the AOL image les should be decompressed. (Off by default)
VPobject = stageModel.getViewpointObject(plane1); timeElem = VPobject.scene.getTimeElem(imgStream); timeElem.aolArt = true;
path
Returns or sets the path for the timeElement. Note that in order to set or change the path, the timeElem must not be running.
running
isStreaming
Returns the streaming state of the timeElement (is it actively streaming or not).
if (timeElem.isStreaming) { chat.print(Currently downloading the large image you requested...); }
MTSScene
An MTSScene object is used to represent the container for the instances, geometry and materials within a single Viewpoint object created by reading in an MTX le. This type of object also supports the methods and properties of MTSBaseObject. Global Properties
scene
Properties
antiAlias
edgeBias
Methods
getInstance(index or name)
Gets a reference to the specied instance. The argument can either be a string or a numeric index.
leg = scene.getInstance(leg);
getInstanceFromIndex(index)
Gets a reference to the specied instance. The index must be an integer greater than or equal to zero.
342
APPENDIX E
leg = scene.getInstanceFromIndex(0);
getInstanceCount()
getRepository()
getTimeElem(index or name)
Gets a reference to the specied time element. The argument can either be a string or a numeric index.
walkTimeElem = scene.getTimeElem(Walking);
getTimeElemFromIndex(index)
Gets a reference to the specied time element. The index must be an integer greater than or equal to zero.
walkTimeElem = scene.getTimeElemFromIndex(0);
getTimeElemCount()
resetTimeElem()
Resets a named time element to the beginning of its time interval and evaluates the time.
scene.resetTimeElem(Walking);
rewindTimeElem()
Rewinds a named time element to the beginning of its time interval but does not evaluate the time.
scene.rewindTimeElem(Walking);
startTimeElem()
Starts a named time element playing from its current time value.
scene.startTimeElem(Walking);
stopTimeElem()
triggerTimeElem()
Rewinds and starts a named time element playing from the beginning of its time interval.
scene.triggerTimeElem(Walking);
MTSGeometry
An MTSGeometry object is used to represent a Viewpoint surface. This object also supports the methods and properties of MTSBaseObject. Properties
backFaceCull
Enables back-face culling during rendering. This will make closed surfaces render more quickly, but may look strange with open surfaces.
geometry.backFaceCull = true;
backFaceDirection
creaseAngle
The crease angle parameter controls the degree of simplication of the geometry.
geometry.creaseAngle = 5.0;
zBuffer
Methods getTriangleCount() Returns the count of the triangles used to represent the object.
numTriangles = geometry.getTriangleCount();
getVertexCount()
MTSInstance
An MTSInstance object is used to represent a Viewpoint instance within a Viewpoint object scene. Such an instance contains a reference to a piece of geometry, along with one or more materials and one or more transformations. An instance also constains an array of child instances. This type of object also supports the methods and properties of MTSBaseObject.
344
APPENDIX E
(Note that within a Viewpoint scene, the Z coordinate is reversed for position. Therefore, if a Viewpoint scene contains multiple instances, moving those instances relative to each other will require using an inverted Z value as compared to the normal Atmosphere coordinate system.) Properties
position / location
contains the position for the instance as an array of three values. (The identical property location is also maintained for backward compatibility.)
instance.location = [1.0, 2.0, 1.0];
rotationAnglesInDegrees
rotationAnglesInRadians
opacity
contains the opacity values (1 - transparency). Note that opacity is not recursive down the instance tree, but applies only to the instance which is directly set.
instance.opacity = 0.75;
remove
scale
visible
contains the ag for whether the object is drawn. Note that visibility is not recursive down the instance tree, but applies only to the instance which is directly set.
instance.visible = false;
prelite
preliteColor
usePreliteColor
renderLayer
Methods
getChild(index or name)
getChildCount()
getGeometry()
getInstance2d - or getGeometry2d()
getMaterial(index or name)
getMaterialCount()
346
APPENDIX E
MTSTexture
An MTSTexture object is used to represent a Viewpoint texture, which may be used by a Viewpoint material to control the appearance of a surface. This object also inherits all the methods of the MTSBaseObject. Properties
scaleX
scaleX
translateX
Change the origin of the texture in the horizontal direction where 1.0 is the width of the texture cell.
textureObj.translateX = 0.5; //offset the texture by horizontally by 50%
translateY
Change the origin of the texture in the vertical direction where 1.0 is the height of the texture cell.
// offset the texture vertically by 20% textureObj.translateY = 0.2;
llColor
Specify the ll color for the texture as an array of three values [ R, G, B ]. Note that setting this property will cover the texture with the color specied. The texture can be exposed again by resetting the texture path using the MTSImageStream property path.
// set to red textureOjb.llColor = [ 1, 0, 0 ];
size
Returns the size of the image as stored in the Viewpoint buffer. (Does not necessarily represent the original image size. See the methods below to obtain exact pixel dimensions of the image used for the texture.)
[localPropertyCodeSample]
mip
Returns whether the texture object is using MipMapping (specied in the MTX le).
isMipped = textureObj.mip;
mipBias
Sets the Mip bias for the texture object (if Mipmapping is enabled in the MTX le). Mipmapping causes the texture to appear blurred at a distance, and helps to eliminate pixelation anomalies during rendering. Typical appropriate values range from 0.25 to 8.0.
Methods
getHeight()
Returns the original vertical size in pixels of the image used for the texture object.
imageHeight = textureObj.getHeight();
getWidth()
Returns the original horizontal size in pixels of the image used for the texture object.
imageWidth = textureObj.getWidth();
MTSInstance2d
An MTSInstance2D object is used to represent a Viewpoint text object. The text may be attached to an Atmosphere object in 3D, or may be placed in a xed position in the display window. (See the instructions for dstPin below.) The geometry object must be rst dened in an XML description le. (It is dened using a <LayerData> tag of a Viewpoint instance. The instance must also contain a geometry tag describing the type of Viewpoint geometry.) Once loaded nearly all aspects of the text object may be modied in real time. It is important to note that the attribute AlwaysVisible=1 must be present in the MTX description le in order for the text to be displayed in Atmosphere. (Text created with the Viewpoint Scene Builder application has this attribute off (0) by default, but can be set to on (1) using the command Show Hot Spot text in the Hot Spot menu.) Properties
text
Species the content (the actual words) to be displayed by the text object.
textObj.text = Hello world!;
textSize
Species the text size, which corresponds directly to the Windows Font size.
textObj.textSize = 24 // set font to size 24
textColor
font
Species the font to be used by the text object. Any Windows font which appears in the Control Panel may be utilized. The default font used by Atmosphere will be the same as the users current default system font.
textObj.font = Times New Roman;
348
APPENDIX E
bold
Apply or remove this font style to the text object. (Default is false, or off.)
textObj.bold = true;
italic
Apply or remove this font style to the text object. (Default is false, or off.)
textObj.italic = true;
underline
Apply or remove this font style to the text object. (Default is false, or off.)
textObj.underline = true;
strikeout
Apply or remove this font style to the text object. (Default is false, or off.)
textObj.strikeout = false;
center
Species the offset of the text object around the geometry as an array of three values [ X, Y, Z ]. Note that these values may be overwritten by the radius property, if it is also present. The last property to be specied (radius or center) is what will take precedent.
textObj.center = [ 5, 2, 0 ];
textAlign
Sets the alignment of text relative to the end of the geometry pointer line. (left aligned = -1; centered = 0; right aligned = 1;)
textObj.textAlign = -1;
anchor
Species the location of the end of the pointer line to the text object as an array of two values [ X, Y ].
textObj.anchor = [ 0.7, 0 ];
radius
Species the distance from the geometry to the text object. Note that this value may be overwritten by the center property, if it is also present. The last property to be specied (radius or center) is what will take precedent.
textObj.radius = 10;
trackPoint
Species the location of the end of the pointer line on the instance as an array of three values [ X, Y, Z ].
textObj.trackPoint = [ 0, 2, 0 ];
dstPin
For text which is xed in the window space(immovable), this property species the distance from the window corner in pixels as an array of two numbers [ X, Y ]. The distance may also be specied as a percentage of the window size using dstPinRelative = true (shown below). Note that in order for text to be xed in the window space, the Viewpoint XML le which denes the text object must also contain these two properties: AnchorWidget = 1 WidgetLine = 0 The second property removes the pointer line which connects the text to the geometry from which it originates. Also, the default origination for xed text is the top left corner of the window. A different origin may be specied using dstPinFlag shown below.
textObj.dstPin = [ 100, -50 ];
dstPinFlag
Species which corner of the window should be used as the point of origination for text which is xed in the window: 0 = top left (the default origin) 1 = top right 2 = bottom left 3 = bottom right
// set the text origin to bottom right textObj.dstPinFlag = 3
dstPinRelative
Causes the property dstpin (above) to use a percentage of window size, where 1.0 equals 100%. When this property is false, dstPin returns to using absolute pixels.
textObj.dstPinRelative = true;
shadow
shadowColor
Sets the color of the text drop shadow as an array of three values [ R, G, B ].
// green shadow text textObj.shadowColor = [ 0, 1, 0 ];
shadowRadius
350
APPENDIX E
alwaysVisible
Returns whether the text will always be visible in Atmosphere, or will only show during a MouseOver event. Note that for this release, changing this property has no effect and should be considered read only. Its also important to note that this attribute must be present in the MTX description le, and set to 1 in order for the text to be visible in Atmosphere.
bIsVisible = textObj.alwaysVisible;
MTSMaterial
An MTSMaterial is an object used to represent a Viewpoint material. This allows for control of different aspects of a surfaces appearance including surface and bump textures, specular and diffuse shading coefcients and opacity. An MTSMaterial object also supports all the methods of MTSBaseObject. Properties
ambientColor
bumpStrength
Scales the apparent depth of the bump map on the surface of the geometry.
material.bumpStrength = 0.7; //set bump strength to 70% intensity
bumpTextureName
Returns the value of the name property for the bump texture.
btName = material.bumpTextureName;
diffuseColor
Species the diffuse color of the material as an array of three values [ R, G, B ]. When rendermode is set to 12 (see below), the diffuse color is composited (combined) with the diffuse texture.
material.diffuseColor = [1.0, 0.0, 0.0]; //set the diffuse color to red.
diffuseTextureName
Returns the value of the name property for the diffuse texture.
dtName = material.diffuseTextureName;
emmissiveColor
environmentTextureName
Returns the value of the name property for the environment texture.
name = material.environmentTextureName;
opacity
Sets the opacity of a material ( 0.0 - 1.0 ) , which allows the underlying geometry to appear transparent.
material.opacity = 0.2; //Nearly transparent
renderMode
Changes the manner in which the Viewpoint scene is rendered. The following settings are most commonly used: renderMode = 1024 (default) renderMode = 7; (wireframe) renderMode = 8; (points & lines) renderMode = 11; (full) renderMode = 12; (color & texture composite)
material.renderMode = 12; //composite the diffuse color and diffuse texture
specularCoefcient
specularColor
Species the specular color to be used on the material as an array of three values [ R, G, B ]. A bright or white value gives the appearance of a hard or smooth surface.
material.specularColor = [0.3, 0.3, 0.3]; // Future enhancement
Methods
getBumpTexture()
getDiffuseTexture()
MTSTimeElem
An MTSTimeElem object is used to present a Viewpoint time element or animation object. Note that these objects are called TimeElem in the MTX le. This type of object also supports the methods and properties of MTSBaseObject. Properties
pauseTime
The ag to control whether the animation is paused. If set to true, while running is also set to true, this ag allows the animator to be set (and rendered) to a particular time.
352
APPENDIX E
// Pause the time element prior to setting the time timeElem.pauseTime = true;
time
The time used to evaluate the animation when timeElem.pauseTime and timeElem.running are both set to true.
// Evaluate the animation at time 1.5 seconds timeElem.time = 1.5;
timeIncrement
The timeIncrement used to update the animation when pauseTime and running are both set to true. It is best to leave this value at zero when evaluating an animation directly using time in a script.
// Increment the time by 0.0 per frame // since we update time in the script timeElem.timeIncrement = 0.0;
speed
The speed at which the animation is to play back when running. This value may be changed continuously such as when adjusting walking speed.
// Play back the animation at 70% of the normal speed timeElem.speed = 0.7;
duration
If the TimeElem has a metatype of kgrp then it is a keyframe group and has a corresponding duration given by this property.
// returns the duration as a oat in seconds walkTime = timeElem.duration;
running
Methods
start()
Tells the time element to increment time with each frame update and to evaluate itself.
timeElem.start ();
stop()
Tells the time element to no-longer increment time with each frame update.
timeElem.stop ();
rewind()
Sets the time value for the time elements to the beginning of the interval but does not evaluate the time element.
trigger()
setSpeed()
Sets the speed of the time element and all its children.
timeElem.setSpeed (0.5);
setPlayOnce()
Set the play once ag, that if true, tells the time element to play once and then stop.
timeElem.setPlayOnce (false);
getChild(index or name)
getChildCount()
MTSTimeElemSWFView
An MTSTimeElemSWFView is used to represent a Viewpoint Time Element of type SWFView. An SWFView contains an SWF vector-based animation and renders it into a surface texture each timestep. This object also inherits all the methods of the MTSBaseObject. Properties
running
pauseTime
realTime
354
APPENDIX E
time
Moves the SWF movie to the specied time, and renders it. Note that the movie must be paused for this property to have an effect.
SWFtimeElem.time = 5; //render the movie at the 5 second mark
loop
Causes the SWF movie to loop continously from beginning to end when playing.
SWFtimeElem.loop = true;
opacity
comp
Composites the movie frame by frame. This causes the movie to only update changed portions of the frame, without redrawing the entire movie area.
SWFtimeElem.comp = true;
clip
base
Returns the path of the folder in which the SWF movie resides.
rootFolder = SWFtimeElem.base;
path
Methods
start()
Starts playing the SWF movie from the last position stopped.
SWFtimeElem.start();
stop()
rewind()
Rewinds the SWF movie to the beginning. Note that the movie area will not be updated until you call start() again.
trigger()
Rewinds the SWF movie to the beginning and also starts the movie playing.
SWFtimeElem.trigger();
setSpeed()
setPlayOnce()
reverseDirection()
getChild(index or name)
getChildCount()
Physics
FastConstraintSolver
A FastConstraintSolver is an object that contains a list constraints or actions between physical models. During physics simulation, the FastConstraintSolver tries to satisfy all of the requirements for each listed contraint/action by changing the position, orientation, and velocity of the physical models affected. After creating a new FastConstraintSolver using the global method, the Solver has Local methods which are then used to create different types of constraints and actions. Once a constraint/action is created, it must be added to an existing Solver list using the Add...() methods shown below. Several guidelines should be considered when determining which constraints or actions should be added to an existing Solver:
356
APPENDIX E
Any physical model involved in a constraint or action should have all of its constraints and actions included in the same FastConstraintSolver. Faster processing may be achieved if unrelated constraints belong to different solvers, such as a hingeConstraint for a door and a wheelConstraint for a vehicle. Constraints and Actions may also be removed or re-added to a Solver list following creation.
(Angular Dashpots and Actions are not constraints by denition, but need to be processed and included in a FastConstraintSolver.) Global Methods
FastConstraintSolver()
Local Methods
createHingeConstraint(PhysicalModel, PhysicalModel)
Creates and returns a new HingeConstraint between the two PhysicalModels. This constraint imitates the common concept of a hinge, such as is used on a door or lid.
solver = FastConstraintSolver(); constraint = solver.createHingeConstraint(a.physicalModel, b.physicalModel); solver.addConstraint(constraint);
createPointToPointConstraint(PhysicalModel, PhysicalModel)
createPrismaticConstraint(PhysicalModel, PhysicalModel)
Creates and returns a new PrismaticConstraint between the two PhysicalModels. This constraint limits an object to a single direction of movement, such as is used in a sliding door.
solver = FastConstraintSolver(); constraint = solver.createPrismaticConstraint(a.physicalModel, b.physicalModel); solver.addConstraint(constraint);
createStiffSpringConstraint(PhysicalModel, PhysicalModel)
createWheelConstraint(PhysicalModel, PhysicalModel)
Creates and returns a new WheelConstraint between the two PhysicalModels. The rst PhysicalModel is the chassis, the second is the wheel.
solver = FastConstraintSolver(); constraint = solver.createWheelConstraint(frame.physicalModel, wheel.physicalModel); solver.addConstraint(constraint);
addConstraint(constraint)
removeConstraint(constraint)
Creates a BreakableConstraint which is added to an existing constraint. This unique type of constraint acts as an arbitrator that determines if a given constraint should remain active. Values for angularStrength and linearStrength specify the forces beyond which the constraint will be abandoned, and the physical models will break apart.
solver = FastConstraintSolver(); constraint = solver.createWheelConstraint(frame.physicalModel, wheel.physicalModel); solver.addConstraint(constraint); breakableConstraint = solver.createBreakableConstraint(constraint, 50, 50); solver.addConstraint(breakableConstraint);
createAngularDashpot(PhysicalModel, PhysicalModel)
addAngularDashpot(AngularDashpot)
removeAngularDashpot(AngularDashpot)
358
APPENDIX E
createDragAction()
Creates and returns a new DragAction.The action has the effect of slowing down the momentum of objects for both direction and rotation.
solver = FastConstraintSolver(); velocityDrag = 1; angularVelocityDrag = 1; dragAction = solverA.createDragAction(velocityDrag, angularVelocityDrag); solverA.addAction(dragAction);
createFluidAction()
Creates and returns a new FluidAction. A Fluid Action causes all dynamic physical models in the world to behave as though the world were lled with a uid.
solver = FastConstraintSolver(); uidAction = solver.createFluidAction(); uidAction.damping = 1; solver.addAction(uidAction);
Creates and returns a new MagneticAction. This action simulates the effect of magnetic attraction or repulsion on physical models. Note that only active, falloff , and strength may be modied following the creation of the Magnetic Action. All other properties are specied at creation time only, and remain constant thereafter.
strength falloff angle maxDistance position direction = = = = 100; 0; 2.0 * 3.1415927; 100;
= Vector( 0, 0, 0 ); = Vector( 0, 0, 0 );
solver = FastConstraintSolver(); magAction = solver.createMagneticAction(strength, falloff, angle, maxDistance, position, direction); magAction.addPhysicalModel(box.physicalModel); magAction.addPhysicalModel(cone.physicalModel); solver.addAction(magAction);
Creates and returns a new MotorAction. This action simulates the effect of wind on a physical model.
axis = Vector( 0, 0, 0 ); spinRate = 3.0; gain = 3.0; maxTorque = 3.0; solver = FastConstraintSolver(); motorAction = solver.createMotorAction(PhysicalModel, axis, spinRate, gain, maxTorque); solver.addAction(motorAction);
Creates and returns a new SimpleRigidWindAction. This action simulates the effect of wind on a single physical model. (Additional wind actions may be created.)
direction strength solver = Vector( 0, 0, -1.0 ); = 3.0; = FastConstraintSolver();
createSingleDragAction()
Creates and returns a new SingleDragAction. The effect is that of slowing down the momentum of the object for both direction and rotation. This action differs from DragAction in that the effect is limited to a single physical model.
solver = FastConstraintSolver(); velocityDrag = 1; angularVelocityDrag = 1; dragAction = solverA.createSingleDragAction(velocityDrag, angularVelocityDrag); solverA.addAction(dragAction);
addAction(action)
removeAction(action)
AngularDashpot
An angular dashpot is a physical entity that applies torques to two physical models in proportion to the degree to which they are away from a preferred relative orientation. They may be thought of as angular springs whose torque depends on the relative orientation and difference in angular velocity between the two physical models. The preferred relative orientation is set using a rotation object. It should be noted that for any of the physics based constraints or actions, it is necessary to assign reasonable mass values when creating the physical models so that physics processing does not become unstable (driven out of scope). The guidelines for mass and inertia are decribed in the method createPhysicalModel(). Properties
damping
360
APPENDIX E
strength
Methods
setRotation(rotation)
Sets the desired resting rotation relative to the rst PhysicalModels coordinate frame.
angularDashpot.setRotation( Rotation(Z, 0.01) );
Code Sample
box1 = SceneGroup(./box.aer).add(); box2 = SceneGroup(./box.aer).add(); loader = new Object(); loader.timestep = function() { if(box1.loaded && box2.loaded) { box1.physicalModel = box1.createPhysicalModel(1); box2.physicalModel = box2.createPhysicalModel(1); solver = FastConstraintSolver(); angularDashpot = solver.createAngularDashpot(box1.physicalModel, box2.physicalModel); angularDashpot.damping = 0.5; angularDashpot.strength = 0.5; rotationValue = Rotation(Z, 0.00000001); angularDashpot.setRotation(rotationValue); solver.addAngularDashpot(angularDashpot); removeAnimator(this); } } addAnimator(loader);
Actions
DragAction
A Drag Action is a subtle force that is applied to all dynamic physical models in the world. The effect is that of slowing down the momentum of objects for both direction and rotation. A Drag Action is created by a method of the FastCon straintSolver(),and has global properties for velocity and angular velocity of drag (maximum = 1).
It should be noted that for any of the physics based constraints or actions, it is necessary to assign reasonable mass values when creating the physical models so that physics processing does not become unstable (driven out of scope). The guidelines for mass and inertia are decribed in the method createPhysicalModel(). Local Properties
angularVelocityDrag
velocityDrag
Code Sample
solverA = FastConstraintSolver(); velocityDrag = 1; angularVelocityDrag = 1; dragAction = solverA.createDragAction( velocityDrag, angularVelocityDrag ); solverA.addAction(dragAction);
FluidAction
A Fluid Action causes dynamic physical models in the world to behave as though the world were lled with a uid. The effect is more signicant than a Drag Action, and similarly applied to both the direction and rotation of objects. A Fluid Action is created by a method of the FastConstraintSolver(), and has a global scalar property for damping. It should be noted that for any of the physics based constraints or actions, it is necessary to assign reasonable mass values when creating the physical models so that physics processing does not become unstable (driven out of scope). The guidelines for mass and inertia are decribed in the method createPhysicalModel(). Local Properties
damping
A property representing the effective viscosity of the uid (water ~ 1). Code Sample
solverA = FastConstraintSolver(); uidAction = solverA.createFluidAction(); uidAction.damping = 1;
362
APPENDIX E
MagneticAction
The MagneticAction simulates the effect of magnetic attraction or repulsion on physical models. The action is created by a method of the FastConstraintSolver, and the source position of the effect is specied as a vector. The effect may be applied to as many SceneGroups as desired using the addPhysicalModel(modelName) method. Note that only three of the properties may be modied following the creation of the Magnetic Action; active, falloff , strength. All other properties are specied at creation time only, and remain constant (affected properties are noted below for convenience.) It should be noted that for any of the physics based constraints or actions, it is necessary to assign reasonable mass values when creating the physical models so that physics processing does not become unstable (driven out of scope). The guidelines for mass and inertia are decribed in the method createPhysicalModel(). Properties
active
A boolean ag controlling whether the magnetic effect is currently processed. (default = true)
magneticAction.active = true;
angle
The cone angle around which the magnetic effect will be experienced (specied in Radians). [Note: this property is specied at creation time only, and remains constant.]
angle = (2.0 * 3.1415927);
falloff
Species the rate at which the magnetic forces will decrease with distance.
magneticAction.falloff = 0;
direction
The direction the magnetic force is aimed (as a Vector). Note that this value only has meaning if the angle property (described above) is reduced from 360 degrees (specied in radians). [Note: this property is specied at creation time only, and remains constant.]
direction = Vector( 0.0, 0.0, -1.0 ); //straight away in Z
maxDistance
The distance beyond which no magnetic force is experienced (specied in feet). [Note: this property is specied at creation time only, and remains constant.]
maxDistance = 100;
position
The source position of the the magnetic force (as a Vector). [Note: this property is specied at creation time only, and remains constant.]
magCenter = theStage.getPrimitive(magCenter);
strength
The relative strength of the magnetic force. Positive values result in an attractive force, and negative values apply a repulsive force. Useful range is between -1000 and 1000.
magneticAction.strength = 200;
Local Methods
addPhysicalModel (PhysicalModel)
Species a PhysicalModel which will experience the Magnetic Action. Many SceneGroups may be added.
magneticAction.addPhysicalModel(box.physicalModel);
Code Sample
box box.anchor box.transform magCenter magSolver = SceneGroup(./box.aer).add(); = theStage.getPrimitive(anchor1); = box.anchor.transform; = theStage.getPrimitive(magCenter); = FastConstraintSolver();
loader = new Object(); loader.timestep = function(now) { if (!box.loaded) return; box.physicalModel box.physicalModel.collide box.physicalModel.acceleration = box.createConvexPhysicalModel(10); = true; = Vector(0.0, -32.0, 0.0);
strength = 200; falloff = 0; angle = 2.0 * 3.1415927; maxDistance = 100; position = magCenter.position; direction = Vector( 0, 0, 0 ); magAction = magSolver.createMagneticAction( strength, falloff, angle, maxDistance, position, direction); magAction.addPhysicalModel(box.physicalModel); magSolver.addAction(magAction); removeAnimator(loader); } addAnimator(loader);
364
APPENDIX E
MotorAction
A MotorAction may be used to apply rotational behavior to a physical model. The motor action is created by a method of the FastConstraintSolver, and applies to a single physical model. Motor action properties represent the common controls and measurements available in real-world motor controllers. Local Properties
gain
This property represents the strength of the motor at any given moment, calculated as the difference between current speed and the desired speed times the gain. If you desire for the motor to have sufcient strength to move other objects, values of 100 or greater should likely be used (depending upon the mass of the objects to be moved). Default value for the controller-motor preset script is 100.
motorAction.gain = 3;
maxTorque
The maximum torque available to the motor (torque is a measurement of the rotational force produced by the motor armature). In the Atmosphere application, maxTorque acts as a limit to the gain property.
motorAction.maxTorque = 3;
spinRate
The rotational speed desired for the motor (angular velocity). Note that if insufcient torque is available, themotor will not reach the desired speed. See the description for maxTorque above.
motorAction.spinRate = 3;
Code Sample
armature armature.anchor armature.transform = SceneGroup(./armature.aer).add(); = theStage.getPrimitive(anchor); = armature.anchor.transform;
armature.solver = FastConstraintSolver(); armature.timestep = function(now) { if (!armature.loaded) { return; } armature.physicalModel = armature.createPhysicalModel(1); armature.physicalModel.collide = true; armature.physicalModel.acceleration = Vector(0.0, 0.0, 0.0); //method expects 5 parameters armature.action = armature.solver.createMotorAction( armature.physicalModel, //physicalModel armature.anchor.position, //axis 3, //spinRate 3, //gain 3); //maxTorque
SingleDragAction
A Single Drag Action is a subtle force that is applied to a specied dynamic physical model. The effect is that of slowing down the momentum of the object for both direction and rotation. This module differs from Drag Action in that the effect can be limited to one object. Numerous Single Drag Actions can be created so that different physical models can experienced customized drag. A Single Drag Action is created by a method of the FastConstraintSolver(), and has adjustable properties for velocity and angular velocity of drag (maximum = 1). It should be noted that for any of the physics based constraints or actions, it is necessary to assign reasonable mass values when creating the physical models so that physics processing does not become unstable (driven out of scope). The guidelines for mass and inertia are decribed in the method createPhysicalModel(). Properties
angularVelocityDrag
velocityDrag
Code Sample
cone = SceneGroup(./cone.aer).add(); cone.anchor = stageModel.getSolidObject(0).rootPrimitive.nd(./anchor1); cone.transform = cone.anchor.transform; cone.solver = FastConstraintSolver(); cone.timestep = function(now) { if (!cone.loaded) return; cone.physicalModel = cone.createConvexPhysicalModel(1); cone.physicalModel.collide = true; cone.physicalModel.acceleration = Vector(0.0, -32.0, 0.0); cone.velocityDrag = 1; cone.angularVelocityDrag = 1;
366
APPENDIX E
cone.singleDragAction
SimpleRigidWindAction
As the name implies, a SimpleRigidWindAction simulates the effect of wind on a physical model. The wind action is created by a method of the FastConstraintSolver. A single SceneGroup is controlled for each wind action, and numerous wind actions can be created. In addition, there are adjustable properties for wind strength and direction, as decribed below. It should be noted that for any of the physics based constraints or actions, it is necessary to assign reasonable mass values when creating the physical models so that physics processing does not become unstable (driven out of scope). The guidelines for mass and inertia are decribed in the method createPhysicalModel(). Properties
active
A boolean ag controlling whether the wind effect is currently processed. (default = true)
simpleRigidWindAction.active = true;
direction
strength
The relative strength of the wind. Useful values range from 0 - 100.
simpleRigidWindAction.strength = 3;
Code Sample
stage = stageModel.getSolidObject(0).rootPrimitive; sphere = SceneGroup(./sphere.aer).add(); sphere.anchor = stage1.nd(./anchor); sphere.position = sphere.anchor.position; sphere.solver = FastConstraintSolver(); sphere.onLoad = function() { sphere.physicalModel = sphere.createPhysicalModel(1); sphere.physicalModel.collide = true; sphere.physicalModel.acceleration = Vector( 0.0, -32.0, 0.0 );
Constraints
BreakableConstraint
A breakable constraint is actually an arbitrator that determines if a given constraint should remain active. The breakable contraint is created by a method of the FastConstraintSolver, and is passed a constraint name and values for linear and angular strength. If the specied constraint experiences stresses which are beyond the strength values given, the constraint is abandoned, and the physical models will break apart. Properties
angularStrength
Species the value at which the constraint will fail for angular stresses (such as experienced at a pivot point).
breakableConstraint.angularStrength = 50;
linearStrength
Species the value at which the constraint will fail for linear stresses (similar to tensile strength).
breakableConstraint.linearStrength = 50;
Code Sample
doorLeft doorLeft.anchor doorLeft.position doorLeft.orientation doorLeft.pivot doorLeft.axis hingeLeft hingeLeft.anchor hingeLeft.position hingeLeft.orientation loader loader.solver = = = = = = = = = = SceneGroup(./resources/doorLeft.aer).add(); theStage.getPrimitive(doorLeft); doorLeft.anchor.position; doorLeft.anchor.orientation; doorLeft.anchor.position; // location of hinge Vector (0,1,0); // axis of hinge SceneGroup(./resources/hingeLeft.aer).add(); stageModel.getSolidObject(0).rootPrimitive.nd(.../hingeLeft); hingeLeft.anchor.position; hingeLeft.anchor.orientation;
368
APPENDIX E
loader.timestep = function(now) { if (!doorLeft.loaded) { return; } if (!hingeLeft.loaded) { return; } doorLeft.physicalModel = doorLeft.createConvexPhysicalModel(2); doorLeft.physicalModel.collide = true; doorLeft.physicalModel.acceleration = Vector(0.0, -32.0, 0.0); hingeLeft.physicalModel hingeLeft.physicalModel.xed = hingeLeft.createConvexPhysicalModel(0); = true;
constraint = this.solver.createHingeConstraint(doorLeft.physicalModel, hingeLeft.physicalModel); constraint.setWorldSpacePivotAndAxis(doorLeft.pivot, doorLeft.axis); breakableConstraint = this.solver.createBreakableConstraint(constraint, 50, 50); this.solver.addConstraint(breakableConstraint); doorLeft.angularDashpot = this.solver.createAngularDashpot(doorLeft.physicalModel, hingeLeft.physicalModel); doorLeft.angularDashpot.setRotation(Rotation(Y, 0.0)); doorLeft.angularDashpot.strength = .5; this.solver.addAngularDashpot(doorLeft.angularDashpot); removeAnimator(this); } addAnimator(loader);
HingeConstraint
A hinge constraint between two physical models simulates the effects of a physical hinge. The constraint includes a pivot point and a rotation axis. The pivot point and axis are specied in world space when being dened relative to the initial position of the physical models. Such a constraint is created using a fast constraint solver. After that, the two objects will be constrained to act as if there is a hinge between them. It should be noted that for any of the physics based constraints or actions, it is necessary to assign reasonable mass values when creating the physical models so that physics processing does not become unstable (driven out of scope). The guidelines for mass and inertia are decribed in the method createPhysicalModel(). Properties
tau
Methods
setWorldSpacePivotAndAxis(Vector pivot, Vector axis)
A point dening the location of the constraint, and the hinge axis direction. Code Sample
cube = SceneGroup(./cube.aer).add(); star = SceneGroup(./star.aer).add(); loader = new Object(); loader.timestep = function() { if (cube.loaded && star.loaded) { cube.physicalModel = cube.createPhysicalModel(1); star.physicalModel = star.createPhysicalModel(10); solver = FastConstraintSolver(); constraint = solver.createHingeConstraint(cube.physicalModel, star.physicalModel); constraint.strength = 1.0; constraint.tau = 1.0; pivot = Vector(0, 0, 0); axis = Vector(0, 1, 0); constraint.setWorldSpacePivotAndAxis(pivot, axis); removeAnimator(this); } } addAnimator(loader);
PointToPointConstraint
A point to point constraint between two physical models simulates the effects of a physical ball joint. The constraint includes a pivot point about which the two physical models rotate freely. The pivot point is specied in world space for the initial placement relative to the two physical models. Such a constraint is created using a fast constraint solver. After that, the two objects will be constrained to act as if there is a ball-joint between them. It should be noted that for any of the physics based constraints or actions, it is necessary to assign reasonable mass values when creating the physical models so that physics processing does not become unstable (driven out of scope). The guidelines for mass and inertia are decribed in the method createPhysicalModel(). Properties
strength
370
APPENDIX E
tau
The point in world space that denes the location of the constraint. Code Sample
cube = SceneGroup(./cube.aer).add(); star = SceneGroup(./star.aer).add(); loader = new Object(); loader.timestep = function() { if (cube.loaded && star.loaded) { cube.physicalModel = cube.createPhysicalModel(1); star.physicalModel = star.createPhysicalModel(10); solver = FastConstraintSolver(); constraint = solver.createPointToPointConstraint(cube.physicalModel, star.physicalModel); constraint.strength = 1.0; constraint.tau = 1.0; pivot = Vector(0, 0, 0); constraint.setWorldSpacePivotPoint(pivot); removeAnimator(this); } } addAnimator(loader);
PrismaticConstraint
A PrismaticConstraint is a physical constraint between two physical models that simulates the effect of sliding on a rail. The objects are held in a xed relative orientation to each other, and at a x displacement orthogonal to the rail, but are free to slide along the rail direction. It is useful for sliding doors, elevators etc. The constraint is created using a fast constraint solver, after which the relative motion will be constrained to sliding along the axis direction. It should be noted that for any of the physics based constraints or actions, it is necessary to assign reasonable mass values when creating the physical models so that physics processing does not become unstable (driven out of scope). The guidelines for mass and inertia are decribed in the method createPhysicalModel().
Properties
tau
The Vector representing the direction of motion to which the PhysicalModels will be constrained. Code Sample
ring = SceneGroup(./ring.aer).add(); pole = SceneGroup(./pole.aer).add(); loader = new Object(); loader.timestep = function() { if (ring.loaded && pole.loaded) { ring.physicalModel = ring.createPhysicalModel(1); pole.physicalModel = pole.createPhysicalModel(10); solver = FastConstraintSolver(); constraint = solver.createPrismaticConstraint(ring.physicalModel, pole.physicalModel); constraint.strength = 1.0; constraint.tau = 1.0; constraint.relativeOrientation = Rotation(Z, 1.0); constraint.relativeTranslation = Vector(1.0, 2.0, 3.0); constraint.slideDirection = Vector(0.0, 1.0, 0.0); removeAnimator(this); } } addAnimator(loader);
StiffSpringConstraint
A stiff spring constraint between two physical models constrains two points on those bodies to remain at a specied distance from each other not matter what other physical motion they may experience. The constraint is created using a fast constraint solver and may be thought of as a stiff physical spring.
372
APPENDIX E
It should be noted that for any of the physics based constraints or actions, it is necessary to assignreasonable mass values when creating the physical models so that physics processing does not become unstable(driven out of scope). The guidelines for mass and inertia are decribed in the methodcreatePhysicalModel(). Properties
length
The time constant for the constraint, similar to damping. (Note that reasonable values range from 0.0 to 1.0.) Methods
setWorldSpacePivotPoints(Vector pivot1, Vector pivot2)
Sets the two points representing the ends of the spring. These points are in world space coordinates (i.e. they are relative to the origin of the StageModel).
setLocalSpacePivotPoints(Vector pivot1, Vector pivot2)
Sets the two points representing the ends of the spring. These points are in local space coordinates (i.e. they are relative to the origins of the corresponding SceneGroups specied when the constraint was created). Code Sample
box1 = SceneGroup(./box.aer).add(); box2 = SceneGroup(./box.aer).add(); loader = new Object(); loader.timestep = function() { if (box1.loaded && box2.loaded) { box1.physicalModel = box1.createPhysicalModel(10); box2.physicalModel = box2.createPhysicalModel(2); solver = FastConstraintSolver(); constraint = solver.createStiffSpringConstraint(box1.physicalModel, box2.physicalModel); constraint.length = 1.0; constraint.strength = 1.0; constraint.tau = 1.0; pivot1 = Vector (0, 0, 0); pivot2 = Vector (1, 0, 0) constraint.setWorldSpacePivotPoints(pivot1, pivot2)
WheelConstraint
A wheel constraint simulates the effects of a wheel being held by a stiff suspension along with a motor to apply torque to the wheels. There are functions to control the preferred speed of the wheels as well as the desired steering angle of the wheel. A set of wheel constraints may be used to attach physical models for the wheels to a physical model for a chassis. A physically realistic vehicle will result. Properties
strength
Sets the desired speed of the motor driving the wheel and the maximum angular force the motor can exert.
setSteeringAngle(oat angleInRadians)
Sets the degree of the angle the wheels are turned around the suspension. Valid range is from -180 to 180 degrees. Default is 0.0 degrees.
setWorldSpacePivotAxleAndSuspension(Vector pivot, Vector axle, Vector suspension)
Sets the point where the wheel constraint is, the axle around which it spins, and the suspension around which the steering angle is set. Code Sample
frame = SceneGroup(./frame.aer).add(); wheel = SceneGroup(./wheel.aer).add(); loader = new Object(); loader.timestep = function() { if (frame.loaded && wheel.loaded) { frame.physicalModel = frame.createPhysicalModel(10); wheel.physicalModel = wheel.createPhysicalModel(2); solver = FastConstraintSolver();
374
APPENDIX E
constraint = solver.createWheelConstraint(frame.physicalModel, wheel.physicalModel); constraint.strength = 1.0; constraint.tau = 1.0; speed = 2.0; maxTorque = 5.0; constraint.setMotorSpeedAndMaxTorque(speed, maxTorque); setSteeringAngle(45); pivot = Vector (0, 0, 0); axle = Vector (1, 0, 0) suspension = Vector(0, 1, 0); constraint.setWorldSpacePivotAxleAndSuspension(pivot, axle, suspension) solver.addConstraint(constraint); removeAnimator(this); } } addAnimator(loader);
Adobe Atmosphere
Adobe Systems Incoporated 345 Park Avenue, San Jose, CA 95110-2704 USA www.adobe.com 90047303 11/03