-1

I am trying to downscale my object using SCNNode here is my code :

 SCNScene * scene = [SCNScene sceneNamed:@"ship.dae"];
    SCNNode *node = [SCNNode node];

   //This line doesn't do anything ! 
    node.scale  = SCNVector3Make(11, 11, 11);

    [scene.rootNode addChildNode:node];


    // set the scene to the view
    _myView.scene = scene;
    _myView.allowsCameraControl = YES;
    _myView.autoenablesDefaultLighting = YES;
    _myView.backgroundColor = [UIColor whiteColor];

But the problem is object's scale doesn't change at all ! what is wrong ?

Nico S.
  • 3,056
  • 1
  • 30
  • 64
iOS.Lover
  • 5,923
  • 21
  • 90
  • 162

2 Answers2

0

With [SCNNode node] you are creating a new node that is unrelated to the scene and the ship. In the next line you scale the (non-existent) geometry of that node.

Scale the rootNode of your scene instead.

If your .dae contains more than only the ship you intended to scale, search for the node containing the ship using [scene.rootNode childNodeWithName:shipNodeName recursively:YES].

Jörg Kirchhof
  • 1,530
  • 1
  • 9
  • 19
0

The answer of Jörg Kirchhof is right. Look at the ship in the SceneKit Editor. The top node of the scene graph is the node you want. In the case of Apple's sample code it is "ship".

SceneKit Editor Scene Graph

Your second line SCNNode *node = [SCNNode node]; does not make any sense it that case because it is just an empty node. Replace that line with the line below.

SCNNode *node = [scene.rootNode childNodeWithName:@"ship" recursively:YES];
Nico S.
  • 3,056
  • 1
  • 30
  • 64