zoukankan      html  css  js  c++  java
  • Arnold AtArray API Test

    #include <ai.h>
    #include <iostream>
    #include <stdio.h>
    #include <vector>
    #include <assert.h>
    
    using namespace std;
    
    void print_the_type()
    {
        printf("AI_TYPE_BYTE   %5d 
    ",AI_TYPE_BYTE);  //0
        printf("AI_TYPE_INT    %5d 
    ",AI_TYPE_INT);   //1
        printf("AI_TYPE_FLOAT  %5d 
    ",AI_TYPE_FLOAT); //4
        printf("AI_TYPE_STRING %5d 
    ",AI_TYPE_STRING);//10
        printf("AI_TYPE_ARRAY  %5d 
    ",AI_TYPE_ARRAY); //13
        printf("AI_TYPE_POINT  %5d 
    ",AI_TYPE_POINT); //8
    }
    
    
    int main()
    {
        print_the_type();
        printf("
    ");
        printf("test AI_TYPE_FLOAT ARRAY
    ");
        AtArray *array = AiArrayAllocate(3,2,AI_TYPE_FLOAT);
        // basic method
        /*
        for(int i=0;i<array->nelements*2;i++)
        {
            AiArraySetFlt(array,i,i);
        }
        */
        float *test = static_cast <float *> (array->data);
        test[0]=1;
        test[1]=2;
        test[5]=6;
    
        for(int i=0;i<array->nelements*2;i++) // MUTIPLY *2 ,because have two float[3],so it's have the 3*2=6 
        {
            cout << AiArrayGetFlt(array,i) <<endl;
        }
        AiArrayDestroy(array);
    
        printf("
    ");
        // test the array point
        printf("test AI_TYPE_POINT ARRAY
    ");
        // create 2 point and have two motion keys 
        // so the data have 4 point ,every point have 3 elements ... the count is 2*3*2 = 12
        AtInt32 keys = 2;
        AtArray *array_type_point = AiArrayAllocate(2,keys,AI_TYPE_POINT);
        assert(array_type_point->nkeys==2);
        assert(array_type_point->nelements==2);
        assert(array_type_point->nelements*2==4);
    
        float * array_raw_pt= static_cast <float *> (array_type_point->data);
        //pt 1
        array_raw_pt[0]=1.0f;
        array_raw_pt[1]=2.0f;
        array_raw_pt[2]=3.0f;
        // pt 2
        array_raw_pt[3]=4.0f;
        array_raw_pt[4]=5.0f;
        array_raw_pt[5]=6.0f;
        // pt3
        array_raw_pt[6]=7.0f;
        //assert(AiArraySetFlt(array,7,8.0f) == 1 ); //arnold will test array_type is same as rh array 
        // cout << array_raw_pt[0] << endl;
        cout.setf(ios::showpoint);
        for(int i=0;i<array_type_point->nelements*keys;i++)
        {
            cout<< i <<"  x : -> " << AiArrayGetPnt(array_type_point,i).x <<endl;
            cout<< i <<"  y : -> " << AiArrayGetPnt(array_type_point,i).y <<endl;
            cout<< i <<"  z : -> " << AiArrayGetPnt(array_type_point,i).z <<endl;
        }
        AiArrayDestroy(array_type_point);
        
        cin.get();
        return 0;
    }

     

  • 相关阅读:
    PHP 上传文件限制
    vim设置golang语法高亮 (Centos)
    linux下安装配置go语言环境
    Vim升华之树形目录插件NERDTree安装图解(ubuntu)
    linux下配置Node.js环境
    RabbitMQ的使用(二)- RabbitMQ服务在单机中做集群
    RabbitMQ的使用(一)- RabbitMQ服务安装
    Exceptionless(二)
    Exceptionless
    SQL Server2012如何打开2016的profiler文件
  • 原文地址:https://www.cnblogs.com/gearslogy/p/5410360.html
Copyright © 2011-2022 走看看