Jump to content

Character on Planet - rectangle around cube


JackFalcon
 Share

Recommended Posts

Hello, this may be a fun challenge for someone with cool results.

Below is a Playground of a rectangle orbiting a cube.

How to make the rectangle rotate in parallel to cube surface? (orthogonal).

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

Details: a cube is rotating on the X Axis, a rectangle has a Y position change off a Raytrace, emulating gravity, like an old time record-player.

Goal: rotate rectangle to be parallel to rotating cube.

Guess: Perhaps a specialized rotate from ray.direction to mesh.rotate.

Problem: Half the time the rotations are correct (parallel), with cube on a margin,  and half the time the rectangle length is perpendicular to the cube, intersecting. That is the challenge.

Guess Details: the needed rotation appears to be a conversion from : ray.direction into mesh.rotate() <- But I have not discovered that part yet.

How to do that? 

 

The notion is for an example of a Character to be able to roll a Planet. And maybe there is a better way?

Thanks-much,

 

Link to comment
Share on other sites

@Gijs  That is great, thank you.

The highlight or visualize the Ray, was very helpful, (Ray Visible). See Ray Helper: http://www.babylonjs-playground.com/#ZHDBJ#37

And for the ju-jitsu.... LookAt(); 

Cool solution:

var normal = pickInfo.getNormal(true);
                rect.lookAt(rect.position.add(normal), 0, Math.PI / 2, 0);

researching.add(normal), thanks for that. +1.

 

Link to comment
Share on other sites

(I deleted the post above because it contained an error I had to fix first)

I tried a cylinder instead of a box, but it gave some unexpected rotations along the way:

http://www.babylonjs-playground.com/#IHBB35#4

But it works right this way:

http://www.babylonjs-playground.com/#IHBB35#6

So if the first method causes problems in your situation, you can try the second (but you should replace the unnecessary new vector with a constant). I'm going try to figure out why the first one behaves that way. Good luck with your project.

Link to comment
Share on other sites

Wow, really cool @jerome. Memorizing... got it! 

Multiple new tools-> adopted. : )

 

Two things came up looking into LookAt()... 

* character flips upside-down (because y+ for lookAt) ->

- How to switch looking face (y- for lookAt)? Keep it orthogonal. looking into that.... (dropped into .max code === wonderful).

-  Possibly import character upside down, init() {lookAt} (reduce code). ok.

* @Gijs included a pitch-correction above (good tip). Like +1.

- A roll-correction might flip over ...(trying). But calculations.

Last, with a normal position from target rotation....

-Is there a way to match normal from cube (ground)  into character rotation? 

Found this: https://www.babylonjs-playground.com/#16YOIL#4

RotationFromAxis()?

Maybe...

...

Digging on those...

I'll post what turns up.

Thanks!

Link to comment
Share on other sites

Solved. will post solution l8r... turned out to be pretty straight-forward.

Hard-coded the rotations to the animation-states (Light & easy).

Just need to finish all the conditionals and clean-stuff-up!

Link to comment
Share on other sites

Hello,

    Here is a link to a Planet built with BabylonJS. With help from @Wingnut and @jerome it explores a form of --> emulated world gravity without physics <--.

    The notion is to allow gamer ability to explore 6 sides of a Single-Bevel-Cube shaped world, or any complex polygon shaped world, by jumping over the edge!

 

     Planets are spherical --> Wait, are planets spheres or complex polygons? (I digress).

     Please, surf this world... msg me if you want the link. In progress...

       ... warning -> lasers....

Link to comment
Share on other sites

I helped with that?  COOL! (though I can't remember doing it)

Oh, did I bring the snacks to the coding session?  Maybe THAT was how I helped.  :)

But, I'm pretty sure... you can search from interstellar horizon to interstellar horizon, and you won't find a single box-shaped planet or star.  Pretty sure.  heh

Link to comment
Share on other sites

Great idea Mr. @Wingnut...

How you helped: the physics experiments (ball bounces around cube), and gravityball() and (http://www.babylonjs-playground.com/#IHBB35#7), orthogonal, and then finally the notion of "physics without physics" - which turned out to be solution. All for purpose of emulated planetary gravity...  oops (forgot to mention...?). 

Lol... : )

Link to comment
Share on other sites

OrbitRanger 1.0 - Planetary Police Patrol - Destination:  Alderon  :)  Cooooooool.  Need a bobsled model as a spacecraft?  Steal and mod your brains out.

Remember that Controller09.js from the flying bedframe?  Well, that ONCE got pasted-into a now-broken bobsled demo.  (its only broken due to .setPhysicsState calls... needing to be updated to mesh.physicsImpostor = (blah blah) -format.

SO... hmm.  You're going to need 24 thruster ports, no matter WHAT space vehicle you fly around.  It needs full Quaternion (no gimbal lock) axes rotation and translation... just like NASA's Spartan satellite (a payload-bay fittable flying gold-foiled box... that shuttle folk use to play-with, doing tests and crap).  The controller code in that PG... is badly written... needs tightening BIG TIME... but... its ready to fly a box or a boblsled... with all 24 thruster ports.  It's a damned spacecraft construction kit, with REAL fake physics!  FUN!!!  Maybe.

Just replace the bobsled with a box flyerframe.handle... and there ya go... applyImpulse festival.

Replace the many keypress listeners... with on-HUD spacecraft nav buttons... and off we go!  (so childlike, I am, eh?  I love toys)  :)

Link to comment
Share on other sites

:) Some folk are tempted to use plugin.setLinearVelocity()... to thrust-around spacecraft.  But there is something magical about using keypress auto-repeat... to fire many little thrust-puffs that accumulate energy into the vehicle.  It provides a nice ease-to-speed and ease-to-stop... like the craft has some serious mass.  Feels good.

We can linear or log-taper the setLinear\AngularVelocity with add/addInPlace/addToRef values, too... get same effect. 

In zero-g, everything happens SLOW... except in space movies.  :)  I think it takes about a half-hour to rotate the ISS 180 degrees around y.  It's a good reason to take a long coffee break.

Link to comment
Share on other sites

Yay Spartan, alright!  *nod*  http://global.jaxa.jp/projects/engineering/research/

That sds-4 at the bottom of the page... that's REALLY boxy.  :) 

Ever play Space Engineers?  That sim has a way to "crumple-up" triangular faces on mesh... making them good and damaged (sub-divider thing - maybe Catmull-Rom crap).

Then you must spacewalk, and do space-welding, and the sub-division crumples slowly re-straighten into flat panels on the spacecraft.  Pretty cool. 

You're a fine coder... E... ahem.  :)  Why import models when you can invent the first crush-able (damage-able) box in BJS?  :)

Link to comment
Share on other sites

:)

Actually, the flying bedframe resembles THIS THING:  https://en.wikipedia.org/wiki/Manned_Maneuvering_Unit

" There were 24 nozzle thrusters placed at different locations on the MMU. "

Yuh, yuh, yuh.  I think they were "cold" thrust... similar to 24 cans of hair spray duct-taped in various locations and orientations.  :D

I love precision spacecraft maneuvering, especially if I had a really nice HUD with numbers and mesh-tracking brackets and junk.

I have a movie idea... comedy... called "Docking School"... about a school for people wanting to get their space-truckers certificate.  They all need to be experts at manual docking, in case automated systems fail on their spacetrucks.  So, its just a lot of fun, as the kids are repeatedly banging-into the sides of the school spacestation... with their "docking trainers", which are built-tough to withstand such impacts.  But, during most of the entire movie... we hear bangs and have camera shakes, occasionally. :)  Fun!

Docking School - The Game will likely happen first, or never.  :)

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