About Store Forum Documentation Contact



Post Reply 
item scale
Author Message
yvanvds Offline
Member

Post: #1
item scale
Hey, i know i can scale a Game::Item with the scale member variable. But how to scale just one dimension instead of all 3 at the same time?

Regards,

yvan
09-12-2010 08:42 PM
Find all posts by this user Quote this message in a reply
Zervox Offline
Member

Post: #2
RE: item scale
youmesh.scale(Vec(0,0,0));
09-12-2010 09:06 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #3
RE: item scale
it's better to scale drawing matrix instead of the mesh
physical actors don't support non-uniform scales
09-13-2010 05:00 PM
Find all posts by this user Quote this message in a reply
yvanvds Offline
Member

Post: #4
RE: item scale
Well i did try to scale the mesh, like Zervox suggested. Works great on its own but then every item with the same mesh is also changed. And it seems there is no copy constructor for a mesh, so i guess i'm not meant to copy them when i create an object?

For matrixes, i came up with this code, but obviously i'm doing something wrong since it only makes the object disappear.
Code:
// setup new scaling
Vec scale;
scale.x = 1.0 + (lastWidth - tmp);
scale.y = 1.0;
scale.z = 1.0 + (lastWidth - tmp);

// get the item matrix and scale it
Matrix m;
item->matrix();
m.setScale(scale);

// add matrix to the item again
item->matrix(m);

Guess i have to look at the Matrix tutorials again?
09-13-2010 09:29 PM
Find all posts by this user Quote this message in a reply
Dynad Offline
Member

Post: #5
RE: item scale
Well you need to set its matrix before drawing.

SetMatrix(MatrixIdentity);

There is always evil somewhere, you just have to look for it properly.
09-13-2010 09:56 PM
Visit this user's website Find all posts by this user Quote this message in a reply
yvanvds Offline
Member

Post: #6
RE: item scale
Well i don't get it. I must be using matrix the wrong way, but i've read the tutorials over and over again, and can't see how i should do this.

I've moved the scale function to the item's drawSolid routine. And made sure it's called. If I use the SetMatrix(m) function, all my objects are on the same spot. I don't see why since i'm only changing the scaling.

And if i use this->matrix(m), nothing happens.

If anyone would like to see the code:
Code:
UInt Item::drawPrepare() {
    UInt modes = __super::drawPrepare() | IndexToFlag(RM_OVERLAY) | IndexToFlag(RM_SOLID);
    return modes;
}

void Item::drawSolid() {
     // newScale is set from another function
    Vec tempScale;
    tempScale.x = 1.0 + (oldScale - newScale);
    tempScale.y = 1.0;
    tempScale.z = 1.0 + (oldScale - newScale);
    oldScale = newScale;
    
    Matrix m;
    m = this->matrix();
    m.setScale(tempScale);
    SetMatrix(m);
    //this->matrix(m);
    __super::drawSolid();
}
09-19-2010 11:52 AM
Find all posts by this user Quote this message in a reply
Driklyn Offline
Member

Post: #7
RE: item scale
Any method that starts with "set" resets the matrix when called. Try using "m.scale(tempScale);" instead.
09-19-2010 09:12 PM
Find all posts by this user Quote this message in a reply
Post Reply