MehdiZagouri Posted November 5, 2017 Share Posted November 5, 2017 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. Quote Link to comment Share on other sites More sharing options...
Arte Posted November 5, 2017 Share Posted November 5, 2017 @MehdiZagouri can you create a playground example? it will help us understand your problem. Quote Link to comment Share on other sites More sharing options...
dbawel Posted November 5, 2017 Share Posted November 5, 2017 @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 Arte and MehdiZagouri 2 Quote Link to comment Share on other sites More sharing options...
Wingnut Posted November 5, 2017 Share Posted November 5, 2017 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. 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. MehdiZagouri 1 Quote Link to comment Share on other sites More sharing options...
max123 Posted November 7, 2017 Share Posted November 7, 2017 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. Wingnut and MehdiZagouri 2 Quote Link to comment Share on other sites More sharing options...
max123 Posted November 7, 2017 Share Posted November 7, 2017 On 05/11/2017 at 11:22 PM, Wingnut said: It's a cool question, though, eh? Make it take step-by-step? Make it act like a ramp? I used a ramp. MehdiZagouri 1 Quote Link to comment Share on other sites More sharing options...
MehdiZagouri Posted November 7, 2017 Author Share Posted November 7, 2017 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. Quote Link to comment Share on other sites More sharing options...
Wingnut Posted November 8, 2017 Share Posted November 8, 2017 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. Quote Link to comment Share on other sites More sharing options...
BlackShadauw Posted June 7, 2018 Share Posted June 7, 2018 @max123 Thanks a lot for your very helpfull setCollisionsByPrefix. I was looking to have nice functionable stairs, now it is Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.