I wrote a plugin to let we walk around inside my model using an XBox gamepad.
I used the gamepad to input camera translation and rotations. I move a vertical stick (Curve) around and collide it with collision surfaces (Breps). I use the point of intersection to centre the stick vertically.
Once the stick is moved and collided, I then position the camera at stick.PointAtStart.
My collision surfaces are large compared to the stick and are mostly flat or are gentle ramps.
This image shows the golden breps and a green stick (near the top). There is a point on the stick that represents the walker’s feet position. The parts of the stick below that point let me walk down ramps.
Anyway, this works well and I am happy walking around my model.
Unfortunately: I got ambitious.
I want to walk around a cylindrical surface and have my camera stick stay aligned to the surface normal.
I’ve been playing around with Brep ClosestPoint which gives me a point of intersection and a normal.
I can move and orient my stick, I can place my camera at stick.PointAtStart.
But I think that I want to set my camera’s up direction to be the surface normal.
In my mind this would roll the camera.
In reality: the setcameraup call appears to do nothing.
In this 3dm file you can see a large, hollow, “cylinder” that has some flat parts coming off it in the +Y direction.
stick.3dm (1.2 MB)
If I stand on the stop of the cylinder and look in +ve Y, looking into the screen: and then use the gamepad to move right - I expect to move around the outside of the cylinder in a clockwise direction.
Now, if my setcameraup worked, then I would expect to see the cylinder rotating in the opposite direction beneath me. A full circle would take me back to the beginning.
But instead, the camera up direction seems locked to be +ve Z so i start sliding down the righthand side of the cylinder until it is above me then I can continue up the left hand side to return to the start (I started at the top)
Do I need to unlock something to make this work?
I see this in ViewportInfo private void SetCameraLock(int which, bool val).
What are the values for which? What is locked or unlocked?
What exactly does SetCameraUp do? Please don’t tell me that it sets the camera up direction is it for rolling the camera about the camera direction?
Anyway, any advice or code samples would be appreciated.