VR Environments by:

Mark Baldridge, Ben Chang, Margaret Dolinsky, Kegan McGurk, Paul Schuette, Roger Wakeman

at the Intermedia Festival of Telematic Arts, Indianapolis, Saturday April 24th

Live Cam:

http://vrt-cam-1.avl.iupui.edu/view/index.shtml

(login: user=guest, pw=guest)

VR researcher Joe LaViola talks about different paradigms for 3D interaction and how these interfaces, developed for the CAVE and other VR systems, can be applied to the new generation of 6DOF controllers

http://www.gamasutra.com/view/feature/4331/from_research_to_games_.php

import direct.directbase.DirectStart
from pandac.PandaModules import *
from direct.task import Task
from direct.showbase import *
import random
import sys
import math

# vrpn_server -millisleep 1 -f vrpn_flock.cfg

class World(DirectObject.DirectObject):
  def __init__(self):
        # Accept the Esc key to quit the game.
    self.accept("escape", sys.exit)

    self.vrpnclient = VrpnClient ('localhost')
    self.tracker0 = TrackerNode(self.vrpnclient,"Tracker0")
    taskMgr.add (self.update,"update")

    self.wand=loader.loadModel("zup-axis")
    self.wand.reparentTo(render)
        # this is a node in the scenegraph.  you can attach stuff to it which will be visible.
    self.myTrackedNode = render.attachNewNode('myTrackedNode')  
   
        # this is the data node that gets the tracker info
        # it is NOT in the scenegraph, but in the mysterious data graph
    base.dataRoot.node().addChild(self.tracker0)
   
   
    t2n = Transform2SG('t2n')
    self.tracker0.addChild(t2n)
   
    t2n.setNode(self.myTrackedNode.node())

        # i think this should work:
        # cube=loader.loadModel("cube")
        # cube.reparentTo(self.myTrackedNode)
   
    base.disableMouse()
    camera.setPos(0,-100,30)
    camera.lookAt(0,0,0)

  def update (self,t):
    self.vrpnclient.poll()
    #camera.setPos(self.myTrackedNode.getPos())
    #camera.setHpr (self.myTrackedNode.getHpr())

    #print self.myTrackedNode.getPos()*1000, self.myTrackedNode.getHpr()
   
    p=self.myTrackedNode.getPos()
   
    p2 = int(p.getX()*100), int (p.getY() * 100), int(p.getZ() * 100)
    print p2    

    self.wand.setPos(p*15)
    #self.wand.setHpr(self.myTrackedNode.getHpr())

    #print self.wand.getPos()
    return Task.cont

 

w=World()
run()

Drag.tar

This example uses an updated MousePickingManager.py, so use the one in this archive. You can drag objects up and down, left and right.

# Click and Drag

from pandac.PandaModules import *
from direct.task import *
from direct.showbase import DirectObject
import direct.directbase.DirectStart
import random
from MousePickingManager import *

import sys

class World (DirectObject.DirectObject):
    def __init__(self):
        self.loadmodels()
        self.mousemanager = MousePickingManager(self)
        self.accept ('escape',self.quit)
       
    def loadmodels(self):
        light1Node=PointLight("light1")
        light1=camera.attachNewNode(light1Node)
        render.setLight(light1)
        camera.setPos(0,-10,3)
        camera.lookAt(0,0,0)
        self.redpawn = Pawn("red pawn",self)
        self.redpawn.obj.setColor(1,0,0,1)
       
        self.bluepawn = Pawn("blue pawn",self)
        self.bluepawn.obj.setColor(0,0,1,1)
        self.bluepawn.obj.setPos(2,3,0)
        taskMgr.add(self.update,"update")

        camera.setH(0)
       
    def update(self,task):

        return task.cont

    def quit (self):
        print "bye bye"
        sys.exit()

