2011年10月7日 星期五

away3d how to move 3D object along a path - part2

preFab 還提供兩種工具 Path Extruder and Path Animator
Path Extruder 可以在 Path 上貼上材質(ie:草皮/柏油/水泥...etc.)
可以用 Geometry -> Path -> Path Extruder
首先點出你要的物件

setting:
select path
subdivision -> 4
closepath
allgntopath
coversegment
mapfit
選材質
build

Path Animator 可以用來預覽效果
Geometry -> Path Animator

seletc path
use camera
offset y:100
allgn to path
preview(camera 沿著 path 移動)

use Object3d
object(your car)
offset y:100
allgn to path
preview(3d object 沿著 path 移動)

away3d how to move 3D object along a path - part1

away3d how to move 3D object along a path
away3d 裡有支援 path animator,可以沿著路徑移動 3D 物件,
以往必需先自己建立路徑,再丟給 PathAnimator 處理

pseudocode:
var aPath:Array = [
new Vector3D(-1000, -1000, -2000),
new Vector3D(-1000, 0, 0),
new Vector3D(1000, 0, 0),
new Vector3D(1000, 1000, -2000),
];
var p:Path = new Path(aPath);
pa = new PathAnimator(path, arrow, o);

簡單的路徑可以自己建立,但是複雜的路徑
這樣搞大概永遠都下不了班,
為了讓大家能夠準時下班,這裡介紹一個好用的工具

2011年10月4日 星期二

away3d load obj/md2/3ds/mqo model

away3d load obj/md2/3ds/mqo model
away3d 可以載入多種 3D 格式,
有興趣可以去翻翻 away3d.loaders。

load obj
loader = Obj.load("resource/Static.obj")

load 3ds
loader = Max3DS.load("resource/monster.3DS", { scaling:5.0 });

load mqo
loader = Metasequoia.load("resource/mion/mion.mqo");

load md2(following md2 texture path)
loader = Md2.load("resource/ogre.md2", { scaling:0.05 } );

objcontainer = new ObjectContainer3D(loader);
scene.addChild(objcontainer);

away3d cube/skybox material

away3d cube/skybox material

cube 六個面貼上相同的材質
cube = new Cube( { material:"blue#white", x: -100, width:50, height:50, depth:50 } );
或者是
cube = new Cube();
cube.material = material;
cube.width = 200;
cube.height = 200;
cube.depth = 200;

cube 六個面貼上不同的材質
cube = new Cube();
cubeMaterial = new CubeMaterialsData();
cubeMaterial.front = new ColorMaterial("random");
cubeMaterial.back = material2;
cubeMaterial.bottom = new ColorMaterial("random");
cubeMaterial.top = new ColorMaterial("random");
cubeMaterial.left = material1;
cubeMaterial.right = new ColorMaterial("random");
cube.cubeMaterials = cubeMaterial;

away3d camera note

away3d camera note
camera 相關原理可以先參考這兩篇
http://www.flashmagazine.com/Tutorials/detail/away3d_basics_the_cameras/
http://blog.tartiflop.com/2008/08/understanding-zoom-focus-and-field-of-view-in-papervision3d/
away3d 有四種 camera,分別是
camera3D:default camera
TargetCamera3D:automatically look at a specified target object
SpringCam:1st and 3rd person camera
HoverCamera3D:hover round a specified target object

本文介紹(最常用) HoverCamera3D,
利用改變 camera.panAngle 及 camera.tileAngle
來產生旋轉及放大縮小的 3D 效果。

away3d video material demo

很久沒碰 away3d,最近因為專案需要,重新看了一下,
這才發現 away3d 做了不少更動,
本篇是以 away3d 3.6 進行 demo
以 videoMaterial 當材質
建立一個可轉動的 cube。

phpfog note

想要玩 php 要自己架 server 弄有的沒的,
現在不用這麼麻煩了,試試 phpfog

基本上操作界面都很直覺,就不多說了,
設定好 SSH key
就可以用 git control source code

on windows using git bash
git clone git@git01.phpfog.com:XXX.phpfogapp.com
git status
git add .
git commit -m "init import"
git push

// debug
error_reporting(E_ALL);
ini_set('display_errors', '1');

另外付費才能修改 include_path 這點倒是比較麻煩。

google+ PHP API

這篇算是上一篇的延續,
google+ 有提供官方 php api

下載後修改 index.php

$client->setApplicationName("Google+ Application Name");
$client->setClientId('your id');
$client->setClientSecret('your secret');
$client->setRedirectUri('https://your.url');
$client->setDeveloperKey('your key'); // Simple API Access

即可取得 access token,差別在於
這邊取得 token 的方式為 server-side flow
response_type=code

之前的方式為 client-side flow
response_type=token