Jump to content

Polyhedrons : first attemp


jerome
 Share

Recommended Posts

Hi guys,

 

Mr Stemkosky, a ThreeJS guy, did a really nice work here : http://stemkoski.github.io/Three.js/Polyhedra.html

He converted to JSON all the data compiled by George Hart here : http://www.georgehart.com/virtual-polyhedra/vp.html

 

That's for the credits...

 

So I just re-used the JSON file and implemented in BJS an algo to build polyhedrons the same way Stemkosky did in ThreeJS.

 

Here is the result :  http://www.babylonjs-playground.com/#21QRSK

 

If you hide the editor (button "-Editor"), you can display the pointed polyhedron name on the screen.

 

There are 126 different shapes here.

I guess I won't hard-code all of them as BJS basic shapes, but maybe only the most useful (how to determine the usefulness of a shape ?) or the smallest ones in term of faces : tetrahedron, pyramid, octohedron, dodecahedron, prism

Having some hard-coded polyhedrons allow to pre-compute their UVs (there are none here), what is  a quite  complex thing to do.

 

Unless you prefer I just code this full bunch as a BJS extension (so no hard coded UVs at all, what is too bad imho)

something like :

Extension.CreatePolyhedron(name, polyhedronTypeId, size, scene) ;

I need to have some polyhedrons in BJS before I start to port the SPS in the BJS core because I want to simplify it :

no more dedicated methods addCubes(), addTetrahedrons(), etc

but only something homogeneous like  :

var model = BABYLON.Mesh.CreateXXX(); // it may be a cube, a sphere, a polyhedron, a ribbon, whatever the geometrySPS.addShape(model, modelNb);model.dispose();
Link to comment
Share on other sites

Titleist might have some use :) for a gaming platform.  Looking at one now.  Never noticed that all the faces are not the same size. 

 

Kind of think the number CreateXXX()'s inside of Mesh.ts would get out of hand.  If you went with an extension,  I would drop this static create pattern thing, and create mesh subclasses.  Just have a constructor for each like:

 

var thing = new Polyhedron.Pyramid(name, size, scene);

 

This would allow someone to subclass them.

Link to comment
Share on other sites

I like the way you dynamically brought in an external script file, btw.  Think I could use that. 

 

Other good shapes are all kinds of balls, sports objects.  Soccer ball, football, hockey puck, basketball, baseball, bowling ball, home plate, etc.  I know it is not what is on offer, but you did ask.  These things are for geometry teachers / academics.

Link to comment
Share on other sites

when I said that BJS odd number version were better ... :D

 

I'm just thinking about how to do.

I'm trying to handle two different issues in the same time :

- to provide to the library the more polygon shapes possible : can you imagine a framework providing almost 150 built-in shapes ? never seen anywhere !

- to pre-compute the UVs on some of them (I guess that I need to add this in the JSON structure) what can be really complex according to the shape itself (especially when its faces are different polygon types)  and the choices about how the texture should be applied on each polyhedron.

 

I think a dedicated file would be a good option to keep clear code anyway.

Link to comment
Share on other sites

You totally totally rock, Jerome!  YAY!!  The George W. Hart/Stemkoski json-o-polyhedra... has finally made the trip to BJS!  WOW!  Excellent!  (Wingy dances!)

 

Ok, I'll get started converting all that static data... to math formulas.  I'll have it done in a few hours.   (yeeeeah, right, Wingleberry)

Link to comment
Share on other sites

  • 3 weeks later...

CreatePolyhedron() at last PRed

var pol = BABYLON.Mesh.CreatePolyhedron("name", {type?: number, size?: number, custom?: polyhedronObject}, scene);
  •  type : embedded polyhedron type number. There are 15 common usual polyhedron types provided (to keep the code light). This will be documented
  •  size, or also sizeX, sizeY, sizeZ : polyhedron size
  •  custom : a polyhedron object reference, copied/pasted from a provided external file (126 samples). This will be documented. If passed, the custom polyhedron is created instead of a BJS core one.
  •  faceColors and faceUV : arrays, nb of faces long, used to set color or image per polyhedron side
  • and of course sideOrientation and updatable parameters

Everything is optional :

BABYLON.Mesh.CreatePolyhedron("name", {}, scene);

will build a simple tetrahedron (type = 0)

 

Link to comment
Share on other sites

Hi guys.  Good work going on here, thanks! 

 

I just wanted to mention... that WAY BACK when I came-across that Hart/Stemkoski json file, I never verified re-use rights for it.  If we are re-publishing all or part of that, maybe we should introduce ourselves and make sure of stuff.  *shrug*  Just thinking.

Link to comment
Share on other sites

You might be right.

Stemkoski added a reference to the site of Hart when clicking on the "I" here : http://stemkoski.github.io/Three.js/Polyhedra.html. Maybe asked he the permission to Hart to use his data ?

