Nvisionxr_ios Tutorial Seven--Motion of objects in the scene

Source: Internet
Author: User

This section teaches you how to make a cube follow the trajectory you want.
Add header file#import ' NVAnimationEffect.h ', inonCreatethe animation class is instantiated in the method, with the code such as:
1. Cube Movement 
 
Code:
 

   /**      *  Building a Nvanimationeffect object        * name  can be taken casually, but to unique       * context  incoming scenes The Nvwidget object of the       * widget  action, in this case the cube is passed in       Total duration of  * duration  movement       */      nvanimationeffect *move = [[nvanimationeffect alloc] initwithanimation:@ "MoveAni"  Context:self Widget:cube Duration:4.0];           //  set keyframes      //  move from (0,0,0) position to (0,10,0) position within 4 seconds       [move createkeyframewithtimepos:0 pos:nvposition (0.0, 0.0, 0.0)  Type: Translate];     [move createkeyframewithtimepos:4 pos:nvposition (0.0,  10.0, 0.0)  TYPE:TRANSLATE];&NBsp;        //  whether to loop animation      [move  setloop:yes];        //  adding an animated object to the scene       [self addanimeffect:move];       //  start to perform sports       [move start];



2, Cube Edge Mobile Edge Scaling 
 
Code:
  

 //  set keyframes      //  within 4 seconds from (0,0,0) The position of the linear move to (0,10,0) the position of the      [move createkeyframewithtimepos:0 pos:nvposition ( 0.0, 0.0, 0.0)  Type:TRANSLATE];     [move  Createkeyframewithtimepos:4 pos:nvposition (0.0, 10.0, 0.0)  Type:TRANSLATE];           //  Open a new motion track, from 1 time to 5 times times in 4 seconds      [ Move createkeyframewithtimepos:0 pos:nvposition (1.0, 1.0, 1.0)  Type:SCALE];      [move createkeyframewithtimepos:4 pos:nvposition (5.0, 5.0, 5.0)  type:scale]; 



3 , Cube Edge moving edge scaling edge self-rotating  
 
code:  
    

  Set keyframes      //  move from (0,0,0) position to (0,10,0) position within 4 seconds       [move createkeyframewithtimepos:0 pos:nvposition (0.0, 0.0, 0.0)  Type:TRANSLATE] ;      [move createkeyframewithtimepos:4 pos:nvposition (0.0, 10.0,  0.0)  Type:TRANSLATE];          //  Open a new motion track, In 4 seconds from 1 time times to 5 times times      [move createkeyframewithtimepos:0 pos:nvposition (1.0,  1.0, 1.0)  type:scale];     [move createkeyframewithtimepos:4  pos:nvposition (5.0, 5.0, 5.0)  Type:SCALE];           //  Open a new motion track, rotate 360 degrees around the z axis in 4 seconds      [move  Createkeyframewithtimepos:0 pos:nvposition (0.0, 0.0, 0.0)  Type:ROTATION];      [move createkeyframewithtimepos:4&nbSp Pos:nvposition (0.0, 0.0, 360.0)  Type:ROTATION];


   
4. Bezier Curve 
Add header file#import ' NVBezierPath.h ',in theonCreatemethod, the trace class is instantiated, and the code
 
Code:
 

 /**      * startPoint  The starting point of the trajectory        * controlpoint1  Control Point 1      * controlpoint2  Control Point 2       * startPoint  end point of the trajectory       **/      nvvector3f startpoint = nvposition (10.0, 0, 5.5);      nvvector3f controlpoint1 = nvposition (6.0, 0, 3.5);      nvvector3f controlpoint2 = nvposition (8.0, 0, 4.5);      nvvector3f endpoint = nvposition (10.0, 0, 0.0);      //   Instance session Bezier objects      mMainPath = [[NVBezierPath alloc]  initwithbezier:mcontext name:@ "Bezierpath"];     //  setting the fine degree of the curve       [mmainpath setsubdivision:msubdivision];     //  set Bezier trace start point      [ mmainpath setpoints:startpoint endpoint:endpoint];     //  Setting Control points       [mMainPath setControlPoints:controlPoint1 Point2:controlPoint2];      //  Stroke Drawing      [mmainpath stroke];    //   Instance session animation object      NVAnimationEffect *move = [[NVAnimationEffect  alloc] initwithanimation:@ "Moveani"  Context:self Widget:cube Duration:4.0];      //  set Bezier curves to animate      [move selectpath:mmainpath type: translate];     //  whether to loop animation      [move setloop:yes] ;          //  adding an animated object to the scene       [Self addanimeffect:move];          //  start to perform sports       [move start];



running the project, you can see that the cube is moving in accordance with its own set of tracks.

Welcome to Contact:

    • Contact information: +86 18801341080

    • E-mail: [email protected]

    • Website: http://www.nvisionxr.com/

    • QQ Group: 416802300


Nvisionxr_ios Tutorial Seven--Motion of objects in the scene

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.