メイン

Papervison3D アーカイブ

2009年2月11日

[Papervision3D Public Beta 2.0 - Great White] cube.geometry.vertices

Papervision3D Public Beta 2.0 - Great WhiteにおいてCubeの引数を試してみる

++++++++++++++++++++++++++++++++++++++++++++++++
Cubeの引数に関して調べてみる
++++++++++++++++++++++++++++++++++++++++++++++++
cubeのAPIにリファレンスによると

Cube(
materials:MaterialsList,
width:Number = 500,
depth:Number = 500,
height:Number = 500,
segmentsS:int = 1,
segmentsT:int = 1,
segmentsH:int = 1,
insideFaces:int = 0,
excludeFaces:int = 0)

となっている。

segmentsS:int = 1,
segmentsT:int = 1,
segmentsH:int = 1,
がよくわからないので


サンプルのFLASHを作成して
実際に頂点の値を取り出してみました。

cube.geometry.vertices.lengthのメソッドで実際の頂点の数が取り出せます。

それぞれの座標は
cube.geometry.vertices[position_num].x;
cube.geometry.vertices[position_num].y;
cube.geometry.vertices[position_num].z;
で取り出せます。

応用としては、
[ActionScript] PaperVision3D Tweenerの応用にあるように、実際には表示しないで立体の座標をとりだし
移動先の座標を割り出すなどの使い方もあるようです。

++++++++++++++++++++++++++++++++++++++++++++++++
ソースはこちら
++++++++++++++++++++++++++++++++++++++++++++++++
package {
import flash.display.*;
import flash.events.*;

import org.papervision3d.view.*;
import org.papervision3d.materials.*;
import org.papervision3d.objects.*;
import org.papervision3d.objects.primitives.*;

import org.papervision3d.materials.utils.MaterialsList;
import org.papervision3d.cameras.*;
import org.papervision3d.materials.special.CompositeMaterial;

import caurina.transitions.Tweener;
import caurina.transitions.properties.*;

import flash.text.TextField;

public class Main extends BasicView {
private var sphere:Sphere;
private var cube:Cube;
private var bitmapFileMaterial:BitmapFileMaterial;
private var position_num:Number = 0;

public function Main() {
//super(1440, 720, true, true, CameraType.FREE);
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.quality = StageQuality.LOW;
init();
}

Public function init():void {

// material
var colorMaterial:ColorMaterial = new ColorMaterial( 0x666666, 0.3 );
var wireframeMaterial:WireframeMaterial = new WireframeMaterial( 0x333333, 1 );
var compositeMaterial:CompositeMaterial = new CompositeMaterial();
compositeMaterial.addMaterial(colorMaterial);
compositeMaterial.addMaterial(wireframeMaterial);
compositeMaterial.doubleSided = true;

// cube
cube = new Cube(new MaterialsList({all:compositeMaterial}), 200, 200, 200, 5, 5, 5);
scene.addChild(cube);

// sphere
sphere = new Sphere(new ColorMaterial(0xFF0000,1),5,10,10);
scene.addChild(sphere);

camera.x = 200;
camera.y = 200
camera.z = 300;
camera.focus = 350;
camera.zoom = 1;
addEventListener(Event.ENTER_FRAME, enterFrameHandler);
startRendering();

// sphere を 頂点の座標で動かす
moveSphare();
}

private function moveSphare(){

if( position_num >= cube.geometry.vertices.length ) position_num = 0;
text_1.text = cube.geometry.vertices.length.toString();
text_2.text = position_num.toString();
text_3.text = cube.geometry.vertices[position_num].x;
text_4.text = cube.geometry.vertices[position_num].y;
text_5.text = cube.geometry.vertices[position_num].z;

Tweener.addTween(sphere, {
x:cube.geometry.vertices[position_num].x,
y:cube.geometry.vertices[position_num].y,
z:cube.geometry.vertices[position_num].z,
time:0.2,
delay:0.1,
transition: "easeInOutQuart",
onComplete: moveSphare });

position_num++;

}

private function enterFrameHandler(event:Event):void {
}
}
}

Author: yoshimax Date: 2009年2月11日 01:38 | | Trackback (0)

2009年2月12日

[Papervision3D Public Beta 2.0 - Great White] geometry.vertices

pv3dのgeometry.vertices を試してみるメモ

papervison3d_cube

cube = new Cube(new MaterialsList({all:compositeMaterial}), 200, 200, 200, 5, 5, 5);

[サンプル FLASH]
[ソース as3]


papervison3d_sphere

sphere2 = new Sphere(compositeMaterial, 200, 10, 10);

[サンプル FLASH]
[ソース as3]


papervision3d_cylinder

cylinder = new Cylinder(compositeMaterial, 200, 200, 10, 10);

[サンプル FLASH]
[ソース as3]


Author: yoshimax Date: 2009年2月12日 02:11 | | Trackback (0)

2009年2月26日

[FLASH as3 pv3d] wonderfl を試してみました

actionscriptの勉強の為に
オンラインで FLASHが作成できる wonderFL で[Papervision3D Public Beta 2.0 - Great White] geometry.vertices
のスクリプトを実行してみました。

ほとんどコピペで動きました。


参考サイト
ブラウザだけでできる!wonderflではじめるFlash制作
第1回 wonderflでFlashのHello World!をつくる

Author: yoshimax Date: 2009年2月26日 01:58 | | Trackback (0)

[FLASH as3 pv3d wonderfl] 頂点の座標を移動して変形を行う

papervision 3dでcubeの図形を書き、その頂点の位置を移動してみます。

頂点の座標に0.5を掛けて立方体を変形してみました。

var v = cube.geometry.vertices[position_num];
Tweener.addTween(v, {
x:cube.geometry.vertices[position_num].x * 0.5,
y:cube.geometry.vertices[position_num].y * 0.5 ,
z:cube.geometry.vertices[position_num].z * 0.5 ,
time:0.2,
delay:0.2,
transition: "easeInOutQuart" });
position_num++;

図形が小さくなっているのが確認できました。

Author: yoshimax Date: 2009年2月26日 03:05 | | Trackback (0)

About Papervison3D

ブログ「Epic->yoshimax」のカテゴリ「Papervison3D」に投稿されたすべてのエントリーのアーカイブのページです。過去のものから新しいものへ順番に並んでいます。

前のカテゴリはmysqlです。

次のカテゴリはperlです。

他にも多くのエントリーがあります。メインページアーカイブページも見てください。

Technorati

Technorati search

» ここにリンクしているブログ

2009年12月

    1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31    

アーカイブ