Visual Aid
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 24/08/2009 at 11:50, xxxxxxxx wrote:
Well , I was hoping I wouldn't have to ask again. LOL but can someone point me in the right direction on how to be able to take the color selected from a COLOR selector in the attributes manager and turning that into the color values for the polygon3D()..
Thanks,
~Shawn
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 24/08/2009 at 11:58, xxxxxxxx wrote:
Vector color = bc->GetVector(YOUR_DESC_FOR_THE_COLOR);
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 24/08/2009 at 12:00, xxxxxxxx wrote:
Thanks Robert, As always. Top Notch!
~Shawn
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 24/08/2009 at 21:00, xxxxxxxx wrote:
Finally, the last step I need to do is to get the polygon that I have created, aligned, resized, and changed the color, to stay locked to the object on which the tag is.
For example, this portion of my plugin creates a visible symmetry plane on an object. I would like this new polygon to stay attached to the object no matter where it is moved around in 3d space. Can someone point me in the right direction on how to accomplish this?
Thanks,
~Shawn
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 25/08/2009 at 01:44, xxxxxxxx wrote:
Multiply the position vectors of the polygon with the global matrix of the object.
Btw. I recommend to really go through the SDK examples as they often provide a solution to your problem.
cheers,
Matthias -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 25/08/2009 at 09:25, xxxxxxxx wrote:
Thanks Matthias. I have been looking through them they are very helpful. I didn't find one that showed how to do this. Is there one specific example I should look at?
~Shawn
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 25/08/2009 at 09:48, xxxxxxxx wrote:
In this case it's just basic vector/matrix algebra. The examples are full of it. If you haven't done it yet I recommend to get familiar with vector/matrix algebra. There is an excellent introduction in the COFFEE documentation called " Using matrices".
cheers,
Matthias -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 25/08/2009 at 10:10, xxxxxxxx wrote:
I'm not finding Using Matrices in the COFFEE documentation. hmmm..
~Shawn
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 25/08/2009 at 10:26, xxxxxxxx wrote:
Please download the CINEMA 4D R9.5 COFFEE docu.
cheers,
Matthias -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 25/08/2009 at 10:35, xxxxxxxx wrote:
Thanks Matthias!
~Shawn
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 25/08/2009 at 14:20, xxxxxxxx wrote:
Okay I have got the plane following the object using the objects matrix. Now I need to figure out how to rotate the plane using the matrix of the object? I am confused because while the baseobject has a SetRot() function, the BaseDraw class does not, What equation would I use to convert the vectors I recieve from the GetRot() from the BaseObject to the vectors that are used to draw the Polygon3D() ?
Thanks in advance.
~Shawn
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 25/08/2009 at 14:55, xxxxxxxx wrote:
Create a rotation matrix and apply it before applying the global matrix to the vectors. MatrixRotX(), MatrixRotY(), MatrixRotZ() are what you need to look for. If you are going to use the vector values from GetRot(), simply use HPBToMatrix(). I see that it now has specific rotation orders as well (this is new in R11!). I would stick with ROT_HPB in this situation.
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 25/08/2009 at 17:34, xxxxxxxx wrote:
This is what I do to get my global matrix to maintain the position of the polygon.
> `
\> Matrix matrix = op->GetMg(); // Get the global matrix \> Vector globalPos = matrix.off; // Get the position from the matrix \>
`
Then in the vectors I put...
> `\> 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 point on each of those axis.
So to create the rotation matrix I would do this?
> `\> Vector rot = op->GetRot(); \> Matrix rotation = HPBToMatrix(rot, ROT_HPB); \>
`
Then what do I add to my vectors?
Thanks,
~Shawn
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 25/08/2009 at 19:25, xxxxxxxx wrote:
Vector p[4] = ???;
p[4] = p[4] * rotation;You'll have to initialize the vectors to the plane point values first (???).
You can't 'add' rotations to a point. It must be a matrix multiplication.
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 25/08/2009 at 19:37, xxxxxxxx wrote:
Okay I have this to declare necessary variables and set up matrices
> `
\> //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); \>
`
And this is where it all gets it's values.
> `
\> 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)}; \> p[4] = p[4] * rotation; \> Vector f[3] = { Vector(color),Vector(color),Vector(color)}; \> bd->SetLightList(BDRAW_SETLIGHTLIST_NOLIGHTS); \> bd->SetTransparency(trans); \> bd->Polygon3D(p,f,TRUE); \> \>
`
As it is , when I added p[4] = p[4] * rotation;
It crashes.
Do you see anything wrong?
Thanks,
~Shawn
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 25/08/2009 at 20:40, xxxxxxxx wrote:
You have four vectors there. p[4] is an invalid index. Sorry if my pseudo-code was confusing. You need to matrix multiply each individual vector:
p[0] = p[0] * rotation;
p[1] = p[1] * rotation;
p[2] = p[2] * rotation;
p[3] = p[3] * rotation;You should also be doing the matrix multiplication before the other stuff though. This is why I put in ??? instead of that complex position math.
Typical order of applying transformations is scale->rotation->position. This keeps the scale and rotation with respect to the object's origin.
It looks like you are using +100 and -100 as the initial plane vector values. Start with the defaults, multiply by the rotation matrix and thenadd in the other values.
-
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.