SpiderPig Posted December 27, 2009 Share Posted December 27, 2009 I'm using C++ 2010, and I'm trying to make a function to rotate a car door, but the door model is loaded in the "main" function so that makes it local only to that function right? How do I get other functions to recognize it too? I've tried Initializing, setting up the graphics and loading the door before "main", but it doesn't work... Any suggestions? (I'm rather new to both C++ and LeadWerks) Thanks Quote Link to comment Share on other sites More sharing options...
carlb Posted December 27, 2009 Share Posted December 27, 2009 would not use 2010 yet, there still a few bug in it stick with the older version Quote Asus ROG STRIX B350-F GAMMING AMD Ryzen 7 1700x 32 gb ddr4 15 TB raid 5 HD Nvidia EVGA 1060GTX Win10 64bit Link to comment Share on other sites More sharing options...
SpiderPig Posted December 27, 2009 Author Share Posted December 27, 2009 Ahhh, really? That'd explain a few problems... Thanks carlb! So is this global Entity problem only with 2010 you think? Or its got nothing to do with it? Quote Link to comment Share on other sites More sharing options...
Niosop Posted December 27, 2009 Share Posted December 27, 2009 Probably nothing to do w/ it. Post some code, too hard to diagnose just guessing what you have. Quote Windows 7 x64 - Q6700 @ 2.66GHz - 4GB RAM - 8800 GTX ZBrush - Blender Link to comment Share on other sites More sharing options...
SpiderPig Posted December 27, 2009 Author Share Posted December 27, 2009 Here's The code I'm using, Everything else works fine. It just doesn't know what 'TailGate' is, #include "engine.h"void UdateTailGate(void);int TailGateAngle=0;int TailGateStatus=0;int main(int argc,char** argv){ Initialize(); Graphics(1024,768); CreateWorld(); TEntity MainCam=CreateCamera(); PositionEntity(MainCam,Vec3(0,6,-7)); RotateEntity(MainCam,Vec3(30,0,0)); TLight MainLight=CreateSpotLight(20.0); TLight MainLight2=CreateSpotLight(20.0); PositionEntity(MainLight,Vec3(0,12,6)); PositionEntity(MainLight2,Vec3(0,12,-6)); SetShadowmapSize(MainLight,2000); SetShadowmapSize(MainLight2,2000); RotateEntity(MainLight,Vec3(90,0,0)); RotateEntity(MainLight2,Vec3(90,0,0)); TEntity Floor=CreatePlane(); ScaleEntity(Floor,Vec3(10,1,10)); TEntity Car=LoadModel("JeepMain.gmf"); TEntity Bonnet=LoadModel("Bonnet.gmf"); PositionEntity(Bonnet,Vec3(0.012,3.177,-1.297)); EntityParent(Bonnet,Car); int BonnetAngle=0; int BonnetStatus=0;//0-closed,1-open,2-opening,3-closeing TEntity TailGate=LoadModel("TailGate.gmf"); PositionEntity(TailGate,Vec3(-1.105,2.249,4.578)); EntityParent(TailGate,Car); TEntity SpareWheel=LoadModel("Wheel.gmf"); PositionEntity(SpareWheel,Vec3(0,2.293,5)); EntityParent(SpareWheel,TailGate); TEntity LeftDoor=LoadModel("LeftDoor.gmf"); PositionEntity(LeftDoor,Vec3(1.975,2.669,-0.618)); EntityParent(LeftDoor,Car); TBuffer Buffer=CreateBuffer(1024,768,BUFFER_COLOR|BUFFER_DEPTH|BUFFER_NORMAL);//buffer for teh lights float CarAng=0.0; while(!KeyHit(KEY_ESCAPE)) { if(KeyHit(KEY_==1) { if(BonnetStatus==0) { BonnetStatus=2; } else { if(BonnetStatus==1) { BonnetStatus=3; } } } if(BonnetStatus==2) { if(BonnetAngle<60) { BonnetAngle++; RotateEntity(Bonnet,Vec3(BonnetAngle,0,0)); } else { BonnetStatus=1;//open } } if(BonnetStatus==3) { if(BonnetAngle>0) { BonnetAngle--; RotateEntity(Bonnet,Vec3(BonnetAngle,0,0)); } else { BonnetStatus=0;//closed } } UdateTailGate(); RotateEntity(Car,Vec3(0,CarAng,0)); CarAng=CarAng-0.2; UpdateWorld(1); SetBuffer(Buffer); RenderWorld(RENDER_ALL); SetBuffer(BackBuffer()); RenderLights(Buffer); SetBuffer(BackBuffer()); Flip(1); } Terminate(); return 0;}void UdateTailGate(void){ if(KeyHit(KEY_T)==1) { if(TailGateStatus==0) { TailGateStatus=2; } else { if(TailGateStatus==1) { TailGateStatus=3; } } } if(TailGateStatus==2) { if(TailGateAngle<100) { TailGateAngle++; RotateEntity(TailGate,Vec3(0,TailGateAngle,0));//Tailgate is an undeclared Identifier } else { TailGateStatus=1;//open } } if(TailGateStatus==3) { if(TailGateAngle>0) { TailGateAngle--; RotateEntity(TailGate,Vec3(0,TailGateAngle,0)); } else { TailGateStatus=0;//closed } }}; Quote Link to comment Share on other sites More sharing options...
Canardia Posted December 27, 2009 Share Posted December 27, 2009 You need to declare the global variables before the functions which use them, and please use the code tag in the forum when you paste code: int TailGateAngle=0; int TailGateStatus=0; void UdateTailGate(void); Quote ■ Ryzen 9 ■ RX 6800M ■ 16GB ■ XF8 ■ Windows 11 ■ ■ Ultra ■ LE 2.5 ■ 3DWS 5.6 ■ Reaper ■ C/C++ ■ C# ■ Fortran 2008 ■ Story ■ ■ Homepage: https://canardia.com ■ Link to comment Share on other sites More sharing options...
SpiderPig Posted December 27, 2009 Author Share Posted December 27, 2009 You know, just as I posted that I thought, "I know how to fix that," At the beginning of the code (before 'main') i added : TEntity Tailgate; Then when I load the model instead of TEntity TailGate=LoadModel("TailGate.gmf"); I just used : TailGate=LoadModel("TailGate.gmf");!!!! And it works fine....(I feel stupid) Thanks though!! Quote Link to comment Share on other sites More sharing options...
SpiderPig Posted December 27, 2009 Author Share Posted December 27, 2009 Ok, I'll declare them before the function, Thanks Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.