Switching between cockpit view and external view

I am trying to switch between two separate models:

  • A cockpit view with a lot of internal detail and a lot of external parts missing
  • An external view with more external detail and minimal cockpit detail

I initially thought that I would just load both models and make one visible and the other invisible (or both invisible). However, from my research, it appears that there are several drawbacks to this method.

So now I am wondering whether I can use the level of detail (LOD) function to accomplish the same result. My understanding is that I would load the cockpit model first and the external model second adding it to the first model using addLevel.

Since the camera distance for the cockpit view is zero and the camera distance for the external view is greater than zero, the models would automatically switch from one to the other when I switch camera distances. Does that make sense?

One possible complication is that each model will have different animated parts. I can load them all and keep track of which animations apply to each model. Are there other potential problems involved with this?

  1. Fyi, the result in both cases will be quite literally the same.
  1. That shouldn’t be a problem - since you’ll probably use 2 (or more) mixers for animations, you can just call mixer.update(dt); of whichever model is visible at the time.
  1. Coupling screen state to camera distance overall sounds like an unnecessarily risky choice - not sure what’s the risk, but when it appears you’ll spend a good amount of time untangling the entire thing. Why not simply toggle between 2 cameras and 2 models?
2 Likes

So both methods are the same? That is interesting. Some commentators said that making an object invisible to the camera does not necessarily make it invisible to the program (ray tracing?) [edit: raycasting] so that the program could still be wasting time on invisible objects.

The 2 cameras and 2 models sounds interesting. I will have to check that out. I have a separate camera for my loading screen, but have not tried to implement that in the main program. Are there any good examples showing how to set up and switch between cameras “on the fly”?

I got it working
FM2 Demo
Hit “v” to switch between views.
One challenge was that I needed to remember to have external animations run (e.g retractable gear) while in internal view.

1 Like

That’s correct, but in most cases you shouldn’t raycast the entire scene - invisible objects wouldn’t be your main performance issue then anyway. You can limit the scope of raycasting to only the visible model / group and its descendants (or alternatively, use layers.)

1 Like