C++ Question please help me with payload coding

Mr Martian

Orbinaut/Addon dev/Donator
Addon Developer
Donator
Joined
Jun 6, 2012
Messages
304
Reaction score
88
Points
28
Location
Sydney, Australia, Earth, Sol
Website
www.orbithangar.com
hey i am trying to create a ship wit vc++ that has a payload and i cant do it. ive read so many tutorials and tried so many different things. ive been trying to learn how to ad payloads for over a week now and its just getting frustrating. i am really new to coding and i was wondering if i post my code here, if someone would like to ad a really simple payload capability, it would really mean a lot to me :)

---------- Post added at 02:51 AM ---------- Previous post was at 02:44 AM ----------

this is the code here:

Code:
//############################################################################//
#define ORBITER_MODULE
#define _CRT_SECURE_NO_WARNINGS
#define _CRT_NONSTDC_NO_DEPRECATE
#include <math.h>
#include <stdio.h>
#include "orbitersdk.h"
//############################################################################//
#include "IPA_Vehicle.h"
//############################################################################//
//Airfoil coefficient functions
//Return lift, moment and zero-lift drag coefficients as a
//function of angle of attack (alpha or beta)
//############################################################################//
//vertical lift component (wings and body)
void VLiftCoeff(VESSEL *v,double aoa,double M,double Re,void *context,double *cl,double *cm,double *cd)
{
 int i;
 const int nabsc=9;
 static const double AOA[nabsc]={-180*RAD,-60*RAD,-30*RAD, -2*RAD, 15*RAD,20*RAD,25*RAD,60*RAD,180*RAD};
 static const double CL[nabsc] ={       0,      0,   -0.4,      0,    0.7,     1,   0.8,     0,      0};
 static const double CM[nabsc] ={       0,      0,  0.014, 0.0039, -0.006,-0.008,-0.010,     0,      0};
 for(i=0;i<nabsc-1 && AOA[i+1]<aoa;i++);
 double f=(aoa-AOA[i])/(AOA[i+1]-AOA[i]);
 *cl=CL[i]+(CL[i+1]-CL[i])*f;  //aoa-dependent lift coefficient
 *cm=CM[i]+(CM[i+1]-CM[i])*f;  //aoa-dependent moment coefficient
 double saoa=sin(aoa);
 double pd=0.015+0.4*saoa*saoa;  //profile drag
 *cd=pd+oapiGetInducedDrag(*cl,1.5,0.7)+oapiGetWaveDrag(M,0.75,1.0,1.1,0.04);
 //profile drag+(lift-)induced drag+transonic/supersonic wave (compressibility) drag
}
//############################################################################//
//horizontal lift component (vertical stabilisers and body)
void HLiftCoeff(VESSEL *v,double betta,double M,double Re,void *context,double *cl,double *cm,double *cd)
{
 int i;
 const int nabsc=8;
 static const double BETA[nabsc]={-180*RAD,-135*RAD,-90*RAD,-45*RAD,45*RAD,90*RAD,135*RAD,180*RAD};
 static const double CL[nabsc]  ={       0,    +0.3,      0,   -0.3,  +0.3,     0,   -0.3,      0};
 for(i=0;i<nabsc-1 && BETA[i+1]<betta;i++);
 *cl=CL[i]+(CL[i+1]-CL[i])*(betta-BETA[i])/(BETA[i+1]-BETA[i]);
 *cm=0.0;
 *cd=0.015+oapiGetInducedDrag(*cl,1.5,0.6)+oapiGetWaveDrag(M,0.75,1.0,1.1,0.04);
}
//############################################################################//
//Class creation
IPA_Vehicle::IPA_Vehicle(OBJHANDLE hObj,int fmodel):VESSEL2(hObj,fmodel){}
IPA_Vehicle::~IPA_Vehicle(){}
//############################################################################//
//Fill animation definition
void IPA_Vehicle::make_anim(int n,int id,int tp,int repeat,int trigkey,int status,double spd,double proc,double init,int grpcnt,int compcnt)
{
 ani[n].id=id;
 ani[n].tp=tp;
 ani[n].repeat=repeat;
 ani[n].trigkey=trigkey;
 ani[n].status=status;
 ani[n].spd=spd;
 ani[n].proc=proc;
 ani[n].init=init;
 ani[n].grpcnt=grpcnt;
 ani[n].compcnt=compcnt;
}
//############################################################################//
//Fill animation component definition
void IPA_Vehicle::make_anim_comp(int n,int c,int msh,int id,int tp,int grp,int parent,VECTOR3 ref,VECTOR3 axshsc,double angle,double st0,double st1)
{
 ani[n].comp[c].msh=msh;
 ani[n].comp[c].id=id;
 ani[n].comp[c].tp=tp;
 ani[n].comp[c].grp=grp;
 ani[n].comp[c].parent=parent;
 ani[n].comp[c].ref=ref;
 ani[n].comp[c].axshsc=axshsc;
 ani[n].comp[c].angle=(float)angle;
 ani[n].comp[c].st0=st0;
 ani[n].comp[c].st1=st1;
}
//############################################################################//
//Define animations
void IPA_Vehicle::define_animations()
{
 int i,j,k,n,a,b;
 //Sequence 0
 make_anim(0,0,0,1,34,1,0.033,0,0,1,1);

 ani[0].grp=(UINT**)malloc(1*sizeof(UINT*));
 static UINT g0[1+1]={1,29}; ani[0].grp[0]=g0;

 ani[0].comp=(animcompinfo*)malloc(1*sizeof(animcompinfo));
 make_anim_comp(0,0,0,3,0,0,-1,_V(0,-0.232,0),_V(0,0,1),6.283,0,1);

 //Sequence 1
 make_anim(1,0,0,0,37,-2,0.079,0,0,1,1);

 ani[1].grp=(UINT**)malloc(1*sizeof(UINT*));
 static UINT g1[3+1]={3,66,6,7}; ani[1].grp[0]=g1;

 ani[1].comp=(animcompinfo*)malloc(1*sizeof(animcompinfo));
 make_anim_comp(1,0,0,0,1,0,-1,_V(0,0,0),_V(0,0,47),0,0,1);

 //Sequence 2
 make_anim(2,0,0,0,2,-2,0.079,0,0,3,3);

 ani[2].grp=(UINT**)malloc(3*sizeof(UINT*));
 static UINT g2[3+1]={3,0,1,2}; ani[2].grp[0]=g2;
 static UINT g3[1+1]={1,0}; ani[2].grp[1]=g3;
 static UINT g4[1+1]={1,2}; ani[2].grp[2]=g4;

 ani[2].comp=(animcompinfo*)malloc(3*sizeof(animcompinfo));
 make_anim_comp(2,0,0,2,1,0,-1,_V(0,0,0),_V(0,0,6),0,0,0.5);
 make_anim_comp(2,1,0,4,2,1,-1,_V(-6.782,0,386.895),_V(29,1,1),0,0.5,1);
 make_anim_comp(2,2,0,5,2,2,-1,_V(6.782,0,386.895),_V(29,1,1),0,0.5,1);

 //Sequence 3
 make_anim(3,0,0,0,3,-2,0.079,0,0,1,1);

 ani[3].grp=(UINT**)malloc(1*sizeof(UINT*));
 static UINT g5[3+1]={3,3,4,5}; ani[3].grp[0]=g5;

 ani[3].comp=(animcompinfo*)malloc(1*sizeof(animcompinfo));
 make_anim_comp(3,0,0,1,1,0,-1,_V(0,0,0),_V(0,-9,0),0,0,1);

 //Zero out components
 for(i=0;i<ANIM_COUNT;i++)for(j=0;j<ani[i].compcnt;j++)ani[i].comp[j].cmpt=NULL;
 
 //Animation core creation
 n=0;
 for(i=0;i<ANIM_COUNT;i++){
  for(j=0;j<ani[i].compcnt;j++){
    if(ani[i].comp[j].tp==0)ani[i].comp[j].cmpdef=new MGROUP_ROTATE   (ani[i].comp[j].msh,&(ani[i].grp[ani[i].comp[j].grp][1]),ani[i].grp[ani[i].comp[j].grp][0],ani[i].comp[j].ref,ani[i].comp[j].axshsc,ani[i].comp[j].angle);
    if(ani[i].comp[j].tp==1)ani[i].comp[j].cmpdef=new MGROUP_TRANSLATE(ani[i].comp[j].msh,&(ani[i].grp[ani[i].comp[j].grp][1]),ani[i].grp[ani[i].comp[j].grp][0],ani[i].comp[j].axshsc);
    if(ani[i].comp[j].tp==2)ani[i].comp[j].cmpdef=new MGROUP_SCALE    (ani[i].comp[j].msh,&(ani[i].grp[ani[i].comp[j].grp][1]),ani[i].grp[ani[i].comp[j].grp][0],ani[i].comp[j].ref,ani[i].comp[j].axshsc);
  }
  ani[i].id=CreateAnimation(ani[i].init);
  n+=ani[i].compcnt;
 }

 //Animation sequences
 //SC3 have a pequliar method of arranging sequences, so we have to sort them accordingly
 //FIXME: Lousy implementation, move to code generator?
 k=0;
 for(k=0;k<n;k++){
  for(i=0;i<ANIM_COUNT;i++){
   for(j=0;j<ani[i].compcnt;j++){
    if(ani[i].comp[j].id!=k)continue;
    int p=ani[i].comp[j].parent;
    if((p>=0)&(p<n)){
     ANIMATIONCOMPONENT_HANDLE prnt=NULL;
     for(a=0;a<ANIM_COUNT;a++)for(b=0;b<ani[a].compcnt;b++)if(ani[a].comp[b].id==p)prnt=ani[a].comp[b].cmpt;
     ani[i].comp[j].cmpt=AddAnimationComponent(ani[i].id,ani[i].comp[j].st0,ani[i].comp[j].st1,ani[i].comp[j].cmpdef,prnt);
    }else ani[i].comp[j].cmpt=AddAnimationComponent(ani[i].id,ani[i].comp[j].st0,ani[i].comp[j].st1,ani[i].comp[j].cmpdef);
    break;
   }
  }
 }
}
//############################################################################//
//All the parameters
void IPA_Vehicle::clbkSetClassCaps(FILEHANDLE cfg)
{
 int i;
 THRUSTER_HANDLE **grps;
 int *grpc;

 //Base stuff
 SetSize(222);
 SetEmptyMass(74000000);
 SetPMI(_V(80,80,80));
 SetCrossSections(_V(53,186.9,25.9));
 SetRotDrag(_V(0.36,0.18,0.15));
 SetTouchdownPoints(_V(0,-55.333,9),_V(-9.15,-55.333,-9),_V(9.15,-55.333,-9));
 SetSurfaceFrictionCoeff(0.07,0.3);
 SetCW(0.12,0.15,1.2,1.8);
 EnableTransponder(true);
 InitNavRadios(4);
 SetCameraOffset(_V(-1.231,-3.064,191.134));

 SetVisibilityLimit(0,0.002);
 SetAlbedoRGB(_V((float)255/255,(float)255/255,(float)255/255));
 SetGravityGradientDamping(0);
 SetWingAspect(0);
 SetWingEffectiveness(0);
 SetMaxWheelbrakeForce(200000);
 SetBankMomentScale(0.006);
 SetPitchMomentScale(0.005);

 //Fuel
 ph_h[0]=CreatePropellantResource(50000000);

 //Thrusters and groups
 grps=(THRUSTER_HANDLE**)malloc(15*sizeof(THRUSTER_HANDLE));
 grpc=(int*)malloc(15*sizeof(int));
 for(i=0;i<15;i++){grps[i]=(THRUSTER_HANDLE*)malloc(17*sizeof(THRUSTER_HANDLE));grpc[i]=0;}
 
 th_h[0]=CreateThruster(_V(0,0,0),_V(0,0,1),5047000000,ph_h[0],5000000000,0,101400);
 grps[0][grpc[0]]=th_h[0];
 grpc[0]++;
 th_h[1]=CreateThruster(_V(0,0,0),_V(0,0,-1),5047000000,ph_h[0],5000000000,0,101400);
 grps[1][grpc[1]]=th_h[1];
 grpc[1]++;
 th_h[2]=CreateThruster(_V(0,0,0),_V(0,1,0),3000000000,ph_h[0],5000000000,0,101400);
 grps[2][grpc[2]]=th_h[2];
 grpc[2]++;
 th_h[3]=CreateThruster(_V(-6,0.7,-0.4),_V(0,-1,0),59060000,ph_h[0],5000000000,0,101400);
 grps[7][grpc[7]]=th_h[3];
 grpc[7]++;
 th_h[4]=CreateThruster(_V(6,-0.7,-0.4),_V(0,1,0),59060000,ph_h[0],5000000000,0,101400);
 grps[7][grpc[7]]=th_h[4];
 grpc[7]++;
 th_h[5]=CreateThruster(_V(-6,-0.7,-0.4),_V(0,1,0),59060000,ph_h[0],5000000000,0,101400);
 grps[8][grpc[8]]=th_h[5];
 grpc[8]++;
 th_h[6]=CreateThruster(_V(6,0.7,-0.4),_V(0,-1,0),59060000,ph_h[0],5000000000,0,101400);
 grps[8][grpc[8]]=th_h[6];
 grpc[8]++;
 th_h[7]=CreateThruster(_V(0,0,15),_V(0,1,0),59060000,ph_h[0],5000000000,0,101400);
 grps[3][grpc[3]]=th_h[7];
 grpc[3]++;
 grps[11][grpc[11]]=th_h[7];
 grpc[11]++;
 th_h[8]=CreateThruster(_V(0,0,-15),_V(0,-1,0),59060000,ph_h[0],5000000000,0,101400);
 grps[3][grpc[3]]=th_h[8];
 grpc[3]++;
 grps[12][grpc[12]]=th_h[8];
 grpc[12]++;
 th_h[9]=CreateThruster(_V(0,0,15),_V(0,-1,0),59060000,ph_h[0],5000000000,0,101400);
 grps[4][grpc[4]]=th_h[9];
 grpc[4]++;
 grps[12][grpc[12]]=th_h[9];
 grpc[12]++;
 th_h[10]=CreateThruster(_V(0,0,-15),_V(0,1,0),59060000,ph_h[0],5000000000,0,101400);
 grps[4][grpc[4]]=th_h[10];
 grpc[4]++;
 grps[11][grpc[11]]=th_h[10];
 grpc[11]++;
 th_h[11]=CreateThruster(_V(0,0,15),_V(1,0,0),59060000,ph_h[0],5000000000,0,101400);
 grps[6][grpc[6]]=th_h[11];
 grpc[6]++;
 grps[9][grpc[9]]=th_h[11];
 grpc[9]++;
 th_h[12]=CreateThruster(_V(0,0,-15),_V(-1,0,0),59060000,ph_h[0],5000000000,0,101400);
 grps[6][grpc[6]]=th_h[12];
 grpc[6]++;
 grps[10][grpc[10]]=th_h[12];
 grpc[10]++;
 th_h[13]=CreateThruster(_V(0,0,15),_V(-1,0,0),59060000,ph_h[0],5000000000,0,101400);
 grps[5][grpc[5]]=th_h[13];
 grpc[5]++;
 grps[10][grpc[10]]=th_h[13];
 grpc[10]++;
 th_h[14]=CreateThruster(_V(0,0,-15),_V(1,0,0),59060000,ph_h[0],5000000000,0,101400);
 grps[5][grpc[5]]=th_h[14];
 grpc[5]++;
 grps[9][grpc[9]]=th_h[14];
 grpc[9]++;
 th_h[15]=CreateThruster(_V(0,0,0),_V(0,0,-1),59060000,ph_h[0],5000000000,0,101400);
 grps[14][grpc[14]]=th_h[15];
 grpc[14]++;
 th_h[16]=CreateThruster(_V(0,0,0),_V(0,0,1),59060000,ph_h[0],5000000000,0,101400);
 grps[13][grpc[13]]=th_h[16];
 grpc[13]++;
 for(i=0;i<15;i++){
  if(i<15)thg_h[i]=CreateThrusterGroup(grps[i],grpc[i],(THGROUP_TYPE)(THGROUP_MAIN+i));
     else thg_h[i]=CreateThrusterGroup(grps[i],grpc[i],THGROUP_USER);
 }

SURFHANDLE tex = oapiRegisterExhaustTexture ("exhaust_atsme");
AddExhaust (th_h, 10, 2, tex);

SURFHANDLE tex2 = oapiRegisterExhaustTexture ("exhaust_atrcs");
AddExhaust (th_h, 10, 2, tex2);

 //Exhausts
 AddExhaust(th_h[0],100,7,_V(0,17.89,-211.068),_V(0,0,-1), tex);
 AddExhaust(th_h[0],150,7,_V(0,17.89,-193.095),_V(0,0,-1), tex);
 AddExhaust(th_h[0],100,7,_V(0,-12.807,-211.068),_V(0,0,-1), tex);
 AddExhaust(th_h[0],150,7,_V(0,-12.807,-193.095),_V(0,0,-1), tex);
 AddExhaust(th_h[1],17,1.4,_V(-13.736,4.766,177.12),_V(0,0,1));
 AddExhaust(th_h[1],17,1.4,_V(13.736,4.766,177.12),_V(0,0,1));
 AddExhaust(th_h[1],17,1.4,_V(-37.883,5.646,20.519),_V(0,0,1));
 AddExhaust(th_h[1],17,1.4,_V(37.883,5.646,20.519),_V(0,0,1));
  AddExhaust(th_h[2],20,2.1,_V(-24.978,-0.929,138.311),_V(0,-1,0));
 AddExhaust(th_h[2],20,2.1,_V(24.978,-0.929,138.311),_V(0,-1,0));
 AddExhaust(th_h[2],20,2.1,_V(24.978,-0.929,128.926),_V(0,-1,0));
 AddExhaust(th_h[2],20,2.1,_V(-24.978,-0.929,128.926),_V(0,-1,0));
 AddExhaust(th_h[2],30,2.1,_V(-49.978,0.293,3.03),_V(0,-1,0));
 AddExhaust(th_h[2],30,2.1,_V(-38.345,0.293,3.03),_V(0,-1,0));
 AddExhaust(th_h[2],30,2.1,_V(49.978,0.293,3.03),_V(0,-1,0));
 AddExhaust(th_h[2],30,2.1,_V(38.345,0.293,3.03),_V(0,-1,0));
 AddExhaust(th_h[2],30,2.1,_V(24.169,-24,-114.860),_V(0,-1,0));
 AddExhaust(th_h[2],30,2.1,_V(24.169,-14.664,-105.475),_V(0,-1,0));
 AddExhaust(th_h[2],30,2.1,_V(-24.169,-14.664,-114.860),_V(0,-1,0));
 AddExhaust(th_h[2],30,2.1,_V(-24.169,-14.664,-105.475),_V(0,-1,0));
 AddExhaust(th_h[9],0.6,0.078,_V(-0.8,-0.25,9.6),_V(0,1,0), tex2);
 AddExhaust(th_h[3],25,2,_V(-27.166,15.593,122.826),_V(0,1,0), tex2);
 AddExhaust(th_h[3],25,2,_V(-25.43,15.593,122.826),_V(0,1,0), tex2);
 AddExhaust(th_h[3],25,2,_V(-23.695,15.593,122.826),_V(0,1,0), tex2);
 AddExhaust(th_h[3],25,2,_V(-26.408,21.138,-70.376),_V(0,1,0), tex2);
 AddExhaust(th_h[3],25,2,_V(-24.697,21.138,-70.376),_V(0,1,0), tex2);
 AddExhaust(th_h[3],25,2,_V(-23.133,21.138,-70.376),_V(0,1,0), tex2);
 AddExhaust(th_h[5],25,2,_V(27.166,15.593,122.826),_V(0,1,0), tex2);
 AddExhaust(th_h[5],25,2,_V(25.43,15.593,122.826),_V(0,1,0), tex2);
 AddExhaust(th_h[5],25,2,_V(23.695,15.593,122.826),_V(0,1,0), tex2);
 AddExhaust(th_h[5],25,2,_V(-27.166,-1.784,122.826),_V(0,-1,0), tex2);
 AddExhaust(th_h[5],25,2,_V(-25.43,-1.784,122.826),_V(0,-1,0), tex2);
 AddExhaust(th_h[5],25,2,_V(-23.695,-1.784,122.826),_V(0,-1,0), tex2);
 AddExhaust(th_h[3],25,2,_V(27.166,-1.784,122.826),_V(0,-1,0), tex2);
 AddExhaust(th_h[3],25,2,_V(25.43,-1.784,122.826),_V(0,-1,0), tex2);
 AddExhaust(th_h[3],25,2,_V(23.695,-1.784,122.826),_V(0,-1,0), tex2);
 AddExhaust(th_h[11],25,2,_V(-33.728,5.108,122.862),_V(-1,0,0), tex2);
 AddExhaust(th_h[11],25,2,_V(-33.728,6.892,122.862),_V(-1,0,0), tex2);
 AddExhaust(th_h[11],25,2,_V(-33.728,8.456,122.862),_V(-1,0,0), tex2);
 AddExhaust(th_h[13],25,2,_V(33.728,8.456,122.862),_V(1,0,0), tex2);
 AddExhaust(th_h[13],25,2,_V(33.728,6.892,122.862),_V(1,0,0), tex2);
 AddExhaust(th_h[13],25,2,_V(33.728,5.108,122.862),_V(1,0,0), tex2);
 AddExhaust(th_h[13],25,2,_V(-34.229,1.674,-70.352),_V(-1,0,0), tex2);
 AddExhaust(th_h[13],25,2,_V(-34.229,3.409,-70.352),_V(-1,0,0), tex2);
 AddExhaust(th_h[13],25,2,_V(-34.229,5.145,-70.352),_V(-1,0,0), tex2);
 AddExhaust(th_h[13],25,2,_V(-32.414,-9.556,-110.831),_V(-1,0,0), tex2);
 AddExhaust(th_h[13],25,2,_V(-32.414,-11.218,-110.831),_V(-1,0,0), tex2);
 AddExhaust(th_h[13],25,2,_V(-32.414,-12.929,-110.831),_V(-1,0,0), tex2);
 AddExhaust(th_h[11],25,2,_V(34.229,1.662,-70.352),_V(1,0,0), tex2);
 AddExhaust(th_h[11],25,2,_V(34.229,3.409,-70.352),_V(1,0,0), tex2);
 AddExhaust(th_h[11],25,2,_V(34.229,5.145,-70.352),_V(1,0,0), tex2);
 AddExhaust(th_h[11],25,2,_V(32.390,-12.975,-110.831),_V(1,0,0), tex2);
 AddExhaust(th_h[11],25,2,_V(32.390,-11.265,-110.831),_V(1,0,0), tex2);
 AddExhaust(th_h[11],25,2,_V(32.390,-9.554,-110.831),_V(1,0,0), tex2);
 AddExhaust(th_h[3],25,2,_V(38.934,-0.22,-32.921),_V(0,-1,0), tex2);
 AddExhaust(th_h[3],25,2,_V(37.174,-0.22,-32.921),_V(0,-1,0), tex2);
 AddExhaust(th_h[3],25,2,_V(35.463,-0.22,-32.921),_V(0,-1,0), tex2);
 AddExhaust(th_h[5],25,2,_V(-35.463,-0.22,-32.921),_V(0,-1,0), tex2);
 AddExhaust(th_h[5],25,2,_V(-37.174,-0.22,-32.921),_V(0,-1,0), tex2);
 AddExhaust(th_h[5],25,2,_V(-38.934,-0.22,-32.921),_V(0,-1,0), tex2);
 AddExhaust(th_h[5],25,2,_V(38.934,11.169,-32.921),_V(0,1,0), tex2);
 AddExhaust(th_h[5],25,2,_V(26.371,21.165,-70.315),_V(0,1,0), tex2);
 AddExhaust(th_h[5],25,2,_V(24.709,21.165,-70.315),_V(0,1,0), tex2);
 AddExhaust(th_h[5],25,2,_V(22.998,21.165,-70.340),_V(0,1,0), tex2);
 AddExhaust(th_h[3],25,2,_V(-37.247,11.145,-32.973),_V(0,1,0), tex2);
 AddExhaust(th_h[3],25,2,_V(-35.292,11.145,-32.973),_V(0,1,0), tex2);
 AddExhaust(th_h[3],25,2,_V(-39.007,11.145,-32.973),_V(0,1,0), tex2);
 AddExhaust(th_h[3],25,2,_V(-24.489,-1.809,-110.857),_V(0,1,0), tex2);
 AddExhaust(th_h[3],25,2,_V(-23.023,-1.809,-110.857),_V(0,1,0), tex2);
 AddExhaust(th_h[3],25,2,_V(-21.263,-1.809,-110.857),_V(0,1,0), tex2);
 AddExhaust(th_h[5],25,2,_V(21.263,-1.809,-110.857),_V(0,1,0), tex2);
 AddExhaust(th_h[5],25,2,_V(23.023,-1.809,-110.857),_V(0,1,0), tex2);
 AddExhaust(th_h[5],25,2,_V(24.489,-1.809,-110.857),_V(0,1,0), tex2);
 AddExhaust(th_h[10],25,2,_V(-27.153,15.541,122.911),_V(0,1,0), tex2);
 AddExhaust(th_h[10],25,2,_V(-23.683,15.541,122.911),_V(0,1,0), tex2);
 AddExhaust(th_h[10],25,2,_V(-25.443,15.541,122.911),_V(0,1,0), tex2);
 AddExhaust(th_h[10],25,2,_V(25.443,15.541,122.911),_V(0,1,0), tex2);
 AddExhaust(th_h[10],25,2,_V(23.683,15.541,122.911),_V(0,1,0), tex2);
 AddExhaust(th_h[10],25,2,_V(27.153,15.541,122.911),_V(0,1,0), tex2);
 AddExhaust(th_h[5],25,2,_V(-24.66,-15.688,-110.837),_V(0,-1,0), tex2);
 AddExhaust(th_h[5],25,2,_V(-22.9,-15.688,-110.837),_V(0,-1,0), tex2);
 AddExhaust(th_h[5],25,2,_V(-21.190,-15.688,-110.837),_V(0,-1,0), tex2);
 AddExhaust(th_h[8],25,2,_V(-26.393,21.147,-70.358),_V(0,1,0), tex2);
 AddExhaust(th_h[8],25,2,_V(-24.633,21.147,-70.358),_V(0,1,0), tex2);
 AddExhaust(th_h[8],25,2,_V(-23.030,21.147,-70.358),_V(0,1,0), tex2);
 AddExhaust(th_h[8],25,2,_V(23.030,21.147,-70.358),_V(0,1,0), tex2);
 AddExhaust(th_h[8],25,2,_V(24.633,21.147,-70.358),_V(0,1,0), tex2);
 AddExhaust(th_h[8],25,2,_V(26.393,21.147,-70.358),_V(0,1,0), tex2);
 AddExhaust(th_h[5],25,2,_V(-26.393,-11.837,-70.358),_V(0,-1,0), tex2);
 AddExhaust(th_h[5],25,2,_V(-24.633,-11.837,-70.358),_V(0,-1,0), tex2);
 AddExhaust(th_h[5],25,2,_V(-23.030,-11.837,-70.358),_V(0,-1,0), tex2);
 AddExhaust(th_h[3],25,2,_V(23.030,-11.837,-70.358),_V(0,-1,0), tex2);
 AddExhaust(th_h[3],25,2,_V(24.633,-11.837,-70.358),_V(0,-1,0), tex2);
 AddExhaust(th_h[3],25,2,_V(26.393,-11.837,-70.358),_V(0,-1,0), tex2);
 AddExhaust(th_h[10],25,2,_V(21.190,-15.688,-110.837),_V(0,-1,0), tex2);
 AddExhaust(th_h[10],25,2,_V(23.119,-15.688,-110.837),_V(0,-1,0), tex2);
 AddExhaust(th_h[10],25,2,_V(24.66,-15.688,-110.837),_V(0,-1,0), tex2);
 AddExhaust(th_h[10],25,2,_V(-23.119,-15.688,-110.837),_V(0,-1,0), tex2);
 AddExhaust(th_h[10],25,2,_V(-21.190,-15.688,-110.837),_V(0,-1,0), tex2);
 AddExhaust(th_h[10],25,2,_V(-24.9,-15.688,-110.837),_V(0,-1,0), tex2);
 AddExhaust(th_h[8],25,2,_V(24.9,-1.68,-111.005),_V(0,1,0), tex2);
 AddExhaust(th_h[8],25,2,_V(22.762,-1.68,-111.005),_V(0,1,0), tex2);
 AddExhaust(th_h[8],25,2,_V(21.159,-1.68,-111.005),_V(0,1,0), tex2);
 AddExhaust(th_h[8],25,2,_V(-21.159,-1.68,-111.005),_V(0,1,0), tex2);
 AddExhaust(th_h[8],25,2,_V(-22.762,-1.68,-111.005),_V(0,1,0), tex2);
 AddExhaust(th_h[8],25,2,_V(-24.9,-1.68,-111.005),_V(0,1,0), tex2);
 AddExhaust(th_h[8],25,2,_V(-27.153,-1.858,122.862),_V(0,-1,0), tex2);
 AddExhaust(th_h[8],25,2,_V(-23.683,-1.858,122.862),_V(0,-1,0), tex2);
 AddExhaust(th_h[8],25,2,_V(-25.491,-1.858,122.862),_V(0,-1,0), tex2);
 AddExhaust(th_h[8],25,2,_V(25.491,-1.858,122.862),_V(0,-1,0), tex2);
 AddExhaust(th_h[8],25,2,_V(23.683,-1.858,122.862),_V(0,-1,0), tex2);
 AddExhaust(th_h[8],25,2,_V(27.153,-1.858,122.862),_V(0,-1,0), tex2);
 AddExhaust(th_h[3],25,2,_V(24.624,-15.676,-110.825),_V(0,-1,0), tex2);
 AddExhaust(th_h[3],25,2,_V(22.937,-15.676,-110.825),_V(0,-1,0), tex2);
 AddExhaust(th_h[3],25,2,_V(21.178,-15.676,-110.825),_V(0,-1,0), tex2);
 AddExhaust(th_h[10],25,2,_V(23.01,-12.181,-70.357),_V(0,-1,0), tex2);
 AddExhaust(th_h[10],25,2,_V(26.383,-12.181,-70.357),_V(0,-1,0), tex2);
 AddExhaust(th_h[10],25,2,_V(24.721,-12.181,-70.357),_V(0,-1,0), tex2);
 AddExhaust(th_h[10],25,2,_V(-23.01,-12.181,-70.357),_V(0,-1,0), tex2);
 AddExhaust(th_h[10],25,2,_V(-26.383,-12.181,-70.357),_V(0,-1,0), tex2);
 AddExhaust(th_h[10],25,2,_V(-24.721,-12.181,-70.357),_V(0,-1,0), tex2);

  	PARTICLESTREAMSPEC contrail_main = {
		0, 23.0, 120, 3000.2, 0.05, 1.3, 9, 99.10, PARTICLESTREAMSPEC::DIFFUSE,
		PARTICLESTREAMSPEC::LVL_PSQRT, 0, 0.1,
		PARTICLESTREAMSPEC::ATM_PLOG, 1e-2, 0.1

	};PARTICLESTREAMSPEC contrail_hover = {
		0, 7.0, 120, 1000.2, 0.05, 0.2, 9, 99.10, PARTICLESTREAMSPEC::DIFFUSE,
		PARTICLESTREAMSPEC::LVL_PSQRT, 0, 0.1,
		PARTICLESTREAMSPEC::ATM_PLOG, 1e-2, 0.1

	};
		PARTICLESTREAMSPEC exhaust_smoke = {
		0, 14.0, 120, 3000.2, 0.05, 1.3, 9, 99.10, PARTICLESTREAMSPEC::DIFFUSE,
		PARTICLESTREAMSPEC::LVL_PSQRT, 0, 0.1,
		PARTICLESTREAMSPEC::ATM_PLOG, 1e-2, 0.1
	};SURFHANDLE tex7 = oapiRegisterParticleTexture ("Exhaust2")
	;exhaust_smoke.tex = oapiRegisterParticleTexture ("Contrail4");
		;AddExhaust (th_h, 16.0, 2.0, tex7);


	PARTICLESTREAMSPEC exhaust_main = {
		0, 10.0, 90, 600.5, 0.05, 0.5, 2, 6.0, PARTICLESTREAMSPEC::EMISSIVE,
		PARTICLESTREAMSPEC::LVL_SQRT, 0, 1,
		PARTICLESTREAMSPEC::ATM_PLOG, 1e-5, 0.1
	};SURFHANDLE tex4 = oapiRegisterParticleTexture ("Exhaust2")
	;exhaust_main.tex = oapiRegisterParticleTexture ("Contrail2");
		;AddExhaust (th_h, 16.0, 2.0, tex4);

  //Exhausts
 ;AddExhaustStream(th_h[0], _V(0,17.89,-193.095), &contrail_main);		//main throttle
  ;AddExhaustStream(th_h[0], _V(0,17.89,-193.095), &contrail_main);
 AddExhaustStream(th_h[0], _V(0,17.89,-193.095), &exhaust_main);
 AddExhaustStream(th_h[0], _V(0,-12.807,-193.095), &contrail_main);
  AddExhaustStream(th_h[0], _V(0,17.89,-193.095), &exhaust_smoke);
 AddExhaustStream(th_h[0], _V(0,-12.807,-193.095), &exhaust_smoke);
  AddExhaustStream(th_h[0], _V(0,-12.807,-193.095), &contrail_main);
 AddExhaustStream(th_h[0], _V(0,-12.807,-193.095), &exhaust_main);		//end main throttle	


  AddExhaustStream(th_h[2], _V(-24.978,-0.929,138.311), &contrail_hover);		//hover smoke
  AddExhaustStream(th_h[2], _V(24.978,-0.929,138.311), &contrail_hover);
  AddExhaustStream(th_h[2], _V(49.966,6.653,258.045), &contrail_hover);
  AddExhaustStream(th_h[2], _V(24.978,-0.929,128.926), &contrail_hover);
  AddExhaustStream(th_h[2], _V(-24.978,-0.929,128.926), &contrail_hover);
  AddExhaustStream(th_h[2], _V(-49.978,0.293,3.03), &contrail_hover);
  AddExhaustStream(th_h[2], _V(-38.345,0.293,3.03), &contrail_hover);
  AddExhaustStream(th_h[2], _V(49.978,0.293,3.03), &contrail_hover);
  AddExhaustStream(th_h[2], _V(38.345,0.293,3.03), &contrail_hover);
  AddExhaustStream(th_h[2], _V(24.169,-24,-114.860), &contrail_hover);
  AddExhaustStream(th_h[2], _V(24.169,-14.664,-105.475), &contrail_hover);	
  AddExhaustStream(th_h[2], _V(-24.169,-14.664,-114.860), &contrail_hover);		//end hover smoke

 //Meshes
 SetMeshVisibilityMode(msh_idh[0]=AddMesh(msh_h[0]=oapiLoadMeshGlobal("SMIPA")),3);

 //Animations
 define_animations();

 //Docks
 CreateDock(_V(0,5.765,179.510),_V(0,0,1),_V(0,1,0));
 CreateDock(_V(0,-11.994,226.518),_V(0,0,1),_V(0,1,0));
 CreateDock(_V(-23.839,-11.098,102.086),_V(-1,0,0),_V(0,1,0));
 CreateDock(_V(-23.839,-11.098,127.936),_V(-1,0,0),_V(0,1,0));
 CreateDock(_V(23.839,-11.098,102.086),_V(1,0,0),_V(0,1,0));
 CreateDock(_V(23.839,-11.098,127.936),_V(1,0,0),_V(0,1,0));

 //Airfoils
 CreateAirfoil3(LIFT_VERTICAL,_V(0,0,0),VLiftCoeff,0,0,69986,1.5);
 CreateAirfoil3(LIFT_HORIZONTAL,_V(0,0,0),HLiftCoeff,0,0,2100,1.5);
 CreateControlSurface2(AIRCTRL_ELEVATOR,70.733,1.5,_V(0,0.7,-14),0,(UINT)-1);
 CreateControlSurface2(AIRCTRL_RUDDER  ,70.733,1.5,_V(0,-0.7,-15),0,(UINT)-1);
 CreateControlSurface2(AIRCTRL_AILERON ,70.733,2.333,_V(12,0.7,-4.7),0,(UINT)-1);
 CreateControlSurface2(AIRCTRL_AILERON ,70.733,2.333,_V(-12,0.7,-4.7),0,(UINT)-1);
}
//############################################################################//
void IPA_Vehicle::clbkLoadStateEx(FILEHANDLE scn,void *vs)
{
 char *line;
 int i,n;

 while(oapiReadScenario_nextline(scn,line)){
  //Animation state loading
  if(!strnicmp(line,"ANIM_",5)){
   sscanf(line+5,"%d",&i);
   if((i>=0)&&(i<ANIM_COUNT)){
    n=0;
    if(i>=10)n=1;
    if(i>=100)n=2;
    if(i>=1000)n=3;
    sscanf(line+6+n,"%d",&ani[i].status);
    sscanf(line+6+n+3,"%lf",&ani[i].proc);
    SetAnimation(ani[i].id,ani[i].proc);
   }
  }else{
   ParseScenarioLineEx(line,vs);
  }
 }
}
//############################################################################//
void IPA_Vehicle::clbkSaveState(FILEHANDLE scn)
{
 SaveDefaultState(scn);
 
 //Animation state
 char cbuf[256],nbuf[256];
 int i;

 for(i=0;i<ANIM_COUNT;i++){
  sprintf(cbuf,"%d %0.4f",ani[i].status,ani[i].proc);
  sprintf(nbuf,"ANIM_%d",i);
  oapiWriteScenario_string(scn,nbuf,cbuf);
 }
}
//############################################################################//
int  IPA_Vehicle::clbkConsumeBufferedKey(DWORD key,bool down,char *kstate)
{
 int i;
 if(!down)return 0;
 for(i=0;i<ANIM_COUNT;i++)if(ani[i].tp==0)if(key==ani[i].trigkey){
  //Animation input
  if(!ani[i].repeat){
   switch(ani[i].status){
    //Fix it short
    case -2:ani[i].status=1;break;
    case -1:ani[i].status=1;break;
    case  1:ani[i].status=-1;break;
    case  2:ani[i].status=-1;break;
    default:ani[i].status=2;
   }
  }else{
   switch(ani[i].status){
    case 1:ani[i].status=0;break;
    case 0:ani[i].status=1;break;
    default:ani[i].status=0;
   }
  }
 }
 return 0;
}
//#######################################################################################//
void IPA_Vehicle::clbkPostStep(double simt,double simdt,double mjd)
{
 //Animation timing controls
 int i;
 for(i=0;i<ANIM_COUNT;i++)if(abs(ani[i].status)==1){
  double da=simdt*ani[i].spd;
  if(ani[i].repeat){
   ani[i].proc=fmod(ani[i].proc+da,1);
  }else{
   if(ani[i].status==-1){
    if(ani[i].proc>0.0)ani[i].proc=max(0.0,ani[i].proc-da);
    else                     ani[i].status=-2;
   }else{
    if(ani[i].proc<1.0)ani[i].proc=min(1.0,ani[i].proc+da);
    else                     ani[i].status=2;
   }
  }
  SetAnimation(ani[i].id,ani[i].proc);
 }
}
//#######################################################################################//
//Creation
DLLCLBK void InitModule(HINSTANCE hModule){}
DLLCLBK void ExitModule(HINSTANCE hModule){}
DLLCLBK VESSEL *ovcInit(OBJHANDLE hvessel,int flightmodel){return new IPA_Vehicle(hvessel,flightmodel);}
DLLCLBK void ovcExit(VESSEL *vessel){if(vessel)delete(IPA_Vehicle*)vessel;}
//#######################################################################################//
 

BruceJohnJennerLawso

Dread Lord of the Idiots
Addon Developer
Joined
Apr 14, 2012
Messages
2,585
Reaction score
0
Points
36
Are you sure youve made it complicated enough? You have enough particle streams there to make it seem like its leaking :lol:. The issue here is that you dont appear to have any sort of function that can create a vessel in the simulation. The steps to getting that are complicated, but a good first step would be to go over to Hlynqacs (sorry I can never remember how its spelled) code repository on sourceforge, find the appropriate function, and add it to your project.
 
Top