Camera Binding

Sep 3, 2012 at 1:58 PM

Hi

Can we use binding so the camera follows a moving object?  (the moving object's position being dynamically variable)


Z

 

Sep 5, 2012 at 1:56 PM
Edited Sep 5, 2012 at 1:57 PM


Answered myself.  More about my lack of binding knowledge than H3D function,  but for general interest for novices like me, this works:

Helix3D should be incorporated into next WPF release!

        <h:HelixViewport3D x:Name="view1" CameraRotationMode="Turntable" IsHeadLightEnabled="True">
            
            <h:HelixViewport3D.Camera>
                <PerspectiveCamera Position="0, -200, 0"  LookDirection="0, 200, 0" FieldOfView="45" UpDirection="0,0,1">
                    <PerspectiveCamera.Transform>
                        <Transform3DGroup>
                            <TranslateTransform3D x:Name="cameraTranslateTransform3D"></TranslateTransform3D>
                        </Transform3DGroup>
                    </PerspectiveCamera.Transform>
                </PerspectiveCamera>
            </h:HelixViewport3D.Camera>
        </h:HelixViewport3D>
then some binding in code since my objects are runtime:
            Binding aBinding = new Binding("OffsetX");
            aBinding.Source = tryMe.outerCasePosition;
            BindingOperations.SetBinding(cameraTranslateTransform3D, TranslateTransform3D.OffsetXProperty, aBinding);