From: <baz...@us...> - 2009-01-07 12:12:55
|
Revision: 8761 http://armagetronad.svn.sourceforge.net/armagetronad/?rev=8761&view=rev Author: bazaarmagetron Date: 2009-01-07 12:12:48 +0000 (Wed, 07 Jan 2009) Log Message: ----------- da...@da...: Added camview, from voodoo Modified Paths: -------------- armagetronad/trunk/armagetronad/resource/proto/Anonymous/original/original.cockpit.xml armagetronad/trunk/armagetronad/resource/proto/cockpit.dtd armagetronad/trunk/armagetronad/src/Makefile.am armagetronad/trunk/armagetronad/src/engine/eCamera.cpp armagetronad/trunk/armagetronad/src/engine/eCamera.h armagetronad/trunk/armagetronad/src/engine/eDisplay.cpp armagetronad/trunk/armagetronad/src/engine/eGrid.cpp armagetronad/trunk/armagetronad/src/engine/eGrid.h armagetronad/trunk/armagetronad/src/render/rViewport.h armagetronad/trunk/armagetronad/src/tron/cockpit/cCockpit.cpp armagetronad/trunk/armagetronad/src/tron/cockpit/cCockpit.h armagetronad/trunk/armagetronad/src/tron/cockpit/cMap.cpp armagetronad/trunk/armagetronad/src/tron/cockpit/cWidgetBase.h armagetronad/trunk/armagetronad/src/tron/gGame.cpp Added Paths: ----------- armagetronad/trunk/armagetronad/src/tron/cockpit/cCamview.cpp armagetronad/trunk/armagetronad/src/tron/cockpit/cCamview.h Property Changed: ---------------- armagetronad/trunk/armagetronad/ Property changes on: armagetronad/trunk/armagetronad ___________________________________________________________________ Modified: bzr:revision-info - timestamp: 2009-01-05 07:12:44.875000000 -0600 committer: da...@da... properties: branch-nick: armagetronad + timestamp: 2009-01-05 13:26:48.996000051 -0600 committer: da...@da... properties: branch-nick: 0.3.1_test Modified: bzr:ancestry:v3-list-QlpoOTFBWSZTWZvbKhsAAAdRgAAQABK6798QIABURMgAAaeoNT1TxT1DQbKaeobXKiyAmlWT7Y5MkdJOtXDtB7w7DOGFBHiOBxaUIu7HQyyQSvxdyRThQkJvbKhs - svn-v3-list-QlpoOTFBWSZTWZvbKhsAAAdRgAAQABK6798QIABURMgAAaeoNT1TxT1DQbKaeobXKiyAmlWT7Y5MkdJOtXDtB7w7DOGFBHiOBxaUIu7HQyyQSvxdyRThQkJvbKhs:7d95bf1e-0414-0410-9756-b78462a59f44:armagetronad%2Ftrunk%2Farmagetronad:8394 svn-v3-list-QlpoOTFBWSZTWZvbKhsAAAdRgAAQABK6798QIABURMgAAaeoNT1TxT1DQbKaeobXKiyAmlWT7Y5MkdJOtXDtB7w7DOGFBHiOBxaUIu7HQyyQSvxdyRThQkJvbKhs:7d95bf1e-0414-0410-9756-b78462a59f44:armagetronad%2Ftrunk%2Farmagetronad:8715 + svn-v3-list-QlpoOTFBWSZTWZvbKhsAAAdRgAAQABK6798QIABURMgAAaeoNT1TxT1DQbKaeobXKiyAmlWT7Y5MkdJOtXDtB7w7DOGFBHiOBxaUIu7HQyyQSvxdyRThQkJvbKhs:7d95bf1e-0414-0410-9756-b78462a59f44:armagetronad%2Ftrunk%2Farmagetronad:8394 svn-v3-list-QlpoOTFBWSZTWZvbKhsAAAdRgAAQABK6798QIABURMgAAaeoNT1TxT1DQbKaeobXKiyAmlWT7Y5MkdJOtXDtB7w7DOGFBHiOBxaUIu7HQyyQSvxdyRThQkJvbKhs:7d95bf1e-0414-0410-9756-b78462a59f44:armagetronad%2Ftrunk%2Farmagetronad:8715 voodoo-20080418152302-ig27bh2y1fbkwp6b Modified: bzr:file-ids - + src/tron/cockpit/cCamview.h ccamview.h-20080418145407-zn5xad2y1yz79x4e-2 src/tron/cockpit/cCamview.cpp ccamview.cpp-20080418145407-zn5xad2y1yz79x4e-1 Modified: bzr:revision-id:v3-list-QlpoOTFBWSZTWZvbKhsAAAdRgAAQABK6798QIABURMgAAaeoNT1TxT1DQbKaeobXKiyAmlWT7Y5MkdJOtXDtB7w7DOGFBHiOBxaUIu7HQyyQSvxdyRThQkJvbKhs - 613 z-...@us...-20080211141509-cwbrb6hmtz9313jr 626 z-...@us...-20080214170110-rhfpd874zuogr3cm 627 z-...@us...-20080214170244-1gstsfe9yzyvrx9b 657 z-...@us...-20080301093905-0jwh1zg9srukp8fn 678 wrt...@us...-20080320130546-cr72y7d9q5a8nk7a 679 z-...@us...-20080324202056-eybvkm0gjomywbcq 680 z-...@us...-20080326104303-kpkkrwiw1fioi0rd 681 epsy-20080327213346-setzm7umdzzuk2dm 683 wrt...@us...-20080402122117-54nak33inuca02o9 684 wrt...@us...-20080402122804-2xhc8bgyrjsa09cd 685 wrt...@us...-20080418093840-cxtpql4xw2vsbmyn 686 ep...@fr...-20080418200503-q16s8az3yewn4x7a 687 ep...@fr...-20080419004917-bq4vguy9vpbkmlo3 688 wrt...@us...-20080419185850-ksm1feadrrhqigjb 689 wrt...@us...-20080423170738-zb8v72r0asm7cp52 691 ep...@fr...-20080427145818-212ave5ohdhth4ph 692 epsy46-20080428164518-07b9wsj90rf82c3y 693 epsy46-20080429194430-hq3fd6i1mnz1vrnz 694 ep...@fr...-20080518131839-uik8hj18c55boh3m 696 z-...@us...-20080618212520-e6ov1rb9b9edwt30 697 wrt...@us...-20080708142300-tu6f7ag7ak0yhdrf 698 wrt...@us...-20080727173310-pv1vq0wj01yfwgfl 699 da...@da...-20080824021014-8aacq5gfp7ktxlxz 700 da...@da...-20080824055426-l5dwhb216uteu7ca 701 da...@da...-20080824172432-lvagd99j28hq8uc1 702 da...@da...-20080824225545-ply97boo9jkqtysn 704 ep...@fr...-20081027173216-nh6d92edtwe35j2g 705 ep...@fr...-20081027203505-42bpegw0fyywzyou 706 ep...@fr...-20081027204727-jcx89jukht9ay72r 707 ep...@fr...-20081028180734-62o6e90rf020xzv8 708 ep...@fr...-20081028224044-f3myemuy87v52ilp 709 ep...@fr...-20081110193848-iksu9rmzzi7jb0qq 710 ep...@fr...-20081114212232-i1q12n375bdpl0sp 712 z-...@us...-20081211141049-wbjceadupsfss5ib 713 da...@da...-20081216223143-1hso83uxyagaubg8 716 lee...@gm...-20081220084635-zv6bpm9rar9yufy7 717 lee...@gm...-20081220085046-6rwe6cqmdlffs4rl 718 lee...@gm...-20081220085502-gpad43pu99t1e6po 719 lee...@gm...-20081220092821-q7uj4w92j6a3a7eb 720 lee...@gm...-20081220094339-k3zb139qp87r4b2w 721 lee...@gm...-20081220100858-uap7k5s22tbipzkt 722 lee...@gm...-20081220111203-rhp5p15agx73xi1k 723 lee...@gm...-20081220112757-mjp2yffddjy5s74e 724 lee...@gm...-20081220114653-k2dqt4wiizipbwas 725 lee...@gm...-20081221181637-6d0tfx7sx7syxfb6 726 lee...@gm...-20081221182603-9bkelm9x7aclb0bw 734 lee...@gm...-20081230173103-fmzio9fanap2rybf 735 lee...@gm...-20081230174204-cppkz4sumguhysa9 736 lee...@gm...-20081230174738-mecjttlpyp1i859c 737 lee...@gm...-20081230174816-qmtp2a3q8m52jsn3 738 lee...@gm...-20081230194247-q6oyx6cqfz03b2lr 739 lee...@gm...-20081231202038-odzabc3wmlqzvskt 740 lee...@gm...-20081231203835-nn2kezh1el82dn1q 741 lee...@gm...-20090101022727-myjxnrvqe5e4l1wz 743 da...@da...-20090103170253-cdtppjz8nzwhngst 744 da...@da...-20090103183413-r1852m22og3lh2uc 745 lee...@gm...-20090103212852-mvsergjd4ao1la77 746 da...@da...-20090103231550-6zn9qzo6gpj9kwu8 748 da...@da...-20090105115751-x3y9oui4xvt43crj 749 da...@da...-20090105131244-nljbq3qp4hp7lg07 + 613 z-...@us...-20080211141509-cwbrb6hmtz9313jr 626 z-...@us...-20080214170110-rhfpd874zuogr3cm 627 z-...@us...-20080214170244-1gstsfe9yzyvrx9b 657 z-...@us...-20080301093905-0jwh1zg9srukp8fn 678 wrt...@us...-20080320130546-cr72y7d9q5a8nk7a 679 z-...@us...-20080324202056-eybvkm0gjomywbcq 680 z-...@us...-20080326104303-kpkkrwiw1fioi0rd 681 epsy-20080327213346-setzm7umdzzuk2dm 683 wrt...@us...-20080402122117-54nak33inuca02o9 684 wrt...@us...-20080402122804-2xhc8bgyrjsa09cd 685 wrt...@us...-20080418093840-cxtpql4xw2vsbmyn 686 ep...@fr...-20080418200503-q16s8az3yewn4x7a 687 ep...@fr...-20080419004917-bq4vguy9vpbkmlo3 688 wrt...@us...-20080419185850-ksm1feadrrhqigjb 689 wrt...@us...-20080423170738-zb8v72r0asm7cp52 691 ep...@fr...-20080427145818-212ave5ohdhth4ph 692 epsy46-20080428164518-07b9wsj90rf82c3y 693 epsy46-20080429194430-hq3fd6i1mnz1vrnz 694 ep...@fr...-20080518131839-uik8hj18c55boh3m 696 z-...@us...-20080618212520-e6ov1rb9b9edwt30 697 wrt...@us...-20080708142300-tu6f7ag7ak0yhdrf 698 wrt...@us...-20080727173310-pv1vq0wj01yfwgfl 699 da...@da...-20080824021014-8aacq5gfp7ktxlxz 700 da...@da...-20080824055426-l5dwhb216uteu7ca 701 da...@da...-20080824172432-lvagd99j28hq8uc1 702 da...@da...-20080824225545-ply97boo9jkqtysn 704 ep...@fr...-20081027173216-nh6d92edtwe35j2g 705 ep...@fr...-20081027203505-42bpegw0fyywzyou 706 ep...@fr...-20081027204727-jcx89jukht9ay72r 707 ep...@fr...-20081028180734-62o6e90rf020xzv8 708 ep...@fr...-20081028224044-f3myemuy87v52ilp 709 ep...@fr...-20081110193848-iksu9rmzzi7jb0qq 710 ep...@fr...-20081114212232-i1q12n375bdpl0sp 712 z-...@us...-20081211141049-wbjceadupsfss5ib 713 da...@da...-20081216223143-1hso83uxyagaubg8 716 lee...@gm...-20081220084635-zv6bpm9rar9yufy7 717 lee...@gm...-20081220085046-6rwe6cqmdlffs4rl 718 lee...@gm...-20081220085502-gpad43pu99t1e6po 719 lee...@gm...-20081220092821-q7uj4w92j6a3a7eb 720 lee...@gm...-20081220094339-k3zb139qp87r4b2w 721 lee...@gm...-20081220100858-uap7k5s22tbipzkt 722 lee...@gm...-20081220111203-rhp5p15agx73xi1k 723 lee...@gm...-20081220112757-mjp2yffddjy5s74e 724 lee...@gm...-20081220114653-k2dqt4wiizipbwas 725 lee...@gm...-20081221181637-6d0tfx7sx7syxfb6 726 lee...@gm...-20081221182603-9bkelm9x7aclb0bw 734 lee...@gm...-20081230173103-fmzio9fanap2rybf 735 lee...@gm...-20081230174204-cppkz4sumguhysa9 736 lee...@gm...-20081230174738-mecjttlpyp1i859c 737 lee...@gm...-20081230174816-qmtp2a3q8m52jsn3 738 lee...@gm...-20081230194247-q6oyx6cqfz03b2lr 739 lee...@gm...-20081231202038-odzabc3wmlqzvskt 740 lee...@gm...-20081231203835-nn2kezh1el82dn1q 741 lee...@gm...-20090101022727-myjxnrvqe5e4l1wz 743 da...@da...-20090103170253-cdtppjz8nzwhngst 744 da...@da...-20090103183413-r1852m22og3lh2uc 745 lee...@gm...-20090103212852-mvsergjd4ao1la77 746 da...@da...-20090103231550-6zn9qzo6gpj9kwu8 748 da...@da...-20090105115751-x3y9oui4xvt43crj 749 da...@da...-20090105131244-nljbq3qp4hp7lg07 750 da...@da...-20090105192648-inoxhljmqqe3dgw7 Modified: armagetronad/trunk/armagetronad/resource/proto/Anonymous/original/original.cockpit.xml =================================================================== --- armagetronad/trunk/armagetronad/resource/proto/Anonymous/original/original.cockpit.xml 2009-01-07 12:09:58 UTC (rev 8760) +++ armagetronad/trunk/armagetronad/resource/proto/Anonymous/original/original.cockpit.xml 2009-01-07 12:12:48 UTC (rev 8761) @@ -548,5 +548,22 @@ </Solid> </Background> </Map> + + <Camview camera="in" view="in"> + <Position x="-0.95" y="-0.95" /> + <Size height="0.15" width="0.3" /> + <Translation x="0.5" y="0" z="0" /> + <Rotation value="150" /> + <Mirror value="true" /> + </Camview> + + <Camview camera="in" view="in"> + <Position x="0.35" y="-0.95" /> + <Size height="0.15" width="0.3" /> + <Translation x="-0.5" y="0" z="0" /> + <Rotation value="210" /> + <Mirror value="true" /> + </Camview> + </Cockpit> </Resource> Modified: armagetronad/trunk/armagetronad/resource/proto/cockpit.dtd =================================================================== --- armagetronad/trunk/armagetronad/resource/proto/cockpit.dtd 2009-01-07 12:09:58 UTC (rev 8760) +++ armagetronad/trunk/armagetronad/resource/proto/cockpit.dtd 2009-01-07 12:12:48 UTC (rev 8761) @@ -18,7 +18,7 @@ usetemplate CDATA '' "> -<!ELEMENT Cockpit ((BarGauge | NeedleGauge | Map | Label | VerticalBarGauge | Rectangle | WidgetTemplate)+)> +<!ELEMENT Cockpit ((BarGauge | NeedleGauge | Map | Label | VerticalBarGauge | Rectangle | WidgetTemplate | Camview )+)> <!ATTLIST Cockpit version CDATA #REQUIRED> <!ELEMENT WidgetTemplate ((DataSet | @@ -103,6 +103,39 @@ )*)> <!ATTLIST Map %CommonWidgetAttributes;> +<!ELEMENT Camview (( Position | + Size | + Background | + Translation | + Rotation | + FOV | + Mirror | + Rise | + MainCameraDir + )*)> +<!ATTLIST Camview %CommonWidgetAttributes;> +<!ATTLIST Camview view CDATA #REQUIRED> + +<!ELEMENT Translation EMPTY> +<!ATTLIST Translation x CDATA "0"> +<!ATTLIST Translation y CDATA "0"> +<!ATTLIST Translation z CDATA "0"> + +<!ELEMENT Rotation EMPTY> +<!ATTLIST Rotation value CDATA "0"> + +<!ELEMENT FOV EMPTY> +<!ATTLIST FOV value CDATA "0"> + +<!ELEMENT Mirror EMPTY> +<!ATTLIST Mirror value (true | false) "false"> + +<!ELEMENT Rise EMPTY> +<!ATTLIST Rise value CDATA "0"> + +<!ELEMENT MainCameraDir EMPTY> +<!ATTLIST MainCameraDir value (true | false) "false"> + <!ELEMENT DataSet ((AtomicData | Conditional | Math | Value)+)> <!ATTLIST DataSet id CDATA ""> Modified: armagetronad/trunk/armagetronad/src/Makefile.am =================================================================== --- armagetronad/trunk/armagetronad/src/Makefile.am 2009-01-07 12:09:58 UTC (rev 8760) +++ armagetronad/trunk/armagetronad/src/Makefile.am 2009-01-07 12:12:48 UTC (rev 8761) @@ -146,6 +146,7 @@ tron/cockpit/cCockpit.h \ tron/cockpit/cWidgetBase.h tron/cockpit/cWidgetBase.cpp \ tron/cockpit/cMap.h tron/cockpit/cMap.cpp \ + tron/cockpit/cCamview.h tron/cockpit/cCamview.cpp \ tron/cockpit/cLabel.h tron/cockpit/cLabel.cpp \ tron/cockpit/cGauges.h tron/cockpit/cGauges.cpp \ tron/cockpit/cRectangle.h tron/cockpit/cRectangle.cpp\ @@ -234,7 +235,7 @@ extralibs= thirdparty/particles/libparticles.a thirdparty/scrap/libscrap.a endif -armagetronad_main_SOURCES = tron/gFloor.cpp tron/cockpit/cCockpit.cpp tron/cockpit/cMap.cpp +armagetronad_main_SOURCES = tron/gFloor.cpp tron/cockpit/cCockpit.cpp tron/cockpit/cMap.cpp tron/cockpit/cCamview.cpp armagetronad_main_CXXFLAGS =$(libtron_a_CXXFLAGS) armagetronad_main_LDADD= libtron.a libenginecore.a libengine.a libnetwork.a libui.a librender.a libtools.a thirdparty/mathexpr/libmathexpr.a ${extralibs} # librubywrap.a Modified: armagetronad/trunk/armagetronad/src/engine/eCamera.cpp =================================================================== --- armagetronad/trunk/armagetronad/src/engine/eCamera.cpp 2009-01-07 12:09:58 UTC (rev 8760) +++ armagetronad/trunk/armagetronad/src/engine/eCamera.cpp 2009-01-07 12:12:48 UTC (rev 8761) @@ -386,7 +386,7 @@ void eCamera::MyInit(){ if (localPlayer){ - mode=localPlayer->startCamera; //PENDING: + if (cameraMain_) mode=localPlayer->startCamera; //PENDING: fov=localPlayer->startFOV; } @@ -422,7 +422,8 @@ // foot=tNEW(eGameObject)(pos,dir,0); distance=0; lastrendertime=se_GameTime(); - grid->cameras.Add(this,id); + if (CameraMain()) grid->cameras.Add(this,id); + else grid->subcameras.Add(this,id); // se_ResetVisibles(id); smoothTurning=turning=0; centerPosLast=centerposLast=CenterPos(); @@ -481,11 +482,12 @@ const ePlayer* eCamera::LocalPlayer() const { return localPlayer; } eCamera::eCamera(eGrid *g, rViewport *view,ePlayerNetID *p, - ePlayer *lp,eCamMode m) + ePlayer *lp,eCamMode m, bool rMain) :id(-1),grid(g),netPlayer(p),localPlayer(lp), // centerID(0), mode(m),pos(0,0),dir(1,0),top(0,0), -vp(view){ + mirrorView_(false), cameraMain_(rMain), renderInCockpit_(false), + vp(view){ /* if (p->pID>=0) localPlayer=playerConfig[p->pID]; @@ -503,8 +505,11 @@ // se_ResetVisibles(se_cameras.Len()); // if (ID!=se_cameras.Len()) se_ResetVisibles(ID); - grid->cameras.Remove(this, id); - + if (cameraMain_) + grid->cameras.Remove(this, id); + else + grid->subcameras.Remove(this, id); + tCHECK_DEST; } @@ -515,6 +520,43 @@ return center; } +void eCamera::SetCenter(eGameObject * c) { + center = c; +} + +bool eCamera::SetCamMode(eCamMode m){ + + if ((localPlayer && localPlayer->allowCam[m] && (!forbid_camera[m])) && m != CAMERA_COUNT) { + mode = m; + switch(mode){ + case CAMERA_IN: + rise=0; + break; + case CAMERA_SMART_IN: + break; + case CAMERA_CUSTOM: + rise=0; + break; + case CAMERA_SERVER_CUSTOM: + rise=0; + break; + case CAMERA_FREE: + break; + case CAMERA_FOLLOW: + break; + case CAMERA_SMART: + smartcamIncamSmooth=1; + z=z+1; + pos=pos+dir.Turn(-1,.1); + break; + case CAMERA_MER: + break; + } + return true; + } + return false; +} + void eCamera::SwitchView(){ zNear = 0.01f; @@ -1444,6 +1486,8 @@ glLoadIdentity(); if(CenterCockpitFixedBefore()){ + glMatrixMode(GL_PROJECTION); + if (mirrorView_) glScalef(-1,1,1); vp->Perspective(fov,zNear,1E+20,se_cameraEyeDistance/2.); gluLookAt(0, @@ -1490,6 +1534,8 @@ glMatrixMode(GL_MODELVIEW); glLoadIdentity(); + glMatrixMode(GL_PROJECTION); + if (mirrorView_) glScalef(-1,1,1); vp->Perspective(fov,zNear,1E+20,-se_cameraEyeDistance/2.); float offset = 0; @@ -1498,7 +1544,7 @@ test.detect(se_cameraInMaxFocusDistance*Center()->Speed()); offset = test.hit; } - + gluLookAt(0, 0, 0, @@ -2191,6 +2237,11 @@ c->Timestep(time-lastTime); su_FetchAndStoreSDLInput(); } + for(int i=grid->subcameras.Len()-1;i>=0;i--){ + //con << time-lastTime<< '\n'; + eCamera *c = grid->subcameras(i); + c->Timestep(time-lastTime); + } lastTime=time; } } Modified: armagetronad/trunk/armagetronad/src/engine/eCamera.h =================================================================== --- armagetronad/trunk/armagetronad/src/engine/eCamera.h 2009-01-07 12:09:58 UTC (rev 8760) +++ armagetronad/trunk/armagetronad/src/engine/eCamera.h 2009-01-07 12:12:48 UTC (rev 8761) @@ -93,7 +93,6 @@ REAL turning; // number of turns in the last seconds REAL smoothTurning; //that value smoothed - REAL distance; // distance travelled so far REAL lastrendertime; // the time this was last rendered @@ -114,6 +113,10 @@ bool renderingMain_; // flag indicating whether the current rendering process is the main process or just a mirror effect + bool cameraMain_; // flag indicating whether the camera is a main camera or a widget view + bool renderInCockpit_; // flag indicating whether the camera is rendered in the cockpit (to disable main rendering) + bool mirrorView_; // flag indicating whether the rendering should be done as in a mirror + static bool InterestingToWatch(eGameObject const * g); //! returns the next view direction if a glance towards targetDir is requested @@ -128,6 +131,7 @@ void MyInit(); public: + bool CenterIncamOnTurn(); bool WhobbleIncam(); bool AutoSwitchIncam(); @@ -135,13 +139,26 @@ bool RenderingMain() const { return renderingMain_; } void SetRenderingMain( bool f ){ renderingMain_ = f; } + bool CameraMain() const { return cameraMain_; } + void SetCameraMain( bool f ){ cameraMain_ = f; } + + bool RenderInCockpit() const { return renderInCockpit_; } + void SetRenderInCockpit( bool f ){ renderInCockpit_ = f; } + + bool MirrorView() const { return mirrorView_; } + void SetMirrorView( bool f ){ mirrorView_ = f; } + + REAL CameraFOV () const {return fov;} + void SetCameraFOV (REAL fovNew) {fov=fovNew;} + const ePlayerNetID* Player() const; const ePlayer* LocalPlayer() const; - eCamera(eGrid *grid, rViewport *vp,ePlayerNetID *owner,ePlayer *lp,eCamMode m=CAMERA_IN); + eCamera(eGrid *grid, rViewport *vp,ePlayerNetID *owner,ePlayer *lp,eCamMode m=CAMERA_IN, bool rMain=true); virtual ~eCamera(); eGameObject * Center() const; + void SetCenter(eGameObject * c); eCoord CenterPos() const; eCoord CenterDir() const; @@ -161,7 +178,13 @@ const eCoord& CameraPos() const {return pos;} eCoord CameraGlancePos() const {return pos;} //! CHECK: this method is redundant with CameraPos(). I leave removing it to you since it is called externally. REAL CameraZ () const {return z;} + REAL CameraRise () const {return rise;} + void SetCameraDir(eCoord &pDir) {dir = pDir;} + void SetCameraPos(eCoord &pPos) {pos = pPos;} + void SetCameraZ (REAL pZ) {z = pZ;} + void SetCameraRise (REAL pRise) {rise = pRise;} + bool CenterAlive() const; bool CenterCockpitFixedBefore() const; @@ -172,6 +195,7 @@ bool Act(uActionCamera *act,REAL x); eCamMode GetCamMode() {return mode;} + bool SetCamMode(eCamMode m); //! Set camera mode, return true if change is allowed and complete, otherwise false #ifndef DEDICATED void Render(); Modified: armagetronad/trunk/armagetronad/src/engine/eDisplay.cpp =================================================================== --- armagetronad/trunk/armagetronad/src/engine/eDisplay.cpp 2009-01-07 12:09:58 UTC (rev 8760) +++ armagetronad/trunk/armagetronad/src/engine/eDisplay.cpp 2009-01-07 12:12:48 UTC (rev 8761) @@ -177,6 +177,7 @@ glTexCoord4f(-1,0.1,zero*h,zero); glVertex4f (-1,0.1,zero*h,zero); + glTexCoord4f(0.1,-1.1,zero*h,zero); glVertex4f (0.1,-1.1,zero*h,zero); @@ -189,16 +190,16 @@ static REAL z=0; - +/* Try to get ride of these functions as it seems useless to use them instead of the cam parameter itself int eGrid::NumberOfCameras(){return cameras.Len();} const eCoord& eGrid::CameraPos(int i){return cameras(i)->CameraPos();} eCoord eGrid::CameraGlancePos(int i){return cameras(i)->CameraGlancePos();} const eCoord& eGrid::CameraDir(int i){return cameras(i)->CameraDir();} REAL eGrid::CameraHeight(int i){return cameras(i)->CameraZ();} +*/ - eWall *displayed_eWall=0; void draw_eWall(eGrid* grid, int v,int i, REAL& zNear, eCamera const * cam) @@ -217,8 +218,8 @@ REAL zDist = z - displayed_eWall->Height(); if ( zDist < zNear ) { - const eCoord& camPos = grid->CameraPos( v ); - const eCoord& camDir = grid->CameraDir( v ); + const eCoord& camPos = cam->CameraPos(); + const eCoord& camDir = cam->CameraDir(); eCoord base = displayed_eWall->EndPoint(0); eCoord end = displayed_eWall->EndPoint(1); @@ -262,7 +263,7 @@ } -void paint_sr_lowerSky(eGrid *grid, int viewer,bool sr_upperSky, eCoord const & camPos){ +void paint_sr_lowerSky(eGrid *grid, int viewer,bool sr_upperSky, eCamera* cam ){ TexMatrix(); glLoadIdentity(); glScalef(.005,.005,.005); @@ -285,13 +286,13 @@ } if (sa>0){ glColor4f(1,1,1,sa); - infinity_xy_plane(camPos,grid->CameraDir(viewer),lower_height); + infinity_xy_plane(cam->CameraPos(),cam->CameraDir(),lower_height); } if (!sr_upperSky && sr_alphaBlend) glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); } -void eGrid::display_simple( int viewer,bool floor, +void eGrid::display_simple( eCamera* cam, int viewer,bool floor, bool sr_upperSky,bool sr_lowerSky, REAL flooralpha, bool eWalls,bool gameObjects, @@ -328,7 +329,7 @@ glDisable(GL_CULL_FACE); - eCoord camPos = CameraGlancePos( viewer ); + eCoord camPos = cam->CameraGlancePos(); // eWallRim::Bound( camPos, 10 ); if (sr_upperSky || se_BlackSky()){ @@ -339,7 +340,7 @@ glColor3f(0,0,0); if ( z < lower_height ) - infinity_xy_plane(camPos, this->CameraDir(viewer),lower_height); + infinity_xy_plane(cam->CameraPos(), cam->CameraDir(), lower_height); glEnable(GL_TEXTURE_2D); } @@ -353,12 +354,12 @@ glColor3f(.5,.5,1); if ( z < upper_height ) - infinity_xy_plane(camPos, this->CameraDir(viewer),upper_height); + infinity_xy_plane(cam->CameraPos(), cam->CameraDir(), upper_height); } } if (sr_lowerSky && !sr_highRim){ - paint_sr_lowerSky(this, viewer,sr_upperSky, camPos); + paint_sr_lowerSky(this, viewer,sr_upperSky, cam); } if (floor){ @@ -379,7 +380,7 @@ #define SIDELEN (se_GridSize()) #define EXTENSION 10 - eCoord center = CameraPos(viewer) + CameraDir(viewer) * (SIDELEN * EXTENSION * .8); + eCoord center = cam->CameraPos() + cam->CameraDir() * (SIDELEN * EXTENSION * .8); REAL x=center.x; REAL y=center.y; @@ -420,7 +421,7 @@ se_glFloorTexture(); se_glFloorColor(flooralpha); - infinity_xy_plane( camPos, CameraDir(viewer) ); + infinity_xy_plane( cam->CameraPos(), cam->CameraDir()); /* old way: draw every triangle for(int i=eFace::faces.Len()-1;i>=0;i--){ @@ -447,7 +448,7 @@ glScalef(0.01*gs,gs,1.); se_glFloorTexture_a(); - infinity_xy_plane( camPos, CameraDir(viewer) ); + infinity_xy_plane( cam->CameraPos(), cam->CameraDir()); se_glFloorColor(flooralpha); @@ -459,7 +460,7 @@ glDepthFunc(GL_LEQUAL); glBlendFunc(GL_SRC_ALPHA,GL_ONE); - infinity_xy_plane( camPos, CameraDir(viewer) ); + infinity_xy_plane( cam->CameraPos(), cam->CameraDir() ); glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); break; @@ -468,7 +469,7 @@ glEnable(GL_DEPTH_TEST); glDepthMask(GL_TRUE); - + TexMatrix(); glLoadIdentity(); ModelMatrix(); @@ -482,7 +483,7 @@ { su_FetchAndStoreSDLInput(); - eWallRim::RenderAll( cameras(viewer) ); + eWallRim::RenderAll( cam ); } if (sr_lowerSky && sr_highRim){ @@ -491,7 +492,7 @@ // glEnable(GL_TEXTURE_GEN_Q); // glEnable(GL_TEXTURE_GEN_R); - paint_sr_lowerSky(this, viewer,sr_upperSky, camPos); + paint_sr_lowerSky(this, viewer,sr_upperSky, cam); // glDisable(GL_TEXTURE_GEN_S); // glDisable(GL_TEXTURE_GEN_T); @@ -508,7 +509,7 @@ if (eWalls){ // glDisable(GL_CULL_FACE); - // draw_eWall(this,viewer,0,zNear,cameras(viewer)); + // draw_eWall(this,viewer,0,zNear,cam); /* #ifdef DEBUG @@ -540,7 +541,7 @@ sr_CheckGLError(); if (gameObjects) - eGameObject::RenderAll(this, cameras(viewer)); + eGameObject::RenderAll(this, cam); eDebugLine::Render(); #ifdef DEBUG @@ -602,63 +603,63 @@ #ifndef DEDICATED ProjMatrix(); - z=CameraHeight(viewer); + z=cam->CameraZ(); if ( zNear > z ) { zNear = z; } - if (sr_floorMirror){ - ModelMatrix(); - glScalef(1,1,-1); + if (sr_floorMirror){ + ModelMatrix(); + glScalef(1,1,-1); - if (z>10) z=10; - glFrontFace(GL_CW); + if (z>10) z=10; + glFrontFace((cam->MirrorView())?GL_CCW:GL_CW); - bool us=false; - bool ls=false; + bool us=false; + bool ls=false; - if (sr_floorMirror>=rMIRROR_ALL){ - us=sr_upperSky; - ls=sr_lowerSky; - } - else if (sr_floorMirror>=rMIRROR_WALLS){ - if (sr_lowerSky) - ls=true; - else if (sr_upperSky) - us=true; - } + if (sr_floorMirror>=rMIRROR_ALL){ + us=sr_upperSky; + ls=sr_lowerSky; + } + else if (sr_floorMirror>=rMIRROR_WALLS){ + if (sr_lowerSky) + ls=true; + else if (sr_upperSky) + us=true; + } - cam->SetRenderingMain(false); - display_simple(viewer,false, - us,ls, - 0, - sr_floorMirror>=rMIRROR_WALLS, - sr_floorMirror>=rMIRROR_OBJECTS, - zNear); - z=CameraHeight(viewer); - glFrontFace(GL_CCW); - ModelMatrix(); - glScalef(1,1,-1); + cam->SetRenderingMain(false && cam->CameraMain()); + display_simple(cam, viewer,false, + us,ls, + 0, + sr_floorMirror>=rMIRROR_WALLS, + sr_floorMirror>=rMIRROR_OBJECTS, + zNear); + z=cam->CameraZ(); + glFrontFace((cam->MirrorView())?GL_CW:GL_CCW); + ModelMatrix(); + glScalef(1,1,-1); - cam->SetRenderingMain(true); - display_simple(viewer,true, - sr_upperSky,sr_lowerSky, - 1-sr_floorMirror_strength, - true,true,zNear); + cam->SetRenderingMain(true && cam->CameraMain()); + display_simple(cam, viewer,true, + sr_upperSky,sr_lowerSky, + 1-sr_floorMirror_strength, + true,true,zNear); - } - else - { - cam->SetRenderingMain(true); - display_simple(viewer,true, - sr_upperSky,sr_lowerSky, - 1, - true,true,zNear); - } - - + } + else + { + glFrontFace((cam->MirrorView())?GL_CW:GL_CCW); + cam->SetRenderingMain(true && cam->CameraMain()); + display_simple(cam, viewer,true, + sr_upperSky,sr_lowerSky, + 1, + true,true,zNear); + } + #ifdef EVENT_DEB // for(int i=eEdge_crossing.Len()-1;i>=0;i--){ // eEdge_crossing(i)->Render(); Modified: armagetronad/trunk/armagetronad/src/engine/eGrid.cpp =================================================================== --- armagetronad/trunk/armagetronad/src/engine/eGrid.cpp 2009-01-07 12:09:58 UTC (rev 8760) +++ armagetronad/trunk/armagetronad/src/engine/eGrid.cpp 2009-01-07 12:12:48 UTC (rev 8761) @@ -2636,7 +2636,6 @@ /* - void eEdge::calc_Len() const{ REAL len2=(*p[0] - *p[1]).NormSquared(); *reinterpret_cast<REAL *>(reinterpret_cast<void *>(&len))=sqrt(len2); Modified: armagetronad/trunk/armagetronad/src/engine/eGrid.h =================================================================== --- armagetronad/trunk/armagetronad/src/engine/eGrid.h 2009-01-07 12:09:58 UTC (rev 8760) +++ armagetronad/trunk/armagetronad/src/engine/eGrid.h 2009-01-07 12:12:48 UTC (rev 8761) @@ -152,14 +152,14 @@ const tList<eGameObject>& GameObjectsInteresting() const{return gameObjectsInteresting;} const tList<eGameObject>& GameObjectsInactive() const{return gameObjectsInactive;} - +/* Try to get ride of these functions as it seems useless to use them instead of the cam parameter itself int NumberOfCameras(); const eCoord& CameraPos(int i); eCoord CameraGlancePos(int i); const eCoord& CameraDir(int i); REAL CameraHeight(int i); +*/ - // int NumberOfCameras(){return eCamera::Number();} // const eCoord& CameraPos(int i){return eCamera::PosNum(i);} // const eCoord& CameraDir(int i){return eCamera::DirNum(i);} @@ -179,7 +179,7 @@ protected: // render helper - void display_simple( int viewer,bool floor, + void display_simple( eCamera* cam, int viewer,bool floor, bool sr_upperSky,bool sr_lowerSky, REAL flooralpha, bool eWalls,bool gameObjects, @@ -225,6 +225,7 @@ // cameras tList<eCamera> cameras; + tList<eCamera> subcameras; // walls // tHeap<eWallView> wallsVisible[MAX_VIEWERS]; Modified: armagetronad/trunk/armagetronad/src/render/rViewport.h =================================================================== --- armagetronad/trunk/armagetronad/src/render/rViewport.h 2009-01-07 12:09:58 UTC (rev 8760) +++ armagetronad/trunk/armagetronad/src/render/rViewport.h 2009-01-07 12:12:48 UTC (rev 8761) @@ -37,14 +37,18 @@ class rViewport{ REAL left,bottom,width,height; + rViewport *rootViewport; public: - rViewport(REAL l,REAL b,REAL w,REAL h):left(l),bottom(b),width(w),height(h){} + void SetRootViewport(rViewport *root) {rootViewport=root;} + rViewport *GetRootViewport() {return rootViewport;} + rViewport(REAL l,REAL b,REAL w,REAL h):left(l),bottom(b),width(w),height(h),rootViewport(0){} // create a subviewport of top rViewport(rViewport &top,rViewport &sub) :left (top.left+top.width*sub.left), bottom(top.bottom+top.height*sub.bottom), width(top.width*sub.width), - height(top.height*sub.height){} + height(top.height*sub.height), + rootViewport(0){} ~rViewport(){tCHECK_DEST;} @@ -64,6 +68,7 @@ //! returns the height and width of the viewport tCoord GetDimensions() const {return tCoord(width, height);} + tCoord GetPosition() const {return tCoord(left, bottom);} static rViewport s_viewportFullscreen, s_viewportLeft,s_viewportRight, @@ -78,7 +83,7 @@ }; -extern int sr_viewportBelongsToPlayer[MAX_VIEWPORTS]; +extern int sr_viewportBelongsToPlayer[MAX_VIEWPORTS]; extern int s_newViewportBelongsToPlayer[MAX_VIEWPORTS]; Added: armagetronad/trunk/armagetronad/src/tron/cockpit/cCamview.cpp =================================================================== --- armagetronad/trunk/armagetronad/src/tron/cockpit/cCamview.cpp (rev 0) +++ armagetronad/trunk/armagetronad/src/tron/cockpit/cCamview.cpp 2009-01-07 12:12:48 UTC (rev 8761) @@ -0,0 +1,291 @@ +/* + +************************************************************************* + +ArmageTron -- Just another Tron Lightcycle Game in 3D. +Copyright (C) 2000 Manuel Moos (ma...@mo...) + +************************************************************************** + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +*************************************************************************** + +*/ +#include "cockpit/cCamview.h" +#include "cockpit/cCockpit.h" +#include "nConfig.h" +#include "tCoord.h" + +#ifndef DEDICATED + +#include "rRender.h" +#include "rScreen.h" +#include "ePlayer.h" +#include "rViewport.h" +#include "eGrid.h" +#include "eCamera.h" +#include "gCycle.h" + +#endif + +static bool stc_forbidHudCamera = false; +static nSettingItem<bool> fcs("FORBID_HUD_CAMERA", stc_forbidHudCamera); + +#ifndef DEDICATED + +namespace cWidget { + +bool Camview::Process(tXmlParser::node cur) { + if ( + WithCoordinates ::Process(cur) || + WithForeground ::Process(cur) || + WithBackground ::Process(cur)) + return true; + if(cur.IsOfType("Camview")) { + view = cur.GetProp("view"); + if (view=="custom") { + camMode = CAMERA_CUSTOM; + } else if (view=="follow") { + camMode = CAMERA_FOLLOW; + } else if (view=="free") { + camMode = CAMERA_FREE; + } else if (view=="in") { + camMode = CAMERA_IN; + } else if (view=="server_custom") { + camMode = CAMERA_SERVER_CUSTOM; + } else if (view=="smart") { + camMode = CAMERA_SMART; + } else if (view=="mer") { + camMode = CAMERA_MER; + } else if (view=="main") { + camMode = CAMERA_SMART; + mainCameraFlag = true; + } else { + view = tString(""); + tERR_WARN("Empty view string"); + DisplayError(cur); + return false; + } +// con << "Set view " << view << "\n"; + return true; + } else if(cur.IsOfType("Translation")) { + cur.GetProp("x", posTranslation.x); + cur.GetProp("y", posTranslation.y); + cur.GetProp("z", z); + posTranslationFlag = true; +// con << "Set translation " << posTranslation.x << " " << posTranslation.y << " " << z << "\n"; + return true; + } else if(cur.IsOfType("Mirror")) { + mirror = cur.GetPropBool("value"); +// con << "Set mirror " << mirror << "\n"; + return true; + } else if(cur.IsOfType("Rise")) { + cur.GetProp("value", rise); + riseFlag = true; +// con << "Set rise " << rise << "\n"; + return true; + } else if(cur.IsOfType("MainCameraDir")) { + mainCameraDirFlag = cur.GetPropBool("value"); +// con << "Set MainCameraDir " << mainCameraDirFlag << "\n"; + return true; + } else if(cur.IsOfType("Rotation")) { + cur.GetProp("value",dirAngle); + dirAngle *= M_PI / 180.; + dirCos = cos(dirAngle); + dirSin = sin(dirAngle); + dirAngleFlag = true; +// con << "Set rotation " << dirAngle << "\n"; + return true; + } else if(cur.IsOfType("FOV")) { + cur.GetProp("value", fov); + fovFlag = true; + if (fov>120) fov=120; + if (fov<30) fov=30; +// con << "Set fov " << fov << "\n"; + return true; + } + + DisplayError(cur); + return false; +} + +void Camview::Render() { + // I haven't checked possible initial matrix state, so init to identity and modelview + if(stc_forbidHudCamera) return; // the server doesn't want us to do that + glClear(GL_DEPTH_BUFFER_BIT); + glMatrixMode(GL_PROJECTION); + glPushMatrix(); + glLoadIdentity(); + glMatrixMode(GL_MODELVIEW); + glPushMatrix(); + glLoadIdentity(); + // Rendering cameras + rViewportConfiguration* viewportConfiguration = rViewportConfiguration::CurrentViewportConfiguration(); + for ( int viewport = viewportConfiguration->num_viewports-1; viewport >= 0; --viewport ) + { + //con << "render subviewport\n"; + eCamera *mc = eGrid::CurrentGrid()->Cameras()(viewport); + if (mc) { + if (cam[viewport]) { + // force mode and FOV as it is lost between rounds ... + if (fovFlag) cam[viewport]->SetCameraFOV(fov); + if (cam[viewport]->GetCamMode()!=camMode) cam[viewport]->SetCamMode(camMode); + // keep original settings + tCoord posOrg = cam[viewport]->CameraPos(), dirOrg = cam[viewport]->CameraDir(); + REAL zOrg = cam[viewport]->CameraZ(), riseOrg = cam[viewport]->CameraRise(); + // apply specific settings + if (posTranslationFlag) { + tCoord d=cam[viewport]->CameraDir(); + tCoord o(-d.y, d.x); + tCoord newPos = posOrg + o*posTranslation.x + d*posTranslation.y; + cam[viewport]->SetCameraPos(newPos); + cam[viewport]->SetCameraZ(zOrg + z); + } + if (dirAngleFlag) { + tCoord dirNew; + if (mainCameraDirFlag) { + dirNew = tCoord(mc->CameraDir().x*dirCos-mc->CameraDir().y*dirSin, + mc->CameraDir().x*dirSin+mc->CameraDir().y*dirCos); + } else { + dirNew = tCoord(cam[viewport]->CameraDir().x*dirCos-cam[viewport]->CameraDir().y*dirSin, + cam[viewport]->CameraDir().x*dirSin+cam[viewport]->CameraDir().y*dirCos); + } + cam[viewport]->SetCameraDir( dirNew ); + } + if (riseFlag) cam[viewport]->SetCameraRise(rise); + // render + viewports[viewport]->Select(); + cam[viewport]->Render(); + cam[viewport]->SetRenderInCockpit(true); + // restore original settings + cam[viewport]->SetCameraPos(posOrg); + cam[viewport]->SetCameraDir(dirOrg); + cam[viewport]->SetCameraZ(zOrg); + cam[viewport]->SetCameraRise(riseOrg); + // check if camera center must be adjusted + if (cam[viewport]->Center()!=mc->Center()) { + cam[viewport]->SetCenter( mc->Center() ); + } + } else if (mainCameraFlag) { + // render + viewports[viewport]->Select(); + mc->Render(); + mc->SetRenderInCockpit(true); + } + } + } + + //restore gl context + glMatrixMode(GL_MODELVIEW); + glPopMatrix(); + glMatrixMode(GL_PROJECTION); + glPopMatrix(); +} + +void Camview::PostParsingProcess() +{ + rViewportConfiguration* viewportConfiguration = rViewportConfiguration::CurrentViewportConfiguration(); + rViewport *vpmod = new rViewport((m_position.x+1)/2,(m_position.y+1)/2,m_size.x,m_size.y*sr_screenWidth/sr_screenHeight); + eGrid *grid = eGrid::CurrentGrid(); + for ( int viewport = viewportConfiguration->num_viewports-1; viewport >= 0; --viewport ) + { + // get the viewport + rViewport *port = viewportConfiguration->Port( viewport ); + // create the subviewport + viewports[viewport] = new rViewport(*port, *vpmod); + viewports[viewport]->SetRootViewport(port); + // create the camera (if not the main cam to render) + if (!mainCameraFlag) { + CreateCamera(viewport); + } +// con << "create subviewport " << m_position.x << " " << m_position.y << " " << m_size.x << " " << m_size.y << "\n"; + } + ReadyFlag = true; + delete vpmod; +} + +// recreate viewports and cams if needed ... +void Camview::BeforeRoundProcess() { + if (!ReadyFlag) + PostParsingProcess(); +} + +// delete viewports and cams ... +void Camview::AfterRoundProcess() { + rViewportConfiguration* viewportConfiguration = rViewportConfiguration::CurrentViewportConfiguration(); + for ( int viewport = viewportConfiguration->num_viewports-1; viewport >= 0; --viewport ) + { + if (!mainCameraFlag) { + delete cam[viewport]; + } + cam[viewport]=0; + delete viewports[viewport]; + viewports[viewport]=0; + } + ReadyFlag = false; +} + +void Camview::CreateCamera(int vp) { + eGrid *grid = eGrid::CurrentGrid(); + const tList<eCamera>& cameras = grid->Cameras(); + int playerID = sr_viewportBelongsToPlayer[ vp ]; + ePlayer* player = ePlayer::PlayerConfig( playerID ); + cam[vp] = new eCamera(grid, + viewports[vp], + player->netPlayer, + player, + camMode, + false); + cam[vp]->SetMirrorView(mirror); + // get main cam + if (fovFlag) cam[vp]->SetCameraFOV(fov); +} + +Camview::Camview(): + view(tString("")), camMode(CAMERA_IN), + dirAngle(0), dirCos(0), dirSin(0), + posTranslation(tCoord(0,0)), + z(0), rise(0), fov(0), + mirror(false), dirAngleFlag(false), + posTranslationFlag(false), + riseFlag(false), fovFlag(false), mainCameraDirFlag(false), mainCameraFlag(false), ReadyFlag(false) +{ + rViewportConfiguration* viewportConfiguration = rViewportConfiguration::CurrentViewportConfiguration(); + for ( int viewport = viewportConfiguration->num_viewports-1; viewport >= 0; --viewport ) + { + viewports[viewport] = 0; + cam[viewport] = 0; + } +} + +Camview::~Camview() +{ + /* + rViewportConfiguration* viewportConfiguration = rViewportConfiguration::CurrentViewportConfiguration(); + for ( int viewport = viewportConfiguration->num_viewports-1; viewport >= 0; --viewport ) + { + // suppress references + viewports[viewport]->SetRootViewport(0); + // suppress widget cams and viewports + delete cam[viewport]; + delete viewports[viewport]; + cam[viewport] = 0; + viewports[viewport] = 0; + }*/ +} + +} +#endif Added: armagetronad/trunk/armagetronad/src/tron/cockpit/cCamview.h =================================================================== --- armagetronad/trunk/armagetronad/src/tron/cockpit/cCamview.h (rev 0) +++ armagetronad/trunk/armagetronad/src/tron/cockpit/cCamview.h 2009-01-07 12:12:48 UTC (rev 8761) @@ -0,0 +1,76 @@ +/* + +************************************************************************* + +ArmageTron -- Just another Tron Lightcycle Game in 3D. +Copyright (C) 2000 Manuel Moos (ma...@mo...) + +************************************************************************** + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +*************************************************************************** + +*/ + +//! @file +//! @brief Contains the class for rendering the camera widget + +#ifndef ARMAGETRON_CCAMVIEW_H +#define ARMAGETRON_CCAMVIEW_H + +#include "cockpit/cWidgetBase.h" + +#ifndef DEDICATED + +#include "ePlayer.h" +#include "eCamera.h" + +namespace cWidget { + +//! Processes and renders a camera "subview" of the grid +class Camview : public WithCoordinates, public WithBackground, public WithForeground { + + // the subviewport and related camera ... + rViewport *viewports[MAX_VIEWPORTS]; + tCHECKED_PTR(eCamera) cam[MAX_VIEWPORTS]; + + // widget settings + tString view; + eCamMode camMode; + REAL dirAngle, dirCos, dirSin; //! Angle, cos and sin of the rotation to apply on camera direction (lookat) + tCoord posTranslation; //! translation to be apply on camera position + REAL z,rise; //! height above the floor and whether we look up or down + REAL fov; //! field of vision; + bool mirror; //! horizontal reflection (mirror view) + bool mainCameraFlag; //! render main player camera in the widget + bool mainCameraDirFlag; //! use main camera direction to deduce view direction + bool dirAngleFlag, posTranslationFlag, riseFlag, fovFlag; //! flag settings to be overwritten ... + bool ReadyFlag; //! flag to indicate whether the widget is ready or need to be reinit (cam and viewport) +public: + void Render(); + void CreateCamera(int vp); + virtual bool Process(tXmlParser::node cur); //!< Passes on to all Process() functions of the base classes and calls Base::DisplayError() on failure + virtual void PostParsingProcess(); + virtual void BeforeRoundProcess(); + virtual void AfterRoundProcess(); + Camview(); //!< default constructor + ~Camview(); //!< default destructor +}; + +} + +#endif +#endif Modified: armagetronad/trunk/armagetronad/src/tron/cockpit/cCockpit.cpp =================================================================== --- armagetronad/trunk/armagetronad/src/tron/cockpit/cCockpit.cpp 2009-01-07 12:09:58 UTC (rev 8760) +++ armagetronad/trunk/armagetronad/src/tron/cockpit/cCockpit.cpp 2009-01-07 12:12:48 UTC (rev 8761) @@ -31,6 +31,7 @@ #include "cockpit/cGauges.h" #include "cockpit/cLabel.h" #include "cockpit/cMap.h" +#include "cockpit/cCamview.h" #include "cockpit/cRectangle.h" #include "nConfig.h" @@ -502,6 +503,7 @@ widget.SetDefaultState(cur.GetPropBool("toggleDefault")); widget.SetSticky(cur.GetPropBool("toggleSticky")); ProcessWidgetCore(cur, widget); + widget.PostParsingProcess(); } void cCockpit::AddEventHandler(int id, cWidget::Base *widget) { @@ -519,6 +521,11 @@ return cWidget::Base_ptr(new cWidget::Label()); if(cur.IsOfType("Map")) return cWidget::Base_ptr(new cWidget::Map()); + if(cur.IsOfType("Camview")) { + cWidget::Camview *w = new cWidget::Camview(); + w->Process(cur); + return cWidget::Base_ptr(w); + } if(cur.IsOfType("Rectangle")) return cWidget::Base_ptr(new cWidget::Rectangle()); return cWidget::Base_ptr(); @@ -764,6 +771,22 @@ } } +void cCockpit::BeforeRoundProcess() { + FOREACH_COCKPIT(i) { + for(widget_list_t::const_iterator w=(*i)->m_Widgets.begin(); w!=(*i)->m_Widgets.end(); ++w) { + (*w)->BeforeRoundProcess(); + } + } +} + +void cCockpit::AfterRoundProcess() { + FOREACH_COCKPIT(i) { + for(widget_list_t::iterator iter = (*i)->m_Widgets.begin(); iter != (*i)->m_Widgets.end(); ++iter) { + (*iter)->AfterRoundProcess(); + } + } +} + static void display_cockpit_lucifer() { static cCockpit static_cockpit(cCockpit::VIEWPORT_TOP); Modified: armagetronad/trunk/armagetronad/src/tron/cockpit/cCockpit.h =================================================================== --- armagetronad/trunk/armagetronad/src/tron/cockpit/cCockpit.h 2009-01-07 12:09:58 UTC (rev 8760) +++ armagetronad/trunk/armagetronad/src/tron/cockpit/cCockpit.h 2009-01-07 12:12:48 UTC (rev 8761) @@ -98,6 +98,9 @@ void AddEventHandler(int id, cWidget::Base *widget); //!< add a key event handler void Render(); //!< Renders the cockpit + static void BeforeRoundProcess(); //!< prepare cockpit before round + static void AfterRoundProcess(); //!< Clean cockpit after a round + //void RenderRootwindow(); //!< Renders the main viewport (all widgets that belong to the entire screen) //void RenderPlayer(float factor); //!< Renders all widgets that belong to the currently active player Modified: armagetronad/trunk/armagetronad/src/tron/cockpit/cMap.cpp =================================================================== --- armagetronad/trunk/armagetronad/src/tron/cockpit/cMap.cpp 2009-01-07 12:09:58 UTC (rev 8760) +++ armagetronad/trunk/armagetronad/src/tron/cockpit/cMap.cpp 2009-01-07 12:12:48 UTC (rev 8761) @@ -40,7 +40,6 @@ #include "rViewport.h" #include "eGrid.h" -#include "eCamera.h" #include "gCycle.h" #endif @@ -467,7 +466,8 @@ m_toggleKey(0), m_clipper(new ClipperRect()), m_currentMode(0) -{} +{ +} } #endif Modified: armagetronad/trunk/armagetronad/src/tron/cockpit/cWidgetBase.h =================================================================== --- armagetronad/trunk/armagetronad/src/tron/cockpit/cWidgetBase.h 2009-01-07 12:09:58 UTC (rev 8760) +++ armagetronad/trunk/armagetronad/src/tron/cockpit/cWidgetBase.h 2009-01-07 12:12:48 UTC (rev 8761) @@ -69,6 +69,9 @@ Base() : m_ParsingTemplate(false), m_Render(true), m_RenderDefault(true), m_Sticky(true) {} virtual ~Base() { } virtual void Render() = 0; //!< Needs to be owerwritten for all widgets that can be rendered (and therefore created) + virtual void PostParsingProcess() {}; + virtual void BeforeRoundProcess() {}; + virtual void AfterRoundProcess() {}; void SetCam(int Cam); //!< Set the camera(s) this widget will be rendered for int GetCam(void) { return m_Cam; } //!< Get the camera(s) this widget will be rendered for Modified: armagetronad/trunk/armagetronad/src/tron/gGame.cpp =================================================================== --- armagetronad/trunk/armagetronad/src/tron/gGame.cpp 2009-01-07 12:09:58 UTC (rev 8760) +++ armagetronad/trunk/armagetronad/src/tron/gGame.cpp 2009-01-07 12:12:48 UTC (rev 8761) @@ -26,7 +26,6 @@ */ #include "eEventNotification.h" -#include "eEventNotification.h" #include "gStuff.h" #include "eSoundMixer.h" #include "eGrid.h" @@ -79,6 +78,7 @@ //#include "uWebinterface.h" #include "gRotation.h" +#include "cockpit/cCockpit.h" #include <math.h> #include <stdlib.h> @@ -759,6 +759,7 @@ su_prefetchInput=false; + cCockpit::AfterRoundProcess(); int i; for (i=ePlayer::Num()-1;i>=0;i--){ if (ePlayer::PlayerConfig(i)) @@ -1204,6 +1205,7 @@ lastTime_gameloop=lastTimeTimestep=0; } + cCockpit::BeforeRoundProcess(); #else se_ResetGameTimer( -PREPARE_TIME - sg_extraRoundTime ); se_PauseGameTimer(false); @@ -1268,14 +1270,18 @@ */ const tList<eCamera>& cameras = grid->Cameras(); - for (int i=cameras.Len()-1;i>=0;i--){ - int p=sr_viewportBelongsToPlayer[i]; - conf->Select(i); - rViewport *act=conf->Port(i); - if (act && ePlayer::PlayerConfig(p)) - ePlayer::PlayerConfig(p)->Render(); - else con << "hey! viewport " << i << " does not exist!\n"; + if (!cameras(i)->RenderInCockpit()) { + int p=sr_viewportBelongsToPlayer[i]; + conf->Select(i); + rViewport *act=conf->Port(i); + if (act && ePlayer::PlayerConfig(p)) + ePlayer::PlayerConfig(p)->Render(); + else con << "hey! viewport " << i << " does not exist!\n"; + } else { + cameras(i)->SetRenderInCockpit(false); + } + } // glDisable( GL_FOG ); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |