tags:

views:

64

answers:

1

I have to modify a WPF application written in C# that displays a complex 3D model with many sub-models or parts. When the user selects a part via an alternate user-interface mechanism, I'd like to rotate, scale, or move the scene so that the sub-model comes into view. No sub-model is completely hidden (i.e. interior to the main model).

What's the best way to do this?

As further information, there is no real top or bottom to the model. It is a 3D representation of a molecule, and the user selects an atom that needs to "scroll into view."

+1  A: 

Get the center (or centroid) of the bounding volume of the submodel. Rotate the camera to look at the center. Move or zoom the view until such that the submodel bounding volume occupies a predefined portion of the screen. This involves solving a simple linear equation relating the viewing volume and the bounding volume. It's fairly easy if your bounding volume is a minimum-bounding-box.

EDIT

In that case you may be better off if you do some googling first. The specific feature you're talking about is usually called 'zoom to fit'. If you do some googling I'm sure you'll find some in-depth discussion of implementations, that will do far better than I could here. The explanation requires you understand things like transformations between screen coordinates and world coordinates and how they are related.

Hmmm. Perhaps I should have mentioned that I'm relatively new to 3D application development. Can you repeat that in English? :-)
SergioL