Stencyl 3.4.0 is now out. Get it now!

3D Library Adventure

mdotedot

  • *
  • Posts: 1259
Last Ludum Dare I got a taste of 3D.

Since that time I was looking into other libraries then ThreeJS (html5 only) which I used first.
I couldn't stand that there was no cross-platform solution.

I've finally found one that does half what I want : Away3D.

With a little help from Justin I was able to draw stuff on all the publication methods of Stencyl.
Since I was using the 3.5 beta version, and didn't want to upgrade my old macbook, I was only able to test using the simulator and didn't have the opportunity to do a device test.

So : iOS Simulator, Android, Linux, Mac, Windows, Flash and HTML5 all work just fine.


Here are some of the screenshots:




  HTML5 Demos

Unfortunately there is no HaXe port of the AwayPhysics library, so for now I'm trying to do stuff with simple physics/collision bounding boxes.

I've started a new journal to investigate how to make an extension out of this.

Best regards from
M.E.
Hanging out in the Chat:  http://www.stencyl.com/chat/

LIBERADO

  • *
  • Posts: 2421
The screenshots look great. An extension for 3D cross-platform will be fantastic.
Despite its limitations, let's hope it was viable enough to make commercial games.
   
Thank you very much for your excellent work.

I'm spanish, excuse me for my bad English.
I'm not a private teacher. Please, post your questions in the public forum.

merrak

  • *
  • Posts: 1600
Nice screenshots so far! Please do keep us posted; this looks really interesting. I'd be particularly interested in learning how you integrated the Away3D library into Stencyl.

mdotedot

  • *
  • Posts: 1259
For Merrak (and for those of you who like to read a lot of stuff)

Log July-August

Investigated:
* BabylonHx
* OmniHx3D
* HaxeBullet (might revisit)
* Away3D (see for all the steps to actually make something work : next post)

                  BabylonHx


This works with haxelib run lime but with an older haxe.
I would have liked to get this to work since it has collision detection / physics and much
more features than Away3D.



Trying to convert the library to Stencyl 3.4 and/or 3.5
     Loads of 'Float32' Type conversion. Comparing stuff to null.
   To even get some small demo to work it took me 2 days to correct all those errors.
   When I started with the next small demo it gave another huge list of errors to correct.
   That was with demos using a scene, camera and 1 object; not even fancy stuff or collision detection



Windows 7 64bit (profesional) [ Windows XP does not work (32bit) ]  in Virtual Box on Mac

Environment variables:

HAXEPATH c:\haxe
NEKO_INSTPATH c:\neko
Download : Haxe 3.2.0rc
    download haxe 3.2.0rc

