Jump to content

Box rotation


Alby
 Share

Recommended Posts

Ahh, you know more than you think.

 

Looking at the latest demo, see line 251?  That is a Boite Factory.  :)  It makes a blank object (invisibly) but then 252 - 258 puts some properties on it.  A person could add more, like this...

this.mesh = BABYLON.Mesh.CreateBox(whatever);this.mesh.material = new BABYLON.StandardMaterial(whatever);this.mesh.actionManager = new BABYLON.ActionManager;this.mesh.actionManager.registerAction(new BABYLON.ExecuteCodeAction(BABYLON.ActionManager.OnPickTrigger, someFuncName ));

Two pieces.  One, a fresh blank Boite object that we start packing with crap.  The second piece... a real BJS mesh that we stored in the Boite.mesh property.  A JS Boite object... that carries a BJS object in one of its pockets.  :)

 

I'm sure there's an official programming term for this.  It's NOT overloading.

 

Overloading is different.  Overloading would be to create a bjs box, and then overload it with...

  bjsbox.x=x;  bjsbox.y=z;  bjsbox.z=z;  bjsbox.size=size;  bjsbox.image=image;  bjsbox.titre=titre;  bjsbox.type=type;

etc. 

 

Overloading can cause property and method name-collisions if not careful, as you can likely already tell. 

 

The first way... the two-piece way... is a bit safer, because Boite.mesh (the BJS) is somewhat separated from the Boite object.  For example, we KNOW there is a property called Boite.mesh (in our 2-piece method - underlined).  We know it is a BJS object, so it has a .rotation... located at Boite.mesh.rotation.  But we could ALSO have a .rotation on Boite itself... located at Boite.rotation.  The two .rotation properties would be safe from one another, because they are namespace-isolated.

 

Just like BJS itself.  How many times have we all typed mybox = BABYLON.CreateBox(whatever);  ??  It's easy to forget that CreateBox is located (domained) in the BABYLON.Mesh namespace.  The correct way... mybox = BABYLON.Mesh.CreateBox(whatever);

 

Remember that I am telling you this from a beginner's point of view, as best I understand all this.  The pro coders speak this stuff MUCH better than I.  In fact, other beginners speak it better than I do.  :)

 

It's more about JS than it is about BJS, but BJS is JS, so it all applies.  I think... if you really want a nice tumor, read about JS "closures" or something like that.  Objects tend to have API's... which is the user "interface" to the object.  You'll see some functions in framework code that look like ...  this._getSomething (with the underscore).  That underscore means that the function is not supposed to be called by users.  It is an internally-used function (but we still call them sometimes, circumventing the domain's api). 

 

Conversely, functions like CreateBox are VERY MUCH exposed and part of .Mesh's api.  Api generally means... which methods/properties are open for the public.  The BJS Scene object is a great example, and a top notch object.

 

But nah, you don't need to worry about ANY of this.... until your project gets big and fat.  For now... we're havin' good fun, and keeping our brains clear of all this coding nonsense.  Let's get back to the ART of it all, eh?  :)  And I'm quite convinced that v1 is a direction vector between vStart and vEnd... so... I see hope for the text planes (text grounds).

 

I am truly amazed that nobody has found the secret, yet.  I think v1 is our friend.  :)

Link to comment
Share on other sites

Yeah, Wingy!

 

A little light begins to come through the darkness of my mind, you are an angel of light who spreads his luminous Wing(y)s to chase away my ignorance! (I'm a great poet, isn't it!)

Don't tell me you are "Lucifer" (the greatest angel of light)? :o .... No, too modest for that! :)

 

Let us be a little serious (I try and it happens!):

 

For our text plane orientation, seeing that it must be double face to be always readable , I suppose we can use the Jerome "front/back/double side light reflection"

 

http://www.html5gamedevs.com/topic/12506-frontbackdouble-side-light-reflection/?hl=%2Bdouble+%2Bside

http://www.babylonjs-playground.com/#K6SNA#14

 

with a dynamic texture on it (in our case text), isn't it?

Link to comment
Share on other sites

Yes, you bet.  Double-sided is certainly an option, and so is cloning the front plane and placing the clone on the back side (after rotating the clone 180 degrees around the Y axis). 

 

