WPF Charting Documentation - SciChart WPF Charts SDK v5.x
Adding 3D CAD Objects to the Chart

New to SciChart WPF v5, it is now possible to add CAD Objects to a 3D Chart, using the Wavefront *.obj file format.

This is demonstrated in the example Add Objects to a 3D Chart.

 

 

Adding Obj Files to the SciChart3DSurface

How does this work?

The SciChart3DSurface.SceneObjects property accepts a collection of ObjectModel3D classes. Each one can specify an *.obj file Source (via URL or stream), a TextureSource, a PositionScaleRotation and CoordinateMode.

Adding ObjectModel3D to SciChart3DSurface
Copy Code
<s3D:SciChart3DSurface Name="sciChart3DSurface"
                       Grid.Column="1"
                       WorldDimensions="250,1,250">
 
    <s3D:SciChart3DSurface.Resources>
        <!--  The 3D chess objects models which are used in this example were created by Fabio Valle, objects are used for  -->
        <!--  demonstrating purposes only to show possibility how to load and manipulate the 3D objects on 3D scene. Fabio's email: fabiovalle3d@gmail.com  -->
        <object:ObjectModelSource x:Key="PawnLowObj3DSource" Source="pack://application:,,,/SciChart.Examples.ExternalDependencies;component/Resources/Objects/Pawn_Low.obj"/>
        <object:ObjectModelSource x:Key="BishopLowObj3DSource" Source="pack://application:,,,/SciChart.Examples.ExternalDependencies;component/Resources/Objects/Bishop_Low.obj"/>
        <object:ObjectModelSource x:Key="KingLowObj3DSource" Source="pack://application:,,,/SciChart.Examples.ExternalDependencies;component/Resources/Objects/King_Low.obj"/>
        <object:ObjectModelSource x:Key="KnightLowObj3DSource" Source="pack://application:,,,/SciChart.Examples.ExternalDependencies;component/Resources/Objects/Knight_Low.obj"/>
        <object:ObjectModelSource x:Key="QueenLowObj3DSource" Source="pack://application:,,,/SciChart.Examples.ExternalDependencies;component/Resources/Objects/Queen_Low.obj"/>
        <object:ObjectModelSource x:Key="RookLowObj3DSource" Source="pack://application:,,,/SciChart.Examples.ExternalDependencies;component/Resources/Objects/Rook_Low.obj"/>
        <object:Rotation3D x:Key="ObjRotationState" Axis="YAxis" Angle="180" />
        <object:TextureSource x:Key="BlackTexture" Source="pack://application:,,,/SciChart.Examples.ExternalDependencies;component/Resources/Objects/BlackWoodTexture.jpg" />
        <object:TextureSource x:Key="WhiteTexture" Source="pack://application:,,,/SciChart.Examples.ExternalDependencies;component/Resources/Objects/WhiteWoodTexture.jpg" />
    </s3D:SciChart3DSurface.Resources>
   
    <s3D:SciChart3DSurface.SceneObjects>
        <!--  The 3D chess objects models which are used in this example were created by Fabio Valle, objects are used for  -->
        <!--  demonstrating purposes only to show possibility how to load and manipulate the 3D objects on 3D scene. Fabio's email: fabiovalle3d@gmail.com  -->
        ...
        <object:ObjectModel3D TextureSource="{StaticResource BlackTexture}" Source="{StaticResource RookLowObj3DSource}" Position="0.0625, 0.6, 0.9375" CoordinateMode="Relative" Scale="0.2, 0.2, 0.2"/>
        <object:ObjectModel3D TextureSource="{StaticResource BlackTexture}" Source="{StaticResource KnightLowObj3DSource}" Position="0.0625, 0.6, 0.8125" CoordinateMode="Relative" Scale="0.2, 0.2, 0.2" Rotation="{StaticResource ObjRotationState}"/>
        <object:ObjectModel3D TextureSource="{StaticResource BlackTexture}" Source="{StaticResource BishopLowObj3DSource}" Position="0.4375, 0.6, 0.3125" CoordinateMode="Relative" Scale="0.2, 0.2, 0.2" Rotation="{StaticResource ObjRotationState}"/>
        <object:ObjectModel3D TextureSource="{StaticResource BlackTexture}" Source="{StaticResource KingLowObj3DSource}" Position="0.0625, 0.6, 0.5625" CoordinateMode="Relative" Scale="0.2, 0.2, 0.2"/>
        <object:ObjectModel3D TextureSource="{StaticResource BlackTexture}" Source="{StaticResource QueenLowObj3DSource}" Position="0.0625, 0.6, 0.4375" CoordinateMode="Relative" Scale="0.2, 0.2, 0.2" Rotation="{StaticResource ObjRotationState}"/>
        <object:ObjectModel3D TextureSource="{StaticResource BlackTexture}" Source="{StaticResource BishopLowObj3DSource}" Position="0.0625, 0.6, 0.3125" CoordinateMode="Relative" Scale="0.2, 0.2, 0.2" Rotation="{StaticResource ObjRotationState}"/>
        <object:ObjectModel3D DrawBoundingBox="True" BoundingBoxStroke="White" TextureSource="{StaticResource BlackTexture}" Source="{StaticResource KnightLowObj3DSource}" Position="0.3125, 0.6, 0.3125" CoordinateMode="Relative" Scale="0.2, 0.2, 0.2" Rotation="{StaticResource ObjRotationState}"/>
        <object:ObjectModel3D TextureSource="{StaticResource BlackTexture}" Source="{StaticResource RookLowObj3DSource}" Position="0.0625, 0.6, 0.0625" CoordinateMode="Relative" Scale="0.2, 0.2, 0.2"/>
        ...
    </s3D:SciChart3DSurface.SceneObjects>
</s3D:SciChart3DSurface>

 

In this case the *.obj files are included as WPF Resources in the target project, however they can just as easily be loaded from stream.

 

 

Loading from Stream

The constructor of ObjectModel3D has an overload which accepts a Stream. If you wish to load the file from memory stream, then use this constructor:

Example Title
Copy Code
/// <summary>    
/// Initializes a new instance of the <see cref="ObjectModel3D"/> class using the specified texture file <see cref="Stream"/>. <see cref="Stream"/> will be closed automatically.
/// </summary>
/// <param name="modelStreamSource">The object model file <see cref="Stream"/>. <see cref="Stream"/> will be closed automatically.</param>
/// <param name="diffuseColor">The diffuse model color</param>
public ObjectModel3D(Stream modelStreamSource, Color diffuseColor)
{
    
}

// or 

/// <summary>
/// Initializes a new instance of the <see cref="ObjectModel3D"/> class using the specified texture file <see cref="Stream"/> and texture file <see cref="Stream"/>. All Streams will be closed automatically.
/// </summary>
/// <param name="modelStreamSource">The object model file <see cref="Stream"/>. <see cref="Stream"/> will be closed automatically.</param>
/// <param name="textureStreamSource">The texture file <see cref="Stream"/>. <see cref="Stream"/> will be closed automatically.</param>
public ObjectModel3D(Stream modelStreamSource, Stream textureStreamSource)
{
    
}

 

Loading other Object3D Types

At the moment, SciChart WPF 3D only supports loading the *.obj file format. However, it is possible to convert between file formats such as *.STL, *.DBX, *.DAQ, *.3DS quickly and easily using Blender - an open source 3D Rendering package.

 

 

 


SCICHART ® is a Registered Trademark in the UK, US and EEC. Copyright SciChart Ltd 2011-2018.

Email us to give feedback!