Search code examples
c++3dsmax

Converting 3D coordinates to 2D in 3ds max


I am trying to convert 3D coordinates of a point in plane object to 2D coordinates considering viewport width and height. I am writing the code in c++.

While going through 3Ds max documentation I found function "MapViewToScreen", Will this function be enough? If so how to implement it. If there are any other methods too please suggest.


Solution

  • Check the link map-world-point-to-viewport-coordinates

    Basically what you need to do is

    //get Transfromation matrix of the plane
    Matrix3 tmMatrix = inode->GetObjectTM( GetCOREInterface()->GetTime() );
    
    ViewExp& vpt = GetCOREInterface()->GetActiveViewExp();
    GraphicsWindow *gwindow= vpt.getGW();
    gwindow->setTransform( Matrix3(1) );
    
    //Your required point, consider only the X and Y part
    IPoint3 out; // X and Y from the bottom left corner
    Point3 in( your_3d_point * tmMatrix );
    gwindow->hTransPoint(&in, &out);