MackeyK24 Posted December 8, 2016 Author Share Posted December 8, 2016 Very Kool // Heightmap var floatView = new Float32Array(options.buffer.buffer); // Vertices for (row = 0; row <= options.subdivisions; row++) { for (col = 0; col <= options.subdivisions; col++) { var position = new Vector3((col * options.width) / options.subdivisions - (options.width / 2.0), 0, ((options.subdivisions - row) * options.height) / options.subdivisions - (options.height / 2.0)); // Compute height var heightMapX = (((position.x + options.width / 2) / options.width) * (options.bufferWidth - 1)) | 0; var heightMapY = ((1.0 - (position.z + options.height / 2) / options.height) * (options.bufferHeight - 1)) | 0; // Unpack height var pos = (heightMapX + heightMapY * options.bufferWidth); var gradient = floatView[pos]; position.y = options.minHeight + (options.maxHeight - options.minHeight) * gradient; // Add vertex positions.push(position.x, position.y, position.z); normals.push(0, 0, 0); uvs.push(col / options.subdivisions, 1.0 - row / options.subdivisions); } } Working Great... You da man @Sebavan Quote Link to comment Share on other sites More sharing options...
Sebavan Posted December 8, 2016 Share Posted December 8, 2016 yep sorry about the typo and hope it is not to blocky due to the compression... Quote Link to comment Share on other sites More sharing options...
MackeyK24 Posted December 8, 2016 Author Share Posted December 8, 2016 Looks good... Now I'm only using VERY LOW POLY now... not trying to make a smooth version like when we first started at the creategroundfromheightmap was the ONLY mesh for the terrain... Now we use Detail mesh/Collision Mesh combo and the collision mesh is made from the new (thanks to @Sebavan) BABYLON.SceneManager.createGroundTerrain() function in BJS unity toolkit. And it only using 50 to 100 subdivisions so it will yield MUCH LOWER POLYS for the terrain collision mesh... SO IT WILL BE BLOCKY... Buts that ok... its just there for collision now anyways... and you can control how DETAILED you want your invisible collision mesh to be with the "Ground Tessellation" option on the Babylon Terrain Generator Component Dude... Thanks again for ALL YOU HELP Sebavan 1 Quote Link to comment Share on other sites More sharing options...
MackeyK24 Posted December 8, 2016 Author Share Posted December 8, 2016 @Sebavan Plus... With us using ALL 4 CHANNELS to transport the packed float value... ITS GOTTA BE BETTER THAN WHAT IT WAS BEFORE Quote Link to comment Share on other sites More sharing options...
MackeyK24 Posted December 8, 2016 Author Share Posted December 8, 2016 @Sebavan Now that i know what going with that packing stuff... Worse case i use C++ (C# DllImport) to encode my Color32 array of pixels as a base64 png encoded image string with no compression... Then we would really be golden WITHOUT loosing ANY precision Sebavan 1 Quote Link to comment Share on other sites More sharing options...
MackeyK24 Posted December 8, 2016 Author Share Posted December 8, 2016 @Sebavan From what I'm reading in unity, there is no need to externally encode PNG because Texture2D.EncodeToPNG does NOT use compression (or it does NOT use a LOSSY compression if it is using compression at all) Can you verify this ? Quote Link to comment Share on other sites More sharing options...
Sebavan Posted December 8, 2016 Share Posted December 8, 2016 yep, I am stupid png is lossless anyway... was thinking of something else I am doing at the same time... Quote Link to comment Share on other sites More sharing options...
MackeyK24 Posted December 8, 2016 Author Share Posted December 8, 2016 Kool deal... then as far as i concerned... Terrains are done Just gotta finish Off Mesh Links (And i may look at throwing in 'touch' and 'virtual joystick' to the contributing factors for the user input manager) Quote Link to comment Share on other sites More sharing options...
RaananW Posted December 9, 2016 Share Posted December 9, 2016 Did Dave ever answer? NasimiAsl 1 Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted December 9, 2016 Share Posted December 9, 2016 He sent me the response NasimiAsl 1 Quote Link to comment Share on other sites More sharing options...
NasimiAsl Posted December 9, 2016 Share Posted December 9, 2016 you do like good friend @Deltakosh GameMonetize 1 Quote Link to comment Share on other sites More sharing options...
RaananW Posted December 9, 2016 Share Posted December 9, 2016 I think i'll start calling @davrous Dave from now on Quote Link to comment Share on other sites More sharing options...
MackeyK24 Posted December 9, 2016 Author Share Posted December 9, 2016 Ready to post first part of my api (babylon.unity.ts) But I don't really know all the ins and outs of the github/gulp build process... I would like to simply in github/master/src/unity/babylon.unity.ts that "SOMEHOW" ends up in /dist/preview release/unity/babylon.unity.js and babylon.unity.d.ts @Deltakosh or @Sebavan can i just send either on of you guys the babylon.unity.ts file and you put where it should go(not sure about how it gets built every night) ... I can then take it from there Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted December 9, 2016 Share Posted December 9, 2016 @Sebavan can help Quote Link to comment Share on other sites More sharing options...
MackeyK24 Posted December 9, 2016 Author Share Posted December 9, 2016 @Sebavan What about the master/src/tools folder... then we can treat the unity toolkit api just like gamepad or virtual joystick ... Just another tool (and also i think it would end up in main babylon.js)... Note: All my runtime components api stuff will actually work WITH or WITHOUT unity created scenes. Remember the unity toolkit REALLY just adds metadata to the scene file... Technically that metadata can get created with anything, even by hand or using other tools. The only real check i do is the loader checkers for node.metadata.unity... If i change that to node.metadata.api or something like that... You could really use my whole scene manager/component from just strait code (WITH OR WITHOUT UNITY)...and use SceneManager.addSceneComponent(mesh, "Project.MyComponent") at runtime. Let me know what you think @Deltakosh Quote Link to comment Share on other sites More sharing options...
Sebavan Posted December 9, 2016 Share Posted December 9, 2016 If it is not tied to Unity, do not call it Unity and makes sense to have in the core dist depending on the added value for everybody. For the unity only related part I would add it in the loaders folder like we already have obj, we could have a custom unity loader for the specific. With both approach you only need to reference your new ts files in the tools/gulp/config.json and that is it, all the rest will be automated. I f you submit the PR, we (I mean @Deltakosh mostly) can probe for the re usability and worst case you ll have to move a bit or rename. Quote Link to comment Share on other sites More sharing options...
MackeyK24 Posted December 9, 2016 Author Share Posted December 9, 2016 Or i can even just keep it apart of the actual unity edit plugin folder... I don't know whats the best spot for the actual babylon.unity.ts Quote Link to comment Share on other sites More sharing options...
MackeyK24 Posted December 9, 2016 Author Share Posted December 9, 2016 @Sebavan and @Deltakosh I like the tools approach.... I will go thru the API (Removing all specific UNITY references and gear the API for more of a Scene Manager And Scene Component API that knows nothing about unity) I will then just pull the UnityFileLoader part into a separate small file and use just like STL and OBJ file loader. Then everybody can choose to use Scene Component API approach or NOT... And also have the option of using Unity to put your scene file together or NOT We can then go from there GameMonetize and Sebavan 2 Quote Link to comment Share on other sites More sharing options...
MackeyK24 Posted December 10, 2016 Author Share Posted December 10, 2016 Having Problem Submitting PR... I am trying to commit the same files i been using the whole time to compile my scene manager api (on my client pc) but when i submit to github its get all kind of syntax errors that should be: [09:58:21] Using gulpfile ~/build/BabylonJS/Babylon.js/Tools/Gulp/gulpfile.js [09:58:21] Starting 'typescript-compile'... [09:58:31] Finished 'typescript-compile' after 10 s [09:58:32] Using gulpfile ~/build/BabylonJS/Babylon.js/Tools/Gulp/gulpfile.js [09:58:32] Starting 'canvas2D'... [09:58:32] Starting 'materialsLibrary'... [09:58:33] Starting 'postProcessesLibrary'... [09:58:33] Starting 'proceduralTexturesLibrary'... [09:58:33] Starting 'loaders'... [09:58:33] Starting 'serializers'... [09:58:33] Starting 'inspector'... [09:58:33] Starting 'sceneManager'... ../../sceneManager/src/babylon.scenecomponents.ts(4,25): error TS1005: '=' expected. ../../sceneManager/src/babylon.scenecomponents.ts(4,31): error TS1005: ';' expected. ../../sceneManager/src/babylon.scenecomponents.ts(4,40): error TS1005: ';' expected. ../../sceneManager/src/babylon.scenecomponents.ts(5,25): error TS1005: '=' expected. ../../sceneManager/src/babylon.scenecomponents.ts(5,30): error TS1005: ';' expected. ../../sceneManager/src/babylon.scenecomponents.ts(5,39): error TS1005: ';' expected. ../../sceneManager/src/babylon.scenecomponents.ts(16,26): error TS1005: '=' expected. ../../sceneManager/src/babylon.scenecomponents.ts(16,32): error TS1005: ';' expected. ../../sceneManager/src/babylon.scenecomponents.ts(16,41): error TS1005: ';' expected. ../../sceneManager/src/babylon.scenecomponents.ts(16,55): error TS1005: '=' expected. ../../sceneManager/src/babylon.scenecomponents.ts(16,88): error TS1005: ';' expected. ../../sceneManager/src/babylon.scenecomponents.ts(110,25): error TS1005: '=' expected. ../../sceneManager/src/babylon.scenecomponents.ts(110,31): error TS1005: ';' expected. ../../sceneManager/src/babylon.scenecomponents.ts(110,40): error TS1005: ';' expected. ../../sceneManager/src/babylon.scenecomponents.ts(118,25): error TS1005: '=' expected. ../../sceneManager/src/babylon.scenecomponents.ts(118,30): error TS1005: ';' expected. ../../sceneManager/src/babylon.scenecomponents.ts(118,39): error TS1005: ';' expected. ../../sceneManager/src/babylon.scenecomponents.ts(126,25): error TS1005: '=' expected. ../../sceneManager/src/babylon.scenecomponents.ts(126,29): error TS1005: ';' expected. ../../sceneManager/src/babylon.scenecomponents.ts(126,37): error TS1005: ';' expected. ../../sceneManager/src/babylon.scenecomponents.ts(171,26): error TS1005: '=' expected. ../../sceneManager/src/babylon.scenecomponents.ts(171,34): error TS1005: ';' expected. ../../sceneManager/src/babylon.scenemanager.ts(38,25): error TS1005: '=' expected. ../../sceneManager/src/babylon.scenemanager.ts(38,27): error TS1005: ';' expected. ../../sceneManager/src/babylon.scenemanager.ts(39,25): error TS1005: '=' expected. ../../sceneManager/src/babylon.scenemanager.ts(39,28): error TS1005: ';' expected. ../../sceneManager/src/babylon.scenemanager.ts(40,25): error TS1005: '=' expected. ../../sceneManager/src/babylon.scenemanager.ts(40,33): error TS1005: ';' expected. ../../sceneManager/src/babylon.scenenavagent.ts(17,25): error TS1005: '=' expected. ../../sceneManager/src/babylon.scenenavagent.ts(17,29): error TS1005: ';' expected. ../../sceneManager/src/babylon.scenenavagent.ts(17,37): error TS1005: ';' expected. ../../sceneManager/src/babylon.scenenavagent.ts(18,25): error TS1005: '=' expected. ../../sceneManager/src/babylon.scenenavagent.ts(18,29): error TS1005: ';' expected. ../../sceneManager/src/babylon.scenenavagent.ts(18,37): error TS1005: ';' expected. ../../sceneManager/src/babylon.scenemanager.ts(4,42): error TS4070: Parameter 'scene' of public static method from exported class has or is using private name 'Scene'. ../../sceneManager/src/babylon.scenemanager.ts(8,57): error TS4070: Parameter 'engine' of public static method from exported class has or is using private name 'Engine'. ../../sceneManager/src/babylon.scenemanager.ts(14,81): error TS4070: Parameter 'engine' of public static method from exported class has or is using private name 'Engine'. ../../sceneManager/src/babylon.scenemanager.ts(14,109): error TS4070: Parameter 'onsuccess' of public static method from exported class has or is using private name 'Scene'. ../../sceneManager/src/babylon.scenemanager.ts(14,167): error TS4070: Parameter 'onerror' of public static method from exported class has or is using private name 'Scene'. ../../sceneManager/src/babylon.scenemanager.ts(22,99): error TS4070: Parameter 'scene' of public static method from exported class has or is using private name 'Scene'. ../../sceneManager/src/babylon.scenemanager.ts(22,127): error TS4070: Parameter 'onsuccess' of public static method from exported class has or is using private name 'AbstractMesh'. ../../sceneManager/src/babylon.scenemanager.ts(22,160): error TS4070: Parameter 'onsuccess' of public static method from exported class has or is using private name 'ParticleSystem'. ../../sceneManager/src/babylon.scenemanager.ts(22,189): error TS4070: Parameter 'onsuccess' of public static method from exported class has or is using private name 'Skeleton'. ../../sceneManager/src/babylon.scenemanager.ts(22,259): error TS4070: Parameter 'onerror' of public static method from exported class has or is using private name 'Scene'. ../../sceneManager/src/babylon.scenemanager.ts(786,45): error TS4073: Parameter 'camera' of public method from exported class has or is using private name 'FreeCamera'. ../../sceneManager/src/babylon.scenemanager.ts(794,45): error TS4073: Parameter 'camera' of public method from exported class has or is using private name 'FreeCamera'. ../../sceneManager/src/babylon.scenemanager.ts(799,46): error TS4073: Parameter 'camera' of public method from exported class has or is using private name 'FreeCamera'. [09:59:01] TypeScript: 34 syntax errors [09:59:01] TypeScript: 13 emit errors [09:59:01] TypeScript: emit failed [09:59:01] Finished 'serializers' after 29 s Since this is my first real commit... I don't know what the deal is here Quote Link to comment Share on other sites More sharing options...
MackeyK24 Posted December 10, 2016 Author Share Posted December 10, 2016 Why can't typescript in babylon js main project have public static function defined like the following (which compiles fine on my machine): export class SceneManager { public static GetInstance(scene: BABYLON.Scene): BABYLON.SceneManager { return ((<any>scene).manager) ? (<any>scene).manager as BABYLON.SceneManager : null; } public static CreateScene(name: string, engine: BABYLON.Engine): BABYLON.Scene { var result: BABYLON.Scene = new BABYLON.Scene(engine); BABYLON.SceneManager.parseSceneMetadata("/", name, result); return result; } public static LoadScene(rootUrl: string, sceneFilename: string, engine: BABYLON.Engine, onsuccess?: (scene: BABYLON.Scene) => void, progressCallBack?: any, onerror?: (scene: BABYLON.Scene) => void): void { var onparse = (scene: BABYLON.Scene) => { BABYLON.SceneManager.parseSceneMetadata(rootUrl, sceneFilename, scene); if (onsuccess) onsuccess(scene); }; BABYLON.SceneLoader.Append(rootUrl, sceneFilename, new BABYLON.Scene(engine), onparse, progressCallBack, onerror); } public static ImportMesh(meshesNames: any, rootUrl: string, sceneFilename: string, scene: BABYLON.Scene, onsuccess?: (meshes: BABYLON.AbstractMesh[], particleSystems: BABYLON.ParticleSystem[], skeletons: BABYLON.Skeleton[]) => void, progressCallBack?: () => void, onerror?: (scene: BABYLON.Scene, message: string, exception?: any) => void): void { var onparse = (meshes: BABYLON.AbstractMesh[], particleSystems: BABYLON.ParticleSystem[], skeletons: BABYLON.Skeleton[]) => { BABYLON.SceneManager.parseMeshMetadata(meshes, scene); if (onsuccess) onsuccess(meshes, particleSystems, skeletons); }; BABYLON.SceneLoader.ImportMesh(meshesNames, rootUrl, sceneFilename, scene, onparse, progressCallBack, onerror); } public static RegisterLoader(handler: (root: string, name: string) => void): void { BABYLON.SceneManager.loader = handler; } } It does not seem to like the following format: module BABYLON { export class SceneManager { public static GetInstance(scene: BABYLON.Scene): BABYLON.SceneManager {} } } Should be able to use as: BABYLON.SceneManagerGetInstance() but the PR submit that this has syntax errors... What kind of syntax does it want??? That seems perfectly fine type script function to me Quote Link to comment Share on other sites More sharing options...
adam Posted December 10, 2016 Share Posted December 10, 2016 I recommend following the instructions on this page on how to set up a dev environment: http://doc.babylonjs.com/generals/how_to_start It looks like Typscript doesn't like "readonly". Quote Link to comment Share on other sites More sharing options...
MackeyK24 Posted December 10, 2016 Author Share Posted December 10, 2016 Hey @Deltakosh I cleaned up and made the first PR. This is the new PURE BabylonJS Managed Scene Component API. Can now use all the Scene Manager And Scene Component API from runtime using just code and NO UNITY There will be the actual 'U3D - BabylonJS Toolkit' which i will put in exporters/unity3d... That new toolkit will use the new pure BabylonJS Scene Manager on the preview index page... Other than that the Unity Exporter is now JUST A GAME IDE... All the Managed Scene Component API is now pure BabylonJS Quote Link to comment Share on other sites More sharing options...
MackeyK24 Posted December 10, 2016 Author Share Posted December 10, 2016 Yo @adam ... Thanks man... That was it ... DOES NOT LIKE 'readonly' Turns out i am using Typescript 2.0.10 compiler on my machine which works great... I think BabylonJS is still compiling with typescript 1.7 Anyways... I made all readonly use 'private _myvar' backing fields and then public get myvar():any { return this._myvar; } Works great now... Thanks for the info Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted December 11, 2016 Share Posted December 11, 2016 So as we discussed just do a pull request in the Extension repo and I will generate all the compilation tools for you (I will also update the readme with a small doc about how to build it :)) Quote Link to comment Share on other sites More sharing options...
MackeyK24 Posted December 11, 2016 Author Share Posted December 11, 2016 Kool Deal... I pre-build the first uploaded version... but if you make compiler options ... That would be awesome GameMonetize 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.