reg:drawing in plane

hi friends,

  Can anyone tell me how to draw in a particular plane(XYZ) using mouse.

You need to transform your 2D cursor coordinates into an 3D ray which starts at the camera and goes through the cursor into your scene.

Then intersect this ray with your 3D plane. Intersection point is the point where to draw.

Here an old code snippet for Delphi/DirectX. However, it should be possible to convert that to OpenGL.

procedure MouseTo3d(x, y: integer; const matProj, matView: TD3DXMatrix; 
                     var Origin, Dir: TD3DXVector3);
var matInvView: TD3DXMatrix;
    v: TD3DXVector3;
begin
  x := trunc(Dx3D^.d3dpp.BackBufferWidth) - x;
  y := trunc(Dx3D^.d3dpp.BackBufferHeight) - y; 
  v.x :=  (((2 * x) / Dx3D^.d3dpp.BackBufferWidth ) - 1) / matProj._00;
  v.y := -(((2 * y) / Dx3D^.d3dpp.BackBufferHeight) - 1) / matProj._11;
  v.z := 1;
  D3DXMatrixInverse( matInvView, nil, matView);
  Dir.x  := v.x*matInvView._00 + v.y*matInvView._10 + v.z*matInvView._20;
  Dir.y  := v.x*matInvView._01 + v.y*matInvView._11 + v.z*matInvView._21;
  Dir.z  := v.x*matInvView._02 + v.y*matInvView._12 + v.z*matInvView._22;
  D3DXVec3Normalize(dir, dir );
  Origin.x := matInvView._30;
  Origin.y := matInvView._31;
  Origin.z := matInvView._32;
end;