Jump to content

which camera to use for rollercoaster


jerome
 Share

Recommended Posts

Hi,

 

I'm currently coding a PG path3D use case.

 

I would like to show a rollercoaster  : http://www.babylonjs-playground.com/#1JPPXD

(path3D model with tangents, normals, binormals on left, final rollercoaster mesh on right)

 

Actually, I would like to do something like this threejs demo when you click on "pline animation ON"  http://threejs.org/examples/#webgl_geometry_extrude_splines.

 

As I didn't investigate BJS cameras so far, I wonder what kind of camera I should opt for : a TargetCamera ?

 

 

My needs are :

  • the cam can be positioned dynamically in space, this position can't be modified by user controls (keyboard, mouse)
  • the cam can aim a target (vector3) or else (don't mind wingy  ;) ) can aim with an axis (vector3)
  • the cam can be rotated/aligned in space, so I could make follow the rollercoaster rails curve... or maybe should I set it in a rotated parent mesh ?

Any clues appreciated :)

 

[EDIT : in the threejs example, the cam doesn't rotate with the curve]

Link to comment
Share on other sites

from the docs:

 

  • FollowCamera - Forum user AlexB was kind enough to contribute the handy FollowCamera to Babylon.js. (Thanks AlexB!) This camera is specifically designed to follow any scene item with a .position... as it moves. It can be set to follow from the rear, from the front, or from any angle. Its follow distance and movement speeds can be set, as well.

I personally never used it and never tested it so.... no idea how well it works. But it works for sure :-)

Link to comment
Share on other sites

As far as I understand, the follow camera ... follows a mesh at certain distance.

 

I want to set my camera at a given position because I compute this position according to the path3D. Idem for the camera target ...

Link to comment
Share on other sites

I would do the following:

- Create a box at a given position

- Create a followCamera, which target is the box above

- Set the box invisible

- Move the box according to the path3D, the camera will automatically follow.

 

And you're done.

The followCamera is easy to set up:

camera.radius = 4;camera.heightOffset = 1.5;

The camera will rotate accordingly to its target.

Link to comment
Share on other sites

mmmh...

I really don't get how cameraDirection works

 

 

(added interpolation now, so the movement is smoother)

 

Look at this : http://www.babylonjs-playground.com/#1JPPXD#4

line 124 : the camera direction is set towards the origin what is a point on the ground where a wagon leaves.

Yet the camera, positioned at pos, doesn't look toward the wagon.

 

Am I missing something ?

Link to comment
Share on other sites

seems to work better when using setTarget instead of this weird cameraDirection: http://www.babylonjs-playground.com/#1JPPXD#5

here, the target is a point at 20 further (dt line 93) and the interpolation step is only 2 (line 99)

If you want more steps to go from segment to the next one, then the camera seems to shake (step = 10 ) : http://www.babylonjs-playground.com/#1JPPXD#6

 

 

grrrrr... camera problems !!! :angry:   the path and animation seem to be working

 

I probably use the wrong camera or the wrong property values...

Link to comment
Share on other sites

If you wish to do something like this:https://googledrive.com/host/0B6-s6ZjHyEwUfkRGTUVVTUxaT01UZUlieGdCODF1blFZZHJFMnRJUHBpcG1KcnBjUVluYXc, then use either targetcam or freecam with no attach.  You need to set camera.lockedTarget on the mesh to aim at.  I think you also still need to shake up camera every time mesh moves, by calling camera._getViewMatrix()

Link to comment
Share on other sites

Well, my camera is moving along the rollercoaster rails and it looks (choice to be done in the code) either at a certain number of points farther on the rails, either in the direction of the current tangent to the rails (vector).

 

So there is no real locked target, like a distant moving or static mesh, since the camera direction changes according to its own position only.

 

What am I suppose to do with the cam viewMatrix then ?

Link to comment
Share on other sites

Since I can't have the cam working as I expect for now, here is a first roller-coaster demo (no subjective POV) introducing some new BJS features for 2.1 I'm proud to have contributed to :

 

Curve3D + hermite spline

path3D

extrusion

rotationFromAxis

 

http://www.babylonjs-playground.com/#21EWAB

 

still investigating to have some smooth subjective view

Link to comment
Share on other sites

As far I understand, the lag occurs each time the value of the target given to setTarget() changes.

Maybe is it a too big difference between two successive values ..?

 

I would like to use cameraDirection instead, but it doesn't behave as I expect (I think we give an axis)

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