I'm slowly figuring all this out. The current issue is that no matter what I set for position, scale, etc. the player camera is always 200+ units above a flat plane. The mainScene is just a scaled flat plane that has additional heightmap objects added with it (via SceneManager.Items). All the added items are modeled 1:1 scale wise. All the game objects except the player are loaded via x3dv files....a link to something explaining these sizing issues, how to make the player (walkcamera) not tower above everything at 12x it's scale would be great.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
If you don't set any camera position explicitly, then we will take the position from the Viewpoint node in the scene set as SceneManager.MainScene. There are various ways how create an X3D file with a Viewpoint node, e.g. you can export it from Blender (Blender's camera will determine Viewpoint), or you can navigate using view3dscene https://castle-engine.io/view3dscene.php and use "Console->Print Viewpoint..." options to generate a viewpoint that you can manually paste into X3D file.
If there is no Viewpoint (or no MainScene assigned), then we automatically calculate a default camera to see the whole world. From your description, this is what happened.
You should use one of the above methods to set camera. It's probably easiest to start by calling SceneManager.walkCamera.SetView(...) or SceneManager.ExamineCamera.SetView(...).
Ok am now attempting to use the AbstractViewPoint example you used in a different thread to set the initial view for the Camera. 3 Scenes - a base scene (flat plane, skybox - loaded first), Structures scene with 4 objects at different spots on the plane and a "viewfrom object" (currently a cube with a named viewpoint on it.) I'm able to bind the viewpoint, but not figuring out the setting the camera to the viewpoint part. I want to bind the camera to the viewpoint so that as the (cube) moves, the camera translates with it.
Last edit: Kelly Asay 2018-05-16
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The first Viewpoint node in the X3D file is automatically "bound", that is: "connected with camera". So if the Viewpoint node position is animated, the camera will move too.
To explicitly "bind" another Viewpoint node, call TViewpointNode.EventSet_Bind.Send(true).
From your description, I don't see what you are doing wrong, so I cannot tell exactly how to fix it :) Hopefully the information given helps. If not, please submit a (simple) testcase (code+data) to reproduce the problem.
Note that to make some 3D object "glued" to the player, it's usually easiest to use Player.Add(Some3DObject) approach described on https://castle-engine.io/manual_player.php . If you want to have something like a weapon or torch "glued" to FPS player, and the player navigation moves this object, then this is better. But I don't know if this is what you need -- just pointing out, in case it is useful:)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
That was very helpful. The camera didn't seem to initialize from the x3dv file so I did it manually. It isn't bound to the node since it can still walk around (WalkCamera), but made step one! The vechicle (cube) will own the player which is basically stationary on the object with the ability to rotate and look up/down. Movement will be via the vehicle (cube).
I'm stepping through the code to get a better idea of how the Viewpoint binding works. Thank you for your help, rare in developers these days.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Note that if you move the vehicle by code, you can also update the camera by code. That is, you can use OnUpdate event (see https://castle-engine.io/manual_quick_2d_game.php about events) and just call SceneManager.WalkCamera.SetView(...) there, every time, to update the camera to be "glued" to the vehicle. In this case, you don't need to worry about where is the Viewpoint node in X3D.
So, there are many ways to do this :)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I'm slowly figuring all this out. The current issue is that no matter what I set for position, scale, etc. the player camera is always 200+ units above a flat plane. The mainScene is just a scaled flat plane that has additional heightmap objects added with it (via SceneManager.Items). All the added items are modeled 1:1 scale wise. All the game objects except the player are loaded via x3dv files....a link to something explaining these sizing issues, how to make the player (walkcamera) not tower above everything at 12x it's scale would be great.
The camera is at the position you have set by instructions like
SceneManager.WalkCamera.SetView(...)orSceneManager.ExamineCamera.SetView(...)SceneManager.RequiredCamera/WalkCamera/ExamineCamera.Position := ...;If you don't set any camera position explicitly, then we will take the position from the Viewpoint node in the scene set as
SceneManager.MainScene. There are various ways how create an X3D file with a Viewpoint node, e.g. you can export it from Blender (Blender's camera will determine Viewpoint), or you can navigate using view3dscene https://castle-engine.io/view3dscene.php and use "Console->Print Viewpoint..." options to generate a viewpoint that you can manually paste into X3D file.If there is no Viewpoint (or no MainScene assigned), then we automatically calculate a default camera to see the whole world. From your description, this is what happened.
You should use one of the above methods to set camera. It's probably easiest to start by calling
SceneManager.walkCamera.SetView(...)orSceneManager.ExamineCamera.SetView(...).This is documented in the manual, https://castle-engine.io/manual_load_3d.php , see section "Set the camera" :)
Ok am now attempting to use the AbstractViewPoint example you used in a different thread to set the initial view for the Camera. 3 Scenes - a base scene (flat plane, skybox - loaded first), Structures scene with 4 objects at different spots on the plane and a "viewfrom object" (currently a cube with a named viewpoint on it.) I'm able to bind the viewpoint, but not figuring out the setting the camera to the viewpoint part. I want to bind the camera to the viewpoint so that as the (cube) moves, the camera translates with it.
Last edit: Kelly Asay 2018-05-16
The first
Viewpointnode in the X3D file is automatically "bound", that is: "connected with camera". So if theViewpointnode position is animated, the camera will move too.You can put a
Viewpointnode together with aBox(or anything else) under oneTransform, and this way indeed animate a cube and the camera will automatically move along with it. You can test animations for viewpoints e.g. in https://github.com/castle-engine/demo-models/blob/master/navigation/viewpoint_transform.x3dv (best to download complete https://castle-engine.io/demo_models.php ).To explicitly "bind" another
Viewpointnode, callTViewpointNode.EventSet_Bind.Send(true).From your description, I don't see what you are doing wrong, so I cannot tell exactly how to fix it :) Hopefully the information given helps. If not, please submit a (simple) testcase (code+data) to reproduce the problem.
Note that to make some 3D object "glued" to the player, it's usually easiest to use
Player.Add(Some3DObject)approach described on https://castle-engine.io/manual_player.php . If you want to have something like a weapon or torch "glued" to FPS player, and the player navigation moves this object, then this is better. But I don't know if this is what you need -- just pointing out, in case it is useful:)That was very helpful. The camera didn't seem to initialize from the x3dv file so I did it manually. It isn't bound to the node since it can still walk around (WalkCamera), but made step one! The vechicle (cube) will own the player which is basically stationary on the object with the ability to rotate and look up/down. Movement will be via the vehicle (cube).
I'm stepping through the code to get a better idea of how the Viewpoint binding works. Thank you for your help, rare in developers these days.
Note that if you move the vehicle by code, you can also update the camera by code. That is, you can use
OnUpdateevent (see https://castle-engine.io/manual_quick_2d_game.php about events) and just callSceneManager.WalkCamera.SetView(...)there, every time, to update the camera to be "glued" to the vehicle. In this case, you don't need to worry about where is theViewpointnode in X3D.So, there are many ways to do this :)