+1

I can't use Helix toolkit to viewport multiple model part at the same time

Philip 8 years ago updated by Fdjjj Duuree 2 years ago 204

Hi Everyone,

I've got an existing Winsform application that model a multi-joint robotic arm, that allows the user to use a trackbar to rotate each joint for a certain degree (snipping of the winsform app below).


Since I've worked out the TranslateTransform and RotateTransform relationship in 2D drawing, I did like to convert it to 3D. I heard that helix toolkit is very good at 3D modelling things. Since I never used it before, so I would like to give helix toolkit a try. What I'm doing is draw the robot arm in wpf and use elementhost to host the drawing in winsform, and in the end aim to achieve the same results as above but in 3D. Currently I applied the same logic I used for the 2D modelling, but with set rotation angle and translation length, as well as I'm trying to get 2 joints connected.

Yet when I run my code, instead of both joints being display (similar to picture above), only 1 joint is present (as shown in picture below).

I don't understands what I did wrong, and since there is very limited documentation available I can't debug and solve the problem myself. So I hope to seek help and solution here.

below is my code:

using System;

using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.IO.Ports;
using System.Windows.Threading;
using HelixToolkit.Wpf;
using HelixToolkit;
using System.Windows.Media.Media3D;

namespace _3DModel
{
/// <summary>
/// Interaction logic for Drawing.xaml
/// </summary>
public partial class Drawing : UserControl
{
HelixViewport3D viewport = new HelixViewport3D();

public Drawing()
{
InitializeComponent();
Draw();
}

private void Draw()
{

#region Camera Viewpoint of the 3D Model
//camera
this.ArmCanvas.Children.Add(viewport);
viewport.DefaultCamera = new PerspectiveCamera();
viewport.DefaultCamera.Position = new Point3D(0, 600, 600);
viewport.DefaultCamera.LookDirection = new Vector3D(0, -600, -600);
viewport.DefaultCamera.UpDirection = new Vector3D(0, 1, 0);

//lighting
DefaultLights light = new DefaultLights();
viewport.Children.Add(light);
#endregion
Model3D joint2, joint3, joint4, joint5, joint6, joint7, baselink;
ModelVisual3D model3d = new ModelVisual3D();
Model3DGroup group = new Model3DGroup();
ModelImporter import = new ModelImporter();

baselink = import.Load(@"C:\Users\tombf\Desktop\Winsform 3D Model\Base Link.obj");
joint2 = import.Load(@"C:\Users\tombf\Desktop\Winsform 3D Model\Link.obj");
joint3 = joint2.Clone();
joint4 = joint2.Clone();
joint5 = joint2.Clone();
joint6 = joint2.Clone();
joint7 = joint2.Clone();

viewport.Children.Remove(model3d);
/*
#region Base Link
Transform3DGroup baseLinkMove = new Transform3DGroup();
TranslateTransform3D baseLinkTranslate = new TranslateTransform3D();
baseLinkTranslate.OffsetX = 0;
baseLinkTranslate.OffsetY = 0;
baseLinkTranslate.OffsetZ = 0;

baseLinkMove.Children.Add(baseLinkTranslate);


RotateTransform3D baseLinkRotate = new RotateTransform3D();
baseLinkRotate.Rotation = new AxisAngleRotation3D(new Vector3D(0, 0, 0), 0);
baseLinkMove.Children.Add(baseLinkRotate);
baselink.Transform = baseLinkMove;

group.Children.Add(baselink);
model3d.Content = group;
viewport.Children.Add(model3d);
#endregion

#region 1st Joint
Transform3DGroup firstJointMove = new Transform3DGroup();
TranslateTransform3D firstJointTranslate = new TranslateTransform3D();
firstJointTranslate.OffsetX = 10;
firstJointTranslate.OffsetY = 0;
firstJointTranslate.OffsetZ = 0;

firstJointMove.Children.Add(firstJointTranslate);


RotateTransform3D firstJointRotate = new RotateTransform3D();
firstJointRotate.Rotation = new AxisAngleRotation3D(new Vector3D(0, 0, 0), 10);
firstJointMove.Children.Add(firstJointRotate);
joint2.Transform = firstJointMove;
group.Children.Add(joint2);
model3d.Content = group;
viewport.Children.Add(model3d);
#endregion

//viewport.Children.Add(model3d);
*/

Transform3DGroup arm = new Transform3DGroup();

TranslateTransform3D armTranslate = new TranslateTransform3D();
RotateTransform3D armRotate = new RotateTransform3D(new AxisAngleRotation3D(new Vector3D(0, 0, 1), 0));
armTranslate.OffsetX = 0;
armTranslate.OffsetY = 0;
armTranslate.OffsetZ = 0;
arm.Children.Add(armTranslate);
baselink.Transform = arm;
arm.Children.Add(armRotate);
baselink.Transform = arm;
group.Children.Add(baselink);
model3d.Content = group;

armTranslate = new TranslateTransform3D();
armRotate = new RotateTransform3D(new AxisAngleRotation3D(new Vector3D(0, 0, 1), 180));
armTranslate.OffsetX = 20;
armTranslate.OffsetY = 0;
armTranslate.OffsetZ = 0;
arm.Children.Add(armTranslate);
joint2.Transform = arm;
arm.Children.Add(armRotate);
joint2.Transform = arm;
//arm.Children.Add(joint2.Transform);
group.Children.Add(joint2);
model3d.Content = group;
viewport.Children.Add(model3d);
}
}
}


These are great wise words from the voice of experience and talented person like you! Thank your for sharing all of this and more motivating us.

เล่นบอลตู้

สมัครเล่นบอลตู้

สมัครแทงบอลvirtual sports

You seemed to have thought of everything in this topic! I will save your site and come back here real soon to read more informative post from you.

น้ำเต้าปูปลาออนไลน์

ทางเข้าแทงน้ำเต้าปูปลา

ทางเข้าเล่นเกมน้ำเต้าปูปลา

These are great wise words from the voice of experience and talented person like you! Thank your for sharing all of this and more motivating us.

แทงบอลสเต็ป

แทงบอลสเต็ปเว็บไหนดี

สมัครแทงบอลสเต็ปเว็บไหนดี

These are great wise words from the voice of experience and talented person like you! Thank your for sharing all of this and more motivating us.

เว็บบอลต่างประเทศ

สมัครเว็บบอลต่างประเทศ

สมัครเว็บแทงบอลต่างประเทศ

These are great wise words from the voice of experience and talented person like you! Thank your for sharing all of this and more motivating us.

ufabetบนมือถือ

สมัครufabetบนมือถือ

สมัครเว็บเดิมพันufabetบนมือถือ