Your browser does not seem to support JavaScript. As a result, your viewing experience will be diminished, and you have been placed in read-only mode.
Please download a browser that supports JavaScript, or enable it if it's disabled (i.e. NoScript).
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 05/10/2009 at 18:24, xxxxxxxx wrote:
User Information: Cinema 4D Version: 11 Platform: Windows ; Language(s) : C++ ;
--------- Hello,
I am creating a box that I would like to be created to be half of the size of an existing cube. I am using Box3D to draw the box and I would like to resize the newly drawn box so that it covers half of the box.
Here is the code I am using to draw the box.
> `
\> \> \> Bool TrueSymmetry::Draw(PluginTag *tag, BaseObject *op, BaseDraw *bd, BaseDrawHelp *bh) \> { \> //GePrint("Draw"); \> BaseContainer *bc=((BaseList2D* )tag)->GetDataInstance(); \> LONG lngMySymPlane =tag->GetDataInstance()->GetLong (SYMMETRY_PLANE); \> LONG trans = 175; \> LONG boxTrans = 200; \> Vector color = bc->GetVector(PLANE_COLOR); \> Vector boxColor = Vector(1,0,0); \> Real size; \> size = .55; \> \> //Matrix for determining scale, rotation, and position. \> Matrix m = op->GetMg(); \> Vector rad = op->GetRad(); \> \> m.v1 *= rad.x+100; \> m.v2 *= rad.y+100; \> m.v3 *= rad.z+100; \> \> \> \> switch (lngMySymPlane) \> { \> \> case XY_PLANE: \> \> if (!tag->GetDataInstance()->GetBool(ENABLE_SYMMETRY)) \> { \> bd->SetTransparency(boxTrans); \> Vector p[8]; \> \> p[0] = m * Vector(-size, -size, -size); \> p[1] = m * Vector( size, -size, -size); \> p[2] = m * Vector( size, -size, size); \> p[3] = m * Vector(-size, -size, size); \> p[4] = m * Vector(-size, size, -size); \> p[5] = m * Vector( size, size, -size); \> p[6] = m * Vector( size, size, size); \> p[7] = m * Vector(-size, size, size); \> \> bd->Box3D(m,size,boxColor); \> } \> \> \>
`
The problem is, that when I draw the box, if I change the vectors under p[] it doesn't change the location of each point of the box? Could someone explain to me how to alter the position of the box and to make it more of a rectangle shape so that it covers onnly half of the cube in the viewport.
Thanks,
~Shawn
On 05/10/2009 at 18:34, xxxxxxxx wrote:
Here's is an example of what I mean.
On 05/10/2009 at 20:51, xxxxxxxx wrote:
As it says, set size to 0.5 and multiply the vectors in the matrix by the lengths. So p[n] = m * Vector(*size* ) where m.v1/v2/v3 are scaled (basis vectors). In other words, specify a unit cube in size as 0.5 and apply scaling via the matrix 'm'.
For instance, if you want to scale the x axis,
// Global Matrix of the object Matrix m = op->GetMg(); // Scale the X-axis basic vector by 1/2 m.v1 *= 0.5f; // Translate along the X-axis by half the bounding box x size // - even though this is a radius, you want your half-box centered in the half-space! m.off.x += (0.5f * op->GetRad().x); // Yellow half-space box Box3D(m, 0.5, Vector(1.0f, 1.0f, 0.0f));
On 05/10/2009 at 20:53, xxxxxxxx wrote:
I should also note that p[n] is not needed. This is shown in the docs for explanatory reasons. The dimensions of the cube are given by the 'size' variable and the matrix.
On 06/10/2009 at 15:50, xxxxxxxx wrote:
Awesome.. Thanks Robert.. That worked like a charm.