AB4D Forum

Full Version: Text Rotation Issue
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi

I have a scene and have placed a 'North' marker at the back of the scene.

When I rotate the scene with the camera, the marker moves as expected, but the text does not face the camera as it rotates.

So, what I have done is but a Y axis rotate on it and set the angle to be the opposite of the camera heading using this markup.

Code:
<!--North Marker-->
                <visuals:CenteredTextVisual3D CenterPosition="0 0 -0.07" TextDirection="1 0 0" UpDirection="0 1 0" FontSize="0.025" TextColor="Green" Text="N">
                    <visuals:CenteredTextVisual3D.Transform>
                        <Transform3DGroup>
                            <RotateTransform3D>
                                <RotateTransform3D.Rotation>
                                    <AxisAngleRotation3D Axis="0,1,0" Angle="{Binding ProjectMissionVM.ActiveProjectMission.SceneCameraHeading, Converter={StaticResource OppositeAngleConverter}, Mode=OneWay}" />
                                </RotateTransform3D.Rotation>
                            </RotateTransform3D>
                        </Transform3DGroup>
                    </visuals:CenteredTextVisual3D.Transform>
                </visuals:CenteredTextVisual3D>

What happens now is that the 'North' text rotates to allways face the camera, BUT losses it's place in the scene, it stays in the same point in space??

What I'm I doing wrong??

Thanks

Jason.

(06-02-2015, 02:52 PM)ZENUAV Wrote: [ -> ]Hi

I have a scene and have placed a 'North' marker at the back of the scene.

When I rotate the scene with the camera, the marker moves as expected, but the text does not face the camera as it rotates.

So, what I have done is but a Y axis rotate on it and set the angle to be the opposite of the camera heading using this markup.

Code:
<!--North Marker-->
                <visuals:CenteredTextVisual3D CenterPosition="0 0 -0.07" TextDirection="1 0 0" UpDirection="0 1 0" FontSize="0.025" TextColor="Green" Text="N">
                    <visuals:CenteredTextVisual3D.Transform>
                        <Transform3DGroup>
                            <RotateTransform3D>
                                <RotateTransform3D.Rotation>
                                    <AxisAngleRotation3D Axis="0,1,0" Angle="{Binding ProjectMissionVM.ActiveProjectMission.SceneCameraHeading, Converter={StaticResource OppositeAngleConverter}, Mode=OneWay}" />
                                </RotateTransform3D.Rotation>
                            </RotateTransform3D>
                        </Transform3DGroup>
                    </visuals:CenteredTextVisual3D.Transform>
                </visuals:CenteredTextVisual3D>

What happens now is that the 'North' text rotates to allways face the camera, BUT losses it's place in the scene, it stays in the same point in space??

What I'm I doing wrong??

Thanks

Jason.

Fixed it!

I set the center point to 0,0,0 and use a translatetransform to set its position in space, it then staying in place and rotates to face the camera!

Code:
<!--North Marker-->
                <visuals:CenteredTextVisual3D CenterPosition="0 0 0" TextDirection="1 0 0" UpDirection="0 1 0" FontSize="0.025" TextColor="Green" Text="N">
                    <visuals:CenteredTextVisual3D.Transform>
                        <Transform3DGroup>
                            <RotateTransform3D>
                                <RotateTransform3D.Rotation>
                                    <AxisAngleRotation3D Axis="0,1,0" Angle="{Binding ProjectMissionVM.ActiveProjectMission.SceneCameraHeading, Converter={StaticResource OppositeAngleConverter}, Mode=OneWay}" />
                                </RotateTransform3D.Rotation>
                            </RotateTransform3D>
                            <TranslateTransform3D OffsetX="0" OffsetY="0" OffsetZ="-0.07" />
                        </Transform3DGroup>
                    </visuals:CenteredTextVisual3D.Transform>
                </visuals:CenteredTextVisual3D>

Hi

How can I rotate the text on the Y axis AND on the X axis at the same time.

This way when the model is tilled up/down the text will tilt and face the camera?

I don't know how to use matrix transform??

Thanks

Jason
For cases when you need to display the text that faces the camera I would recommend that you create an overlay canvas, put the text in TextBlock element and calculate the TextBlock position with using Point3DTo2D method on the camera (to create a 2D position of a 3D point).

You will also need to update the position on each camera change and on Viewport3D size changed (so subscribe to those two events).

The overlay canvas control need to be created after the Viewport3D and should occupy the same space as Viewport3D - for example:

<Grid>
<Viewport3D ... />
<Canvas Name="OverlayCanvas">
<TextBlock Name="OverlayTextBlock" Text="..." />
</Canvas>
</Grid>