The "smart plane" I mentioned earlier... is also an option.  This smart plane would monitor the viewing angle of the camera continuously (in the registerBeforeRender animation loop), and when the camera is looking at the back side, it places the dynamicTexture on the back (probably by using some properties on textures called uOffset and vOffset).  Same for front side.  The smart plane watches where the camera is, and moves its texture when needed.

 

DynamicTexture is a subClass of texture, so it inherits uOffset and vOffset. 

 

That's advanced robotics, though.  :)  Text planes that are camera-position aware!  Cooooooool.  Fancy!  We might get there.  Essentially, it would be a "look at" or a "billboard mode" made specifically for textures.  It moves the texture around on the mesh (in 180 degree steps), but doesn't move the mesh around in space.  Coooool.  Maybe we'll try that, later.  :)

 

Remember how this all started?  It started when Wingy needed to use GROUNDs instead of planes.  (I needed a text plane with both a width and height setting.)  This is because when I used .scaling on a regular plane, it caused the dynamicTexture (the text) to stretch/distort.  When I changed from CreatePlane to CreateGround, it broke planeBetweenPoints().

 

Way to break stuff, Wingy!  :/

 

Something tells me that the use of a quaternion in planeBetweenPoints... is a mistake, here.  Or possibly just not needed.  Still investigating.  We might need a new forum topic, because I don't know how many transformation experts are reading this.  I've probably scared them off with my yapping.

 

Today, house cleaning.  :)  Tomorrow... there will be a post here from one of the transformCoordinates experts... and a new groundBetweenPoints() function... that fixes our textplane rotation problems.  Please God Please!  hehe 

 

But know that it has been very enjoyable talking with you, Alby, and with the others who have participated in this topic.  Only 178 comments to go!  :)

Link to comment
Share on other sites

@Alby : If you use a double-sided mesh, well, the texture will be visible each side as light reflection.

But your text will be the same orientation both sides :(

The double side option doesn't invert the texture on the second face.

 

About positioning your text planes, I just opened this topic : http://www.html5gamedevs.com/topic/14309-meshlocateorigin-axisx-axisy-axisz/

Link to comment
Share on other sites

Ahh, this thread had a baby!  Alright.  Our social club is growing, Alby.  :)  Thanks for the help with this, Jerome!  I know you have other projects going, but, I'm 100% onboard transformation tutorials.  (Yay Transformation Lab v1)  ;)

 

I think slow-motion is important in visualizing transforms (very hard to do, I think).  We need a tall toolbar... showing readouts of the current view matrix, and a highlighted mesh's worldMatrix, and the projection matrix, and two user matrices that we can do math stuff upon... and maybe see the results.  We need arrows, we need tri-grids, we need readouts, we need simple demo mesh, we need a quaternion warning system... in case the quaternions attack, and we are going to need 2000 LBS. of Purina Puppy Chow. ;)

 

That's an insider ref, Alby.  Deltakosh once wrote a funny blog entry talking about some heavy-demanding new BJS users he once had to deal-with, and he referred to them as "puppies". :)  So, it has become a running joke.  I'm a proud puppy, yet I try to be helpful and not over-demanding.  But sometimes, I still lean-on DK more than I should need-to.  He's treated me great...  no matter how whiney I get.  Pretty cool.  Really cool, actually.

 

Puppychat!  Yay!  Playground Puppies!  We need petting!  Rotational petting!  :)  We MIGHT be getting close to saying goodbye to standard bjs planes and/or grounds.  We may soon "plot" our own text planes. Wow!

 

Let's say we used SC's rho, theta, and phi... to make a "radial" sticking out of the center sphere.  We can't see it, but it has a 'direction' and a 'magnitude' (a length) which is the same as rho, I believe.  Then we MAKE an invisible plane by plotting our own points that are "aligned" with our new invisible radial.  THEN... we use this as the parent to the real text planes.  We will be able to "slide" the text planes up and down the radial... or make them as long as the radial... anything.  Radial = spoke.  We just need Jerome (or anyone) to tell us how to plot those points... along that radial.  (in-line with it)  Or, we need to "hack it out" ourselves.  All the tools we need.... are in the framework.

 

Hopefully, when we are done... textPlane.position.x will be WHERE (how far from the sphere) on the invisible radial... the textPlane lies.  Y and Z are predominently un-used.  Right, Jerome?  textPlane.position.x = 0 means the left edge of the text plane is at sphere center.  x = 50 means that the left edge... is 50 units away from the sphere center... but we're still on the radial.  THAT... would ROCK!  :)

 

