Code Monkey home page Code Monkey logo

alternativa3d's People

Contributors

avkviring avatar chrisdenham avatar ffelini avatar fomkin avatar idkravitz avatar lanior avatar leonid-gaev avatar leonidgaev avatar makc avatar nordonoscillius avatar pecheny avatar therabbitwindfall avatar wilsonsilva avatar yaski avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

alternativa3d's Issues

Why does BitmapTextureResource have to lose _texture?

This is more like forum question, but - since it's down - here goes:

            } else {
                _texture = null;
                throw new Error("Cannot upload without data");
            }

Why does it have to do that? I could understand throw, but "= null" part is mysterious 😕

Performance optimizations using object literals

Object literals are faster than the new operator

Strings, Numbers (including int and uint), and Boolean objects are usually instantiated using literal notation (var str:String = “text”). Objects and Arrays are often instantiated using the “new” operator – this is seldom necessary (only in the case of a fixed-length Array), and is slower.

var o:Object = {}; is faster than var o:Object = new Object();

and

var a:Array = []; is faster than var a:Array = new Array();

ExporterA3D doesn't export materials

Оказалось, что ExporterA3D не умеет экспортировать обычный StandartMaterial в котором находится BitmapTextureResource.

private function exportMap(source:TextureResource, channel:int, dest:A3D2):int {
            if (source == null) return -1;
            var result:A3D2Map = mapsMap[source];
            if (result != null) return result.id;
            if (source is ExternalTextureResource) {
                var resource:ExternalTextureResource = source as ExternalTextureResource;
                result = new A3D2Map(channel, mapID, exportImage(resource, dest));
                if (dest.maps == null) dest.maps = new Vector.<A3D2Map>();
                dest.maps[mapID] = result;
                mapsMap[source] = result;

                return mapID++;
            }
            return -1;
        }

