vujadin / BabylonHx

Port of Babylon.js 3D engine to Haxe.
http:/paradoxplay.com/babylonhx
Apache License 2.0
189 stars 43 forks source link

Decals.hx #121

Open ghost opened 8 years ago

ghost commented 8 years ago

Decals.hx with haxe 3.3 and lime do not work as expected. It places decals with random positions.

I think scene.pick is little bit buggy.

mightymarcus commented 8 years ago

It doesn't work with 3.2.1 and older lime versions too. I am using latest lime and latest openfl with a commit from 28.06. for now, and there it works.

ghost commented 8 years ago

i do not have openfl, but lime is latest as I know -- 3.0.3.

ghost commented 8 years ago

from Decals.hx

            var onPointerDown = function (x:Int, y:Int, button:Int) {           
                // check if we are under a mesh -- , function (mesh) { return mesh == zombie; }
                trace("Scene X: " + scene.pointerX);
                trace("Scene Y: " + scene.pointerY);
                trace("X: " + x);
                trace("Y: " + y);

                var pickInfo = scene.pick(x, y);
                //var pickInfo = scene.pick(scene.pointerX, scene.pointerY);
                    trace("hit: " + pickInfo.hit);
                    trace("pickedMesh: " + pickInfo.pickedMesh.id);
                    trace("pickedPoint: " + pickInfo.pickedPoint);
                    trace("getNormal: " + pickInfo.getNormal());
                    trace("getTextureCoordinates: " + pickInfo.getTextureCoordinates());

                if (pickInfo.hit) {
                    var decalSize = new Vector3(0.03, 0.03, 0.03);
                    var newDecal = Mesh.CreateDecal("decal", zombie, pickInfo.pickedPoint, pickInfo.getNormal(true), decalSize);
                    newDecal.material = decalMaterial;
                }
            }

I do not move mesh, just click one point -- but got

Done(0)
haxelib run lime run "project.xml" windows -release
Running process: C:\HaxeToolkit\haxe\haxelib.exe run lime run "project.xml" windows -release
Engine.hx:378: BabylonHx - Cross-Platform 3D Engine | 2016 | www.babylonhx.com | GL version: 4.0.0 - Build 10.18.10.3958 | GL vendor: Intel | GL renderer: Intel
Decals.hx:78: Scene X: 401
Decals.hx:79: Scene Y: 295
Decals.hx:80: X: 401
Decals.hx:81: Y: 295
Decals.hx:85: hit: true
Decals.hx:86: pickedMesh: box
Decals.hx:87: pickedPoint: {X:-0.00249999999999928 Y:0.0166666666666667 Z:-1.5}
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Decals.hx:88: getNormal: {X:1 Y:0 Z:0}
Decals.hx:89: getTextureCoordinates: {X:0.505555555555556 Y:0.500833333333333}
Decals.hx:78: Scene X: 401
Decals.hx:79: Scene Y: 295
Decals.hx:80: X: 401
Decals.hx:81: Y: 295
Decals.hx:85: hit: true
Decals.hx:86: pickedMesh: box
Decals.hx:87: pickedPoint: {X:1.5 Y:0.0166666666666667 Z:-0.00249999999999937}
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Decals.hx:88: getNormal: {X:0 Y:0 Z:1}
Decals.hx:89: getTextureCoordinates: {X:0.500833333333333 Y:0.494444444444444}
Decals.hx:78: Scene X: 401
Decals.hx:79: Scene Y: 295
Decals.hx:80: X: 401
Decals.hx:81: Y: 295
Decals.hx:85: hit: true
Decals.hx:86: pickedMesh: box
Decals.hx:87: pickedPoint: {X:0.00249999999999928 Y:0.0166666666666667 Z:1.5}
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Decals.hx:88: getNormal: {X:-1 Y:0 Z:0}
Decals.hx:89: getTextureCoordinates: {X:0.505555555555556 Y:0.500833333333333}

Additionally it writes me hit: true even if do not touch mesh.

mightymarcus commented 8 years ago

I already opend this issue with the wrong pick. I'm using an older commit for now. From 28.06.2016. There it works . That will be fixed soon I think.