The new baby-topic is getting a lot of attention.  I'm not going to talk over there.  That should help ensure the baby-topic's success.  ;)

Link to comment
Share on other sites

@Jerome : thank you for opening that new post more general about the problems encountered by one of my requests (and surely others users requests), hope it will bear fruit for all the community.

 

 

Wingy,.... we need a tall toolbar...and so on.... , but we need mostly Wingy, especially puppies like me! :D

 

Sure you are also a good prophet (combined with an angel, classy! ;) )....

With your description of the near future of text plane I see already mine oriented with my tought in a holographic way in the middle of my living room!

Ready? I've got great confidence in you! you'll find the soluce!

Link to comment
Share on other sites

  • 3 weeks later...

Cool!  How did it turn-out?

 

@Everyone in our social club:  We've all wandered-around with "the spawned topics" from here... (the kids)... how was it? 

 

Do you think it's time we bring this thread back to the top and get back to milking our HOME issues?  Huh?  :)  For cryin' out loud!  (whatever the hell THAT means)

 

Ok, let's see... Alby's wandering around trying to make a library of functions... um... Jerome has "run with" the AlbyText plane issue... and I think it caused him a tumor and he went to the Bahamas for 3 weeks.  Nice.  Dbawel... I think HE is still sane... amazingly enough.  But he has kept his distance from AlbyPlanes... and thus might not be affected by the disease/poison.  ;)

 

I think Alby is living in the woods these days... unkempt... raising a pride of wolves, I hear. 

 

"Can you still hear us, Alby?  Come come come... we have food and computers... c'mon out-of them woods."

 

Me?  Still working that storage building from hell... every other day... and getting behind on my BJS workplay.  Sigh.  PARTY!!!  (ahem)

Link to comment
Share on other sites

I certainly am not sane.  I thought I'd be able to build a node.js server and a multiuser real time app in a week, and was sorely bitch slapped.  I haven't gotten HTML labeling working in the script yet, but I'm close.  There is an example of what I'm doing in a seperate post, and I'm stuck on using a ground object as opposed to a plane that I can transform.  Any help would be appriciated.  :wacko:

Link to comment
Share on other sites

Please, consider this scene : http://www.babylonjs-playground.com/#VYM1E

I have here two spheres at given positions.

I want to set a textured plane from one to the other sphere and I want this plane to always face the cam.

I don't know anything about angles or whatever :

 

http://www.babylonjs-playground.com/#VYM1E#1

 

Does it work with animated mesh in a render loop too ?

yes, sir : http://www.babylonjs-playground.com/#VYM1E#2

 

 

up to you now, Alby ;)

Link to comment
Share on other sites

Perfect your demo!

 

Thank you, Jerome, but for me no fire in the house! ;)

 

Maybe possibility to have like BABYLON.Mesh.BILLBOARDMODE_ALL a new mode called  BABYLON.Mesh.JEROMEREBASE_ALL?

Just an idea! (don't kill me Jerome! ;) )

Link to comment
Share on other sites

COOOL! 

 

Ah, but Jerome, you need to put some text on your plane, so we can see if it is always upright.  I bet it ain't.  :o

 

Aside:  Hey Alby/gang, have you seen a picture of Jerome?  He's got the face of a friggin' movie star! 

 

Jerome, what the hell are you doing in IT and not making the big bux in motion pictures?

 

(though I am super-glad you are here in IT with us!)

Link to comment
Share on other sites

:D

For the text orientation, since it is mandatory to have a different texture each face (else it will be read from right to left), I think the best way, would be to have a face with the current text and the other side with the text simply upside down.

Test with a tiny paper : write the same text both faces, the first face normal, the other face inverted upside down, then rotate your paper around its width, you'll ever see the text upright

You see what I mean ...

Quite easy.

I let Alby having fun (I hope) with this :)

Link to comment
Share on other sites

Well I tried to "hijack" Jerome function to suit it to my project, but it seems I have a little problem :

 

http://www.babylonjs-playground.com/#12ZRI0#11

 

Labels are well oriented, not a problem with Jerome function but surely with mine (FacedLabelBetweenPoints - line 111) seems it doesn't take in account my redSphere (Mesh1)...

