locked
3D Tools TrackballDecorator RRS feed

  • Question

  • Hi,
    i'm testing the possibilities of the 3d space. I piced up a .dll with 3D Tools. There is an element which is called
    TrackballDecorator. I made a 3d cube, putted it in a viewport and the viewport in the TrackballDecorator Element.
    When i start the exe, the cube appears in 3d, all is right. But if i click the mouse and move it, the cube starts
    to rotate like it should, but the camera it too close and i only see a part of the cube.

    Anyone there who knows whats going wrong?

    Here is the code if you like to see for yourself: 

    <Window 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
        xmlns:Tools="clr-namespace:_3DTools;assembly=3DTools" 
        x:Class="Cubecontol_01.Window1" 
    x:Name="Window" 
    Title="Window1" 
    Width="640" Height="480"
     
    <Grid x:Name="LayoutRoot"
     
            <Tools:TrackballDecorator> 
            
            <Viewport3D> 
    <Viewport3D.Camera> 
    <PerspectiveCamera FarPlaneDistance="100.000000" NearPlaneDistance="0.100000" UpDirection="0,1,0" LookDirection="0,0,-1" Position="0,0,0" FieldOfView="50"
    <PerspectiveCamera.Transform> 
    <Transform3DGroup> 
    <RotateTransform3D> 
    <RotateTransform3D.Rotation> 
    <AxisAngleRotation3D Axis="0.772239,0.341341,0.535848" Angle="77.185380875237669"/> 
                                
    </RotateTransform3D.Rotation> 
    </RotateTransform3D> 
    <TranslateTransform3D OffsetX="7.4811315536499023" OffsetY="-6.5076398849487305" OffsetZ="5.3436651229858398"/> 
    </Transform3DGroup> 
    </PerspectiveCamera.Transform> 
    </PerspectiveCamera> 
    </Viewport3D.Camera> 
    <ModelVisual3D> 
    <ModelVisual3D.Content> 
    <Model3DGroup> 
    <Model3DGroup x:Name="MG_Cube"
    <Model3DGroup.Transform> 
    <TranslateTransform3D OffsetX="0.0" OffsetY="0.047152850776910782" OffsetZ="0.0"/> 
                            
                            
    </Model3DGroup.Transform> 
    <GeometryModel3D x:Name="OB_Cube"
    <GeometryModel3D.Material> 
    <DiffuseMaterial x:Name="MA_Material" Brush="#cccccc"/> 
                                
                                
    </GeometryModel3D.Material> 
    <GeometryModel3D.BackMaterial> 
    <DiffuseMaterial x:Name="MA_Material_2" Brush="#cccccc"/> 
                                
                                
    </GeometryModel3D.BackMaterial> 
    <GeometryModel3D.Geometry> 
    <MeshGeometry3D x:Name="ME_Cube_001" 
    Positions="1,1,-1 1,-1,-1 -1,-1,-1 -1,1,-1 1,1,1 -1,1,1 -1,-1,1 0.999999,-1,1 1,1,-1 1,1,1 0.999999,-1,1 1,-1,-1 1,-1,-1 
    0.999999,-1,1 -1,-1,1 -1,-1,-1 -1,-1,-1 -1,-1,1 -1,1,1 -1,1,-1 1,1,1 1,1,-1 -1,1,-1 -1,1,1" 
    Normals="0,0,-1 0,0,-1 0,0,-1 0,0,-1 0,0,1 0,0,1 0,0,1 0,0,1 1,0,0 1,0,0 1,0,0 1,0,0 0,-1,0 
    0,-1,0 0,-1,0 0,-1,0 -1,0,0 -1,0,0 -1,0,0 -1,0,0 0,1,0 0,1,0 0,1,0 0,1,0" 
    TextureCoordinates="" 
    TriangleIndices="0 1 2 0 2 3 4 5 6 4 6 7 8 9 10 8 10 11 12 13 14 12 14 15 16 17 18 16 18 19 20 21 22 20 22 23" 
    /> 
    </GeometryModel3D.Geometry> 
    </GeometryModel3D> 
    </Model3DGroup> 
    <Model3DGroup x:Name="MG_Lamp"
    <Model3DGroup.Transform> 
    <Transform3DGroup> 
    <RotateTransform3D> 
    <RotateTransform3D.Rotation> 
    <AxisAngleRotation3D Axis="0.205942,0.331517,0.920697" Angle="110.36735588645911"/> 
                                        
    </RotateTransform3D.Rotation> 
    </RotateTransform3D> 
    <ScaleTransform3D ScaleX="1.0" ScaleY="1.0" ScaleZ="0.99999994039535522"/> 
    <TranslateTransform3D OffsetX="4.0092644691467285" OffsetY="-5.1628155708312988" OffsetZ="5.9038619995117188"/> 
                                
    </Transform3DGroup> 
                            
    </Model3DGroup.Transform> 
    <DirectionalLight Color="#ffffff" Direction="0.771101,0.199883,-0.604525"/> 
    </Model3DGroup> 
    </Model3DGroup> 
    </ModelVisual3D.Content> 
    </ModelVisual3D> 
    </Viewport3D> 
     
            </Tools:TrackballDecorator> 
                
    </Grid> 
    </Window> 

    • Edited by bee-dee Friday, August 1, 2008 12:25 PM codechanges
    Friday, August 1, 2008 12:24 PM

All replies

  • Your perspective camera is at point 0,0,0  try backing it up on the Z axis, say 0,0,10.

    Play with the LookDirection as well as Position and you can omit the camera transform so it won't jump.

     

     

    <PerspectiveCamera
    FarPlaneDistance="100.000000"
    NearPlaneDistance="0.100000"
    UpDirection="0,1,0"
    LookDirection="-0.5,-0.5,-1"
    Position="3,3,6"
    FieldOfView="50">
    <!--<PerspectiveCamera.Transform>
    <Transform3DGroup>
    <RotateTransform3D>
    <RotateTransform3D.Rotation>
    <AxisAngleRotation3D
    Axis="0.772239,0.341341,0.535848"
    Angle="77.185380875237669"/>
    </RotateTransform3D.Rotation>
    </RotateTransform3D>
    <TranslateTransform3D
    OffsetX="7.4811315536499023"
    OffsetY="-6.5076398849487305"
    OffsetZ="5.3436651229858398"/>
    </Transform3DGroup>
    </PerspectiveCamera.Transform>-->

    Sunday, May 3, 2009 6:51 PM
  • You must have figured this by now.

    The problem is near plane distance, give the value as -10000 instead of a positive 0.100

    Thursday, October 30, 2014 11:53 AM