mercredi 22 juin 2016

As3 Workers Passing custom Objects

Making a worker that renders a mesh from away3d and sends it over to the display. I went ahead and registered all the classes so my "WorldRender" worker could pass a mesh in AMF format to my main swf and add it on stage. Think of my worker as someone that keeps track of all the parts of my world from a storage area and parses them properly.

I'm able to create a worker just fine. Waiting until the worker is ready to handle commands and everything. Ran into a few errors before where it didn't know what a Mesh or a Sector was but now all of the primary classes are registered.

Yet.

Yet..

enter image description here

Here I am registering both MaterialBase and BounidngVolumeBase and my worker thread is still throwing the same type errors it did when I didn't register my other classes.

TypeError: Error #1034: Type Coercion failed: cannot convert Object@75fe569 to away3d.materials.MaterialBase.
TypeError: Error #1034: Type Coercion failed: cannot convert Object@75f8df1 to away3d.bounds.BoundingVolumeBase.

I don't want to have to go and use a class made of primitives like a custom Cube class and then render the mesh on my main thread because of the way my engine works. . . I'm already indexing the meshes to be able to remove easily by matching them with other values in a dimensional vector. (Actually on second thought I'm not sure which would use more memory matching child index with a Cube class in both the main and worker thread or storing a collection of meshes for ease of access in my worker thread...Okay, maybe the first one, but I really want to know why this isn't working at this time for the sake of speed)

Either way, any help on this would be appreciated as my energy from the coffie shot mix I had is starting to wear out.

Sources: WorldRender worker swf http://ift.tt/28OKiWp WorldRender class in main thread http://ift.tt/28LMAlt

RenderEngine constructor exerpt calling on my WorldRender class in my main thread ("supervisor" of WorldRender for camera movement and other future render engines)

    worldRender = new WorldRender(_viewport);

    var targetXDistance:int = _viewport.camera.x + (_viewDistance / 2);
    var targetZDistance:int = _viewport.camera.z + (_viewDistance / 2);

    for (var x:int = _viewport.camera.x - (_viewDistance / 2); x < targetXDistance; x++)
    {
        for (var z:int = _viewport.camera.z - (_viewDistance / 2); z < targetZDistance; z++)
        {
            var sectorToRender:Sector = world.getSector(x, 0, z);

            //order:RENDER , sector:SECTOR, combine:BOOLEAN
            var order:Object = new Object();
            order.order = WorldRender.RENDER;
            order.sector = sectorToRender;
            order.combine = true;

            worldRender.issueOrder(order);

        }
    }

Aucun commentaire:

Enregistrer un commentaire