In the picture above you can see a part of my application. I load a file with different values and afterwards I parse them. Then I draw a 3D coordinate system to show the Lab color space. To draw each sphere I use the Mesh - function:
/// <summary>
/// Vertex für die Kugel
/// </summary>
struct Vertex
{
public float x, y, z; // Position of vertex in 3D space
public int color; // Diffuse color of vertex
/// <summary>
/// Konstruktor der Vertex
/// </summary>
/// <param name="_x">X(A) - Position</param>
/// <param name="_y">Y(L) - Position</param>
/// <param name="_z">Z(B) - Position</param>
/// <param name="_color">Die Farbe</param>
public Vertex(float _x, float _y, float _z, int _color)
{
x = _x; y = _y; z = _z;
color = _color;
}
// Das Format des Vertex
public static readonly VertexFormats FVF_Flags = VertexFormats.Position | VertexFormats.Diffuse;
}
/// <summary>
/// Erstellt das Mesh
/// </summary>
/// <param name="device">Das 3D Device</param>
/// <param name="color">Die Farbe der Kugel</param>
/// <param name="labValues">Die Lab Werte der Kugel</param>
public void createMesh(Device device, Color color, params float[] labValues)
{
// Erstellt die Kugel mit der Anbindung an das Device
mesh = Mesh.Sphere(device, radius, slices, stacks);
// Kopiert das Mesh zum Erstellen des VertexArrays
Mesh tempMesh = mesh.Clone(mesh.Options.Value, Vertex.FVF_Flags, device);
// Erstellt den VertexArray
Vertex[] vertData = (Vertex[])tempMesh.VertexBuffer.Lock(0, typeof(Vertex), LockFlags.None, tempMesh.NumberVertices);
// Weist jedem Vertex die Farbe und die Position zu
for (int i = 0; i < vertData.Length; ++i)
{
vertData[i].color = color.ToArgb();
vertData[i].x += labValues[1];
vertData[i].y += labValues[0] - 50f;
vertData[i].z += labValues[2];
}
// Gibt den VertexBuffer in der Kopie frei
tempMesh.VertexBuffer.Unlock();
// Löscht den Mesh aus dem Speicher
mesh.Dispose();
// Legt die Kopie in der Meshinstanz ab
mesh = tempMesh;
}
One of the functions is to zoom the device. Now I want to add a click event for each sphere to show any informations. But I have no idea how to implement this event. The sphere-object doesn't support any events.
Thank you for your help!!