#include<stdio.h>
#include<vgwin.g>
#include <vgwin.h>
#include <math.h>
#define PATHAIRCRAFT "thunderbird.flt"
vgObject* createNewVegaObject(const char*filepath,const char*name,float multiple);
int main()
{
vgObject *objfly;
vgScene *sce;
vgPosition *pos;
vgPlayer *plyfly;
vgObserver *obs;
vgMotion *mot;
vgWindow *win;
float x=0,y=0,z=0,h=0,p=0,r=0,vel=1.5;
float obs_x=75,obs_y=20,obs_z=5,obs_h=90,
obs_p=0,obs_r=0;//视图坐标变量,初始为右视图
int key;
vgInitSys(); //初始化系统
vgDefineSys("town.adf");
//改变主窗口外观
win = vgGetWin(0);
vgProp(win,VGWIN_WINBORDER,VG_OFF);//不显示窗口边框
//vgProp(win,VGWIN_WINCURSOR,VG_OFF);//不在窗口内显示鼠标
vgConfigSys();
vgSetWinPosToFullScreen(win);//满屏显示vega窗口
char *i = PATHAIRCRAFT;//指明飞机模型所在路径(此处为当前工程文件夹)
char *j="fly";
objfly=createNewVegaObject(i,j,0.5f);//将fly.flt加入objfly
sce=vgGetScene(0); //申请sce
vgAddSceneObj(sce,objfly); //往sce中加入objfly
obs = vgGetObserv(0); // 得到视点
mot = vgGetMot(0);
vgProp(mot,VGCOMMON_ENABLED,VG_ON);
vgProp(mot,VGMOT_MODEL,VGMOT_DRIVE);//设置运动方式为SPIN
vgProp(mot,VGOBS_TETHERSTATE,VGOBS_DYNAMIC);
vgObservMot(obs,mot);
plyfly=vgNewPlyr();
vgProp( plyfly,VGPLYR_ADD_OBJ,VG_ON );
vgProp( plyfly,VGCOMMON_ENABLED,VG_ON );
vgAddPlyrObj(plyfly,objfly);//将模型对象与角色对象绑定
pos = vgNewPos();//创建一个位置坐标
//飞机前进3600步
while(y<=13600)
{
//设置视图位置:
vgProp(obs,VGOBS_TETHERSTATE,VGOBS_FIXED);
vgProp(obs,VGOBS_LOOKAT_TARGET,VGOBS_L_NONE);
vgObservPlyr(obs,plyfly);
vgPosVec(pos,obs_x,obs_y,obs_z,obs_h,obs_p,obs_r);
vgObservTetherPos(obs,pos);
key=vgGetWinKey(win);
switch(key)
{
case 'f'://前视图
case 'F':
obs_x=0;
obs_y=90;
obs_z=5;
obs_h=180;
obs_p=0;
vgName(obj,name);
vgProp(obj,VGOBJ_CS,VGOBJ_DYNAMIC);
vgProp(obj,VGOBJ_PARTS,VG_ON);
vgProp(obj,VGOBJ_CONSTRAIN,VG_OFF);
vgProp( obj, VGOBJ_SCALE, multiple ); //