Difference between revisions of "Fringe Physics"

From Immersive Visualization Lab Wiki
Jump to: navigation, search
m (Rmaloney moved page Physics Lab to Fringe Physics: Project renaming)
(Project Goals)
Line 6: Line 6:
 
* Encapsulate a system of object creation and physics handling
 
* Encapsulate a system of object creation and physics handling
 
* Enabled user interactions using OSG intersection
 
* Enabled user interactions using OSG intersection
* Integrate system with ZSpace for enhanced immersion
+
* Integrate system with zSpace for enhanced immersion
 +
* Allow for puzzle solving elements
 +
* Integrate custom geometry into the Bullet simulation
  
 
===Developers===
 
===Developers===

Revision as of 17:08, 17 March 2015

Contents

Project Overview

The concept of this project is to create a room with a physics-enabled ballpit in the center. The user would have the ability to interact with the balls by picking them up and moving them to certain stations. These stations can be anything from antigravity fields and seesaws to trampolines and infintely dense miniplanets, and is solely dependent on the creativity of the individual.

Project Goals

  • Integrate the Bullet Engine to OpenSceneGraph by linking the two worlds
  • Encapsulate a system of object creation and physics handling
  • Enabled user interactions using OSG intersection
  • Integrate system with zSpace for enhanced immersion
  • Allow for puzzle solving elements
  • Integrate custom geometry into the Bullet simulation

Developers

Software Developer

  • Robert Maloney

Project Adviser

  • Jurgen Schulze

Technologies

  • CalVR
  • OpenSceneGraph v3.0.1
  • Bullet Engine v2.8.1
  • ZSpace

Timeline

Basic Scene

Basic Scene
Seesaw in the center of a ballpit
Physics-enabled box on the end of the stylus for initial interaction

The first step was to create a scene with primitive objects for initial testing: a small box for our manipulated object, and a bigger box pushed down by its halflength to serve as our ground. Once this scene was in place, the physics engine had to be integrated.

The Bullet Engine is a completely separate entity from OpenSceneGraph, but both systems have very similar frameworks that allow us to easily connect the two. By making a static box equal to the ground box, and a kinematic box equal to the smaller rendered box, we can simulate physics by synchronizing the matrices of the two worlds. I added a bit more functionality by allowing the physics box to be manipulated by the arrow keys and spacebar, effectively forcing the rendered box to slide and hop.

Once this basic simulation was achieved, the next step was to create a system by which one could generate objects with a few important parameters. This system would completely handle the rendering and updating of its objects by linking the rendered and physical world, and simply return Nodes for adding to the scene. This was created as an ObjectFactory and a BulletHandler. The ObjectFactory creates the object based on the user's preference, and then signals the BulletHandler to create its physical counterpart. Before every frame, the rendered world's matrices are synched with the physical world.

In order to see both the full power of the Bullet Engine and a prototype of the ballpit, I simulated a volume of 400 spheres. Once the simulation has begun, the spheres go into action, dispersing and filling the low end of the scene. An invisible wall has also been implemented to contain the objects in the scene.

Antigravity Field

The next step of the project involved creating the stations. My first station was the antigravity field, because the first thing I wanted to do with a physics engine was defy it. The Antigravity Field revolves around the functionality of a special object in the Bullet Engine, the btGhostObject. It does not create impulses against colliding objects, like the spheres do, but still keeps track of collisions in an AABB.

By attaching a Vec3 to the btGhostObject, I was able to create a basic Antigravity Field. On every frame, the AGFs check for collisions. For all dynamic objects inside the AABB, the AGF's gravity vector is applied. In order to create the illusion of realistic gravity when outside these fields, there is actually an AGF encompassing all the others. Coupling it with a hierarchical algorithm gives us a deterministic way of applying gravity. In future iterations, I am going to change the AGFs to add to gravity instead of write it.

Seesaw

The second station I created was a seesaw, which is quite simple with the Bullet Engine. The engine allows us to define a hinge constraint that limits rotation of the object. In order to abstract from manually defining the hinge vector for each object, the ObjectFactory determines the hinge between the smallest dimensions for x-axis and y-axis.

ZSpace and Interaction

The final step was to integrate the scene into ZSpace with interaction from the stylus. I had originally attempted to solve this problem using the same btGhostObject that I used for the AGFs. However, that proved to be unsuccessful because of how the Bullet Engine handles collisions. I was lucky enough to create the Antigravity Fields as AABBs, so the Bullet Engine handled them perfectly, as long as they weren't rotated. However, Bullet Engine uses Broadphase collision detection, which utilizes bounding volumes to efficiently compute collisions. It also has narrowphase for more realistic collision, but ghost objects do not use narrowphase. This resulted in a huge box containing the stylus, causing the algorithm to pick up spheres straight down from the stylus origin.

In order to solve this, I switch to an implementation by OSG, the IntersectVisitor. It allows me to define a line segment in the center of the stylus, and send this segment through the entire scene graph, returning all nodes that intersect it. Combining this implementation with a closest-object search allowed me to select the object I wanted to grab. In order to preserve its location relative to the stylus, I saved the distance in a vector and reapplied it every time the stylus' position and rotation were updated. This gives the user a realistic feel of picking up objects, rather than them teleporting to a predifined point on the stylus. In order to help isolate the grabbed object from the rest, the one selected becomes black for the duration of the grab.

Combining all of these pieces resulting in this final scene:

PhysicsLab FinalScene.png