Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 10-16-2005, 06:20 PM   #1
Xeef
Off-Line
 
Xeef's Avatar
 
Join Date: Aug 2004
Location: Ibiza/Spain language :Hungarian/German/ abit English
Posts: 6,539
Default Matrix

have a couple of cascaded MC's each have diferent Matrixtransformations on them

let's say for now Master & Master.Slave

now i rotate the Master by 45º

so the Master & the Slave is rotated (this shoud by so)

now i wana Scale the Slave
and here coms the problem !
it's scales BUT in the coordinatesystem of the Master !
and tath shoud NOT by !!!

how can i calculate this ?????

see code for more :

Code:
_root.createEmptyMovieClip("Master", 0);
TM = new flash.geom.Transform(Master);
_bmp1 = new flash.display.BitmapData(150, 150, false, 0x00FF0000);
Master.attachBitmap(_bmp1, 0);
Master.createEmptyMovieClip("Slave", 1);
TS = new flash.geom.Transform(Master.Slave);
_bmp2 = new flash.display.BitmapData(50, 50, false, 0x000000FF);
Master.Slave.attachBitmap(_bmp2, 1);
//
M = new flash.geom.Matrix();
M.translate(100, 50);
TM.matrix = M;
//Rotate Master
M.identity();
M.rotate(45/180*Math.PI);
Tmp = TM.matrix.clone();
M.concat(Tmp);
TM.matrix = M;
//Scale Slave
M.identity();
M.scale(2, 1);
Tmp = TS.matrix.clone();
M.concat(Tmp);
TS.matrix = M;
////////////////////////////
//
//
//This is how it shoud look :
//
_root.createEmptyMovieClip("Master1", 1);
TM1 = new flash.geom.Transform(Master1);
_bmp1 = new flash.display.BitmapData(150, 150, false, 0x00FF0000);
Master1.attachBitmap(_bmp1, 0);
_root.createEmptyMovieClip("Slave1", 2);
TS1 = new flash.geom.Transform(Slave1);
_bmp2 = new flash.display.BitmapData(50, 50, false, 0x000000FF);
Slave1.attachBitmap(_bmp2, 1);
//
M = new flash.geom.Matrix();
M.translate(350, 50);
TM1.matrix = M;
TS1.matrix = M;
//
M.identity();
M.rotate(45/180*Math.PI);
Tmp = TM1.matrix.clone();
M.concat(Tmp);
TM1.matrix = M;
M.identity();
M.rotate(45/180*Math.PI);
Tmp = TS1.matrix.clone();
M.concat(Tmp);
TS1.matrix = M;
//
M.identity();
Orgmatrix = TS1.matrix.clone();
M.a = 2;
M.d = 1;
//
M.tx = Orgmatrix.tx;
M.ty = Orgmatrix.ty;
//
Orgmatrix.tx = 0;
Orgmatrix.ty = 0;
Orgmatrix.concat(M);
TS1.matrix = Orgmatrix;
__________________

test your self -->http://www.actionscript.org/forums/s...86&postcount=8
Xeef is offline   Reply With Quote
Old 10-16-2005, 06:40 PM   #2
senocular
six eyes
 
senocular's Avatar
 
Join Date: Jan 2003
Location: San Francisco, CA (USA)
Posts: 7,875
Send a message via ICQ to senocular Send a message via AIM to senocular Send a message via MSN to senocular Send a message via Yahoo to senocular
Default

so what do you want to happen? You do not want it to scale in the coordinate space of the master? In the example, its not. Im confused as to what you're after
__________________
(6)
senocular is offline   Reply With Quote
Old 10-16-2005, 07:03 PM   #3
Xeef
Off-Line
 
Xeef's Avatar
 
Join Date: Aug 2004
Location: Ibiza/Spain language :Hungarian/German/ abit English
Posts: 6,539
Default

i wana Scale the Slave what's inside the Master in the Coordinate space of _root

the 1. part of the code whit the Master.Slave the scale is done in the Master Space
BUT it shoud by done in the _root Space
as the result of the 2. part looks (where BOTH are on _root this is just to demonstrate what result i wana get)
__________________

test your self -->http://www.actionscript.org/forums/s...86&postcount=8
Xeef is offline   Reply With Quote
Old 10-16-2005, 11:31 PM   #4
Xeef
Off-Line
 
Xeef's Avatar
 
Join Date: Aug 2004
Location: Ibiza/Spain language :Hungarian/German/ abit English
Posts: 6,539
Default

Hmmmm

this Matrix stoff is a realy hard stoff !


Code:
var cRad = Math.PI/180;
//
_root.createEmptyMovieClip("Master", 0);
Master.Matrix = new flash.geom.Transform(Master);
Master._bmp = new flash.display.BitmapData(150, 150, false, 0x00FF0000);
Master.attachBitmap(Master._bmp, 0);
Master.createEmptyMovieClip("Slave", 1);
Master.Slave.Matrix = new flash.geom.Transform(Master.Slave);
Master.Slave._bmp = new flash.display.BitmapData(50, 50, false, 0x000000FF);
Master.Slave.attachBitmap(Master.Slave._bmp, 1);
//
TempMatrix = new flash.geom.Matrix();
TempMatrix.rotate(45*cRad);
TempMatrix.translate(100, 50);
Master.Matrix.matrix = TempMatrix;
//
TempMatrix = new flash.geom.Matrix();
TempMatrix.scale(1, 2);
TempMatrix.rotate(-45*cRad);
TempMatrix.translate(80, 60);
Master.Slave.Matrix.matrix = TempMatrix;
//
//
//
//
//
//
//
Matrix_Apply = new flash.geom.Matrix();
Matrix_Apply.scale(1.5, 1);
Master.Slave.Matrix.matrix = MatrixWrap(Master.Matrix.matrix, Master.Slave.Matrix.matrix, Matrix_Apply);
//
function MatrixWrap(Matrix_Parent, Matrix_Self, Matrix_Apply) {
	var Matrix_Parent = Matrix_Parent.clone();
	var Matrix_Self = Matrix_Self.clone();
	var Matrix_Apply = Matrix_Apply.clone();
	var Matrix_Return = new flash.geom.Matrix();
	//
	
	var X = Matrix_Self.tx;
	Matrix_Self.tx = Matrix_Parent.tx =0;
	var Y = Matrix_Self.ty;
	Matrix_Self.ty = Matrix_Parent.ty = 0;
	//
	Matrix_Return.concat(Matrix_Self);
	Matrix_Return.concat(Matrix_Parent);
	Matrix_Return.concat(Matrix_Apply);
	Matrix_Parent.invert();
	Matrix_Parent.tx += X;
	Matrix_Parent.ty += Y;
	Matrix_Return.concat(Matrix_Parent);
	return Matrix_Return;
}
seams to work
__________________

test your self -->http://www.actionscript.org/forums/s...86&postcount=8
Xeef is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 06:25 AM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.