PDA

View Full Version : setting a scaling on z


Halloula1985
02-02-2010, 12:31 PM
Hello,

i wanna set the scaling on the z axe,i mean,each time i give a value,the scaling in a z axe changes,but i didn't know what node to usefor that.
any one have an idea please ?
thanks

Hal

Halloula1985
02-02-2010, 01:33 PM
i tryed the following code :


int main( int argc, char** argv )

{
....

SoSelection *selection = new SoSelection;
selection->ref();
selection->policy = SoSelection::SINGLE;
selection-> addSelectionCallback(selectionCB,(void*)0);


SoSeparator *root = new SoSeparator;
selection->addChild(root);


SoInput mySceneInput;
mySceneInput.openFile("ZONE1.iv");

SoSeparator *starObject = SoDB::readAll(&mySceneInput);

SoTransform *m = new SoTransform ;
m->ref();
m->scaleFactor.setValue(0,0,2);
starObject->addChild(m);

root->addChild(starObject);

....


but it's not working,can any one tell me what's wrong ?
thx

mikeheck
02-02-2010, 03:39 PM
i tryed the following code :
. . .
but it's not working,can any one tell me what's wrong ?

The transform can only affect nodes that are traversed after the transform has been set. When you call starObject->addChild() you are adding the transform node as the last child of that Separator, therefore none of the other children will be affected by this transform.

There are several different ways you could fix this. One is to change that addChild call to:
starObject->insertChild( m, 0 );
making the transform node the first child of the Separator.

-Mike

Halloula1985
02-02-2010, 04:20 PM
hi again,

well,i add the node as u suggested,the problem is before i was having my file.iv in my boundingbox,but because of the scale,we almost can't see any of the shapes,that's why i wanted to change the scale,now i'am just having a line(of the bbx) and not my.iv any more.
i'am wondering if i'am using the right node..
i joined a screenshot,may be you have a solution for this..

thanks in advance

mikeheck
02-02-2010, 04:28 PM
well,i add the node as u suggested,the problem is before i was having my file.iv in my boundingbox,but because of the scale,we almost can't see any of the shapes,that's why i wanted to change the scale,now i'am just having a line(of the bbx) and not my.iv any more.
i'am wondering if i'am using the right node..


Yes, SoTransform is the right node.

But notice that you are setting the X and Y scale factors to 0. This effectively makes all X and Y coordinates = 0...
Probably what you meant to do was:
m->scaleFactor.setValue( 1, 1, 2 );

-Mike

Halloula1985
02-02-2010, 04:42 PM
yes, thanks it worked.

Hal