Extrac into c:\haxe (so copy paste files from the 3.2.0rc directory


For neko version refer to this list:

HAXE     NEKO

2.*   1.*

3.0.0   2.0.0

3.1.3   2.0.0

3.2.0   2.0.0

3.3.0   2.1.0

3.4.0   2.1.0



So Neko 2.0.0 it is. Download from package.chocolatey.org/packages/neko/2.0.0 > neko.2.0.0.nupkg

 7-zip unarchive



* haxelib selfupdate

current version is now 3.2.0-rc.3



* haxelib install lime

(5.3.0)

* haxelib run lime setup windows

(Vc++ Express  installation)





* haxelib install lime 2.7.0

* haxelib install hxcpp 3.2.193

* haxelib install openfl 3.4.0

* haxelib install actuate 1.8.6

* haxelib install format 3.2.1

* haxelib install poly2trihx 0.1.4



* Download & install git : https://git-scm.com/download/win

* haxelib git BabylonHx https://github.com/vujadin/BabylonHx


* haxelib git BabylonHxSimpleTest https://github.com/jfroco/BabylonHxSimpleTest
 haxelib_client 3.2.0rc3
 actuate 1.8.7
 hxcpp 3.4.64
 openfl 3.4.0
 lime : 2.7.0
haxelib run lime setup (will install windows)

If you want to install Visual C++ 2015 you need to select language:
*        Custom -> Next
*         Programming Languages (collapse)
*        Visual C++ languages
*         Next
*          Signing with your microsoft account (create one if needed)
*      Team : click on not now link next to button
*   Start Visual Studio so that it goes through the project phase.

               


* haxelib run lime build project.xml windows
This takes some time as it creates afile:
      bin_lime\windows\cpp\bin\BabylonHx_Lime.exe

This works!

Attempt with Stencyl (installed into c:\abc)

* haxelib setup c:\abc\plaf\haxe\lib

* haxelib list

Should list stencyl among others

If you want to make another version active use:
* haxelib set lime 3.2.1
* haxelib run lime setup (installs bunch of stuff)


* haxelib install hxcpp
* haxelib install lime
* haxelib run lime setup windows
* haxelib run lime build project.xml windows

Failed due to type mismatches.

After moving back and forth between different stencyl versions (3.2 upwards)
and not getting good compilation and with the week re-coding to not get much done
I gave up on BabylonHX

               OmniHx3D

After installation it immediately gave huge lists of type errors.
Not wanting to go the same route as with Babylon: I gave up

----

               Away3D

Finally a library that didn't reported an error when using just a 3d View.

The next post has the steps to get a sample working on haxe AND in Stencyl

« Last Edit: August 17, 2017, 05:57:28 am by mdotedot »
Best regards from
M.E.
Hanging out in the Chat:  http://www.stencyl.com/chat/

mdotedot

  • *
  • Posts: 1259
I've made the following test case:

* Oracle Linux
* Stencyl Beta 3.5 9480
* Copy-Pasted the native example to a Away3D folder and modified the info.txt, blocks.xml and renamed the .hx to Away3D.hx
* Modify the blocks.xml and info.txt to reflect the Away3D references.
* Download the Away3D github haxe library and put it the away3d folder in the engine-extension


To test outside Stencyl I used these steps:
* haxelib setup <your plaf/haxe/lib path>


run.sh
Code: [Select]

# to set the environment in Stencyl : haxelib setup $HOME/Downloads/plaf/haxe/lib
rm -rf Export/flash/release/bin/Away3D.swf # remove Example
haxelib run openfl build project.xml flash # build example
/root/Downloads/ext-tools/players/flash-10-linux Export/flash/release/bin/Away3D.swf

               Away3D.hx
Code: [Select]
import openfl.display3D.*;

import openfl.display.StageScaleMode;
import openfl.display.StageAlign;
import openfl.display.Sprite;
import openfl.display.BitmapData;
import openfl.display.Bitmap;
import openfl.events.Event;
import openfl.geom.Vector3D;
import openfl.Lib;


import openfl.display3D.*;
import openfl.display.Stage3D;

import openfl.display.Shape;

// Away3D
import away3d.containers.View3D;
import away3d.debug.*;
import away3d.entities.Mesh;
import away3d.materials.*; // colorMaterial
import away3d.primitives.*; // CubeGeometry
import away3d.utils.Cast;
import away3d.events.*;
import away3d.core.managers.*;

import away3d.events.*;


class Away3D extends Sprite{

        // Stencyl will use pass root stage
        private var stg:openfl.display.Stage;

        private  var _view:View3D;

        //scene objects
        private var _plane:Mesh;
        private  var _cube:Mesh;
        private var _player:Mesh;

        public var context:openfl.display3D.Context3D;
        private var cubeMaterial:ColorMaterial;
        private var collidedMaterial:ColorMaterial;

        #if stencyl
                private var engine:com.stencyl.Engine;
        #end

        // render loop
        private  function _onEnterFrame(e:Event):Void
        {


                _cube.rotationY+=1;
                _cube.rotationX+=1;
                //_cube.rotationZ+=0.1;
                #if stencyl
                        engine.setGameAttribute('Debug', 'PlayerX:'+_player.x);
                #end

                _player.x+=1;

                // Collision Detection
                if (_cube.worldBounds.overlaps(_player.worldBounds)){
                        _cube.material = collidedMaterial;
                        _cube.x=_cube.x+5;
                }else{
                        _cube.material = cubeMaterial;
                } // collision


                _view.render();

        } // onEnterFrame


        private function init(){
 trace('in init');
                // Context
                context = stg.stage3Ds[0].context3D;

                // away3D view
                _view = new View3D();
                addChild(_view);


                _view.camera.z = -1200;
                _view.camera.y = 200;
                _view.camera.lookAt(new Vector3D());

                cubeMaterial=new ColorMaterial(0xff0000);
                collidedMaterial=new ColorMaterial(0xff00ff);


                _cube = new Mesh(new CubeGeometry(200, 200, 200, 1, 1, 1, false),  new ColorMaterial(0xff0000));

                _cube.x = 300;
                _cube.y = 160;
                _cube.z = -250;

                _player = new Mesh(new CubeGeometry(130, 130, 130,1,1,1, false),  new ColorMaterial(0xffff00));
                _player.y=160;
                _player.z=-250;
trace(' the cube is : '+_cube);

                _view.scene.addChild(_cube);
                _view.scene.addChild(_player);


                // render listener
                stg.addEventListener(Event.ENTER_FRAME, _onEnterFrame);
        } // init

#if stencyl
        public  function stencyl(_engine:com.stencyl.Engine){

                engine=_engine;
                stg=engine.root.stage;

                // for android/iOS : force opaqueBackground : Stencyl overwrite
                #if mobile
                        // You still need 'no color' on scene property
                        engine.root.stage.opaqueBackground=null;
                #end
                stg.addChild(this);
                init();
        }
#end

        // haxelib run will call this (project.xml Main '')
        public function new() {
                super();
                #if !stencyl
                        //
                        // Stage
                        //
                        stg=openfl.Lib.current.stage;
                        stg.addChild(this);
                        init();
                #end
        }


} // Away3D class

// eof haxe file




               project.xml
Code: [Select]
<?xml version=”1.0" encoding=”utf-8"?>
<project>

 <meta title="Away3DTest" package="" version="1.0.0" company="MyCompany" />
 <app main="Away3D" path="Export" file="Away3D" />
 <source path="." />

 <haxelib name="openfl" />

</project>

You can now do the run.sh on the system to get a swf file.

STENCYL

Create a scene with background properties set to NO COLOR !!!!!!!!!

Add Away3D extension using the Settings : Extension tab.


To call the code from Stencyl this is all it takes:
Code: [Select]
var a=new Away3D();
a.stencyl(Engine.engine);


Since this code works we now can make more examples and investigate all the Away3D possibilities.


Thanks to Justin to get the engine.root.stage from the Stencyl Engine since without this it
would not show antyhing.
Best regards from
M.E.
Hanging out in the Chat:  http://www.stencyl.com/chat/

mdotedot

  • *
  • Posts: 1259
First Person Terrain Walking Demo







A lot of animated Knights






Mouse Pointing at Objects




« Last Edit: August 17, 2017, 07:09:07 am by mdotedot »
Best regards from
M.E.
Hanging out in the Chat:  http://www.stencyl.com/chat/


mdotedot

  • *
  • Posts: 1259
Thanks Squeeb.

Hopefully I can create an actual game with it.

This last demo looks promising to pull it off. Use the numbers to do an animation:



Best regards from
M.E.
Hanging out in the Chat:  http://www.stencyl.com/chat/

NobodyX

  • *
  • Posts: 1195
Wow, this is really cool!!!!! :D Interested to see what you make with it.

I'm sure I'm not smart enough to use it as is but if it ever gets integrated with easy design mode blocks to let people add 3d models to their otherwise 2d games then that would be incredibly wild. Could be neat for backgrounds, special bosses, cutscenes, etc. (I have no expectations of this btw, just dreaming)
“If you wind up with a boring, miserable life because you listened to your mom, your dad, your teacher, your priest, or some guy on TV telling you how to do your shit, then YOU DESERVE IT.”
― Frank Zappa

JeffreyDriver

  • Posts: 1243
This is incredible. Can't wait to see where this goes.

merrak

  • *
  • Posts: 1600
An interesting read!

Earlier in the summer I had bookmarked BabylonHX as something to look into, but I decided to write my own renderer for my purposes. It's nice to know this can be done, though... especially if I ever get stuck. I just recently started digging into OpenFL, learning what stages are and how rendering is done at a lower level. I think I see what you're doing now, if my understanding of how Stencyl is built over OpenFL is right.

Anyway.. looking forward to what you come up with in the next phase :) Great work so far!