However, the Hart site says, in the copyright part, says this : 

  • "All the text and 2D images of Virtual Polyhedra are copyright 1996, 1997, 1998, 1999 by George W. Hart, with all rights reserved. They may not be reproduced in any form without my expressed written permission, except for the incidental reproduction which is inherent in your real-time viewing (and local caching) of the information with a web browser.

    However, upon request, I will likely grant reproduction permission for noncommercial purposes. You can send me email at [email protected]

    An exception is the collection of individual *.wrl files which contain the mathematical description of each polyhedron. Because these contain mathematical information, they may be of use to others with an interest in polyhedra. They may be reproduced and used for noncommercial purposes. Note that a written comment to this effect is already present in each of the data files."

As we use Stemkosky data, what are actually Hart data parsed from WRL into JSON (and if my legal English understanding is good enough), I guess we match the exceptional case of his copyright disclaimer. 

The original sources of data (Stemkoski + Hart) will of course be written in the provided extension file.

Link to comment
Share on other sites

Yeah, we probably fall-under the same .WRL (data only) non-commercial thing... maybe.  But don't we need commercial rights?  Some of our users are going to "market" their stuff... and.. hmm.  *shrug*

 

Let's get Davrous to fire a cool two-way email at the boys.  He's a smooth talker... and that baby face... gets 'em EVERY TIME!  :D

 

I'll email 'em... if folks think I should.  You can, too, Jerome. 

 

I exchanged short interaction with Prof. Stemkoski... on his blog.  He's a sweetheart.  Hart seems ok, too... by the words on his site.  But I think DK would be the one who would need to get the official perms.

 

Um... how close are we... to being able to dynamically gen those shapes? 

 

I can break-into, or continually-talk until they ALLOW me-into... the code vaults at MathLab, Inc.  heh  Thoughts?

Link to comment
Share on other sites

Ok

If one of the native english speaker here could gently ask, this would be great indeed. I don't feel comfortable enough in English to do such a request correctly.

 

I'm not expert in US laws but I'm not sure some computed coordinates can be copyrighted. We would have get the same results if we had done the computations by ourselves : box vertex coordinates are the same whomever does the computation.

 

We can't really dynamically compute all this data with a universal algo because it really depends on the polyhedron category, so at least an algo per category. If we had done it, we would have done the same : to precompute everything because it's simpler and lighter than implementing dozens fo different algos.

 

Before you gave the link to Stemkosky site, I implemented the tetrahedron in the SPS and started then to study many other regular polygons on the basis of the attached document (french maths, you won't like :D ) : I was just about to begin to compute the first platonic solid vertex coordinates ... just as Hart did.

geometrie_espace.pdf

Link to comment
Share on other sites

Oooh, you did that with class and good taste.  Nice. 

 

Deltakosh, did you want to handle this?  I would be glad to translate something French-written... into English, and smooth the wording.  I can deliver, or someone else can.  I'm a little scared to take this on by myself, though.  If I screwed it up, folks would hate me forever.  :)

 

I would like to have "authorization" by Deltakosh or one of the co-founders... before I move forward on this.  You should have a strong say, too, Jerome.  And, forum users should be able to have a say on this too, but those preferences might be overridden by "the big dogs".  heh  (I'm NOT a big dog, I'm just a noisy dog.)

 

I suggest that we offer Mr. Stemkoski and Mr. Hart... a usage rights statement from them... inside that same directory, or included in that .md documentation.  And, I have $20 to donate to their causes.

 

By including usage rights statements by these authors on our site, we will cover our butts from users who use this data for commercial purposes.  We have then included the authors... into our site and project... and they will have editing powers on those usage rights statements. 

 

And... maybe... we can get these guys to join the forum and have good geometry fun with us.  Essentially, we bring 'em on-board and hug them until they submit to our evil wonderful plans.  :D

 

Thoughts?

 

I can also email Mr. Hart as a NON-representative of BJS, and just "test the waters", too.  (offering-up a few hypothetical usage situations for him/them to comment-on).

 

Anything goes, guys.  Let me know if/when/where I can be of service, I am more than glad to do it.

Link to comment
Share on other sites

You are right Wingy.

We need to ask them gently. And I don't think this kind of smart people want some money (maybe I'm wrong).

 

I can also add a link to the copyright terms of Hart and explicitly write that, according to these rules, the BJS user can only use the extension file in a non-commercial project unless they (Hart/Stemkoski) accept. Don't know ...

 

Waiting for their reply, I don't change anything for now.

If they don't accept, I will detail the copyright terms on the extension site (it's then the user responsibility to respect them) and I will probably just recompute the internal provided polyhedron coordinates  by my own (or lower their number) or get them already computed from somewhere else on the web (there are plenty of websites about this).

And maybe I will just get the same results from another source.

 

 

[EDIT] I just added something about the rights in the doc : https://github.com/BabylonJS/Extensions/blob/master/Polyhedron/readme.md

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