gnash-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gnash-dev] Bug with Trasnformation Matrixes for embeded objects


From: Dima Codreanu
Subject: [Gnash-dev] Bug with Trasnformation Matrixes for embeded objects
Date: Mon, 13 Mar 2006 19:02:53 -0800 (PST)

Hi everybody.
I have been working on porting gnash to windows for the last 2 weeks (I work only on weekends actually). I have succeded at last and everything is working fine with the exception of networking (I dont know any good ports of networking for win32), sound (havent been able to find a port for ogg vorbis) and I have an impresion that xml too (it doesnt seem to get compiled at all thanks to some #ifdefs, but I dont have libxml on win32 anyway). Rob has been doing some work in this direction as I recall, except that I am doing a port to vc++, not cygwin. I have run into some missing functions as well and implemented them. I will adress the portability issues little later, after a run a diff test with what I had before to know exactly what I changed in the sources to make it compile and run.
I have run into another problem as I was testing one of my flash files I did a few years ago. It seems that the geometry is wrong for layered stuff. I had a movie clip inside the main scene. The movie clip was 30 pixels wide. The movie clip itself contains an image 100 pixels wide. so, the image is shrinked in the original scene in pixel measurements. I have a script that dublicates the movie clip and places them in a maze form (imagine a chess board). So what I do is something like
bn._x = i * bn._width...
and it masses things up completely, and it works perfectuly in Flash.
I have debugged the code and it seems there is a bug with transformation matrixes.
The width of the movie clip is calculated as the global matrix multiplied by local matrix, i.e. the sprite bounding matrix.
The sprite bouding matrix is in turn the character's matrix.
This seems good, but the characters matrix is the global matrix multiplied by something...
The problem is, if the character returns the width in the outer measurements (it returned 30 pixels), then the srite returns the outer measurements (returned 30 pixes as well, not 100 as it is really in the flash file). So the sprite reports the width as it whould have been seen from the scene. it is shrinked by a factor of 3.3 (multiplied by 0.3). So why does the movie clip multiply the width of the objects inside it with the global matrix the second time??? this means that 30 pixels got multiplied again with 0.3 and returned 10 pixels.The result of this was that the script placed the dublicates in the wrong places.
I have trie the following to solve the problem:
from generic_character::
virtual float get_width()
{
matrix m = get_world_matrix();
float w = m_def->get_width_local() * m.m_[0][0];
return w;
}
I have changed  
float w = m_def->get_width_local() * m.m_[0][0]; to
float w = m_def->get_width_local() /* * m.m_[0][0]*/;
this will make the characters report measurements in local coordinates and the parents whould deal with converting them to the right ones.
I have also tried to leave the characters as they are, but changed the code in movie_clip not to multiply the measurement of the children with its matrix.
Both way worked.
But what does the swf specification say about this?
When an object is embeded within a parent, accesing the width should return the real width it appears on screen? or it depends where it is called from?
For example, I whould have liked it if the scripts implemented inside a movie clip whould work with local coordinates, and the scripts implemented in the main scene, to work with scene coordinates. But I am not sure it applies.
Does anyone know anything about this issue?
It seems more natural to me to let every object report its local width, height, _x, _y, etc, and let the parents do the trasformation. Or it could be the case that every object retuns the global coordinates (just as they would have been seen on the screen) but the parents should upply the inverse tranformation to return them to the right level of coordinate system. If it is done like this, then accesing a child from within a movie clip will return in that movie clips coordinates. If the child in question is in turn a movie clip with lots of chidren, then it will prove very useful. For example, I can write a script that animates something inside a movie clip. This movie clip will in turn be animated by a outer script. Now, I dont want the script inisde the movie clip even know that the movie clip is being animated, so it must access the _x and _y coordinate of its children as if the movie clip was not animated.
Does it make any sense what I have just said?
I can send you the swf and the flash file if anyone wants to have a look, but it is written in Flash 4 and uses old syntax. The scripts are not very big however.
 
By the way? has the Timer Function been implemented? I have some flash files that uses the heartbeat function of a timer, and they simple dont call that function (Again, it works with Flash player). It might be something related to windows incomplete portability, but just wanted to know if it works on Linux? I have no Linux on my machine, so I did everything in visual C++ (7.1), so it might be stuff that didn't port nicely.
PS. by the way, how can I get access to modify the sources direclty on the server and what should I do to get access on the server? I am knew both to Linux as well as cvs and the whole idea of open source projects. How can I get started?
Thanks...

strk <address@hidden> wrote:
On Mon, Mar 13, 2006 at 01:38:14AM +0800, Michael Carlson wrote:
> Ah, this is really helpful, and although I need to digest some of the
> concepts you talked about a little further, I think that is the right
> idea for case 2 of the 2 original cases I gave. As far case 1 - say
> calling, for example, Date.UTC() - Do you have a solution for this?
>
> The way I understand it, when gnash is asked to find "Date.UTC", it's
> going to get the Date object (which currently is an as_value of type
> function - the constructor for the Date object, which is defined in
> date_new in Date.cpp), and try to get a member of this object called
> "UTC" (which it won't be able to find, because the constructor is an
> as_value which is not derived from as_object and has no child
> members).

The 'Date' object should be threated as an as_object.
If 'Date' is currently a c_function (most likely) it should
be changed to an function_as_object instead.
This will expose as_object interface (function_as_object
derives from it).
One of the interface is get_member, this will be given "UTC".
UTC is seeked for (by as_object::get_member) in either
the local members list or in the inherited members (Date.__proto__
which is as_object::m_prototype).

If you want

var a = new Date();
a.UTC();

To work, then 'UTC' should be 'exported', which is:

Date.prototype.UTC != undefined;

But you also want

Date.UTC();

To be available.
These will likely be two entries in two different hashes:

s_global['Date'].m_properties['UTC'] // the 'exported' one
s_global['Date']['UTC']; // the 'local' one

Both version will likely point to the same as_value, being
the c_function, so that the following should evaulate to true:

Date.prototype.UTC == Date.UTC


--strk;




>
> - Mike
>
> On 3/12/06, strk wrote:
> > Hello Mike, nice to hear you're working on this.
> > I'm not sure I understand your questions, anyway they look
> > like something I worked on already for Function.cpp.
> >
> > Basically we need to model ActionScript inheritance as
> > a whole.
> >
> > I started with assumption from AS1, which are as follows:
> >
> > 1. Every function has a 'prototype' member which
> > contains 'exported' (virtual, I'd say) members.
> >
> > 2. Every object has a __proto__ member pointing
> > to it's constructor's 'prototype' member.
> >
> > 3. The 'prototype' member of a function has a 'constructor'
> > element pointing to the function itself.
> >
> > Following this, I made as_object::get_member always look,
> > recuring, into the __proto__ element when a member is not
> > found locally.
> >
> > To make a simple example, consider the Object class.
> > In Gnash this is currently NOT a class, but somtething hard-coded.
> > It it has to be a class it would ba an as_function_object
> > member of the s_global (Actionscript's _global) object and
> > named 'Object'.
> >
> > When following actionscript code is found:
> >
> > var a = new Object();
> >
> > The variable 'a' would be constructed by the s_global['Object']
> > as_function_object, which would be Object class' constructor.
> >
> > a['__proto__'] would then point to s_global['Object']['prototype']
> >
> > When calling a.toString() ( current handling being hard-coded)
> > Gnash should look at a['toString'], when not finding it (this
> > is already implented in as_object::get_member) it will look
> > into a['__proto__']['toString'] and will find it.
> > The found member would really be Object.toString().
> >
> > The code I used for Function is not surely the best one, but
> > works fine as far as I tested it.
> >
> > The point is to be able to do, in actionscript, something like
> > this:
> >
> > var d = new Date();
> > Date.prototype.sayHello = function() { trace("Hello"); }
> > d.sayHello();
> >
> > This is *known* to be expected to work, and it is commonly used
> > with the MovieClip class, adding functions to the drawing API.
> >
> > I'm interested in discussing this further, and please let
> > me know if I completely missed your point :)
> >
> > --strk;
> >
> > On Sun, Mar 12, 2006 at 02:50:33AM +0800, Michael Carlson wrote:
> > > Hey Everyone,
> > >
> > > I'm going through and implementing some of the basic actionscript
> > > classes, and ran into a problem - I don't know how to create static
> > > members with the current code.
> > > The first idea to come to my head was
> > > to add static members to the constructor object itself (to cover case
> > > 1 below), as well as adding the member to each instance of the class
> > > when created (in the normal non-static way) using the constructor (to
> > > cover case 2 below).
> > >
> > > For reference, examples of the two basic cases (that I can think of)
> > > using Date's UTC function (which is static):
> > >
> > > case 1) Date.UTC(params);
> > > case 2) var x = new Date(); x.UTC(params);
> > >
> > > However, if the static member is a variable which is non-constant
> > > (which fortunately none I've encountered so far are - maybe none are -
> > > but can the user define a variable like this that is?), this would
> > > cause problems as each instance of the class would have its own
> > > separate version of the variable. Furthermore, at the moment the
> > > constructors are all created as an as_value (of type function), which
> > > seems to be unable to have arbitrarily named "members" like objects do
> > > anyways.
> > >
> > > Should we add a new as_value type of "constructor", which has the
> > > ability to hold named members like normal objects? Or should we make
> > > the constructor and the uninstantiated object definition separate
> > > entities in code, in which the static variables would exist in the
> > > uninstantiated object definition (this seems to solve all the problems
> > > I thought of, but it might be overkill and overcomplicate the code)?
> > >
> > > What is the proper solution here?
> > >
> > > - Mike
> > >
> > >
> > > _______________________________________________
> > > Gnash-dev mailing list
> > > address@hidden
> > > http://lists.gnu.org/mailman/listinfo/gnash-dev
> >
> > --
> > ----------------------------------------------------------------------
> > State-collected Geographic Data is public property !
> > Reject the INSPIRE directive.
> > Sign the petition: http://petition.publicgeodata.org
> >
> >
> > _______________________________________________
> > Gnash-dev mailing list
> > address@hidden
> > http://lists.gnu.org/mailman/listinfo/gnash-dev
> >
>
>
> _______________________________________________
> Gnash-dev mailing list
> address@hidden
> http://lists.gnu.org/mailman/listinfo/gnash-dev

--
----------------------------------------------------------------------
State-collected Geographic Data is public property !
Reject the INSPIRE directive.
Sign the petition: http://petition.publicgeodata.org


_______________________________________________
Gnash-dev mailing list
address@hidden
http://lists.gnu.org/mailman/listinfo/gnash-dev


Yahoo! Travel
Find great deals to the top 10 hottest destinations!
reply via email to

[Prev in Thread] Current Thread [Next in Thread]