Nikkita31

  • Posts: 129
Hi Guys.

Wow. This is really awesome!  :o  :o  :o If this becomes a success, I will not hesitate to pay for it's further development. Looking forward to this. Great Job. Let's see what Chief has to say about this.

regards,
Nikki

mdotedot

  • *
  • Posts: 1259
Thanks for all the feedback.

This weeks investigation (Next Post = actual part of pipeline)

I had a look at some tools to create 3D assets. Previously I used examples from Away3D and things I found on the internet.
But I want to get a grasp on the tools needed to actually make these assets.

My personal preferences:
* Free to use : I have no problem paying for stuff but I should need that tool daily or really often to make it worth my money.
* Somewhat user-friendly. Although I do realise it is a new skill that needs to be learned.
* Preferably one tool

If anybody know of a good (free) 3D tool that can export OBJ and MD5(anim/mesh) please let me know!!





Away Builder
URL: http://awaytools.com/awaybuilder/live-tool/

This gives a taste of what you can do to create scenes. This looks very promising to get into the pipeline.
Especially for non-animated objects.

It is free. It is from the same makers as the library so a good integration as far as I can now tell with my tests.

You can download the tool to your computer rather than using the online version (if it ever gets to be pulled offline)

Download URL: https://github.com/awaytools/AwayBuilder


