void movableEventSource3D_MouseClick(object sender, Ab3d.Common.EventManager3D.MouseButton3DEventArgs e) { Material newMaterial; if (_isSelected) { newMaterial = new DiffuseMaterial(Brushes.Blue); } else { newMaterial = new DiffuseMaterial(Brushes.Gold); } MovableBoxVisual3D.Material = newMaterial; _isSelected = !_isSelected; }
void modelEventSource_MouseClick(object sender, Ab3d.Common.EventManager3D.MouseButton3DEventArgs e) { if (!ReferenceEquals(e.RayHitResult.MeshHit, _rootMesh)) // UH: we did not hit the mesh of the current object { return; } bool isFound = false; int index1 = e.RayHitResult.VertexIndex1; int index2 = e.RayHitResult.VertexIndex2; int index3 = e.RayHitResult.VertexIndex3; int j = 0; for (int i = 0; i < _rootMesh.TriangleIndices.Count; i += 3) { if (_rootMesh.TriangleIndices[i] == index1 && _rootMesh.TriangleIndices[i + 1] == index2 && _rootMesh.TriangleIndices[i + 2] == index3) { isFound = true; break; } j++; } if (isFound) { SelectTriangle(j); } else { SelectTriangle(-1); } }