Papervision3Dの練習 DisplayObject3D
BasicViewを使う
DisplayObject3D練習
package {
import org.papervision3d.materials.utils.MaterialsList;
import org.papervision3d.materials.WireframeMaterial;
import org.papervision3d.objects.primitives.Arrow;
import org.papervision3d.objects.primitives.Cone;
import org.papervision3d.objects.primitives.Cube;
import org.papervision3d.objects.primitives.Cylinder;
import org.papervision3d.objects.primitives.PaperPlane;
import org.papervision3d.objects.primitives.Plane;
import org.papervision3d.objects.primitives.Sphere;
import org.papervision3d.view.BasicView;
/**
* BasicViewを使う
* DisplayObject3D練習
*/
public class Pv3dstudy extends BasicView
{
//
public function Pv3dstudy()
{
//マテリアル
var wfm:WireframeMaterial = new WireframeMaterial(0x9933FF);
var wfm_A:WireframeMaterial = new WireframeMaterial(0x99FFCC);
var wfm_B:WireframeMaterial = new WireframeMaterial(0xD9A36F);
var wfm_C:WireframeMaterial = new WireframeMaterial(0x33AAFF);
var wfm_D:WireframeMaterial = new WireframeMaterial(0xA9F36F);
var wfm_E:WireframeMaterial = new WireframeMaterial(0xA9F3FF);
wfm_E.doubleSided = true;
//3Dオブジェクト 立方体------------
var cube:Cube = new Cube(new MaterialsList({all:wfm,top:wfm_A,right:wfm_B,back:wfm_C}), 200, 200 , 200, 4, 4, 4);
scene.addChild(cube);
//傾ける localRotation
cube.localRotationX = 30;
cube.localRotationZ = 30;
cube.x = 100;
//3Dオブジェクト 矢印------------
var arrow:Arrow = new Arrow(wfm_D);
scene.addChild(arrow);
arrow.scale = 0.8;
arrow.x = 150;
arrow.y = 200;
//傾ける pitch、yaw、roll
arrow.pitch(20);//X
arrow.yaw(60);//Y
arrow.roll(30);//Z
//3Dオブジェクト 三角錐------------
var cone:Cone = new Cone(wfm_B,80,200,15);
scene.addChild(cone);
cone.x = -200;
cone.y = 100;
cone.z = -200;
//傾ける rotation
cone.rotationX = 20;
cone.rotationZ = 30;
//3Dオブジェクト 円柱------------
var cylinder:Cylinder = new Cylinder(wfm_A, 50, 200, 10, 10);
scene.addChild(cylinder);
cylinder.x = 150;
cylinder.y = -250;
cylinder.z = -100;
//傾ける localRotation
cylinder.localRotationX = 40;
cylinder.localRotationZ = 30;
//紙飛行機--------------------
var pplane:PaperPlane = new PaperPlane(wfm_E,2);
scene.addChild(pplane);
pplane.x = -200;
pplane.y = -200;
//傾ける localRotation
pplane.localRotationX = 20;
pplane.localRotationY = -20;
pplane.localRotationZ = -20;
//平面--------------------
var plane:Plane = new Plane(wfm_E, 200, 200, 4, 4);
scene.addChild(plane);
plane.x = -200;
plane.y = 300;
//傾ける rotation
plane.rotationX = 40;
plane.rotationY = 30;
plane.rotationY = 10;
//球体-----------------------
var sphere:Sphere = new Sphere(wfm_B, 120, 12, 6);
scene.addChild(sphere);
sphere.x = 350;
sphere.y = -160;
sphere.z = 100;
/* 左ねじの法則で回転
* rotationXYZ 軸:よくわからない。。。(自転)
* pitch、yaw、roll 軸:オブジェクトのwidth,height,depth方向(自転)
*
* 右ねじの法則で回転
* localRotationXYZ 軸:オブジェクトのwidth,height,depth方向(自転)
*
* ぽいです
* rotationXYZとpitch、yaw、rollは正負逆?
*
* 行列とかベクトルとか勉強しなきゃ理解しづらそう
* */
//レンダリング実行
startRendering();
}
}
}