import wildtangent.webdriver.*; import java.applet.*; public class Scene { Main Parent; WTCamera CameraView; WTStage Stage; WTModel Chassis1; WTModel Chassis2; WTModel Axle; WTModel Wheel_Right; WTModel Wheel_Left; WTModel DriveShaft; WTModel DriveShaft2; WTModel SupportBar; WTModel SupportBar2; WTModel Shocks; WTModel NeedleModel; WTBitmap TundraTex1; WTBitmap TundraTex2; WTBitmap TireTex; WTBitmap DriveShaftTex; WTBitmap AxleTex; WTBitmap ShadowTex; WTBitmap DustTex; WTBitmap FlareTex[]; WTBitmap TreadTex; WTBitmap BrakeLight; WTBitmap CabLight; WTBitmap ReverseLight; WTBitmap Speedometer; WTContainer Needle; WTDrop SpeedometerDrop; WTLight AmbientLight; WTLight PointLight; WTContainer Flare[]; WTGroup FlareGroup; WTGroup FlareDummyGroupContainer; WTGroup FlareDummyGroup; WTGroup Camera; WTAudioClip Sound_Engine[]; WTAudioClip Sound_Shocks1; WTAudioClip Sound_Shocks2; WTAudioClip Sound_Skid; WTAudioClip Sound_Shift; String TexturePath="media/textures/"; String ModelPath="media/models/"; String ImagePath="media/images/"; String SoundPath="media/sounds/"; int LinePosition=0; int SceneCompleted=0; int SceneElements[] = new int[200]; int ElementCount=53; boolean SceneInitialized=false; public void init(Main ParentClass){ Parent=ParentClass; FlareTex = new WTBitmap[7]; Sound_Engine = new WTAudioClip[10]; Flare = new WTContainer[7]; setupScene(); loadMedia(); } void setupScene(){ Stage = Parent.Wt.createStage(); CameraView = Parent.scene.Stage.createCamera(); CameraView.setViewRect(0,0,640,480); Parent.Wt.setResolution(640,480,16); } void loadMedia() { int Loop=0; SceneInitialized=true; // LOAD COMMON MODELS Chassis1 = Parent.Wt.createModel("media/models/chassis_1.wt",0); Chassis2 = Parent.Wt.createModel("media/models/chassis_2.wt",0); Axle = Parent.Wt.createModel("media/models/axle.wt",0); DriveShaft = Parent.Wt.createModel("media/models/driveshaft.wt",0); DriveShaft2 = Parent.Wt.createModel("media/models/driveshaft.wt",0); SupportBar = Parent.Wt.createModel("media/models/supportbar.wt",0); SupportBar2 = Parent.Wt.createModel("media/models/supportbar.wt",0); Wheel_Left = Parent.Wt.createModel("media/models/wheel_left.wt",0); Wheel_Right = Parent.Wt.createModel("media/models/wheel_right.wt",0); Shocks = Parent.Wt.createModel("media/models/shocks.wt",0); NeedleModel = Parent.Wt.createModel("media/models/needle.wt",0); NeedleModel.setScale(.0011f,.0011f,.0011f); Needle = Parent.Wt.createContainer(); Needle.attach(NeedleModel); // LOAD COMMON TEXTURES if(!Parent.DetailTextures){ Parent.DetailLensFlare=false; Parent.DetailDustClouds=false; Parent.DetailTreadMarks=false; } if(!Parent.DetailSoundQuality){ SoundPath = "media/sounds_low/"; } if(Parent.DetailTextureQuality==1)TexturePath = "media/textures_med/"; if(Parent.DetailTextureQuality==0)TexturePath = "media/textures_low/"; if(Parent.DetailTextures){ if(Parent.DetailTextureQuality > 0){ TundraTex1 = Parent.Wt.createBitmap(TexturePath + "chassis1.wpg",0); TundraTex2 = Parent.Wt.createBitmap(TexturePath + "chassis2.wpg",0); TireTex = Parent.Wt.createBitmap(TexturePath + "tire.wpg",0); } else{ TundraTex1 = Parent.Wt.createBitmap(TexturePath + "chassis1.wjp",0); TundraTex2 = Parent.Wt.createBitmap(TexturePath + "chassis2.wjp",0); TireTex = Parent.Wt.createBitmap(TexturePath + "tire.wjp",0); } DriveShaftTex = Parent.Wt.createBitmap(TexturePath + "driveshaft.wpg",0); AxleTex = Parent.Wt.createBitmap(TexturePath + "axle.wpg",0); ShadowTex = Parent.Wt.createBitmap(TexturePath + "shadow.wpg",0); ShadowTex.setColorKey(0,0,0); TreadTex = Parent.Wt.createBitmap("media/images/tread.wpg",0); TreadTex.setColorKey(0,0,0); BrakeLight = Parent.Wt.createBitmap("media/images/blite.wpg",0); BrakeLight.setColorKey(0,0,0); CabLight = Parent.Wt.createBitmap("media/images/clite.wpg",0); CabLight.setColorKey(0,0,0); ReverseLight = Parent.Wt.createBitmap("media/images/rlite.wpg",0); ReverseLight.setColorKey(0,0,0); DustTex=Parent.Wt.createBitmap("media/images/dust.wpg",0); DustTex.setColorKey(0,0,0); } Speedometer = Parent.Wt.createBitmap("media/images/speedometer.wpg",0); Speedometer.setColorKey(0,0,0); SpeedometerDrop = CameraView.addDrop(Speedometer,true); SpeedometerDrop.setPosition(5,310); // LOAD SOUNDS if(Parent.DetailSoundEffects){ Sound_Shift = Parent.Wt.createAudioClip(SoundPath + "shift.wwv",0); Sound_Engine[0] = Parent.Wt.createAudioClip(SoundPath + "reverse.wwv",0); Sound_Engine[1] = Parent.Wt.createAudioClip(SoundPath + "idle.wwv",0); Sound_Engine[2] = Parent.Wt.createAudioClip(SoundPath + "idle3.wwv",0); Sound_Engine[3] = Parent.Wt.createAudioClip(SoundPath + "idle2.wwv",0); Sound_Engine[4] = Parent.Wt.createAudioClip(SoundPath + "reverse_kill.wwv",0); Sound_Engine[5] = Parent.Wt.createAudioClip(SoundPath + "idle_kill.wwv",0); Sound_Engine[6] = Parent.Wt.createAudioClip(SoundPath + "second.wwv",0); Sound_Engine[7] = Parent.Wt.createAudioClip(SoundPath + "secondkill.wwv",0); Sound_Engine[8] = Parent.Wt.createAudioClip(SoundPath + "third.wwv",0); Sound_Engine[9] = Parent.Wt.createAudioClip(SoundPath + "thirdkill.wwv",0); /* while(!Sound_Engine[0].getIsLoaded() || !Sound_Engine[1].getIsLoaded() || !Sound_Engine[2].getIsLoaded() || !Sound_Engine[3].getIsLoaded() || !Sound_Engine[4].getIsLoaded() || !Sound_Engine[5].getIsLoaded() || !Sound_Engine[6].getIsLoaded() || !Sound_Engine[7].getIsLoaded() || !Sound_Engine[8].getIsLoaded() || !Sound_Engine[9].getIsLoaded()){ }*/ Sound_Shocks1 = Parent.Wt.createAudioClip(SoundPath + "suspen1.wwv",0); Sound_Shocks2 = Parent.Wt.createAudioClip(SoundPath + "suspen1.wwv",0); Sound_Skid = Parent.Wt.createAudioClip(SoundPath + "skid.wwv",0); } // CREATE GROUPS FOR LENS FLARE CALCULATION FlareDummyGroupContainer=Parent.Wt.createGroup(); FlareDummyGroup=Parent.Wt.createGroup(); FlareGroup=Parent.Wt.createGroup(); Camera=Parent.Wt.createGroup(); Parent.scene.Stage.addObject(FlareDummyGroupContainer); Parent.scene.Stage.addObject(FlareDummyGroup); Parent.scene.Stage.addObject(FlareGroup); Parent.scene.Stage.addObject(Camera); Parent.scene.Stage.addObject(Needle); Camera.addObject(CameraView); Camera.addObject(FlareGroup); Camera.addObject(Needle); Needle.setPosition(-.405f,-.255f,1.1f); if(Parent.DetailLensFlare){ for(Loop=0;Loop<4;Loop++){ FlareTex[Loop]=Parent.Wt.createBitmap("media/images/flare" + (Loop+1) + ".wpg",0); FlareTex[Loop].setColorKey(0,0,0); } for(Loop=0;Loop<7;Loop++){ Flare[Loop]=Parent.Wt.createContainer(); } Flare[0].attachBitmap(FlareTex[0],.2f,.2f,64,64); Flare[0].setBitmapOpacity(80); Parent.scene.Stage.addObject(Flare[0]); FlareGroup.addObject(Flare[0]); Flare[1].attachBitmap(FlareTex[2],.3f,.3f,64,64); Flare[1].setBitmapOpacity(80); Parent.scene.Stage.addObject(Flare[1]); FlareGroup.addObject(Flare[1]); Flare[2].attachBitmap(FlareTex[3],.08f,.08f,64,64); Flare[2].setBitmapOpacity(50); Parent.scene.Stage.addObject(Flare[2]); FlareGroup.addObject(Flare[2]); Flare[3].attachBitmap(FlareTex[1],.2f,.2f,64,64); Flare[3].setBitmapOpacity(30); Parent.scene.Stage.addObject(Flare[3]); FlareGroup.addObject(Flare[3]); Flare[4].attachBitmap(FlareTex[0],.03f,.03f,64,64); Flare[4].setBitmapOpacity(90); Parent.scene.Stage.addObject(Flare[4]); FlareGroup.addObject(Flare[4]); Flare[5].attachBitmap(FlareTex[2],.15f,.15f,64,64); Flare[5].setBitmapOpacity(30); Parent.scene.Stage.addObject(Flare[5]); FlareGroup.addObject(Flare[5]); Flare[6].attachBitmap(FlareTex[3],.35f,.35f,64,64); Flare[6].setBitmapOpacity(40); Parent.scene.Stage.addObject(Flare[6]); FlareGroup.addObject(Flare[6]); FlareDummyGroupContainer.addObject(FlareDummyGroup); } // APPLY TEXTURES TO MODELS if(Parent.DetailTextures){ Chassis1.setTexture(TundraTex1); Chassis2.setTexture(TundraTex2); Axle.setTexture(AxleTex); DriveShaft.setTexture(DriveShaftTex); DriveShaft2.setTexture(DriveShaftTex); Wheel_Left.setTexture(TireTex); Wheel_Right.setTexture(TireTex); } else{ Chassis1.setColor(180,124,54); Chassis2.setColor(180,124,54); Axle.setColor(30,30,30); DriveShaft.setColor(70,70,70); Wheel_Left.setColor(50,50,50); Wheel_Right.setColor(50,50,50); } // SCALE MODELS SupportBar.setAbsoluteScale(1,1,1.1f); DriveShaft.setAbsoluteScale(1,1,1.1f); SupportBar2.setAbsoluteScale(1,1,.7f); DriveShaft2.setAbsoluteScale(1,1,.6f); // CREATE LIGHTS AmbientLight = Parent.Wt.createLight(0); PointLight = Parent.Wt.createLight(3); Stage.addObject(AmbientLight); Stage.addObject(PointLight); PointLight.setOrientation(0,0,1,120f); AmbientLight.setColor(200,200,200); PointLight.setColor(255,255,255); } }