Actionscript 3.0 :: Matrix3d Local To Global Coordinates For Rotation?
Feb 4, 2010
I made a cube with as3. I wanted it to rotate in the Y Axis according to the horizontal mouse movement. It works nice when this is all I want. But if I try to also make it rotate on the X axis with the vertical mouse movement, things get screwy.
This happens because the transformations are added in the global coordinates, not the local ones. So, for Example, if I wanted the cube to rotate 30 degrees along its Y axis, I have to find a way to translate that into the global coordinates, and then apply that to the matrix3D of each face. I need a local to global translator.
[Code]...
View 1 Replies
Similar Posts:
Dec 19, 2011
I was trying to convert global coordinates to local coordinates of a UIComplenent in my flex project using below code using below code
var gp:Point = new Point(e.stageX,e.stageY); //global point
var lp:Point = uic.globalToLocal(gp); //local point
uic is UIComponent in which I have subclass of Sprite for drawing something I have set the sprite's mouseEnabled and mouseChildren to false to not interrupt the mouse event. above code is within uic's mousemove event where I was tracing the gp and lp gp was giving correct value and suprisingly lp was giving negetive values. when I move the move to the top left corner of uic i expect lp to be 0,0 but it is giving the -width of of uic. I broke my head for hours and ended up finding an alternate by using offsets. Infact my original code was much simpler like this which was same issue
var lp:Point = new Point(e.localX,e.localY);
I am not sure what exactly is causing this problem. the workaround had lot of issues and it creating a mess in my rest of the algorithms.Just now I found even more interesting thing (which is actually weird). for some reason I went and create a new lp2
var lp2:Point = new Point(e.localX,e.localY);
now surprisingly it was giving correct values as expected and I went back and changed the code as
var gp:Point = new Point(e.stageX,e.stageY); //global point
var lp:Point = uic.globalToLocal(gp); //local point
var lp2:Point = new Point(e.localX,e.localY);
var lp2:Point = uic.globalToLocal(gp);
now it is expected to have all the lp, lp2 and lp3 variables to be same but weiredly lp two is giving wrong value and lp2 and lp3 were giving correct. I am suspecting using the variable lp has something to do. I am not sure about that but above proves it so right now I am using lp2.
View 1 Replies
Nov 4, 2009
'm trying to make a "room" in flash in which you can "move" around in.I set up the room with flash cs4 3d functionality.
SWF:
http://www.swfcabin.com/open/1257388415
(use arrows)
[code]....
View 1 Replies
Dec 14, 2009
I am trying to rotate a Sprite in three dimensions around its centerpoint, and I am struggling to understand some of the behavior of matrix3D.
Ive overridden the set rotationX, rotationY, and rotationZ methods of the Sprite as follows:
override public function set rotationX (_rotationX:Number) : void {
this.transform.matrix3D.prependTranslation(this.width/2.0, this.height/2.0, 0);
this.transform.matrix3D.prependRotation(-this.rotationX, Vector3D.X_AXIS);
[Code].....
I am using prependTranslation to correct the centerpoint of the rotation, and the first prependRotation to cancel out any previously-applied rotation.
Testing it out, rotationX works exactly as expected, and the Sprite rotates around its horizontal axis.
rotationY and rotationZ also appear to work fine. However, there is one problem: whenever rotationY or rotationZ are set, all of the other rotation values change as well. This is not a problem with rotationX -- if I set rotationX, nothing else changes. But if I set rotationY or rotationZ all the rotation values change, which is a problem for my app (which is trying to save and restore values).
I think I am just lacking some understanding about what is going on with matrix3D. How can I implement this so there is no interdependence between the values?
View 2 Replies
Jun 25, 2009
I'm studying John Lindquist's example from here: [URL] I'm trying to figure out how to add restrict his matrix3d method, so the sphere has limited movement.
Code:
Select all override protected function onRenderTick(event:Event=null):void {
var currentMousePoint:Point = new Point(viewport.containerSprite.mouseX, viewport.containerSprite.mouseY);
if(isMouseDown) {
var difference:Point = currentMousePoint.subtract(previousMousePoint);
[Code] .....
View 2 Replies
Dec 15, 2011
I have a texInput component,which is placed inside containers like following
<s:BorderContainer ...>
<mx:VBox ...>
<mx:HBox ...>
[code].....
View 1 Replies
Jul 24, 2008
I did a search but to no avail. What I'm trying to achieve is to get the global rotation of a nested movie clip instance. Much like localToGlobal, except for rotation, not x,y.The only solution I can think of currently is to add all the parent rotations together with the current rotation.[code]I am hoping there is some simple localToGlobal type function for rotation.
View 7 Replies
Oct 19, 2010
I am trying to determine the global coordinates of the visible rectangle that is currently rendered on the stage.
Specifically, if a canvas has an explicit height and width and is a child of a panel that has a scrollbar, the scrollbar can "hide" a part of the canvas. ContentToGlobal(x,y) provides the global position of the content at the time, but content coordinates can scroll off the boundaries of the parent panel and continue to give x,y coordinates that are not visible.
Is there a way to determine the viewable rectangle that is not hidden by anything?
View 2 Replies
Apr 24, 2009
I have a MovieClip ("mc3" that moves dynamically) inside of a MovieClip ("mc2" that moves dynamically) that is on the stage ("stage" that is static). I need to find the value of mc3's x in relation to the stage? I need to make it into a variable. I am trying to do the math, can't figure it out. Also tried localToGlobal and failed.
View 5 Replies
Oct 27, 2010
I have a small problem with usage localToGlobal and than back to local. I can get global coordinate of my nested mc in question alright. Than i check if this coordinate + value of my mc.width is more than my stage width. I get to this part with no problem. Than if value is bigger (so mc is not on the stage i mean if part is off the stage i change value so it is stage width - mc.width). So i get value in global coordinates that i need. But how do i apply this to my nested clip is my question? For reference here is my code:
[Code]...
View 3 Replies
Feb 25, 2007
Is there a simple way of determining a nested movieclip's global rotation?I have several nested movieclips that need to know what their rotation is to the main stage.
View 1 Replies
Aug 18, 2010
I have a symbol originally created at [-100,-100] coordinate (left top corner). Now I put an instance of this symbol on a stage at [0,0] stage coordinates (by dragging it with a mouse in IDE). Having this instance can I still determine original [-100,-100] position from actionscript somehow? ([code]...
View 4 Replies
Feb 2, 2012
how I can count the B point's coordinates (see attached image... or not as I am a new user...pf!). I know the arrow's rotation - so the angle (let's say it is -120), A's coordinates (0, 0) - A is the middle point of the arrow, and that the distance between A and B is 50 px.
View 1 Replies
Mar 27, 2009
I have a movie clip on my stage and it is named quest. Within quest, there are several frames representing the entire game (it's a text based adventure). Every once in a while, there will be an inventory item in one of those frames that has the ability to be dragged and dropped into the inventory box (which is a seperate movie clip on the main stage).
All of that works fine, however, since the movieclip that can be dragged was defined in the 'quest' movieclip, once the user needs to move on to the next frame in the quest panel, the inventory item disappears from the inventory box.
View 1 Replies
Sep 15, 2011
in my Controller Class:[code]brick it's inside a container and its position in x axis is 200px.When the brick is moving, the x and y value are based on stage x and y mouse.The 0 in the stage should correspond to -200 inside my container.How can i use globalToLocal method?instead write:brick.x = (mouseX - mouseX%theGrid.getGridSize())-200;
View 16 Replies
Sep 7, 2011
I have a problem where I make a variable in one class and change it using the constructor method in another.Is there anyway that I can make that variable available in all methods in this class? Here is the code:
[Code]...
View 3 Replies
May 27, 2010
i'm trying to trace the x and y coordinates from within a sprite. i've added a rectangle to the stage:
var rect:Rectangle = new Rectangle(10, 10, 200, 200);
addChild(rect);
rect.x = rect.y = 100;
adding a Mouse_Move event to the rect, i can trace mouseX and mouseY to receive the coordinates of the stage while moving over the rect, but how do i get the local x and y coordinates? so if i mouse over the very top left of the rect sprite, the mouseX and mouseY return 10 as the global coordinates, but how do i make it return 0 and the local coordinates of the sprite?
i assumed localX and localY was what i was looking for, but this doesn't work:
function mouseOverTraceCoords(evt:MouseEvent):void
{
trace(mouseX, mouseY, evt.localX, evt.localY);
}
View 3 Replies
Oct 19, 2009
I have this movie clip on a stage that I need everything to be center on stage even after resize.the clip structure is rootclip.child.child.the first time I click the button the tween works fine. If you click a second time the clips start start to drift away from center stage. And if I resize the stage everything seem to fall apart. the 203.5 is half the width of the MC that I'm trying to center. So it's total width is 407px.
ActionScript Code:
this.startButton.onRelease = function () {
var introHead_currentPos_x = _root.instructMc._x;[code]....
View 0 Replies
Mar 22, 2011
From Pro Adobe flash can I export an animation's data? like the x and y coordinates and rotation values for individual images in a sequence
View 1 Replies
Aug 28, 2006
i just want to ask if there's a way to avoid the trip to global security panel to access local .swf?
View 3 Replies
Sep 27, 2008
I wonder if a keyframe on an actions layer that has an action in it will work like a keyframe on other layers, meaning it will make all actions on the previous action frame inactive and only the actions on its corresponding action sheet available.If that is the case, is it possible to have at least two action layers to separate global and local actions?
View 9 Replies
Feb 20, 2012
I have a texInput component,which is placed inside containers like following
<s:BorderContainer ...>
<mx:VBox ...>
<mx:HBox ...>
<mx:TextInput ...>
[code]....
Now after initialization i want to get the location of my textInput with respect to Application.I tried with with localToGlobal(PointofLocalCoridnate), then it is not giving the correct location of textInput.
View 8 Replies
Jul 4, 2010
I'm trying to load a local xml file:
xmlLoader.load(new URLRequest("../xml/xmlData.xml"));
But I'm getting this security sandbox violation:
#2148: Only local-with-filesystem and trusted local SWF files may access local resources.
I don't get this error when I embed the XML file directly with the EMBED metadata tag.
View 3 Replies
Jan 2, 2009
I'm assigning raw matrix values through Matrix3D.rawData.When assigning certain matrices it yields the following error:
ArgumentError: Error #2188: Invalid raw matrix. Matrix must be invertible.
However, I believe the matrix data I'm passing represent an invertible matrix!Is this a (known) bug? Or is the matrix not invertible and is my math failing me?
View 15 Replies
Jan 6, 2009
I am trying to experiment with new CS4 and AS3 to create 3D aplications using matrix3D class.i recently encountered a problem in the Code and I am unable to compile it even. URL:[URL]
Error Notification in FLA:
1119: Access of possibly undefined property XAXIS through a reference with static type Class.
[code]....
View 1 Replies
Oct 27, 2009
I have a simple 3D tween that I created to 3D rotate a bitmap logo (in a movieclip) on it's x axis. It works great during testing but I noticed that when I tested it on the website that the pivot point was totally off! I had to use the matrix.prependTranslation() method to alter the pivot point so that the clip would rotate & remain centered. This is totally broken when I run in the browser but works great outside of the browser?
[Code]...
View 1 Replies
Jun 19, 2010
I've created a game in Flash and I'm using Matrix3D and Vector3D. It works perfectly locally, but as soon as I put it on a server, the graphics don't render and I only see a thin line where a sphere should be.
I've done all the imports, but nothing seems to get it working!
View 1 Replies
May 21, 2007
I was reading the 'Isometric Transformations' tutorial by Danko Kozar and I have a few questions. I understand what all the code does, but not how it does it. First of all, how does the following code work:
transforms x,y,z coordinates into Flash x coordinate
xFla = function (x, y, z) {
// cartesian coordinates[code].....
I understand that it converts 3d coordinates to 2d coordinates, but I don't understand how. What numbers whould be punched into x, y, and z to acquire certain desired effects?Also, what's the difference between moveTo and lineTo:
red line
style(1, "0xFF0000", 100);
plot(0, 0, 0);
draw(200, 0, 0);
View 4 Replies
Apr 2, 2010
I have some filters set up, and have assigned some global vars to them, which I then use in my Filters code to display the filters: myText:Filters [globals.data.glow1, globals.data.stroke1, globals.data.shad1] Works perfectly. Now I want to assign a global var to each global filter var to determine if it should be shown or not. So...
[Code]...
View 7 Replies
May 3, 2010
Im making a little app in flash using papervision I want to make a regular movieClip show up in the same place as a papervision object. The coordinates seem like perspective is affecting the number displayed.
View 2 Replies