The Source Code

This artwork was created using a combination of Flash ActionScript 3 Papervision3D, Cocoa and C.

Code sneak peak

Some of the code librarys we will be using is open source and we would like to acknoledge them. They include ARToolit, Papervision3D and more coming soon.

Each character will act as a 3D block with hit detecdtion on it. Here is a smaple class I have working in Flex. Still developing this... there are still a few bugs.

package com.gogetheard.flartoolkit.view
{
import flash.events.*;
import flash.text.*;
import flash.utils.Timer;

import org.papervision3d.materials.BitmapColorMaterial;
import org.papervision3d.materials.WireframeMaterial;
import org.papervision3d.materials.utils.MaterialsList;
import org.papervision3d.objects.DisplayObject3D;
import org.papervision3d.objects.primitives.Cube;

public class Block extends DisplayObject3D
{
public var cube:Cube;
private var targScene:Object;
public var talking:Boolean = false;
public var idNum:int;
private var block:Block;
private var timer:Timer;
private var boxWidth:Number = 50;
private var radius:Number = 2000;
private var ang:Number = 45;
private var xloc:Number;
private var yloc:Number;
private var zloc:Number;
private var isCubePressed:Boolean = false;


public function Block(targ:Object, id:Number, w:Number, xl:Number, yl:Number, zl:Number)
{
targScene = targ;
idNum = id;
boxWidth = w;
xloc=xl;
yloc=yl;
zloc=zl;
initBlock();
}
private function initBlock():void
{




var materialsList:MaterialsList = new MaterialsList();
var wire:WireframeMaterial = new WireframeMaterial(0xFFFFFF*Math.random(), 1, 6);
wire.interactive = true;
var solid:BitmapColorMaterial = new BitmapColorMaterial(0xFFFFFF*Math.random(), 1);
solid.interactive = true;


materialsList.addMaterial(wire, "all");


//materialsList.addMaterial(mat, "all");
//materialsList.addMaterial(new BitmapColorMaterial(0xFFFFFF*Math.random(), 1), "all");
cube = new Cube(materialsList, boxWidth * 2, boxWidth * 2, boxWidth * 2);
//cube.z = Math.sin((ang*idNum)*Math.PI/180) * radius;
//cube.x = Math.cos((ang*idNum)*Math.PI/180) * radius;




cube.x = xloc;
cube.y = yloc;
cube.z = zloc;

addChild(cube);
initTimer();
}

private function initTimer():void
{
//trace("init timer");
timer = new Timer(1000,0);
timer.start();
timer.addEventListener(TimerEvent.TIMER, timerEvent);
}
private function timerEvent(e:TimerEvent):void
{
//trace(idNum,"switch")
switch(idNum){
case 1:
//cube.x += 10;
if(this.cube.hitTestObject(targScene.getChildByName("block2")) && !talking){
if(!talking){
talking = true;
trace("hit 12 talking:",talking);
}else{
trace("conversing 12 talking:",talking);
}
}
if(this.cube.hitTestObject(targScene.getChildByName("block3")) && !talking){
talking = true;
trace("hit 13 talking:",talking);
}
if(this.cube.hitTestObject(targScene.getChildByName("block4")) && !talking){
talking = true;
trace("hit 14 talking:",talking);
}
/*else{
//talking = false;
trace("hit 10 talking:",talking);
}*/

break;

case 2:
if(this.cube.hitTestObject(targScene.getChildByName("block1"))){
trace("hit 21");
}
if(this.cube.hitTestObject(targScene.getChildByName("block3"))){
trace("hit 23");
}
if(this.cube.hitTestObject(targScene.getChildByName("block4"))){
trace("hit 24");
}
break;

case 3:
if(this.cube.hitTestObject(targScene.getChildByName("block1"))){
trace("hit 31");
}
if(this.cube.hitTestObject(targScene.getChildByName("block2"))){
trace("hit 32");
}
if(this.cube.hitTestObject(targScene.getChildByName("block4"))){
trace("hit 34");
}



break;

case 4:
if(this.cube.hitTestObject(targScene.getChildByName("block1"))){
trace("hit 41");
}
if(this.cube.hitTestObject(targScene.getChildByName("block2"))){
trace("hit 42");
}
if(this.cube.hitTestObject(targScene.getChildByName("block3"))){
trace("hit 43");
}break;
}
//trace("timer:\n",this.hitTestObject(targScene.getChildByName("block1")));
//cube.z -= 10;
}
private function createText():void
{
var txtFmt:TextFormat = new TextFormat("Helvetica",100, 255);
var txt:TextField = new TextField();
txt.embedFonts = true;
txt.antiAliasType = AntiAliasType.ADVANCED;
txt.autoSize = TextFieldAutoSize.LEFT;
txt.border = false;

txtFmt.color = 0x333333; // Make the text yellow
txtFmt.size = 222;
txtFmt.letterSpacing = -2;
txt.text = "test";
txt.setTextFormat(txtFmt);

//addChild(txt);

}


}
}

 


Please send all feedback here


© 2009 Rhys Turner and Melissa Ramos