DirectX click object?

anthony.selby

Well-known member
Joined
Sep 3, 2009
Messages
65
Programming Experience
5-10
so I created a simple directx app that displays a teapot and rotates around

what I want to do is be able to click on the teapot somewhere and change the color of that pixel (10 pixels) like if i had a paint brush ... the question is:

is there a way within directx to know if and where I'm clicking on the teapot or do I have to do all that ... which from what I can think of is a lot ?

any pointers would be great

thanks :)
 
I used a "pick" sub ... that worked to finding the if i clicked in the mesh or not

VB.NET:
 Private Function MeshPick(ByVal mesh As Direct3D.Mesh, ByVal x As Single, ByVal y As Single) As Boolean
        Dim v3Near As New Vector3(x, y, 0)
        Dim v3Far As New Vector3(x, y, 1)

        Dim closestHit As Microsoft.DirectX.Direct3D.IntersectInformation

        v3Near.Unproject(mobjDX9.Viewport, mobjDX9.Transform.Projection, mobjDX9.Transform.View, mobjDX9.Transform.World)
        v3Far.Unproject(mobjDX9.Viewport, mobjDX9.Transform.Projection, mobjDX9.Transform.View, mobjDX9.Transform.World)
        v3Far.Subtract(v3Near)

        If mesh.Intersect(v3Near, v3Far, closestHit) Then
            Return True
        Else
            Return False

        End If
    End Function
 
Back
Top