ios3dcocoapodsmeshcocos3d

Can I have an acces to parts of a .pod file?


I'm new in Cocos3D and I have two questions concerning the parts of the 3D model.

As I understood, a .POD file consits of several parts. In my example, I have a 3D Car, which has the parts: - wheel - tire - class (etc.) and these parts have submeshes. I see this, when I open the pod file with PVRShaman.

Now my questions:

  1. Is it possible for me to have access to these parts? E.g. I want to change the color of the wheel. Can I do this programmatically?

  2. When I tap on a part, I want to know, on which part I have tapped. E.g. I want to tap on the wheel, and I know, that the wheel was selected. How can I do this?

Thank you very much!

Update: after the second proposal, my method looks like this:

-(void) nodeSelected: (CC3Node*) aNode byTouchEvent: (uint) touchType at: (CGPoint) touchPoint {
     NSLog(@"Node selected: %@", aNode.name);
     CC3Ray touchRay = [camera unprojectPoint: touchPoint];
     CC3NodePuncturingVisitor* puncturedNodes = [self nodesIntersectedByGlobalRay: touchRay];

     // The reported touched node may be a parent. We want to find the descendant node that
     // was actually pierced by the touch ray, so that we can attached a descriptor to it.
     CC3Node* localNode = puncturedNodes.closestPuncturedNode;

     NSLog(@"Node local: %@", localNode.name); 
}

Solution

  • Yes this is definitely possible.

    Lets say you have a POD file of a car with doors, tires, steering wheel, etc.
    If you want to access the tire of the car in cocos3d, you will need the name of the tire node, this should have been set in your 3d editor (maya, blender, etc).

    Lets say you used maya and that you have set all four tire nodes names to:
    L_back_tire, L_front_tire, R_back_tire, R_front_tire.

    Then you would do this

    //load car and all the child nodes of the car 
    CC3PODResourceNode *car = [CC3PODResourceNode nodeFromFile:@"Car.pod"];
    [self addChild:car];
    
    //the car and all its child node (tires,doors,etc.) have been loaded into the scene
    //so this is how you would fetch the left tire
    CC3Node *leftTire = [car getNodeNamed:@"L_back_tire"];
    
    //do more stuff with that tire her