What can I learn in the Sprite3DTest example of cocos2dx ver3.3? cocos2dxsprite
1. Sprite3DBasicTest Sprite3D two basic creation methods (1). directly use an obj with clips (3dmax object)
Sprite3D: create ("sprite3dTest/scene01.obj ");
(2) Use an object without materials and set the materials by yourself.
Auto sprite = Sprite3D: create ("Sprite3DTest/boss1.obj ");
Sprite-> setScale (3.f );
Sprite-> setTexture ("Sprite3DTest/boss.png ");
(3)
Auto sprite = EffectSprite3D: createFromObjFileAndTexture ("Sprite3DTest/boss1.obj", "Sprite3DTest/boss.png ");
2. Sprite3DHitTest drag and drop (1) Click to set the transparency target-> setOpacity (100) in onTouchBegan );
Remove the transparency target-> setOpacity (255) from onTouchEnded );
(2) mobile onTouchMoved
Target-> setPosition (target-> getPosition () + touch-> getDelta ());
(3) addEventListenerWithSceneGraphPriority more sprite z order determines the order of loss
3. Sprite3DEffectTest some shader application examples encapsulate the specific implementation into javast3doutline
4.20.3dmaxfile, use fbx-conv.exe to convert std: string fileName = "Sprite3DTest/orc. c3b ";
Auto sprite = EffectSprite3D: create (fileName );
5. Sprite3DWithSkinOutlineTest shader effect in c3b 6. Playing the animation Animate3DTest and switching the demo of the turtle (1) the same c3b can either create a sprite or create an action
Std: string fileName = "Sprite3DTest/tortoise. c3b ";
Auto sprite = Sprite3D: create (fileName );
Sprite-> setScale (0.1f );
Auto s = Director: getInstance ()-> getWinSize ();
Sprite-> setPosition (Vec2 (s. width * 4.f/5.f, s. height/2.f ));
AddChild (sprite );
_ Sprite = sprite;
Auto animation = Animation3D: create (fileName );
(2) animation can be split by time, which is defined in 3Dmax.
If (animation)
{// The Time of the two animations is different. These are defined in 3Dmax.
Auto animate = Animate3D: create (animation, 0.f, 1.933f );
_ Swim = RepeatForever: create (animate );
Sprite-> runAction (_ swim );
_ Swim-> retain ();
_ Hurt = Animate3D: create (animation, 1.933f, 2.8f );
_ Hurt-> retain ();
_ State = State: Deming;
}
(3) The tortoise calls reachEndCallBack at the end of the game.
Obtain the opposite action through reverse
Auto inverse = (MoveTo *) _ moveAction-> reverse ();
180 degree steering along Y axis
Auto rot = RotateBy: create (1.f, Vec3 (0.f, 180.f, 0.f ));
(4) The hurt action of the tortoise is played in onTouchesEnded, but the callback of the end of the hurt action cannot be implemented here, SO _ hurt-> getDuration () is used ()
To obtain the end time, and perform a renewCallBack to return to the _ swim action.
Auto delay = DelayTime: create (_ hurt-> getDuration ()-Animate3D: getTransitionTime ());
Auto seq = Sequence: create (delay, CallFunc: create (CC_CALLBACK_0 (Animate3DTest: renewCallBack, this), nullptr );
Question? Animate3D: What is getTransitionTime () used?
Why does void Animate3DTest: update (float dt) be used to maintain an intermediate state hurt_to_washming and writable ming_to_hurt?
7. AttachmentTest: Installs a weapon to obtain a skeleton. Bip001 R Hand is defined in 3Dmax.
Auto sp = Sprite3D: create ("Sprite3DTest/axe. c3b ");
Sprite-> getAttachNode ("Bip001 R Hand")-> addChild (sp );
Click to remove the additional Node
_ Sprite-> removeAllAttachNode ();
8. Sprite3DReskinTest skin replacement, dynamic material replacement (mesh) (1) font size
TTFConfig ttfConfig ("fonts/arial. ttf", 20 );
Auto label1 = Label: createWithTTF (ttfConfig, "Hair ");
Should the mesh name be defined in 3dm?
_ GirlPants [0] = "Girl_LowerBody01 ";
_ GirlPants [1] = "Girl_LowerBody02 ";
_ GirlUpperBody [0] = "Girl_UpperBody01 ";
_ GirlUpperBody [1] = "Girl_UpperBody02 ";
_ GirlShoes [0] = "Girl_Shoes01 ";
_ GirlShoes [1] = "Girl_Shoes02 ";
_ GirlHair [0] = "Girl_Hair01 ";
_ GirlHair [1] = "Girl_Hair02 ";
(2) Hide the alternative part during initialization and switch the display when you click switch.
Auto girlPants = sprite-> getMeshByName (_ girlPants [1]);
If (girlPants)
{
GirlPants-> setVisible (false );
}
9. How does the Sprite3DWithOBBPerfromanceTest box collide with a 3D model?
10. sprite3d1_test 3D Model Image
?
Common summary:
1. orientation setting of 3d latitude
Sprite-> setRotation3D (Vec3 (0,180, 0 ));
2. sprite-> setEffect () add special effects
3. sprite-> getAttachNode ("Bip001 R Hand") Get a skeleton
4. sprite-> getMeshByName (_ girlPants [1]); get the material
Reference Cocos2d-x 3.3 3D development function introduction http://cn.cocos2d-x.org/tutorial/show? Id = 1582