http://atassyu.tripod.com/Main.swfのソース
|
http://atassyu.tripod.com/NewProject3.swfのソース
|
http://atassyu.tripod.com/NewProject4.swfのソース
|
http://atassyu.tripod.com/NewProject5.swfのソース
|
http://atassyu.tripod.com/NewProject6.swfのソース
package
{
//
// 参考
// 書籍 池田泰延, Flash 3D コンテンツ制作のための Papervision3D 入門
// Web http://wonderfl.net/
// http://forum.papervision3d.jp/viewtopic.php?f=8&t=152
//
import flash.events.*;
import flash.events.MouseEvent;
import flash.geom.Point;
import flash.net.URLRequest;
import flash.net.navigateToURL;
import org.papervision3d.materials.ColorMaterial;
import org.papervision3d.materials.shadematerials.*;
import org.papervision3d.materials.special.Letter3DMaterial;
import org.papervision3d.materials.utils.*;
import org.papervision3d.lights.*;
import org.papervision3d.objects.DisplayObject3D;
import org.papervision3d.typography.fonts.*;
import org.papervision3d.typography.Text3D;
import org.papervision3d.view.*;
import org.papervision3d.view.stats.*;
import org.papervision3d.render.*;
import org.papervision3d.objects.parsers.*;
import org.papervision3d.materials.BitmapFileMaterial;
import org.papervision3d.objects.primitives.*;
import org.papervision3d.events.*;
/**
* ...
* @author TESAGEKABAN Atassyu
*/
public class Main extends BasicView {
// Bitmap
private var wrap:DisplayObject3D;
private var obj:Plane;
// Heart
private const ORBITAL_RADIUS:int = 300;
//private const CUBE_SIZE:int = 30;
private const CUBE_SIZE:int = 80;
private const CUBE_MAX:int = 30;
private var wrapHeart:DisplayObject3D;
private var cube:Cube;
private var cubes:Vector.<Cube> = new Vector.<Cube>
private var angle:Number;
// BBS
private var wrapBBS:DisplayObject3D;
private var textBBS:Text3D;
// Source
private var wrapSrc:DisplayObject3D;
private var textSrc:Text3D;
public function Main():void {
super( 0, 0, true, true );
// stats
//var stats:StatsView = new StatsView( renderer );
//addChild( stats );
// Bitmap
wrap = new DisplayObject3D();
scene.addChild( wrap );
var mat:BitmapFileMaterial = new BitmapFileMaterial( "mentroom.jpg", true );
mat.interactive = true;
mat.doubleSided = true;
obj = new Plane( mat, 640, 480 );
obj.x = 600;
obj.z = 0;
obj.addEventListener( InteractiveScene3DEvent.OBJECT_CLICK, clickHandler );
wrap.addChild( obj );
// Heart
var light:PointLight3D = new PointLight3D( false, false );
scene.addChild( light );
wrapHeart = new DisplayObject3D();
scene.addChild( wrapHeart );
//var color:ColorHSV = new ColorHSV( 0, 0.5, 0.5 );
//var material:FlatShadeMaterial = new FlatShadeMaterial( light, 0xFFFFFF, 0x111111, 50 );
var material:GouraudMaterial = new GouraudMaterial( light, 0xFF0000, 0x110000, 50 );
//var material:GouraudMaterial = new GouraudMaterial( light, color.value32, 0x111111, 50 );
//var material:PhongMaterial = new PhongMaterial( light, 0xFFFFFF, 0x111111, 50 );
//var material:CellMaterial = new CellMaterial( light, 0xFFFFFF, 0x111111, 10 );
cube = new Cube( new MaterialsList( { all:material } ), CUBE_SIZE, CUBE_SIZE, CUBE_SIZE, 1, 1, 1 );
wrapHeart.addChild( cube );
cubes.push( cube );
for ( var i:int=1; i<CUBE_MAX; i++ ) {
cube = new Cube( new MaterialsList( { all:material } ), CUBE_SIZE, CUBE_SIZE, CUBE_SIZE, 1, 1, 1 );
wrapHeart.addChild( cube );
angle = ( i/CUBE_MAX/2 )*360*Math.PI/180;
cube.x = Math.sin( angle )*ORBITAL_RADIUS*i/10;
cube.y = Math.cos( angle )*ORBITAL_RADIUS*i/10;
cubes.push( cube );
cube = new Cube( new MaterialsList( { all:material } ), CUBE_SIZE, CUBE_SIZE, CUBE_SIZE, 1, 1, 1 );
wrapHeart.addChild( cube );
angle = ( i/CUBE_MAX/2 )*360*Math.PI/180;
cube.x = -Math.sin( angle )*ORBITAL_RADIUS*i/10;
cube.y = Math.cos( angle )*ORBITAL_RADIUS*i/10;
cubes.push( cube );
}
cube = new Cube( new MaterialsList( { all:material } ), CUBE_SIZE, CUBE_SIZE, CUBE_SIZE, 1, 1, 1 );
wrapHeart.addChild( cube );
angle = ( 1/2 )*360*Math.PI/180;
cube.x = Math.sin( angle )*ORBITAL_RADIUS*i/10;
cube.y = Math.cos( angle )*ORBITAL_RADIUS*i/10;
cubes.push( cube );
// BBS
wrapBBS = new DisplayObject3D();
scene.addChild( wrapBBS );
var materialBBS:Letter3DMaterial = new Letter3DMaterial( 0x000099 );
materialBBS.interactive = true;
materialBBS.doubleSided = true;
var fontBBS:HelveticaBold = new HelveticaBold();
textBBS = new Text3D( "BBS", fontBBS, materialBBS );
textBBS.x = 700;
textBBS.z = 0;
textBBS.scale = 5;
textBBS.lookAt( DisplayObject3D.ZERO );
//textBBS.addEventListener( InteractiveScene3DEvent.OBJECT_CLICK, clickHandlerBBS );
for ( i = 0; i < textBBS.letters.length; i++) {
textBBS.letters[i].addEventListener(
InteractiveScene3DEvent.OBJECT_CLICK, clickHandlerBBS
);
}
wrapBBS.addChild( textBBS );
// Source
wrapSrc = new DisplayObject3D();
scene.addChild( wrapSrc );
var materialSrc:Letter3DMaterial = new Letter3DMaterial( 0x009900 );
materialSrc.interactive = true;
materialSrc.doubleSided = true;
//var fontSrc:HelveticaBold = new HelveticaBold();
//var fontSrc:HelveticaLight = new HelveticaLight();
var fontSrc:HelveticaRoman = new HelveticaRoman();
textSrc = new Text3D( "Source", fontSrc, materialSrc );
textSrc.x = 800;
textSrc.z = 0;
textSrc.scale = 5;
textSrc.lookAt( DisplayObject3D.ZERO );
//textSrc.addEventListener( InteractiveScene3DEvent.OBJECT_CLICK, clickHandlerSrc );
for ( i = 0; i < textSrc.letters.length; i++) {
textSrc.letters[i].addEventListener(
InteractiveScene3DEvent.OBJECT_CLICK, clickHandlerSrc
);
}
wrapSrc.addChild( textSrc );
// start
startRendering();
addEventListener( Event.ENTER_FRAME, loop );
//addEventListener( MouseEvent.CLICK, clickHandler );
}
private function loop(e:Event):void {
var rot:Number = (mouseX / stage.stageWidth ) * 720;
//camera.x = 1000 * Math.sin( rot * Math.PI / 180 );
//camera.z = 1000 * Math.cos( rot * Math.PI / 180 );
//camera.y = 2000 * ( mouseY / stage.stageHeight );
wrap.rotationY += 0.5;
obj.rotationY += 1;
obj.rotationX += 0.3;
obj.rotationZ += 0.07;
wrapHeart.rotationX += 0.03;
wrapHeart.rotationY += 0.2;
wrapBBS.rotationY += 0.4;
wrapSrc.rotationY += 0.3;
for ( var i:int = 0; i < cubes.length; i++ ) {
cubes[ i ].rotationX += 0.3;
cubes[ i ].rotationZ += 1;
}
}
//private function clickHandler( e:MouseEvent ):void {
private function clickHandler( e:InteractiveScene3DEvent ):void {
navigateToURL( new URLRequest( "in9902.htm" ) );
//navigateToURL( new URLRequest( "http://0bbs.jp/atassyu/" ) );
}
private function clickHandlerBBS( e:InteractiveScene3DEvent ):void {
navigateToURL( new URLRequest( "http://0bbs.jp/atassyu/" ) );
}
private function clickHandlerSrc( e:InteractiveScene3DEvent ):void {
navigateToURL( new URLRequest( "flash/NewProject5.htm" ) );
}
}
}
// end.