Downside: it cannot do animations ( although it looked it would do it   >:(   )


Magica Voxel

A really nice tool and it can do OBJect animations. Unfortunately this is not automatically interpreted by the Away3D code.
But I might give it a shot when exporting single frames to the engine and make an in-engine-animation.


Houdini

Houdini Apprentice 16.0.671 (non-commercial version) 

Could not get animation to work.


mixamo

https://www.mixamo.com/store/#/autorigger?action=fuserig&character_id=9b08702f-518e-4658-bed0-875576ed80c8&version=1.4

This can export to DAE but from what I’ve seen it is only human animation

What bothers me the most is that it is from Adobe. Now free but probably will be the same as photoshop and other things from Adobe: subscription based.



daz3d
URL: https://www.daz3d.com/
register to download. (supposedly free, so no trial period)

Result : too large DAE file 60MB (!)
But what the main issue is:  Too much emphasis on human animation.


iclone
Not free in the long run and it is too expensive for my taste

Blender

Lots of reports that it doesn’t work.
Let us see what does and does not work !

(See Next Post)
Best regards from
M.E.
Hanging out in the Chat:  http://www.stencyl.com/chat/

mdotedot

  • *
  • Posts: 1259
So for the next phase I'm looking to create some assets with Blender.

I have found a way to get animations to export. It is a very delicate process.
I hope to get a better, steady workflow since currently I'm struggling a lot to get my head around 3D tools like Blender.
It probably can do amazing stuff and it would likely be the free tool that I want that can do both animation and object generation.

As always I like programming more than creating assets/levels so I kind of lack the spirit to really investigate and learn Blender the way I kind of should.

But at least I have now a process that allows m.e. to create something myself and use it in the Away3D engine!



  Blender Exporting Animations
Best regards from
M.E.
Hanging out in the Chat:  http://www.stencyl.com/chat/

mdotedot

  • *
  • Posts: 1259
After a long weekend of investigations, Blender, AwayBuilder  I have decided to alter the Away3D engine a bit for future use.

The issue was that loading MD5Mesh and/or OBJ files the materials are either not loaded with the objects or are referenced in such a manner that the Away3D engine would re-map the (color)textures again.

For our future extension we need a way to map / bind a color or mapped texture to a (sub)mesh.

So I changed some part of the parsers.  I will document this for future reference:


* away3d/loaders/parsers/OBJParser.hx
Change parseLine function to:
Code: [Select]
private function parseLine(trunk:Array<String>):Void
{
switch (trunk[0]) {
case "mtllib":
_mtlLib = true;
//_mtlLibLoaded = false; // M.E. mtl file doesn't get found in the extras folder .. only base-folder :(
//loadMtl(trunk[1]);     // M.E.Don't try to load otherwise other code is not executed
case "g":
createGroup(trunk);
case "o":
createObject(trunk);
case "usemtl":
if (_mtlLib) {
// if (trunk[1] != "")      // M.E. don't change trunk
// trunk[1] = "def000"; //M.E. keep the original name

_materialIDs.push(trunk[1]);
_activeMaterialID = trunk[1];
if (_currentGroup != null)
_currentGroup.materialID = _activeMaterialID;

}
case "v":
parseVertex(trunk);
case "vt":
parseUV(trunk);
case "vn":
parseVertexNormal(trunk);
case "f":
parseFace(trunk);
}
}


*away3d/loaders/parsers/MD5MeshParser.hx
Make the loader set a default material when subMesh contains a material name
Code: [Select]
for (i in 0..._meshData.length){
_geometry.addSubGeometry(translateGeom(_meshData[i].vertexData, _meshData[i].weightData, _meshData[i].indices));

}
// M.E. : Make a default material and give it the material name from the MD5Mesh file
for(j in 0 ... _mesh.subMeshes.length){
_mesh.subMeshes[j].material=new ColorMaterial(0x00); // Default to a material
_mesh.subMeshes[j].material.name=_shaders[j];
}
//_geometry.animation = _animation;
// _mesh.animationController = _animationController;
Best regards from
M.E.
Hanging out in the Chat:  http://www.stencyl.com/chat/