Viewport3D and real time

Hi,

I am working on project of software to supervise an assembly line in real time. I am beginner in 3D environment and I would know if someone could advice me an “optimum method” to calculate the transformation of models with a minimum calculus.

I am work on 3D model of Robot Arm.

The Robot Arm is compound of: BASE, FOREARM, ARM and HAND. Each one depends of previous one so I declare the model like this:

// Structure 1

<Model3DGroupx:Name="base_Group">

<Model3DGroupx:Name="BASE">

</Model3DGroup>

<Model3DGroupx:Name="forearm_Group">

<Model3DGroupx:Name="FOREARM">

</Model3DGroup>

<Model3DGroupx:Name="arm_Group">

<Model3DGroupx:Name="ARM">

</Model3DGroup>

<Model3DGroupx:Name="hand_Group">

<Model3DGroupx:Name="HAND">

</Model3DGroup>

</Model3DGroup>

</Model3DGroup>

</Model3DGroup>

</Model3DGroup>

But I work in real time and if I apply a transformation to each “Group” this way will take more calculus than if I calculate the transformation to each separate element (base, arm …) then apply to them. The model will be that:

// Structure 2

<Model3DGroupx:Name="BASE">

</Model3DGroup>

<Model3DGroupx:Name="FOREARM">

</Model3DGroup>

<Model3DGroupx:Name="ARM">

</Model3DGroup>

<Model3DGroupx:Name="HAND">

</Model3DGroup>

Is there a way to set a linear dependence between each element? And optimise the calculus?

Thank you.

[13711 byte] By [Dreck] at [2007-12-22]
# 1

I think that you will find that flattening the hierarchy does not yield any performance gain. You are essentially replacing this:

(((World * Base) * ForeArm) * Arm) * Hand)

With this:

World * Base
World * ForeArm
World * Arm
World * Hand

It's likely you will actually come out behind attempting to flatten the hierarchy since you're code will be duplicating effort with the system. Were you experiencing performance issues that lead you to believe that transformations were slow?

Regards,
- Daniel [msft]

All postings are provided "As Is" with no warranties, and confers no rights.

danlehen at 2007-8-30 > top of Msdn Tech,Visual Studio Orcas,Windows Presentation Foundation (WPF)...
# 2

Sorry for responding late, I was in vacancy and working on something else.

Thanks you for responding to my post.

Currently transformations are not slow, but I don’t know exactly the process used by “WinFx” to calculate the rendering. If in the future there will a lot of models, flatten the hierarchy could give a gain? :

// Structure 1
ModelVisual3D mv3d_World = MainViewport3D.Children[0] as ModelVisual3D;
Model3DGroup m3dg_World = mv3d_World.Content as Model3DGroup;
Model3DGroup m3dg_base_Group = m3dg_World.Children[3] as Model3DGroup;
Model3DGroup m3dg_forearm_Group = m3dg_base_Group.Children[1] as Model3DGroup;
Model3DGroup m3dg_arm_Group = m3dg_forearm_Group.Children[1] as Model3DGroup;
Model3DGroup m3dg_hand_Group = m3dg_arm_Group.Children[1] as Model3DGroup;
m3dg_base_Group.Transform = new
MatrixTransform3D(matrice3D_Base);
m3dg_forearm_Group.Transform = new
MatrixTransform3D(matrice3D_Forearm);
m3dg_arm_Group.Transform = new
MatrixTransform3D(matrice3D_Arm);
m3dg_hand_Group.Transform = new
MatrixTransform3D(matrice3D_Hand);

// Structure 2 (Flat hierarchy)
ModelVisual3D mv3d_World = MainViewport3D.Children[0] as ModelVisual3D;
Model3DGroup m3dg_World = mv3d_World.Content as Model3DGroup;
Model3DGroup m3dg_Robot = m3dg_World.Children[3] as Model3DGroup;
Model3DGroup m3dg_base = m3dg_Robot.Children[0] as Model3DGroup;
Model3DGroup m3dg_forearm = m3dg_Robot.Children[1] as Model3DGroup;
Model3DGroup m3dg_arm = m3dg_Robot.Children[2] as Model3DGroup;
Model3DGroup m3dg_hand = m3dg_Robot.Children[3] as Model3DGroup;
matrice3D_Base.Prepend(matrice3D_World);
// Base
m3dg_base_Group.Transform = new
MatrixTransform3D(matrice3D_Base);
matrice3D_Forearm.Prepend(matrice3D_Base);
// Base + Forearm
m3dg_forearm_Group.Transform = new
MatrixTransform3D(matrice3D_Forearm);
matrice3D_Arm.Prepend(matrice3D_Forearm);
// Base + Forearm + Arm
m3dg_arm_Group.Transform = new
MatrixTransform3D(matrice3D_Arm);
matrice3D_Hand.Prepend(matrice3D_Arm);
// Base + Forearm + Arm + Hand
m3dg_hand_Group.Transform = new
MatrixTransform3D(matrice3D_Hand);

[You said: "It's likely you will actually come out behind attempting to flatten the hierarchy since you're code will be duplicating effort with the system."]

Does the system calculate "immediately" coordinates of each Model (MeshGeometry3D) after set transformation to a group (Structure 1)? Or does it wait all transformations for each group and then in later "step" apply the transformation sum to each Model (before rendering?):

First case : ( ( ( Hand_Model * Base_Transform ) * ForeArm_Transform ) * Arm_Transform ) * Hand_Transform.

Second case : ( Base_Transform * ForeArm_Transform * Arm_Transform * Hand_Transform ) * Hand_Model.

( Hand_model is the MeshGeometry3D )

Thank you

Dreck at 2007-8-30 > top of Msdn Tech,Visual Studio Orcas,Windows Presentation Foundation (WPF)...

Visual Studio Orcas

Site Classified