crayon3d team. outline overview features creating a scene creating nodes collision events ...
TRANSCRIPT
![Page 1: Crayon3D Team. Outline Overview Features Creating a Scene Creating Nodes Collision Events Using a Wiimote Using the Helper Classes Class](https://reader035.vdocuments.site/reader035/viewer/2022062314/56649f175503460f94c2e101/html5/thumbnails/1.jpg)
Crayon3D Team
![Page 2: Crayon3D Team. Outline Overview Features Creating a Scene Creating Nodes Collision Events Using a Wiimote Using the Helper Classes Class](https://reader035.vdocuments.site/reader035/viewer/2022062314/56649f175503460f94c2e101/html5/thumbnails/2.jpg)
Outline Overview Features Creating a Scene Creating Nodes Collision Events Using a Wiimote Using the Helper Classes Class Diagram Glove and IR Glasses
![Page 3: Crayon3D Team. Outline Overview Features Creating a Scene Creating Nodes Collision Events Using a Wiimote Using the Helper Classes Class](https://reader035.vdocuments.site/reader035/viewer/2022062314/56649f175503460f94c2e101/html5/thumbnails/3.jpg)
Overview• Crayon3D provides a set of tools allowing
aspiring game developers to easily use Wiimotes as an input device
• Crayon3D also provides a very simple interface to the physics engine, Open Dynamics Engine (ODE)
“Make development easier for BVW so students can focus more on making their
worlds entertaining”
![Page 4: Crayon3D Team. Outline Overview Features Creating a Scene Creating Nodes Collision Events Using a Wiimote Using the Helper Classes Class](https://reader035.vdocuments.site/reader035/viewer/2022062314/56649f175503460f94c2e101/html5/thumbnails/4.jpg)
Overview
Crayon3D ClassesCrayon3DSceneCrayon3DNodeWiimote HandlerCursorGesture Recognition Handler
![Page 5: Crayon3D Team. Outline Overview Features Creating a Scene Creating Nodes Collision Events Using a Wiimote Using the Helper Classes Class](https://reader035.vdocuments.site/reader035/viewer/2022062314/56649f175503460f94c2e101/html5/thumbnails/5.jpg)
Overview
• Minimum Requirements– OS: Windows XP or Higher– Bluetooth Support– Files:
• wiiuse.dll• wiiuse_al.dll• wiiuse_al.py• wiimote_handler.py• Crayon3DScene.py• Crayon3DGesture.py
![Page 6: Crayon3D Team. Outline Overview Features Creating a Scene Creating Nodes Collision Events Using a Wiimote Using the Helper Classes Class](https://reader035.vdocuments.site/reader035/viewer/2022062314/56649f175503460f94c2e101/html5/thumbnails/6.jpg)
Crayon3D Platform Features Full integration with the Wiiuse Library
Support for:○ Accessing wiimote data (buttons, accelerometer, IR camera)○ Accessing wiimote expansion devices (nunchuk, classic
controller, guitar hero 3 controller) Includes helper classes for:
Controlling and managing wiimote resources IR Point tracking as a cursor (for finger tracking) Button controls (for use with IR Point cursor) IR Point tracking for Fish Tank VR Gesture Recognition
Simple interface to the ODE library Well-documented source code Online API Reference Expandable
![Page 7: Crayon3D Team. Outline Overview Features Creating a Scene Creating Nodes Collision Events Using a Wiimote Using the Helper Classes Class](https://reader035.vdocuments.site/reader035/viewer/2022062314/56649f175503460f94c2e101/html5/thumbnails/7.jpg)
Creating a Scene
What is a scene?A stage setting, a place of an occurrence or
actionMerriam-Webster Dictionary
The scene is the Virtual World○ It contains everything in the world
EnvironmentObjects
![Page 8: Crayon3D Team. Outline Overview Features Creating a Scene Creating Nodes Collision Events Using a Wiimote Using the Helper Classes Class](https://reader035.vdocuments.site/reader035/viewer/2022062314/56649f175503460f94c2e101/html5/thumbnails/8.jpg)
Creating a Scene• To create a scene:
1. Specify the environment model and position it in the world
2. Specify the physics properties of the worlda. Default – use the default Crayon3D propertiesb. Manual – specify properties manually
3. Specify the collision geometry of the modela. Mesh – based on the polygon data of the modelb. Plane – normal plane extending to infinityc. Manual – specify specific ODE collision
geometry
![Page 9: Crayon3D Team. Outline Overview Features Creating a Scene Creating Nodes Collision Events Using a Wiimote Using the Helper Classes Class](https://reader035.vdocuments.site/reader035/viewer/2022062314/56649f175503460f94c2e101/html5/thumbnails/9.jpg)
Creating a Scene# Load the model of the environment to be usedenv_model = loader.loadModel(‘environment.egg');
# Scale it appropriately and place it in the worldenv_model.setPos(0, 0, 0);
# Create the Crayon3DScene using the environment model we just createdself.scene = Crayon3DScene(env_model);
# Use default physics for our sceneself.scene.setDefaultPhysics();
# Set the collision geometry of the environment to the scene# Use the actual polygons of the model to create the collision geometryself.scene.setEnvGeomMesh();
![Page 10: Crayon3D Team. Outline Overview Features Creating a Scene Creating Nodes Collision Events Using a Wiimote Using the Helper Classes Class](https://reader035.vdocuments.site/reader035/viewer/2022062314/56649f175503460f94c2e101/html5/thumbnails/10.jpg)
Creating a Scene
Physics in the scene can be started or stopped
self.scene.startPhysics()
self.scene.stopPhysics() Before starting the physics in the scene,
make sure to wait for at least half a second to make sure that all objects are properly placed in the world
![Page 11: Crayon3D Team. Outline Overview Features Creating a Scene Creating Nodes Collision Events Using a Wiimote Using the Helper Classes Class](https://reader035.vdocuments.site/reader035/viewer/2022062314/56649f175503460f94c2e101/html5/thumbnails/11.jpg)
Creating Nodes
What are nodes?Nodes are the objects in the sceneNodes must belong to a scene
Scene
Object1 Node
Object1 Node
Object1 Node
![Page 12: Crayon3D Team. Outline Overview Features Creating a Scene Creating Nodes Collision Events Using a Wiimote Using the Helper Classes Class](https://reader035.vdocuments.site/reader035/viewer/2022062314/56649f175503460f94c2e101/html5/thumbnails/12.jpg)
Creating Nodes• To create a node:
1. Create a node in the scene2. Specify the model to be used for that node3. Specify the Physics properties for the node
a. Box – the node will be treated like a boxb. Sphere – the node will be treated like a spherec. Manual – specify the physics properties
manually• Manipulating nodes is similar to how you
manipulate nodes in Panda3D.– Note that scaling and shearing the nodes is
not yet supported. Calling these functions will not do anything.
![Page 13: Crayon3D Team. Outline Overview Features Creating a Scene Creating Nodes Collision Events Using a Wiimote Using the Helper Classes Class](https://reader035.vdocuments.site/reader035/viewer/2022062314/56649f175503460f94c2e101/html5/thumbnails/13.jpg)
Creating Nodes# Load the model to be used by the nodemodel = loader.loadModel(‘model.egg’);
# Create the new node from the scene and give it a unique namebox = self.scene.newNode(‘model_name’);
# Set the model of the node to the model that we just createdbox.setModel(model);
# Set the collision geometry and physics properties of the node by# giving the length, width and height of the bounding box of the
node.box.setDefaultPhysicsBox(1, 1, 1);
![Page 14: Crayon3D Team. Outline Overview Features Creating a Scene Creating Nodes Collision Events Using a Wiimote Using the Helper Classes Class](https://reader035.vdocuments.site/reader035/viewer/2022062314/56649f175503460f94c2e101/html5/thumbnails/14.jpg)
Collision Events Collision events can be handled by specifying an
event handler for the event: “ode-collision”
self.accept("ode-collision", onCollision)
The event handler should accept an additional parameter This additional parameter will contain information about
the nodes that collided To get the information, do this: (assume the additional
parameter is called entry)
onCollision(entry):# This is the first nodecrayonNode1 = self.scene.findNodeByGeom(entry.getGeom1());# This is the second nodecrayonNode2 = self.scene.findNodeByGeom(entry.getGeom2());
![Page 15: Crayon3D Team. Outline Overview Features Creating a Scene Creating Nodes Collision Events Using a Wiimote Using the Helper Classes Class](https://reader035.vdocuments.site/reader035/viewer/2022062314/56649f175503460f94c2e101/html5/thumbnails/15.jpg)
Using a Wiimote Connecting a wiimote to the PC requires
Bluetooth connection To connect to a wiimote using Blue Soleil:
Press and hold buttons 1 and 2 simultaneouslySearch for nearby Bluetooth devices. You
should see a Nintendo RVL-CNT-01Connect to this deviceOnce connected release the buttons you are
holding.Do this for all wiimotes you want to use
![Page 16: Crayon3D Team. Outline Overview Features Creating a Scene Creating Nodes Collision Events Using a Wiimote Using the Helper Classes Class](https://reader035.vdocuments.site/reader035/viewer/2022062314/56649f175503460f94c2e101/html5/thumbnails/16.jpg)
Using a Wiimote
Note for Blue Soleil:Ensure that you unplug all wiimotes that are
not being used.○ Right click on the Nintendo RVL-CNT-01 and
check if there is an unplug optionIf there is click it to unplugIf there is none then the device is already unplugged
![Page 17: Crayon3D Team. Outline Overview Features Creating a Scene Creating Nodes Collision Events Using a Wiimote Using the Helper Classes Class](https://reader035.vdocuments.site/reader035/viewer/2022062314/56649f175503460f94c2e101/html5/thumbnails/17.jpg)
Using a Wiimote
Crayon3D provides several classes that will make it easier to access data from wiimotes and its possible extensions (nunchuk, classic controller, guitar hero 3 controller)Wiiuse Abstraction Layer
○ Python interface to the wiiuse libraryWiimote Handler
○ Helper class for managing and accessing wiimote information
![Page 18: Crayon3D Team. Outline Overview Features Creating a Scene Creating Nodes Collision Events Using a Wiimote Using the Helper Classes Class](https://reader035.vdocuments.site/reader035/viewer/2022062314/56649f175503460f94c2e101/html5/thumbnails/18.jpg)
Using a Wiimote• Wiimote Handler
– Specify the types of wiimotes that you need• WIIMOTE_TRACKER – only accepts the IR
camera information of the wiimote• WIIMOTE_BUTTON – only accepts button input
from the wiimote (and expansion input)• WIIMOTE_ACCEL – only accepts accelerometer
input from the wiimote• WIIMOTE_BUTTON_ACCEL – ony accepts button
and accelerometer input from the wiimote (and expansion input)
• WIIMOTE_ALL – accept all inputs from the wiimote
![Page 19: Crayon3D Team. Outline Overview Features Creating a Scene Creating Nodes Collision Events Using a Wiimote Using the Helper Classes Class](https://reader035.vdocuments.site/reader035/viewer/2022062314/56649f175503460f94c2e101/html5/thumbnails/19.jpg)
Using the Wiimote
Wiimote handler can theoretically support up to 15 wiimotes simultaneously
![Page 20: Crayon3D Team. Outline Overview Features Creating a Scene Creating Nodes Collision Events Using a Wiimote Using the Helper Classes Class](https://reader035.vdocuments.site/reader035/viewer/2022062314/56649f175503460f94c2e101/html5/thumbnails/20.jpg)
Using the Wiimote
1. Create a wiimote handler object
2. Start the wiimote handler object and specify the wiimotes that you want to use
3. Wait for button events or get wiimote data using the accessor functions provided
4. Before the application quits, make sure to stop the wiimote handler.
![Page 21: Crayon3D Team. Outline Overview Features Creating a Scene Creating Nodes Collision Events Using a Wiimote Using the Helper Classes Class](https://reader035.vdocuments.site/reader035/viewer/2022062314/56649f175503460f94c2e101/html5/thumbnails/21.jpg)
Using the Wiimote
Note that the wiimote handler object (and consequently the helper classes that require it) should be started last during the initialization sequence of the application
This ensures that the system is not busy when initializing the wiimotes
![Page 22: Crayon3D Team. Outline Overview Features Creating a Scene Creating Nodes Collision Events Using a Wiimote Using the Helper Classes Class](https://reader035.vdocuments.site/reader035/viewer/2022062314/56649f175503460f94c2e101/html5/thumbnails/22.jpg)
Using the Wiimote• Handling Wiimote Button Press and
Release events– Just specify an event handler for the events:
• WM_BUTTON_PRESSED• WM_BUTTON_RELEASEDThe handler functions should accept three more
parameters, btn, dev and index:btn tells the function which button was pressed or
releaseddev tells the function if the button is a wiimote button
or an expansion button (necessary if you’re using expansions)
Index tells the function which wiimote sent the event (necessary if you’re using multiple wiimotes)
![Page 23: Crayon3D Team. Outline Overview Features Creating a Scene Creating Nodes Collision Events Using a Wiimote Using the Helper Classes Class](https://reader035.vdocuments.site/reader035/viewer/2022062314/56649f175503460f94c2e101/html5/thumbnails/23.jpg)
Using the Wiimote Getting IR Information from the wiimote:
IR Structure○ dot : contains the four IR source information○ num_dots : number of IR sources seen by the
wiimote○ x, y : Corrected XY coordinates of the wiimote with
respect to the IR sources○ z : Arbitrary Z distance of the wiimote with respect
to the IR sources – a value will only be computed if there are at least two IR sources visible
○ aspect : Aspect ratio of the screen, 0 for 4:3 and 1 for 16:9 – this determines the size of the XY coordinate space (560x420 and 660x370, respectively)
![Page 24: Crayon3D Team. Outline Overview Features Creating a Scene Creating Nodes Collision Events Using a Wiimote Using the Helper Classes Class](https://reader035.vdocuments.site/reader035/viewer/2022062314/56649f175503460f94c2e101/html5/thumbnails/24.jpg)
Using the WiimoteThe Dot structure:
○ visible : Determines if the dot is visible or not○ x, y : Corrected XY coordinates of the IR
source○ rx, ry : Raw XY coordinates of the IR source
as reported by the wiimote○ XY coordinates for the dots are on a fixed
virtual screen resolution of 1024x768
![Page 25: Crayon3D Team. Outline Overview Features Creating a Scene Creating Nodes Collision Events Using a Wiimote Using the Helper Classes Class](https://reader035.vdocuments.site/reader035/viewer/2022062314/56649f175503460f94c2e101/html5/thumbnails/25.jpg)
Using the WiimoteIR Structure (sample code)
# Get IR structure of the first wiimoteir = wmHandler.getIRData(0);
# print X and Y position of the wiimote with respect to the IR sourcesprint ir.xprint ir.y# print the arbitrary Z distanceprint ir.z# Get the individual dot informationfor i in range(4):
# Print the X and Y position of the IR dot if it is visibleif(print ir.dot[i].visible): print ir.dot[i].x; print ir.dot[i].y;
![Page 26: Crayon3D Team. Outline Overview Features Creating a Scene Creating Nodes Collision Events Using a Wiimote Using the Helper Classes Class](https://reader035.vdocuments.site/reader035/viewer/2022062314/56649f175503460f94c2e101/html5/thumbnails/26.jpg)
Using the Wiimote
Getting Accelerometer DataOrient Structure
○ roll : Contains roll rotation information of the wiimote
○ pitch : Contains the pitch rotation information of the wiimote
○ yaw : Contains the yaw rotation information of the wiimote
![Page 27: Crayon3D Team. Outline Overview Features Creating a Scene Creating Nodes Collision Events Using a Wiimote Using the Helper Classes Class](https://reader035.vdocuments.site/reader035/viewer/2022062314/56649f175503460f94c2e101/html5/thumbnails/27.jpg)
Using the WiimoteOrient Structure (sample code):
# Get the accelerometer data of the first wiimoteorient = wmHandler.getAccelData(0);
# Print the rollprint orient.roll;# Print the pitchprint orient.pitch;# Print the yawprint orient.yaw;
![Page 28: Crayon3D Team. Outline Overview Features Creating a Scene Creating Nodes Collision Events Using a Wiimote Using the Helper Classes Class](https://reader035.vdocuments.site/reader035/viewer/2022062314/56649f175503460f94c2e101/html5/thumbnails/28.jpg)
Using the Wiimote
Getting Nunchuk DataNunchuk Structure
○ js : Joystick informationang : Angle of the joystick (0 – 360 degrees)mag : Magnitude of the joystick (value is 1 if the
player is pushing the joystick to the maximum, 0 if the player is not pushing the joystick)
○ orient : Accelerometer information of the nunchuk (similar to the Wiimote accelerometer information)
![Page 29: Crayon3D Team. Outline Overview Features Creating a Scene Creating Nodes Collision Events Using a Wiimote Using the Helper Classes Class](https://reader035.vdocuments.site/reader035/viewer/2022062314/56649f175503460f94c2e101/html5/thumbnails/29.jpg)
Using the WiimoteNunchuk Structure (sample code)
# Get the nunchuk structure connected to the first wiimotenc = wmHandler.getNunchukData(0);
# Print the joystick information of the nunchukprint nc.js.ang; # angleprint nc.js.mag; # magnitude
# Print the accelerometer informationprint nc.orient.roll;print nc.orient.pitch;print nc.orient.yaw;
![Page 30: Crayon3D Team. Outline Overview Features Creating a Scene Creating Nodes Collision Events Using a Wiimote Using the Helper Classes Class](https://reader035.vdocuments.site/reader035/viewer/2022062314/56649f175503460f94c2e101/html5/thumbnails/30.jpg)
Using the Helper Classes
Crayon3D provides a helper class if you want to use the wiimote as an IR tracker (ie. For finger tracking)Cursor Class
In addition to the IR tracker, Crayon3D also provides a helper class for recognizing gestures drawn using the Cursor helper classGesture Recognition Handler
![Page 31: Crayon3D Team. Outline Overview Features Creating a Scene Creating Nodes Collision Events Using a Wiimote Using the Helper Classes Class](https://reader035.vdocuments.site/reader035/viewer/2022062314/56649f175503460f94c2e101/html5/thumbnails/31.jpg)
Using the Helper Classes• Cursor
– To create a cursor for finger tracking1. Create a wiimote handler object and start it with at
least one WIIMOTE_TRACKER2. Create a cursor object:
a. Specify the images to be used by the cursor (200x200 images) – you can specify multiple images here if you want to
b. Specify the wiimote handler objectc. Specify the index of the WIIMOTE_TRACKER that is
used to track the IR points
self.wmHandler = WiimoteHandler();self.wmHandler.start([WIIMOTE_TRACKER, WIIMOTE_BUTTON]);self.cursor = Cursor([‘cursor.png'], self.wmHandler, 0);
![Page 32: Crayon3D Team. Outline Overview Features Creating a Scene Creating Nodes Collision Events Using a Wiimote Using the Helper Classes Class](https://reader035.vdocuments.site/reader035/viewer/2022062314/56649f175503460f94c2e101/html5/thumbnails/32.jpg)
Using the Helper Classes
The cursor class can be switched to use keyboard and mouse input if you don’t specify the wiimote handler and tracker index
self.cursor = Cursor(['textures/cursors/cursor_hand.png'])
![Page 33: Crayon3D Team. Outline Overview Features Creating a Scene Creating Nodes Collision Events Using a Wiimote Using the Helper Classes Class](https://reader035.vdocuments.site/reader035/viewer/2022062314/56649f175503460f94c2e101/html5/thumbnails/33.jpg)
Using the Helper Classes• Gesture Handler
– The gesture handler class allows the users to specify specific gestures to recognize and when these gestures are recognized, an event will be sent for notification
– Gestures are specified using a pattern of numbers• Look at the keypad:
– 8 means up, 7 means up-left, 4 means left, 1 means down-left, etc…
– 5 and 0 doesn’t mean anything
• For example, for a square drawn like this: up, right, down, left the pattern will be “8624”
• The gesture handler uses the Levenshtein algorithm to find the best match
![Page 34: Crayon3D Team. Outline Overview Features Creating a Scene Creating Nodes Collision Events Using a Wiimote Using the Helper Classes Class](https://reader035.vdocuments.site/reader035/viewer/2022062314/56649f175503460f94c2e101/html5/thumbnails/34.jpg)
Using the Helper Classes
7
4
12
3
6
98
Pattern = “8624”
![Page 35: Crayon3D Team. Outline Overview Features Creating a Scene Creating Nodes Collision Events Using a Wiimote Using the Helper Classes Class](https://reader035.vdocuments.site/reader035/viewer/2022062314/56649f175503460f94c2e101/html5/thumbnails/35.jpg)
Using the Helper Classes• To create a gesture handler object:
1. Specify a name for the gesture handler object, this name will also be used to generate events when a gesture is recognized
2. Specify the pattern of gestures and their identifiers. These identifiers will be passed to the event handler.
3. Specify the IR cursor object that will be used to draw4. Specify if the gestures will be visible5. Specify the color of the gestures
• Using the gesture handler1. Start drawing2. Stop drawing3. Handle gesture recognition event
![Page 36: Crayon3D Team. Outline Overview Features Creating a Scene Creating Nodes Collision Events Using a Wiimote Using the Helper Classes Class](https://reader035.vdocuments.site/reader035/viewer/2022062314/56649f175503460f94c2e101/html5/thumbnails/36.jpg)
Using the Helper Classesself.gestureHandler =
GestureRecognition("GESTURE_EVENT", [("369871", 0), # fish ("866224", 1), # square ("87412369", 2)], # circle self.cursor, True, 1, 0, 0);
To start drawing:self.gestureHandler.beginGesture();
To stop drawing:self.gestureHandler.endGesture();
![Page 37: Crayon3D Team. Outline Overview Features Creating a Scene Creating Nodes Collision Events Using a Wiimote Using the Helper Classes Class](https://reader035.vdocuments.site/reader035/viewer/2022062314/56649f175503460f94c2e101/html5/thumbnails/37.jpg)
Using the Helper Classes
Gesture HandlerHandling gesture recognition events:
○ Create an event handler for the name specified during creation of the gesture handler object
○ The event handler should accept three parameters:evt_data : this is the identifier for the gesture that was
recognizedx : this is the x position in 2D coordinates of the
approximate mid-point of the whole gesturey : this is the y position in 2D coordinates of the
approximate mid-point of the whole gesture
![Page 38: Crayon3D Team. Outline Overview Features Creating a Scene Creating Nodes Collision Events Using a Wiimote Using the Helper Classes Class](https://reader035.vdocuments.site/reader035/viewer/2022062314/56649f175503460f94c2e101/html5/thumbnails/38.jpg)
Wiimote I/F Physics I/F
Wiimote Handler
Helper Classes
Wiiuse
Wiiuse Abstraction
Layer
Crayon3D Scene
Crayon3D Node
ODE
CursorGesture
Recognition
Used for finger tracking
Handles polling and managing Wiimote
information.
Crayon3D Class Diagram
![Page 39: Crayon3D Team. Outline Overview Features Creating a Scene Creating Nodes Collision Events Using a Wiimote Using the Helper Classes Class](https://reader035.vdocuments.site/reader035/viewer/2022062314/56649f175503460f94c2e101/html5/thumbnails/39.jpg)
Glove and IR Glasses
Gloves:Buy from Giant Eagle / CVS
○ Black Stanley GlovesBuy from RadioShack
○ 3 High Output 5mm Infrared LED○ SPST Submini PC Board Toggle Switch○ Round PCB Kit
![Page 40: Crayon3D Team. Outline Overview Features Creating a Scene Creating Nodes Collision Events Using a Wiimote Using the Helper Classes Class](https://reader035.vdocuments.site/reader035/viewer/2022062314/56649f175503460f94c2e101/html5/thumbnails/40.jpg)
Glove and IR Glasses
![Page 41: Crayon3D Team. Outline Overview Features Creating a Scene Creating Nodes Collision Events Using a Wiimote Using the Helper Classes Class](https://reader035.vdocuments.site/reader035/viewer/2022062314/56649f175503460f94c2e101/html5/thumbnails/41.jpg)
Glove and IR Glasses
IR GlassesBuy from Amazon.com
(http://www.amazon.com/AO-Safety-97490-Vision-Glasses/dp/B000S97ZW4)
○ AO Safety Safety Glasses V2 Light VisionBuy from RadioShack
○ High Output 5mm Infrared LED
Replace the regular LEDs with the Infrared LED from RadioShack
![Page 42: Crayon3D Team. Outline Overview Features Creating a Scene Creating Nodes Collision Events Using a Wiimote Using the Helper Classes Class](https://reader035.vdocuments.site/reader035/viewer/2022062314/56649f175503460f94c2e101/html5/thumbnails/42.jpg)
Questions?
More information is available in the API reference and the wiiuse.net website