Surely something I missed....(brain? ;):(  ),..

 

 

 

I stop now searching where is the bug (mine) but tomorrow I come back, I'll sleep on it!

Link to comment
Share on other sites

Hey dude... you got shish kabob skewers sticking out of your skybox  :)

 

You're doing well, Alby!  I hope you still have the "fun challenge" attitude... because...  you're going to win this one!  You're just inches away.

 

For now, if I were you, I would not place striders from box to box.  I think you should experiment only with sphere-to-box striders... at this time.  *shrug*

 

Maybe.  :)

Link to comment
Share on other sites

Hi Wingy!

 

Seems Inches are long inches!... for the moment! ;)

 

http://www.babylonjs-playground.com/#VYM1E#3

 

I try this with jerome function demo a little "tuned", it works...

but with scene.registerBeforeRender(function() line 197 (I had forgot to take in account in http://www.babylonjs....com/#12ZRI0#11 )

seeing it takes only the last call of "my" function - line 200, I wonder how to put callings functions in a loop

 

Label are not yet from left to right, tried invert - line 174 but it is not yet the soluce...

 

A little advice Wingy (or Jerome)?

Link to comment
Share on other sites

Ok, what?  I'm confused.  I see inverted text.  Am I supposed-to?  And why is that box so +Y?  I had to get a ladder to climb up there!

 

Are we waiting for Alby to write a new createTextPlane(name, startAtMesh, endAtMesh, planeHeight, textTexture)  ??   ;)

 

And inside THAT function, he'll do two-sided?  errr?  Where am I? 

 

And yeah, thanks Jerome.  I'm seeing lots of cool production coming from you... I want to study ALL OF IT!  I'm going-to, soon.  You're taking the crucial steps needed to make a "transformation workshop" where folks can really learn this stuff fast and easy.  Excellent!

 

What do you think, Albinator?  boite.spanner = createTextPlane(blah blah blah) ??

 

Or, maybe...  boite.spanner = new AlbyTools.Spanner(blah blah blah)     That's looks better, eh?

 

If you'll notice (even in BJS framework)...  when the function has the word 'create' in it, don't use 'new'.

 

I smell a mad scientist at work!  I think Alby is brewing-up some kind of game plan in his laboratory.  Look out!  :)

Link to comment
Share on other sites

Not yet (for the laboratory), just in bed with a bad attack of flu,... stewed brain... but I ll come back, you are not yet got rid of your nightmare, Wingy ! ;)

 

Have a nice WE (surely better than mine!)

Link to comment
Share on other sites

Alby, I LIKE having you around!  You're funny, and you keep the tech from getting too serious.  Some of these guys are doing things with an eye on money/corp, and they are a little tense.  They want forum answers RIGHT NOW, and no room for frivolities.  I can understand that, but, sometimes it takes the enjoyment out of projects.  Your project, Alby, has been COMPLETELY enjoyable, so far.  We have all gotten to learn things, and we've been able to see some stumbling points that we can try to iron-out for the future users... it's all excellent.

 

The only bummer... Alby is sick!  That totally sucks!  GET WELL SOON, buddy! 

 

How about a song of the old-west mesh drives?  Would that make you feel better?

 

Rawhide! 

 

---------

Keep movin' with collision...

Quite a poor decision...

Bounding box precision...

RAW MESH!

 

Don't try to understand 'em,

just rotate, move, expand 'em.

You'll need... Jerome right by your side.

 

All the things we're making...

realities we're faking...

...are waiting at the end-of... our ride.

 

Head 'em up, move 'em out,

Move 'em on, head 'em up

Head 'em out, move 'em on...

RAW MESH!  (whip crack, etc)  :)

---------

 

Just goofy off-topic social junk, eh?  Yep, in our enjoyable "gather-around Alby's campfire" knitting and quilting club, the knitting and quilting is just something we do between great conversations.  Eat your hearts out, heavy techies.  :)  (they're jealous of us)  Jerome is kind of techie, but he's a mesh wrangler, so he belongs with us, here, on the lone prairie.

 

PS: Dbawel... you're still in the club, too... but you wrote three great posts that scared the dog.  Yeah, we're with you, regarding linear algebra and similar subjects, but, we're going to need some excellent visualization tools to help us learn these things.  Thank goodness we have BJS... ready to create such tools...  for free.

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