- 2009-11-20 (金) 21:00
- Papervision3D
ClockMakerさんのブログを見て、3Dの表現もどんどんやっていくぞーっということで,参考にさせていただきながら、Papervision3Dで地球を作ってみました。
ソース
=====================================
// PV3Dライブラリをインポート
import org.papervision3d.view.*;
import org.papervision3d.materials.*;
import org.papervision3d.objects.primitives.*;
import org.papervision3d.objects.special.*;
import org.papervision3d.materials.special.*;
// 3Dの初期設定
var world:BasicView = new BasicView();
world.startRendering();
addChild(world);
// マテリアルを作成
// ビットマップアセットマテリアルは引数にライブラリの画像を指定
var material:BitmapAssetMaterial = new BitmapAssetMaterial(‘earthmap1′);
// 球面(Sphere)を作成します
// Sphereの引数の1番目にマテリアルを指定
// 2~4番目の引数は球面の半径、横のポリゴン分割数、縦のポリゴン分割数
var sphere:Sphere = new Sphere(material, 250, 15, 15);
// 3D空間に球面を追加
world.scene.addChild(sphere);
// 球面を回転
addEventListener(Event.ENTER_FRAME, function(e){
sphere.rotationY += 1;
sphere.rotationX += 1;
});
// パーティクルを生成
var particleMat:ParticleMaterial = new ParticleMaterial(0xffffff, 1);
var particles:ParticleField = new ParticleField(particleMat, 500, 4, 2000, 2000, 2000);
world.scene.addChild(particles);
// アニメーション
var rot:Number = 0; // 角度
addEventListener(Event.ENTER_FRAME, function(e){
rot += 0.5; // 毎フレーム角度を0.5ずつ足していく
// 角度に応じてカメラの位置を設定
world.camera.x = 1000 * Math.sin(rot * Math.PI / 180);
world.camera.z = 1000 * Math.cos(rot * Math.PI / 180);
});
======================================
好きなバスケのボールも回してみようとテクスチャを作ってみたのですが、線がガタガタになったり部分的に細くなったりで、全然イケてないボールになってしまったので、公開はやめときます。
三角形とか四角形だとテクスチャも幅広く使用できそうだけど、球体になると素材自体をよく考えて作らないと良いものは出来ないなと実感しました。デザインスキルとスクリプトの理解と使い道、しっかり考えて勉強していこうと思います。
- Newer: IE5.5 IE6で透過PNGを表示する | IE PNG Fix 2.0
- Older: モバイルギャラリーサイト
Comments:0
Trackbacks:0
- Trackback URL for this entry
- http://www.clutch-shot.com/blog/wp-trackback.php?p=234
- Listed below are links to weblogs that reference
- Papervision3D from Clutch-shot.com