Message 1 of 4
Recreate Saved Views from Camera params
Not applicable
01-31-2012
09:34 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I am saving the Camera params from a Saved View into a database.
var oView = _state.CurrentView.ViewPoint as nw.InwNvViewPoint2;
var camera = oView.Camera;
var scv = new SavedCameraView();
scv.Name = viewName;
scv.AspectRatio = camera.AspectRatio;
scv.HeightField = camera.HeightField;
scv.PostionData1 = camera.Position.data1;
scv.PostionData2 = camera.Position.data2;
scv.PostionData3 = camera.Position.data3;
scv.Projection = (int)camera.Projection;
scv.RotationAngle = camera.Rotation.angle;I want to be able to recreate this SavedView on reentering the model but reconstructing it from the saved camera params.
Here is my attempt.
InwSavedViewsColl savedViews = _state.SavedViews();
InwOpView sv = (InwOpView)_state.ObjectFactory(nwEObjectType.eObjectType_nwOpView, null, null);
sv.name = scv.Name;
//sv.anonview = (InwOpAnonView)_state.CurrentView;
var camera = (InwNvCamera)_state.ObjectFactory(nwEObjectType.eObjectType_nwNvCamera, null, null);
var viewPoint = (InwNvViewPoint2)_state.ObjectFactory(nwEObjectType.eObjectType_nwNvViewPoint, null, null);
var axis = (InwLUnitVec3f)_state.ObjectFactory(nwEObjectType.eObjectType_nwLUnitVec3f, null, null);
//axis.data1 = 0;
//axis.data2 = 0;
//axis.data3 = 0;
camera.AspectRatio = scv.AspectRatio.Value;
camera.HeightField = scv.HeightField.Value;
camera.Position.data1 = scv.PostionData1.Value;
camera.Position.data2 = scv.PostionData2.Value;
camera.Position.data3 = scv.PostionData3.Value;
camera.Projection = (nwEProjection) scv.Projection;
camera.Rotation = (InwLRotation3f)_state.ObjectFactory(nwEObjectType.eObjectType_nwLRotation3f, null, null);
camera.Rotation.SetValue(axis, scv.RotationAngle.Value);
viewPoint.Camera = camera;
sv.anonview.ViewPoint = viewPoint;
savedViews.Add(sv);The issue is that Camera.Rotation.angle is not set. You cannot set it directly as it is read only.
If I run the code as is, the reconstructed SavedView has Rotation angle =0, and AspectRatio and HeightField are incorrect.
I assume I need to do some Vector maths here instead of what I am doing?
How can achieve this step?