CameraController not defined

Anonymous 9 years ago 0
This discussion was imported from CodePlex

ppcomma wrote at 2011-12-21 21:07:


Hi! I need to add HelixView3D on my form in the code. so, run-time error:: "cameracontroller not defined". What should I do?

objo wrote at 2011-12-21 21:44:

Are you using an old version? The control has been renamed to HelixViewport3D.

Are you calling any methods on the control before the control template has been applied? (the camera controller is undefined until the template is applied).

In what part of the code are you adding the control?

Is it possible to create the control in the view XAML? See the examples.

ppcomma wrote at 2011-12-21 22:13:

this is my code.. i have to add HVP3D dynamically..

[] AllFiles = Directory.GetFiles(@"C:\Users\..", "*.3ds"); HelixViewport3D[] hel_ar = new HelixViewport3D[AllFiles.Count()]; for (int i = 0; i < AllFiles.Count(); i++) { hel_ar[i] = new HelixViewport3D(); PerspectiveCamera myPCamera = new PerspectiveCamera(); myPCamera.Position = new Point3D(10000, 0, 0); myPCamera.LookDirection = new Vector3D(-1, 0, 0); myPCamera.FieldOfView = 60; hel_ar[i].Viewport.Camera = myPCamera; DirectionalLight myDirectionalLight = new DirectionalLight(); myDirectionalLight.Color = Colors.White; myDirectionalLight.Direction = new Vector3D(-0.61, -0.5, -0.61); hel_ar[i].Viewport.Height = 115; hel_ar[i].Viewport.Width = 115; Model3DGroup m3d = new Model3DGroup(); m3d = ModelImporter.Load(AllFiles[i]); m3d.Children.Add(myDirectionalLight); ModelVisual3D m = new ModelVisual3D(); m.Content = m3d; hel_ar[i].Viewport.Children.Add(m); stackPanel1.Children.Add(hel_ar[i]); }

ppcomma wrote at 2011-12-21 22:22:

Thanks, i did it

ppcomma wrote at 2012-01-28 15:52:

One more question..

I create HelixViewport3D in C# code and import 3ds model. When i run project, HelixViewport does not show anything until doubleMMB.

What should i do to fix it? i want helixviewport to show my model at once.

objo wrote at 2012-01-29 09:20:

It seems like your camera position/look direction is wrong. Try to use the ZoomExtents or ResetCamera method in HelixViewport3D after importing the 3ds model.

There is currently not a "ModelLoaded" event on the FileModelVisual3D, I think that is something that should be added.