class Pawn (DirectObject.DirectObject):
    def __init__(self,name,world):
        self.name=name
        self.world=world

        p=loader.loadModel("pawn")
        p.setName(name)
        p.reparentTo(render)      

        p.setTag("mouseInteraction","1")
        p.setPythonTag("pythonObject",self)
           
        self.obj=p
        self.dragging=False

        self.accept("mouseDown"+self.name,self.onClick)
        self.accept("mouseUp"+self.name,self.onRelease)
        self.accept("mouseUpOutside"+self.name,self.onRelease)
       
        taskMgr.add(self.update,"update")

    def onClick(self):
        self.dragging=True
        self.dragOffset=self.obj.getPos() - self.world.mousemanager.getLastPickPoint()
        print self.dragOffset
        # store distance

    def onRelease(self):
        self.dragging=False

    def update(self,task):
        if self.dragging:
            p=self.world.mousemanager.getMousePositionOnXZPlane()
            self.obj.setPos(p+self.dragOffset)
        return task.cont

w=World()

run()

Examples of using mouse events to interact with objects.
ClickOnObject.tar

Read the rest of this entry »

projectile and colllision tutorial image

This tutorial includes projectiles, simple fake physics, collisions, mouse interaction, and some handy vector math techniques to create a simple game.

There are several steps:

  1. Create a projectile and animate it through code
  2. Set up interaction to aim and launch the projectile
  3. Create and animate targets to hurl projectiles at
  4. Set up collision detection so you know when the target has been hit

All the completed code, with models and Maya files, is included in this archive:

TUTORIAL FILES

Read the rest of this entry »

# Mouse Example 4
# Moving an object around to follow the mouse

from pandac.PandaModules import *
from direct.task import *
from direct.showbase import DirectObject
import direct.directbase.DirectStart
import random

from MousePickingManager import *

class World(DirectObject.DirectObject):
  def __init__(self):

    self.mousemanager = MousePickingManager(self)

    taskMgr.add(self.update,"update")

    self.hand = loader.loadModel("models/hand")
    self.hand.reparentTo(render)
    camera.setPos(0,-10,0)
    self.light = render.attachNewNode(PointLight('light1'))
    self.light.reparentTo(render)
    self.light.setPos(0,-50,50)
    render.setLight(self.light)

  def update(self,task):
    # get the current position of the mouse on the screen
    mousepos = self.mousemanager.getMouse()
    x=mousepos.getX() * 4
    y=mousepos.getY() * 4

    self.hand.setPos(x,0,y)
   
    return Task.cont

w=World()
run()

# Rotate a model based on mouse movement

from pandac.PandaModules import *
from direct.task import *
from direct.showbase import DirectObject
import direct.directbase.DirectStart
import random

from MousePickingManager import *

class World(DirectObject.DirectObject):
  def __init__(self):

    self.mousemanager = MousePickingManager(self)

    taskMgr.add(self.update,"update")

    self.eye = loader.loadModel("models/eye")
    self.eye.reparentTo(render)
    camera.setPos(0,-10,0)

  def update(self,task):
    # get the current position of the mouse on the screen
    mousepos = self.mousemanager.getMouse()
    x=mousepos.getX()
    y=mousepos.getY()

    print x,y

    xangle = x * 45
    yangle = y * -45

    self.eye.setH(xangle)
    self.eye.setP(yangle)

    return Task.cont

w=World()
run()

NavigationExample_1.tar

Mouse Examples Set 1

# Mouse Example 1
# Getting mouse position and checking the buttons

from pandac.PandaModules import *
from direct.task import *
from direct.showbase import DirectObject
import direct.directbase.DirectStart
import random

from MousePickingManager import *

class World(DirectObject.DirectObject):
  def __init__(self):
    self.mousemanager = MousePickingManager(self)
    taskMgr.add(self.update,"update")

  def update(self,task):
    # get the current position of the mouse on the screen
    mousepos = self.mousemanager.getMouse()
    print mousepos
   
    leftbutton = self.mousemanager.getButtonState(0)

    print leftbutton
    return Task.cont

w=World()
run()

Read the rest of this entry »