Почему только if (source is ExternalTextureResource) { ???????? Невероятно!
Я бы сделал пуллреквест только у вас там бинарные библиотеки.

No Wiki?

Could we please have a wiki to post tutorials and how-tos?

Blurry Sprite3D

When we use Sprite3D we don't want to scale up the bitmapdata if it is not power of two. So, we need to have something like Image in starling.

I made changes (hardcode) to reach such behavior.
Here are some changes in BitmapTextureResource.as:

            if (resizeForGPU) {
                var wLog2Num:Number = Math.log(data.width)/Math.LN2;
                var hLog2Num:Number = Math.log(data.height)/Math.LN2;
                var wLog2:int = Math.ceil(wLog2Num);
                var hLog2:int = Math.ceil(hLog2Num);
                if (wLog2 != wLog2Num || hLog2 != hLog2Num || wLog2 > 11 || hLog2 > 11) {
                    // Resize bitmap
                    wLog2 = (wLog2 > 11) ? 11 : wLog2;
                    hLog2 = (hLog2 > 11) ? 11 : hLog2;
                    source = new BitmapData(1 << wLog2, 1 << hLog2, data.transparent, 0x0);
                    source.copyPixels(data, data.rect, new Point(0, 0));
                    scaleUV = new Rectangle(0, 0, data.width / source.width, data.height / source.height);
                }
            }

So, we copy data without resizing. source.copyPixels(data, data.rect, new Point(0, 0)); Then save scaleUV to set them in Sprite3D.as:

            geometry.setAttributeValues(VertexAttributes.POSITION, Vector.<Number>([0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0]));
            geometry.setAttributeValues(VertexAttributes.NORMAL, Vector.<Number>([0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1]));
            geometry.setAttributeValues(VertexAttributes.TEXCOORDS[0], Vector.<Number>([0, 0, 0, scaleV, scaleU, scaleV, scaleU, 0]));
            geometry.setAttributeValues(VertexAttributes.TEXCOORDS[1], Vector.<Number>([0, 0, 0, scaleV, scaleU, scaleV, scaleU, 0]));
            geometry.setAttributeValues(VertexAttributes.TEXCOORDS[2], Vector.<Number>([0, 0, 0, scaleV, scaleU, scaleV, scaleU, 0]));
            geometry.setAttributeValues(VertexAttributes.TEXCOORDS[3], Vector.<Number>([0, 0, 0, scaleV, scaleU, scaleV, scaleU, 0]));
            geometry.setAttributeValues(VertexAttributes.TEXCOORDS[4], Vector.<Number>([0, 0, 0, scaleV, scaleU, scaleV, scaleU, 0]));
            geometry.setAttributeValues(VertexAttributes.TEXCOORDS[5], Vector.<Number>([0, 0, 0, scaleV, scaleU, scaleV, scaleU, 0]));
            geometry.setAttributeValues(VertexAttributes.TEXCOORDS[6], Vector.<Number>([0, 0, 0, scaleV, scaleU, scaleV, scaleU, 0]));
            geometry.setAttributeValues(VertexAttributes.TEXCOORDS[7], Vector.<Number>([0, 0, 0, scaleV, scaleU, scaleV, scaleU, 0]));

I don't know how to integrate it correct into the main code. So it would be great to see similar changes in the next releases.

Thanks.

Z ordering wrong on Android

Everything works fine on Windows. However, when I take my code to Android, the Z ordering of objects is all wrong. The following code produces these outputs:

Windows 7 64 Home Premium, Adobe AIR 3.3:http://i49.tinypic.com/20jo2kg.png - Right

Android 3.2.1 Le Pan II, Adobe AIR 3.3: http://i50.tinypic.com/1z1sgtc.png - Wrong

(Flex 4.6 SDK, AIR 3.3 SDK, Alternativa3D 8.27, FlashDevelop 4.0.4 RTM with default "AIR Mobile AS3 App" profile)

package 
{
    import alternativa.engine3d.core.Camera3D;
    import alternativa.engine3d.core.Object3D;
    import alternativa.engine3d.core.View;
    import alternativa.engine3d.lights.OmniLight;
    import alternativa.engine3d.materials.StandardMaterial;
    import alternativa.engine3d.primitives.Box;
    import alternativa.engine3d.resources.BitmapTextureResource;
    import flash.display.BitmapData;
    import flash.display.Stage3D;
    import flash.events.Event;
    import flash.display.Sprite;
    import flash.display.StageAlign;
    import flash.display.StageScaleMode;

    [SWF(width = "1024", height = "720")]

    public class Main extends Sprite 
    {
        public var
            stage3D     :Stage3D = stage.stage3Ds[0],
            scene       :Object3D = new Object3D(),
            camera      :Camera3D;

        public function Main():void 
        {
            stage.scaleMode = StageScaleMode.NO_SCALE;
            stage.align = StageAlign.TOP_LEFT;

            stage3D = stage.stage3Ds[0];
            stage3D.addEventListener(Event.CONTEXT3D_CREATE, onContext3dCreate);
            stage3D.requestContext3D();
        }

        private function onContext3dCreate(event:Event):void
        {
            camera = new Camera3D(1, 10000);
            camera.view = new View(stage.stageWidth, stage.stageHeight);
            camera.view.hideLogo();
            camera.rotationX = -.5;
            camera.rotationY = -1;
            scene.addChild(camera);
            addChild(camera.view);

            var light:OmniLight = new OmniLight(0xffffff, 5000, 10000);
            scene.addChild(light);

            var normalMap:BitmapTextureResource = new BitmapTextureResource(new BitmapData(1, 1, false, 0x7f7fff));
            normalMap.upload(stage3D.context3D);

            var texture:BitmapTextureResource = new BitmapTextureResource(new BitmapData(1, 1, false, 0xff0000));
            texture.upload(stage3D.context3D);
            var material:StandardMaterial = new StandardMaterial(texture, normalMap);

            var boxSize:uint = 50;
            var boxCount:int = 10;
            for (var x:int = 0; x < boxCount; x++)
                for (var z:int = 0; z < boxCount; z++)
                {
                    var box:Box = new Box(boxSize - 5, 10, boxSize - 5);
                    box.geometry.upload(stage3D.context3D);
                    box.getSurface(0).material = material;
                    box.x = (boxSize * x) - (boxCount * boxSize);
                    box.y = 50;
                    box.z = boxSize * z;
                    scene.addChild(box);
                }

            camera.render(stage3D);
        }
    }
}

Android and IOS wrong MouseEvent3D Z order

Only on Android and IOS if you have for example a box on a plane and click on the box, the mouseevent3D will always target the plane.

So the issue is concerning MouseEvent3D with overlapping object.

lookAt methods point in wrong y direction

I have two comments about the lookAt methods (in DirectionalLight, SpotLight, Camera3D, and possibly elsewhere):

  1. I think this method should be implemented in Object3D, not in multiple subclasses.
  2. When deltaY is non-zero, the lookAt method produces incorrect results for me. It points down when it should point up and vice versa. If you aren't able to trivially reproduce this, let me know and I'll investigate the cause further.

Thanks!

Null pointer exception during publish 3ds

Hi

When I try to publish my 3ds file with textures in http://a3dplayer.com/ Iget error

TypeError: Error #1009: Cannot access a property or method of a null object reference.
at alternativa.engine3d.loaders::ExporterA3D/exportGeometry()[C:\Develop\platform\clients\fp11\libraries\Alternativa3D\trunk\target\checkout\src\alternativa\engine3d\loaders\ExporterA3D.as:523]
at alternativa.engine3d.loaders::ExporterA3D/exportMesh()[C:\Develop\platform\clients\fp11\libraries\Alternativa3D\trunk\target\checkout\src\alternativa\engine3d\loaders\ExporterA3D.as:370]
at alternativa.engine3d.loaders::ExporterA3D/exportHierarchy()[C:\Develop\platform\clients\fp11\libraries\Alternativa3D\trunk\target\checkout\src\alternativa\engine3d\loaders\ExporterA3D.as:256]
at alternativa.engine3d.loaders::ExporterA3D/exportHierarchy()[C:\Develop\platform\clients\fp11\libraries\Alternativa3D\trunk\target\checkout\src\alternativa\engine3d\loaders\ExporterA3D.as:267]
at alternativa.engine3d.loaders::ExporterA3D/export()[C:\Develop\platform\clients\fp11\libraries\Alternativa3D\trunk\target\checkout\src\alternativa\engine3d\loaders\ExporterA3D.as:171]
at projects.editor.clients.fp11.Alternativa3DEditor.export.exportSWF.progressPhase::ExportProgressPhase/prepareModelSource()
at projects.editor.clients.fp11.Alternativa3DEditor.export.exportSWF.progressPhase::ExportProgressPhase()
at projects.editor.clients.fp11.Alternativa3DEditor.app::ExportController/exportToSWF()
at projects.editor.clients.fp11.Alternativa3DEditor.app.views.topPanel::TopPanel/__exportSWF_click()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at alternativa.gui.mouse::MouseManager/onClick()[C:\work\fb3\AlternativaGUI\target\checkout\src\alternativa\gui\mouse\MouseManager.as:990]
at alternativa.gui.mouse::MouseManager/onMouseUp()[C:\work\fb3\AlternativaGUI\target\checkout\src\alternativa\gui\mouse\MouseManager.as:1128]

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.