Jump to content

Tree Challenge?


JohnK
 Share

Recommended Posts

I was working on some tree generator using proctree (http://snappytree.com/) with babylon.js.

May have a look here http://www.babylonjs-playground.com/#1YZ8R1#0

 

Just note that this not working right actually, probably i am missing something with the babylon mesh creation.

It seems that the mesh geometry was created without any errors but does not render at all...

Link to comment
Share on other sites

@Deltakosh and @Dad72 an extension would be a good idea. Not certain I am up to it. It has taken me two months to get this far and I am not happy with it yet. Think I am going to make some major changes. The code seems too messy and some of the branch angles do not look correct.

 

@hen seems a good approach. A lot to work through to find UV problem. Will follow how you get on with interest.

Link to comment
Share on other sites

I think its not too hard to fix the UVs... its probably a problem how i push the UVs in to babylon format.

Im looking at it now.

myTree.faces.forEach(function(f) {        var uva = myTree.UV[f[0]];        var uvb = myTree.UV[f[1]];        var uvc = myTree.UV[f[2]];        trunkUVs.push(uva[0], uva[1]);        trunkUVs.push(uvb[0], uvb[1]);        trunkUVs.push(uvc[0], uvc[1]);    });
Link to comment
Share on other sites

Yes i dont have the textures hosted somewhere.

You could just replace the texture urls and everything should look fine.

 

It would be easy to turn this in to some babylon module, but i could do this only in pure js... since i never coded typescript before.

Link to comment
Share on other sites

@hen Typescript is really just javascript with some extra bits... most of the time you can just paste your javascript into a .ts file and it will work, or it will work with just a few changes.  I'd really recommend you give it a try though, once you get over the initial confusion of setting up the editor to compile the .ts files and such, its much nicer to work with.

 

The main trick you need to learn is to use "any" a lot. If you are using a .js file that doesn't have typescript definitions, just give it a type of "any" and it will basically ignore all the typescript checking and just work like normal js. You can use that to get your stuff into typescript without any really modification and then slowly add typescript sugar on top.

Link to comment
Share on other sites

I will try that next weekend. 

Generating the trees is a bit slow at the moment, because im pushing alot of data around.
I think this would work much better when we just use the proctree algo to generate babylon mesh right away.

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...