« ごはんと暴年会2008のお知らせ | トップページ | そうめんのMonitorで先読み的なものをつくる »
3D回転しているものを正面を向かせる
2008/12/05
CS4から3軸回転(rotationX,rotationY,rotationZ)ができるようになってうれしくて毎日ぐるぐるさせてますが、sprite自体は平面なので回転によってはペラペラしてしまいます。
なので常に前を向かせてみました。
最初、回転している親のrotationX,rotationY,rotationZをみて補正しようとしていましたが、どちらを向いているかさっぱりわからなくなってきたのでmatrix3Dを使います。
//自分の位置を保存
var v3:Vector3D=new Vector3D(this.x,this.y,this.z)
//回転している親のmatrixを複製
var mat3D:Matrix3D=pO.transform.matrix3D.clone();
//反転
mat3D.invert();
//位置を補正
mat3D.position=v3
//代入
this.transform.matrix3D=mat3D
2点おまけで注意点。
・Z座標と重なり順は別の話。
重なり順が上のものは、いくらZを大きくしても小さくなる(遠いので)だけで重ね順が下のZ座標が小さいものより後ろにはいきません。
対応策としてこちら。
インポートしたら1行でZ座標でZソートしてくれます。
import com.theflashblog.fp10.*
SimpleZSorter.sortClips(stage, true);
・spriteのキャプチャは見えている状態になる。
これはいい話。bitmapdataにdrawする時にZ座標が違うと見えないとかはありません。
bitmapdataには見えている状態が描かれます。
東スポブログパーツ by BM11
- 3D
- AIR
- AS2
- AS3
- ActiveX
- AfterEffects
- Arduino
- Benchmark
- BitmapData
- CS4
- Command
- Cookie
- Date
- Dictionary
- DisplacementMapFilter
- Dynamic Sound Generation
- Error
- Event
- EventDispatcher
- ExternalInterface
- F-site
- FLARToolKit
- FLV
- FMIS
- FMS
- File
- FileReference
- FireBug
- FireFox
- Fireworks
- Flash Lite
- FlashDevelop
- FlashPlayer10
- FlashVars
- Flex
- FocusEvent
- Font
- FuseKit
- Gainer
- Google Map
- HydroTween
- IE
- JActionScriptors
- JPGEncoder
- JSFL
- JSON
- JavaScript
- MP3
- MP3FileReferenceLoader
- Math
- Matrix3D
- Max/MSP/Jitter
- Mobile
- MovieClip
- NetConnection
- NetStream
- Number
- Object
- ObjectDetection
- ObjectDumper
- PaperVision3D
- Particle
- Progression
- RGB
- RTMFP
- Rectangle
- SQLite
- SSL
- SWFAddress
- SampleDataEvent
- Sound
- SparkProject
- Sprite
- TOYOTA
- TeraClock
- TextBox
- TextField
- TextFormat
- TextSnapshot
- Thread
- ThunderBolt
- Tips
- TweenMax
- Tweener
- Vector3D
- Vitz
- Wonderfl
- Works
- Xray
- alpha
- android
- animation
- api
- as3
- as3corelib
- byteArray
- christmas
- chumby
- class
- clock
- color
- computeSpectrum
- constructor
- continue
- cookpad
- crossdomain
- detection
- duplicateMovieClip
- enabled
- event
- flash時計
- flexbuilder plugin
- flosc
- flv
- fps
- funnel
- getDefinitionByName
- getTimer
- gravsynth
- iPhone
- insertCommand
- iphone
- kayac
- mProjector
- mask
- match
- memo
- mouseEnabled
- mxp
- nativePath
- new
- php
- png
- red
- scale9Grid
- sendAndLoad
- setInterval
- swfObject
- swift3D
- textHeight
- tips
- trace
- tracking
- upload
- vector
- web
- wmode
- wonderfl
- xml
- アニメーション
- イラスト
- ガジェット
- ガベージコレクション
- クラシックトゥイーン
- サンプルコード
- ショートカット
- タイムライン
- デコンパイラ
- デザインパターン
- デバッガ
- データ型
- バグ
- パブリッシュ設定
- フレーム
- ブログパーツ
- プラグイン
- プロパティ
- ボーンツール
- ポップアップブロック
- メモリ
- モーショントゥイーン
- リファクタリング
- リンケージ
- ローディング
- 勉強会
- 携帯
- 時計
- 書籍
- 正規表現
- 爆速
- 緑さん
- 縦書き
- 軽量化








