Visual Aid



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 25/08/2009 at 21:12, xxxxxxxx wrote:

    I should add that you might get better results if you simply multiply the plane vectors by the global matrix:

    p[0] = p[0] * m;
    p[1] = p[1] * m;
    p[2] = p[2] * m;
    p[3] = p[3] * m;

    And then adjust the positions from there (minus the global positions which are part of the matrix). This would remove a lot of complications as the global matrix multiplication puts the plane into the 'space' of the object. Then you can adjust relative to that. I hope that is clear. :)



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 25/08/2009 at 21:27, xxxxxxxx wrote:

    So the first thing I would do would be to perform these multiplications.

    > `

      
    \>  p[0] = p[0] * m;  
    \>  p[1] = p[1] * m;  
    \>  p[2] = p[2] * m;  
    \>  p[3] = p[3] * m;  
    \>  
    

    `

    Then perform these calculations?
    > `

      
    \>  Vector p[4] = { Vector(-lngMaxX-100+globalPos.x,-lngMaxY-100+globalPos.y,0+globalPos.z),Vector(-lngMaxX-100+globalPos.x,lngMaxY+100+globalPos.y,0+globalPos.z),Vector(lngMaxX+100+globalPos.x,lngMaxY+100+globalPos.y,0+globalPos.z),Vector(lngMaxX+100+globalPos.x,-lngMaxY-100+globalPos.y,0+globalPos.z)};  
    \>  
    

    `

    lngMaxX, lngMaxY, and lngMaxZ are the greatest points at those axes, these are determine using a for loop which cycles through until it finds the greates point on that plane.

    So I would do the multiplication, then add/subtract the variables in the vectors?

    So final code should look like this?
    > `

      
    \>  p[0] = p[0] * m;  
    \>  p[1] = p[1] * m;  
    \>  p[2] = p[2] * m;  
    \>  p[3] = p[3] * m;  
    \>    
    \>    
    \>  Vector p[4] = { Vector(-lngMaxX-100+globalPos.x,-lngMaxY-100+globalPos.y,0+globalPos.z),Vector(-lngMaxX-100+globalPos.x,lngMaxY+100+globalPos.y,0+globalPos.z),Vector(lngMaxX+100+globalPos.x,lngMaxY+100+globalPos.y,0+globalPos.z),Vector(lngMaxX+100+globalPos.x,-lngMaxY-100+globalPos.y,0+globalPos.z)};  
    \>  
    

    `



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 25/08/2009 at 21:57, xxxxxxxx wrote:

    Okay, I must be doing something wrong. This is the code under the whole draw() function.    I am only altering the XY plane right now found under "case XY_PLANE:", the other 2 are using the old code.

    With the new code, everything works except rotation. it scales properly, it translates properly, it just doesn't rotate at all.

    Do you see anything wrong?

    Thanks,

    ~Shawn

    > `

      
    \>    
    \>  Bool TrueSymmetry::Draw(PluginTag *tag, BaseObject *op, BaseDraw *bd, BaseDrawHelp *bh)  
    \>  {  
    \>    
    \>       BaseContainer *bc=((BaseList2D* )tag)->GetDataInstance();  
    \>       LONG lngMySymPlane =tag->GetDataInstance()->GetLong (SYMMETRY_PLANE);  
    \>       LONG trans = 175;  
    \>       Vector color = bc->GetVector(PLANE_COLOR);  
    \>         
    \>    
    \>       //Used to lock the poistion of the visualized symmetry plane to the object   
    \>       Matrix matrix = op->GetMg(); // Get the global matrix  
    \>      Vector globalPos = matrix.off; // Get the position from the matrix  
    \>         
    \>       Matrix m = op->GetMg();  
    \>       Vector rot = op->GetRot();  
    \>       GePrint ("The Rotation Coordinates are... " + RealToString(rot.x) + RealToString(rot.y) + RealToString(rot.z));  
    \>       Matrix rotation = HPBToMatrix(rot, ROT_HPB);  
    \>         
    \>       //For resizing the plane  
    \>       PolygonObject* objPoly;  
    \>       objPoly=(PolygonObject* )op;  
    \>       Vector * arrPoint;  
    \>       arrPoint=objPoly->GetPointW();  
    \>       LONG lngI;  
    \>       LONG lngPointCount=objPoly->GetPointCount();  
    \>       LONG lngMaxX=0;  
    \>       LONG lngMaxY=0;  
    \>       LONG lngMaxZ=0;  
    \>    
    \>       //Determine the largest x,y,and z values for the object  
    \>       for (lngI=0;lngI<lngPointCount;lngI++)  
    \>       { if (arrPoint[lngI].x>lngMaxX)  
    \>       { lngMaxX=arrPoint[lngI].x;}  
    \>       }  
    \>    
    \>       for (lngI=0;lngI<lngPointCount;lngI++)  
    \>       { if (arrPoint[lngI].y>lngMaxY)  
    \>       { lngMaxY=arrPoint[lngI].y;}  
    \>       }  
    \>    
    \>       for (lngI=0;lngI<lngPointCount;lngI++)  
    \>       { if (arrPoint[lngI].z>lngMaxZ)  
    \>       { lngMaxZ=arrPoint[lngI].z;}  
    \>       }  
    \>    
    \>  // lngMaxX, ingMaxY, and ingMaxZ now hold the largest x,y, and z values of the mesh.  
    \>    
    \>       switch (lngMySymPlane)  
    \>       {  
    \>    
    \>            case XY_PLANE:  
    \>              
    \>            if (tag->GetDataInstance()->GetBool(SHOW_PLANE)) // If SHOW_PLANE is checked, then draw the polygon.  
    \>            {  
    \>            Vector p[4];  
    \>            p[0] = p[0] * m;  
    \>            p[1] = p[1] * m;  
    \>            p[2] = p[2] * m;  
    \>            p[3] = p[3] * m;  
    \>            p[0] = p[0] + Vector(-lngMaxX-100,-lngMaxY-100,0);  
    \>            p[1] = p[1]     + Vector(-lngMaxX-100,lngMaxY+100,0);  
    \>            p[2] = p[2]     + Vector(lngMaxX+100,lngMaxY+100,0);  
    \>            p[3] = p[3]     + Vector(lngMaxX+100,-lngMaxY-100,0);  
    \>            Vector f[3] = { Vector(color),Vector(color),Vector(color)};  
    \>            bd->SetLightList(BDRAW_SETLIGHTLIST_NOLIGHTS);  
    \>            bd->SetTransparency(trans);  
    \>            bd->Polygon3D(p,f,TRUE);  
    \>    
    \>            return true;  
    \>            }  
    \>            else //If SHOW_PLANE is unchecked, say goodbye to the polygon.  
    \>            {  
    \>            Vector p[4] = { Vector(0,0,0),Vector(0,0,0),Vector(0,0,0),Vector(0,0,0)};  
    \>            Vector f[3] = { Vector(0,0,0),Vector(0,0,0),Vector(0,0,0)};  
    \>            bd->Polygon3D(p,f,FALSE);  
    \>            }  
    \>    
    \>           return DRAW_HANDLES|DRAW_AXIS;  
    \>            break;  
    \>    
    \>            case YZ_PLANE:  
    \>            if (tag->GetDataInstance()->GetBool(SHOW_PLANE)) // If SHOW_PLANE is checked, then draw the polygon.  
    \>            {  
    \>            Vector p[4] = { Vector(0+globalPos.x,-lngMaxY-100+globalPos.y,-lngMaxZ-100+globalPos.z),Vector(0+globalPos.x,-lngMaxY-100+globalPos.y,lngMaxZ+100+globalPos.z),Vector(0+globalPos.x,lngMaxY+100+globalPos.y,lngMaxZ+100+globalPos.z),Vector(0+globalPos.x,lngMaxY+100+globalPos.y,-lngMaxZ-100+globalPos.z)};  
    \>            Vector f[3] = { Vector(color),Vector(color),Vector(color)};  
    \>            bd->SetLightList(BDRAW_SETLIGHTLIST_NOLIGHTS);  
    \>            bd->SetTransparency(trans);  
    \>            bd->Polygon3D(p,f,TRUE);  
    \>            return true;  
    \>            }  
    \>            else //If SHOW_PLANE is unchecked, say goodbye to the polygon.  
    \>            {  
    \>            Vector p[4] = { Vector(0,0,0),Vector(0,0,0),Vector(0,0,0),Vector(0,0,0)};  
    \>            Vector f[3] = { Vector(0,0,0),Vector(0,0,0),Vector(0,0,0)};  
    \>            bd->Polygon3D(p,f,FALSE);  
    \>            }  
    \>    
    \>           return DRAW_HANDLES|DRAW_AXIS;  
    \>            break;  
    \>    
    \>            case XZ_PLANE:  
    \>            if (tag->GetDataInstance()->GetBool(SHOW_PLANE)) // If SHOW_PLANE is checked, then draw the polygon.  
    \>            {  
    \>            Vector p[4] = { Vector(-lngMaxX-100+globalPos.x,0+globalPos.y,-lngMaxZ-100+globalPos.z),Vector(-lngMaxX-100+globalPos.x,0+globalPos.y,lngMaxZ+100+globalPos.z),Vector(lngMaxX+100+globalPos.x,0+globalPos.y,lngMaxZ+100+globalPos.z),Vector(lngMaxX+100+globalPos.x,0+globalPos.y,-lngMaxZ-100+globalPos.z)};  
    \>            Vector f[3] = { Vector(color),Vector(color),Vector(color)};  
    \>            bd->SetLightList(BDRAW_SETLIGHTLIST_NOLIGHTS);  
    \>            bd->SetTransparency(trans);  
    \>            bd->Polygon3D(p,f,TRUE);  
    \>            return true;  
    \>            }  
    \>            else //If SHOW_PLANE is unchecked, say goodbye to the polygon.  
    \>            {  
    \>            Vector p[4] = { Vector(0,0,0),Vector(0,0,0),Vector(0,0,0),Vector(0,0,0)};  
    \>            Vector f[3] = { Vector(0,0,0),Vector(0,0,0),Vector(0,0,0)};  
    \>            bd->Polygon3D(p,f,FALSE);  
    \>            }  
    \>    
    \>           return DRAW_HANDLES|DRAW_AXIS;  
    \>            break;  
    \>       }  
    \>  }  
    \>    
    \>    
    \>  
    

    `



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 25/08/2009 at 22:29, xxxxxxxx wrote:

    1. Instead of determining the bounding box yourself, use GetMp() and GetRad(). ;)

    2. Of course, with use of only 'm', you don't need the HPBToMatrix() and globalPos. :)

    3. To size the plane polygon, don't add values, multiply by the vector returned in GetRad(). Start your plane polygon at size of 1x1x1 so as to be centered at the origin (Vector(0.5, 0.0 0.5) etc.). The matrix 'm' will put it into the object's space. GetRad() will scale it to be as big as the object's bounding box.



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 26/08/2009 at 07:06, xxxxxxxx wrote:

    okay this is what I have now..   Now it creates a thin line coming out of the corner of the object.

    Do you see a problem?

    ~Shawn

    > <code>
    >
    >> `

      
    \>    
    \>  Bool TrueSymmetry::Draw(PluginTag *tag, BaseObject *op, BaseDraw *bd, BaseDrawHelp *bh)  
    \>  {  
    \>    
    \>       BaseContainer *bc=((BaseList2D* )tag)->GetDataInstance();  
    \>       LONG lngMySymPlane =tag->GetDataInstance()->GetLong (SYMMETRY_PLANE);  
    \>       LONG trans = 175;  
    \>       Vector color = bc->GetVector(PLANE_COLOR);  
    \>         
    \>    
    \>       //Used to lock the poistion of the visualized symmetry plane to the object   
    \>       Matrix matrix = op->GetMg(); // Get the global matrix  
    \>      Vector globalPos = matrix.off; // Get the position from the matrix  
    \>         
    \>       Matrix m = op->GetMg();  
    \>       Vector rot = op->GetRot();  
    \>       Vector rad = op->GetRad();  
    \>    
    \>       GePrint ("The Rotation Coordinates are... " + RealToString(rot.x) + RealToString(rot.y) + RealToString(rot.z));  
    \>         
    \>       //For resizing the plane  
    \>       PolygonObject* objPoly;  
    \>       objPoly=(PolygonObject* )op;  
    \>       Vector * arrPoint;  
    \>       arrPoint=objPoly->GetPointW();  
    \>       LONG lngI;  
    \>       LONG lngPointCount=objPoly->GetPointCount();  
    \>       LONG lngMaxX=0;  
    \>       LONG lngMaxY=0;  
    \>       LONG lngMaxZ=0;  
    \>    
    \>       //Determine the largest x,y,and z values for the object  
    \>       for (lngI=0;lngI<lngPointCount;lngI++)  
    \>       { if (arrPoint[lngI].x>lngMaxX)  
    \>       { lngMaxX=arrPoint[lngI].x;}  
    \>       }  
    \>    
    \>       for (lngI=0;lngI<lngPointCount;lngI++)  
    \>       { if (arrPoint[lngI].y>lngMaxY)  
    \>       { lngMaxY=arrPoint[lngI].y;}  
    \>       }  
    \>    
    \>       for (lngI=0;lngI<lngPointCount;lngI++)  
    \>       { if (arrPoint[lngI].z>lngMaxZ)  
    \>       { lngMaxZ=arrPoint[lngI].z;}  
    \>       }  
    \>    
    \>  // lngMaxX, ingMaxY, and ingMaxZ now hold the largest x,y, and z values of the mesh.  
    \>    
    \>       switch (lngMySymPlane)  
    \>       {  
    \>    
    \>            case XY_PLANE:  
    \>              
    \>            if (tag->GetDataInstance()->GetBool(SHOW_PLANE)) // If SHOW_PLANE is checked, then draw the polygon.  
    \>            {  
    \>            Vector p[4];  
    \>            p[0] = Vector(-1,-1,0);  
    \>            p[1] = Vector(1,-1,0);  
    \>            p[2] = Vector(1,1,0);  
    \>            p[3] = Vector(1,-1,0);  
    \>    
    \>            p[0] = p[0] * m;  
    \>            p[1] = p[1] * m;  
    \>            p[2] = p[2] * m;  
    \>            p[3] = p[3] * m;  
    \>    
    \>            p[0] = p[0] * rad +100;  
    \>            p[1] = p[1] * rad +100;  
    \>            p[2] = p[2] * rad +100;  
    \>            p[3] = p[3] * rad +100;  
    \>    
    \>            Vector f[3] = { Vector(color),Vector(color),Vector(color)};  
    \>    
    \>            /*  
    \>            p[0] = p[0] + Vector(-lngMaxX-100,-lngMaxY-100,0);  
    \>            p[1] = p[1]     + Vector(-lngMaxX-100,lngMaxY+100,0);  
    \>            p[2] = p[2]     + Vector(lngMaxX+100,lngMaxY+100,0);  
    \>            p[3] = p[3]     + Vector(lngMaxX+100,-lngMaxY-100,0);  
    \>    
    \>            */  
    \>    
    \>              
    \>            bd->SetLightList(BDRAW_SETLIGHTLIST_NOLIGHTS);  
    \>            bd->SetTransparency(trans);  
    \>            bd->Polygon3D(p,f,TRUE);  
    \>    
    \>            return true;  
    \>            }  
    \>            else //If SHOW_PLANE is unchecked, say goodbye to the polygon.  
    \>            {  
    \>            Vector p[4] = { Vector(0,0,0),Vector(0,0,0),Vector(0,0,0),Vector(0,0,0)};  
    \>            Vector f[3] = { Vector(0,0,0),Vector(0,0,0),Vector(0,0,0)};  
    \>            bd->Polygon3D(p,f,FALSE);  
    \>            }  
    \>    
    \>           return DRAW_HANDLES|DRAW_AXIS;  
    \>            break;  
    \>    
    \>            case YZ_PLANE:  
    \>            if (tag->GetDataInstance()->GetBool(SHOW_PLANE)) // If SHOW_PLANE is checked, then draw the polygon.  
    \>            {  
    \>            Vector p[4] = { Vector(0+globalPos.x,-lngMaxY-100+globalPos.y,-lngMaxZ-100+globalPos.z),Vector(0+globalPos.x,-lngMaxY-100+globalPos.y,lngMaxZ+100+globalPos.z),Vector(0+globalPos.x,lngMaxY+100+globalPos.y,lngMaxZ+100+globalPos.z),Vector(0+globalPos.x,lngMaxY+100+globalPos.y,-lngMaxZ-100+globalPos.z)};  
    \>            Vector f[3] = { Vector(color),Vector(color),Vector(color)};  
    \>            bd->SetLightList(BDRAW_SETLIGHTLIST_NOLIGHTS);  
    \>            bd->SetTransparency(trans);  
    \>            bd->Polygon3D(p,f,TRUE);  
    \>            return true;  
    \>            }  
    \>            else //If SHOW_PLANE is unchecked, say goodbye to the polygon.  
    \>            {  
    \>            Vector p[4] = { Vector(0,0,0),Vector(0,0,0),Vector(0,0,0),Vector(0,0,0)};  
    \>            Vector f[3] = { Vector(0,0,0),Vector(0,0,0),Vector(0,0,0)};  
    \>            bd->Polygon3D(p,f,FALSE);  
    \>            }  
    \>    
    \>           return DRAW_HANDLES|DRAW_AXIS;  
    \>            break;  
    \>    
    \>            case XZ_PLANE:  
    \>            if (tag->GetDataInstance()->GetBool(SHOW_PLANE)) // If SHOW_PLANE is checked, then draw the polygon.  
    \>            {  
    \>            Vector p[4] = { Vector(-lngMaxX-100+globalPos.x,0+globalPos.y,-lngMaxZ-100+globalPos.z),Vector(-lngMaxX-100+globalPos.x,0+globalPos.y,lngMaxZ+100+globalPos.z),Vector(lngMaxX+100+globalPos.x,0+globalPos.y,lngMaxZ+100+globalPos.z),Vector(lngMaxX+100+globalPos.x,0+globalPos.y,-lngMaxZ-100+globalPos.z)};  
    \>            Vector f[3] = { Vector(color),Vector(color),Vector(color)};  
    \>            bd->SetLightList(BDRAW_SETLIGHTLIST_NOLIGHTS);  
    \>            bd->SetTransparency(trans);  
    \>            bd->Polygon3D(p,f,TRUE);  
    \>            return true;  
    \>            }  
    \>            else //If SHOW_PLANE is unchecked, say goodbye to the polygon.  
    \>            {  
    \>            Vector p[4] = { Vector(0,0,0),Vector(0,0,0),Vector(0,0,0),Vector(0,0,0)};  
    \>            Vector f[3] = { Vector(0,0,0),Vector(0,0,0),Vector(0,0,0)};  
    \>            bd->Polygon3D(p,f,FALSE);  
    \>            }  
    \>    
    \>           return DRAW_HANDLES|DRAW_AXIS;  
    \>            break;  
    \>       }  
    \>  }  
    \>    
    \>  
    

    `
    >
    > </code>



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 26/08/2009 at 08:47, xxxxxxxx wrote:

    Solved the problem....

    Ended up doing this....

    > `

      
    \>       Matrix m = op->GetMg();  
    \>       Vector rad = op->GetRad();  
    \>    
    \>       m.v1 *= rad.x+100;  
    \>       m.v2 *= rad.y+100;  
    \>       m.v3 *= rad.z+100;  
    \>  
    

    `

    Then doing this to set the values of the vectors for polygon3D()

    > `

      
    \>            Vector p[4];  
    \>    
    \>            p[0] = Vector(-1,-1,0);  
    \>            p[1] = Vector(-1,1,0);  
    \>            p[2] = Vector(1,1,0);  
    \>            p[3] = Vector(1,-1,0);  
    \>    
    \>            p[0] = p[0] * m;  
    \>            p[1] = p[1] * m;  
    \>            p[2] = p[2] * m;  
    \>            p[3] = p[3] * m;  
    \>  
    

    `

    Thanks for your help Robert and Matthias.

    ~Shawn


Log in to reply