Jump to content

Rays/rotations/directions


max123
 Share

Recommended Posts

hehe... you and getzel are working on lookAt and billboardMode at the same time.  Getz is wondering why lookAt and billboardMode use only Quats and don't report in Euler at mesh.rotation property... like camera.rotation does with a set .target does.  Protractor ops.  :)

ANYWAY... all that crap aside... I have some stolen SC/Cartesian stuff in:  http://www.babylonjs-playground.com/#J6ZLH#3

See lines 45-57.  It is used in the particle system custom start-position function in lines 10-16.  It makes the dome-o-particles.  Not my code.  Creds included in source.

Hope this helps.

Link to comment
Share on other sites

Ok, let's look at this nightmare playground you have going here.  Not sure why you are wanting spherical coordinates... but let's see if my little mind can figure this out, or beg to the correct forum helpers.

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

I didn't change much of anything.  I just started studying your ray.  Every time I have used rays, I follow it with a scene.pickWithRay... but that is just used to gather a wrapper called pickingInfo/pickInfo.  So, I thought about your custom ray.  There is lots of contorted math going-on in the ray2 function.  All of it is over my head... but, I guess that is where you wanted to use spherical coords.  It's all algebraically cool with me. heh

Here is one small thing that my pee brain saw, though.  var r2 = new Ray2(box.position, box._rotationQuaternion.toEulerAngles(), scene);

Hmm.  Are you trying to get the direction a mesh is facing, using its gotten-from-quat euler .rotation value? 

I'm no pro, but doesn't the 2nd param need to be a direction instead of an orientation?  Do you possibly need to use the rotation values... to calculate a "forward vector" first, and then use THAT as the ray's 2nd param?  Possibly, you need to convert a rotation, to a direction?

This crap makes my brain hurt, but I'll do guessing with the best of 'em, too.  I don't mind embarrassing myself in public.  :D

Hopefully, smarter people will comment, soon.

Link to comment
Share on other sites

What I'm trying to do here is to visualize a Ray. :) Since my math is abysmal, doing so will help me (and hopefully other mathematically-challenged devs) see if my Rays are indeed going in the direction I intend them to go. BTW, you've lost me on direction vs orientation question... Aren't they the same thing? :) 

Link to comment
Share on other sites

[Wingy hugs transformNormal... cuz Deltakosh saved Wingy's big fat project... with that, years ago.]  :)

When you make a spacecraft... using physics applyImpulse vernier thrusters for 3-axis attitude control, you need transformNormal MUCH.  The spacecraft can get Quat-rotated in any strange orientation, but when it comes time to TRANSLATE (position, not rotation)... you want the thrust to come directly out of the side, bottom, front/back... of the spacecraft.  The needed force-vector for .positional impulsings... needs to be transformed by the current craft.rotationQuaternion... or else the positioning thrusts won't happen in the correct direction.

http://www.html5gamedevs.com/topic/20350-moving-and-rotate-a-physic-object-from-a-newbie/?do=findComment&comment=115583

A little talk about my flyer.  (snore).  Top section of code... looks similar to DK's solution...  transformNormal. (yay)  Designed specifically for keeping ducks in a row.  Keepin' ya squared-up with your locals.  :)

Link to comment
Share on other sites

Thanks, @Deltakosh! It's working... Almost :)

Here's another PG: http://www.babylonjs-playground.com/#1NE4XO#11
If you look at line 32, the function r2.getRay().intersectsBox(b2._boundingInfo.boundingBox) returns false for some reason.

On the side note, I think the title of this topic is now misleading; it would be useful for others of mods renamed it to smth like "Rays/rotations/directions"

Link to comment
Share on other sites

Hi Max and fellow campfire projecteers.  :)

http://www.babylonjs-playground.com/#1NE4XO#12

Watch console.  It appears that your white lines are not aligned with your ray.  Ya got a little troubleshooting still to do.  :)  Good luck.  Cool project, by the way... I really like it.  I can foresee a future Babylon.Tools.showRayLines(ray) ... feature.  Soon, you're going to earn your "BJS Core Contributor" merit badge.  ;)

Link to comment
Share on other sites

"Tie me picking ray down, sport... tie me picking ray down."  :D

Good news, for ya.  Rumor has it that you already got your BJS Core Contributor merit badge... because you got "co-creator" rating on the new multi-picking feature.  Congrats!  :) 

Max:  a cleaner solution would be an all-penetrating ray returning an array of pickedMesh objects ordered on hit-first basis.

Deltakosh:  Please let me introduce: scene.multiPick and scene.multiPickWithRay:  http://www.babylonjs-playground.com/#7CPS7

You guys rock!  Thanks to you both!  Well done.

I got CC merit badge with light.setDirectionToTarget() ... line 70 here.  I didn't code it, but it was something I needed, and I found the solve on the web.  Then Deltakosh asked if "we" could use it for core, and I was SO PROUD that I nearly died! (I'm a bit of a simpleton - I get excited over little things, sometimes.)  heh.  (Wingy uses a power buffer and a little Carnauba wax on your shiny new badge.)

Link to comment
Share on other sites

Ha-ha, I'm hardly a "co-creator" - it was Delta who implemented the whole shebang, - but thanks!! :)

Back to the ray... It looks like it returns "false" where it should return "true" because box2 is moved: if comment out line 25 

b2.position.x = -2;

then everything works as expected. Is there a way to tell BJS's engine "hey, the position of this bloody box has changed. can you now update yourself please and stop using the old pos for calculations?"

Link to comment
Share on other sites

Ahh, but are you assuming something, here?  Even when the thing was clearly not working right... you were getting TRUE when the white lines shoot straight down.

Now you move the box to directly under the white lines, and suddenly... you think the ray is working correctly.  But really, its doing exactly the same thing... showing true when white lines aim -Y-ish.

I would look for a problem with your ray never getting aimed at all, and thus stuck in straight down condition.  *shrug*  I think ray direction != white lines.

Ya know... your project is really a two-piece thing.  One piece is... view a direction vector as a linesMesh with arrowhead with vector magnitude==line length.

The other piece is "playing with rays"  :)

But direction vectors... really don't have an origin, right?  No starting point, but their ending point is magnitude away-from its starting point... which doesnt exist.

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