Jump to content

How to camera go upstairs !


MehdiZagouri
 Share

Recommended Posts

@MehdiZagouri -

As @Arte requested, please create a playground scene so we can understand the end goal. Otherwise, there are many methods to model "stairs", but there are far too many variables here to say what the best method is until we understand the application. Also, why is it an issue to move the camera "upstairs" as there is no such thing as upstairs - only a camera position / translation.

DB

Link to comment
Share on other sites

It's a cool question, though, eh?  Make it take step-by-step?  Make it act like a ramp? 

Tilt camera UP the incline when ascending, and DOWN the incline when descending?  Camera stays free to turn and tilt during the entire trip? (How? Make camera parented to invisible mesh, then move mesh up/down the stairs?  Maybe yeah!)  ;)

We had an escalator playground demo around here, somewhere.  Where was that puppy?  Oh yeah... right here.

There are camera-animation trigger-sensors on each end of the ride.   I'm sure this can be done "slimmer" and wiser.

When approaching top sensor for a ride down the escalator, you shouldn't look downward too much.  If you do, your nose will get hooked on the sensor and the belt will suck your brains out-of your nostrils.  :D 

Or, maybe not.  :)  In brief, if you get "stuck" on a sensor, you are probably not very level-headed.  heh.  ahhhh... camera comedy, gotta love it.

I know, I know, escalators are off-topic in stairs discussions.  *sigh*    Aside:  Hiya @dbawel... good to see ya!  Hi to @MehdiZagouri and @Arte, too, of course.

Link to comment
Share on other sites

On 05/11/2017 at 6:42 PM, MehdiZagouri said:

Hi,

I created stairs using CreateBox , i'm asking if it's the right way !

And i'm asking also , how can i make the camera go upstairs !

Thank you for your answers.

I've made something like this and it's working fine for my needs. Here are the steps I took (do you geddit? steps?):

1.

- Create model in Blender. 
- Define simple meshes in Blender for collisions (mostly Planes). So for your staircase you'll use a rotated plane.
- Give a certain prefix to those Planes, e.g. "collider_". 
- Export .babylon.

2.
Loop through the meshes and apply required properties to all meshes with prefix "_collider":

public static setCollisionsByPrefix(prefix: string, scene: any): void {

    for (let i = 0; i < scene.meshes.length; i++) {

        let mesh = scene.meshes[i];
        if (mesh.name.indexOf(prefix) === 0) {
            mesh.checkCollisions = true;
            mesh.visibility = 0;
            mesh.isPickable = false;
        }
    }
}

3.
Apply Scene/Camera settings:

scene.gravity = new BABYLON.Vector3(0, -.5, 0); // You might want to play with the Y value.
scene.collisionsEnabled = true;

camera.ellipsoid = new BABYLON.Vector3(.5, 1, .5);
camera.checkCollisions = true;
camera.applyGravity = true;

 

You see the pink bits? These are collision meshes in my Scene.

5a01b75174eb4_ScreenShot2017-11-07at13_37_04.thumb.png.aaf7cf9ed6dd83f71b7580d277c3de08.png

Link to comment
Share on other sites

Thank you for your answers !

@Wingnut thanks you for the solution ! but i don't need a ramp ! i need normal stairs , right in the picture ! ( i don't know how to create a model ).

@max123 i need to create stairs like you did ! i never used Blender, and i have no idea , the time to finish my project pressed me, so i don't have much time to start from the zero.

 

Macdonaldtown_Railway_Station_stairs_to_platform.jpg

Link to comment
Share on other sites

Hi again.

     A playground-search for in-code occurrences of 'stairs'... produced some results.

One of the results was this... https://www.babylonjs-playground.com/#4G18GY#12

In this tasty playground, we see two usages of the BJS ExtrudePolygon feature.

Generally-speaking, extrudes need two primary values... shape, and depth (and depth is sometimes called/related-to path).

In the demo above, the shape (the side-view outline) is created with math... in lines 51-77.

You can open your browser console and see the shape array (un-plotted) via line 79.  Remember: the stairs array is the shape that is used in the extrude.

The stairs array (the shape) is a JS array containing 54 Babylon.Vector3 objects, which "plot" the shape of the stairs... in "worldSpace". 

BUT... there are no "Y" values set in ANY Vector3... throughout the entire shape generator code (51-77).  It is a shape that is flat on the ground (sort-of), just like a house blue-print/floor-plan.

Then, in line 81... KABOOM... our extruder goes to work, using shape and depth!  Magical!

Line 82-86 position and rotate the staircase.  PARTY!  I didn't create this scene.  I found it with our cool playground searcher page

Note:  This is a small scene, units-wise.  Use camera.wheelPrecision = someNumber;   ... to adjust mouseWheel smoothness.  SomeNumber = 200 is a good start, and don't forget control-dragging... to slide-around the camera.target (slew/strafe the camera).  Good for stairs close-examination.  Get TOO close, and camera.minZ becomes a factor.

Hope this helps. :)

Link to comment
Share on other sites

  • 6 months later...

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