Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change the rigid body skin to null ( temporary ) trow an exception ( unmanged ) #25

Open
LucaEstiva opened this issue Oct 7, 2013 · 3 comments

Comments

@LucaEstiva
Copy link

Hi Li i have a new problem for you ... :)
Class AWPCollisionObject

Original code:

public function set skin(value:ObjectContainer3D):void
{
//
m_skin = value;
_originScale.setTo( m_skin.scaleX, m_skin.scaleY, m_skin.scaleZ );
}

Modified code:

public function set skin(value:ObjectContainer3D):void
{
//
m_skin = value;
//
if( m_skin != null )
_originScale.setTo( m_skin.scaleX, m_skin.scaleY, m_skin.scaleZ );
}

This is because in Games Maker the extra mesh class object contains all the physics object properties ( and more ). Whe these property are exported, this duplicate all the extra properties ( one, standard for the mesh, and one referenced by the body ) and in my case this cause a wrong result when the mesh are imported ... And because the object are the same before it is saved and after i need to set this properties to null ....

Ok Li ?

@muzerly
Copy link
Member

muzerly commented Oct 7, 2013

ok, you can change this first, I will add this to dev branch.

在 2013年10月7日,下午4:50,Luca Filippini [email protected] 写道:

Hi Li i have a new problem for you ... :)
Class AWPCollisionObject

Original code:

public function set skin(value:ObjectContainer3D):void
{
//
m_skin = value;
originScale.setTo( mskin.scaleX, m_skin.scaleY, m_skin.scaleZ );
}

Modified code:

public function set skin(value:ObjectContainer3D):void
{
//
m_skin = value;
//
if( m_skin != null )
originScale.setTo( mskin.scaleX, m_skin.scaleY, m_skin.scaleZ );
}

This is because in Games Maker the extra mesh class object contains all the physics object properties ( and more ). Whe these property are exported, this duplicate all the extra properties ( one, standard for the mesh, and one referenced by the body ) and in my case this cause a wrong result when the mesh are imported ... And because the object are the same before it is saved and after i need to set this properties to null ....

Ok Li ?


Reply to this email directly or view it on GitHub.

@LucaEstiva
Copy link
Author

I Li, after some attempts whit the class ( object ) serializations and clone with this code ( this code works but i haven't time to test where and when ... )

Class ObjectDuplicator:

package GamesMakerClass.Utils
{

import flash.utils.describeType;
import flash.utils.getDefinitionByName;
import flash.utils.getQualifiedClassName;

//------------------------------------------------------------------------------------------------------------
/**
 * 
 * 
 */
//------------------------------------------------------------------------------------------------------------
public class ObjectDuplicator
{

    //------------------------------------------------------------------------------------------------------------
    /**
     * 
     * 
     */
    //------------------------------------------------------------------------------------------------------------
    public function ObjectDuplicator()
    {
    }

    //------------------------------------------------------------------------------------------------------------
    /**
     * 
     * 
     */
    //------------------------------------------------------------------------------------------------------------
    public static function newSibling( sourceObj:Object ):*
    {

        //
        if( sourceObj )
        {

            //
            var objSibling:* = null;

            //
            try
            {

                //
                var classOfSourceObj:Class = getDefinitionByName( getQualifiedClassName( sourceObj ) ) as Class;
                //
                objSibling = new classOfSourceObj();

            }
            catch( err:Object )
            {

                //
                trace("newSibling error: " + err );

            }

            //
            return objSibling;
        }

        //
        return null;

    }

    //------------------------------------------------------------------------------------------------------------
    /**
     * 
     * 
     */
    //------------------------------------------------------------------------------------------------------------
    public static function clone( source:Object ):Object
    {

        //
        var clone:Object;

        //
        if( source )
        {

            //
            clone = newSibling( source );
            //
            if( clone ) copyData( source, clone );

        }

        //          
        return clone;

    }

    //------------------------------------------------------------------------------------------------------------
    /**
     * 
     * 
     */
    //------------------------------------------------------------------------------------------------------------
    public static function copyData( source:Object, destination:Object ):void
    {

        // Copies data from commonly named properties and getter/setter pairs
        if( ( source ) && ( destination ) )
        {

            //
            try
            {

                //
                var sourceInfo:XML = describeType( source );
                //
                var prop:XML;

                //
                for each( prop in sourceInfo.variable )
                {
                    //
                    if( destination.hasOwnProperty( prop.@name ) ) destination[prop.@name] = source[prop.@name];
                }

                //
                for each( prop in sourceInfo.accessor )
                {
                    //
                    if( prop.@access == "readwrite" )
                    {
                        //
                        if( destination.hasOwnProperty( prop.@name ) ) destination[prop.@name] = source[prop.@name];
                    }
                }

            }
            catch( err:Object )
            {

                //
                trace( err );

            }
        }
    }

}

}

@LucaEstiva
Copy link
Author

After adding the OBJECT type to the away AWD2 parser, and after :) some object cast errors .... ( i need time to study them )

You Decide ....
For now i have used one object ( class ) without or with the constructor ( like C++ struct or class, or the same thing, right ... ) thath describe the physics rigid body and or other properties and after the loader have finished loading the mesh data, ( i have saved the "SHAPE" in the extra properties of the mesh ) i can recreate the body...

Wow Li ... it's hard ;) Sry and thanks ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants