Jump to content

Instances require base mesh for the lifetime of the instance?


georage
 Share

Recommended Posts

I think I have answered my own question, but it seems you can't dispose of a root mesh that is used to build instances without deleting all the instances from the scene as well.

Is that right?

I created a "galaxy" (OK, a small one!) of various star types. I created one root star for each star type then made several thousand instances of each star type with different xyx positions and scaling. It works great.

But when I dispose of the root meshes everything disappears. I guess this is how it is supposed to work. Reminds me of a game I worked on where we had to keep all the magic items in a hidden treasure chest somewhere in the game world and whenever a player got a magic sword we just copied one from the hidden chest.

-- George

 

 

Link to comment
Share on other sites

I think you are correct about the instances, G... but I'm not sure.  Makes sense.  Clones... are different, though.  Clones don't inherit their master's material, though.  Instances do.

*shrug*

Ya know, mister G... that there is some HUGE star-field images... laying around on the web, free.  If you used a BABYLON.Layer image with .isBackground = true, and... screwed-around enough, you could pan that...  well heck... here's a bad version I once made.  http://playground.babylonjs.com/#1XQKP1#11

Potential poor-man's starfield.  :)

But then... there's these equi-rectangular things...  special images used as single-image skyboxes.  http://playground.babylonjs.com/#11GAIH#11

That's really something, too.  If you could find a public-usable equi-rectangular starfield image... perhaps you could save yourself a few thousand mesh.  :)

But real mesh stars/planets ARE cool, eh?  SPS (solid particle system)... or ANY particle system... would get you real mesh stars... for minimum byte/load costs.  Both solid and standard particle systems... have a function in them... something like startPositionFunction(), and you get to replace that with your own function.  Easily.

Well heck, I got a "star dome" that I once did... with standard particles... using a custom startPositionFunction().  http://playground.babylonjs.com/#J6ZLH#2

See the custom startPositionFunction in lines 11-16?  It uses a couple other functions stolen from the web... to plot (start) particles in a spherical shape, and it has some anti- pole-clustering features, too.  Works sort of ok.   See the updateFunction at line 20?  That is the OTHER function in particle systems... that folks often "customize".  The one in that PG does nothing... but lets go look at version #4.

Version 4 (starts at line 21) (myUpdateFunction) still doesn't do much... except... lines 34 and 35... which cause star twinkle extraordinaire.  Try changing that *10 to *50 ... in line 35, and RUN again.  WOW!

Custom particle placing, and custom particle updating.  FUN!  Particles are low vertices... better bang-for-the-buck than instances, I suspect.  But one sad note.  Particles don't do godrays.  They once did, but that feature was lost in the depth-rendering wars, I believe.  :)

Anyway, thought I'd tell you of a few more ways of doing stars... in case you wanted to go experimenting.

Link to comment
Share on other sites

Thanks Wingy. 

I am just making 1 or 2 stars at a time for the godrays thing.

Separately I am using instances to create a thousand or so stars at a time and storing the x, y, z coords in a database. In truth I don't even need to use meshes to generate random positions ... but it is fun to look at the results.

I like your examples. That #4 is really neat. I can maybe use that for something! I also like one I saw you did with CORONAS ... almost like a godrays thing. You have skills son!

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...