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 \n",AI_TYPE_BYTE); //
printf("AI_TYPE_INT %5d \n",AI_TYPE_INT); //
printf("AI_TYPE_FLOAT %5d \n",AI_TYPE_FLOAT); //
printf("AI_TYPE_STRING %5d \n",AI_TYPE_STRING);//
printf("AI_TYPE_ARRAY %5d \n",AI_TYPE_ARRAY); //
printf("AI_TYPE_POINT %5d \n",AI_TYPE_POINT); //
} int main()
{
print_the_type();
printf("\n");
printf("test AI_TYPE_FLOAT ARRAY\n");
AtArray *array = AiArrayAllocate(,,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[]=;
test[]=;
test[]=; for(int i=;i<array->nelements*;i++) // MUTIPLY *2 ,because have two float[3],so it's have the 3*2=6
{
cout << AiArrayGetFlt(array,i) <<endl;
}
AiArrayDestroy(array); printf("\n");
// test the array point
printf("test AI_TYPE_POINT ARRAY\n");
// 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 = ;
AtArray *array_type_point = AiArrayAllocate(,keys,AI_TYPE_POINT);
assert(array_type_point->nkeys==);
assert(array_type_point->nelements==);
assert(array_type_point->nelements*==); float * array_raw_pt= static_cast <float *> (array_type_point->data);
//pt 1
array_raw_pt[]=1.0f;
array_raw_pt[]=2.0f;
array_raw_pt[]=3.0f;
// pt 2
array_raw_pt[]=4.0f;
array_raw_pt[]=5.0f;
array_raw_pt[]=6.0f;
// pt3
array_raw_pt[]=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=;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 ;
}

Arnold AtArray API Test

上一篇:ASP.NET(C#) Web Api通过文件流下载文件到本地实例


下一篇:你见过吗?9款超炫的复选框(Checkbox)效果