Entwickler-Ecke

WinForms - mehrere 3D-Modell positionieren


Elis2010 - Do 19.05.11 14:19
Titel: mehrere 3D-Modell positionieren
Hallo
Ich habe 4 verschiedene 3D-Modell und möchte die mit dem Maus in Richtige Position bringen genauso wie Logosteine.Ich habe ein Automodell und möchte zumbeispiel die Reifen,die Türen usw in Richtige Position bringen.Ich habe so eingegeben,dass die Karosserie nur um sich dreht und alle andere wird mit Translation hin und her geschoben.Aber wenn ich auf dem Oberflächte klicke,bewegen sich alle teile gleichzeitig und mein Programm ist nicht fähig die Teile in Richtige Position zu bringen.Ich bin wirklich ratlos und brauche eure Hilfe.Danke schön

C#-Code:

C#-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
public void render()
        {
            mausStatus = maus.CurrentMouseState;
            mausButtons = mausStatus.GetMouseButtons();
            if (mausButtons[1] != 0)
            {
                rotationX -= 0.01f * mausStatus.X;
                rotationY -= 0.01f * mausStatus.Y;
                rotationZ -= 0.05f * mausStatus.Z;

            }

            if (mausButtons[0] != 0)
            {
                punktX -= 0.01f * mausStatus.X;
                punktY -= 0.01f * mausStatus.Y;
                punktZ -= 0.01f * mausStatus.Z;
                // m_Device.Transform.World = Matrix.Translation(punktX, punktY, punktZ);

            }
.
.
.
.
Funktion rendern{
m_Device.BeginScene();
//Mesh1
  for (int i = 0; i < mesh.NumberAttributes; i++)
            {
                m_Device.Material = material[i];
                m_Device.Transform.World = Matrix.RotationYawPitchRoll(rotationX, rotationY, 0);

                mesh.DrawSubset(i);
            }
//Mesh2
            for (int i = 0; i < mesh2.NumberAttributes; i++)
            {
                world = Matrix.Identity;
                world = Matrix.Scaling(0.0f0.5f0.5f);
                world *= Matrix.RotationX(380);
                m_Device.Material = material2[i];

                m_Device.Transform.World = Matrix.Translation(punktX, punktY, punktZ);

                mesh2.DrawSubset(i);
            }
}


Moderiert von user profile iconKha: C#-Tags hinzugefügt