00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 #include "GUI/ViewPort.H"
00037 #include "Util/log.H"
00038 #include "Util/WorkThreadServer.H"
00039 #include "Util/JobWithSemaphore.H"
00040 #include "Component/ModelManager.H"
00041 #include "Raster/GenericFrame.H"
00042 #include "Image/Layout.H"
00043 #include "Image/MatrixOps.H"
00044 #include "Media/FrameSeries.H"
00045 #include "Transport/FrameInfo.H"
00046 #include <stdlib.h>
00047 #include <math.h>
00048
00049 double pos[3];
00050 double side[3];
00051 double R[12];
00052
00053 Image<PixRGB<byte> > frame;
00054
00055 namespace
00056 {
00057 class ViewPortLoop : public JobWithSemaphore
00058 {
00059 public:
00060 ViewPortLoop()
00061 :
00062 itsPriority(1),
00063 itsJobType("controllerLoop")
00064 {}
00065
00066 virtual ~ViewPortLoop() {}
00067
00068 virtual void run()
00069 {
00070 double cameraParam[3][4] = {
00071 {350.475735, 0, 158.250000, 0},
00072 {0.000000, -363.047091, 118.250000, 0.000000},
00073 {0.000000, 0.000000, 1.000000, 0.00000}};
00074
00075 ViewPort vp("ViewPort", "ground.ppm", "", false, false,
00076 320, 240, cameraParam);
00077 vp.setTextures(false);
00078 vp.setDrawWorld(false);
00079 vp.setWireframe(false);
00080 vp.setZoom(0.85);
00081
00082
00083 double cam_xyz[3] = {10.569220,-210,140.959999};
00084 double cam_hpr[3] = {102.500000,-26.500000,-5.500000};
00085 vp.dsSetViewpoint (cam_xyz, cam_hpr);
00086
00087
00088
00089
00090
00091 while(1)
00092 {
00093 double cameraParam[16] = {
00094 0.995441, 0.044209, -0.084521, 0.000000, 0.095269, -0.504408, 0.858193, 0.000000,
00095 -0.004694, -0.862333, -0.506320, 0.000000, -6.439873, 11.187120, 197.639489, 1.000000};
00096
00097 vp.initFrame(cameraParam);
00098 vp.dsDrawSphere(pos,R,1.3f);
00099
00100 vp.dsSetColor (1,1,0.0);
00101
00102 vp.dsSetColor (0.5,0.5,0.5);
00103 vp.dsDrawBox(pos,R,side);
00104
00105
00106
00107 vp.updateFrame();
00108
00109 frame = flipVertic(vp.getFrame());
00110
00111 }
00112 }
00113
00114 virtual const char* jobType() const
00115 { return itsJobType.c_str(); }
00116
00117 virtual int priority() const
00118 { return itsPriority; }
00119
00120 private:
00121 const int itsPriority;
00122 const std::string itsJobType;
00123 };
00124 }
00125
00126 int main(int argc, char *argv[]){
00127
00128 ModelManager manager("Test Viewport");
00129
00130 nub::ref<OutputFrameSeries> ofs(new OutputFrameSeries(manager));
00131 manager.addSubComponent(ofs);
00132
00133
00134 if (manager.parseCommandLine(argc, argv, "", 0, 0) == false) return(1);
00135
00136 manager.start();
00137
00138
00139 pos[0] = 0;
00140 pos[1] = 0;
00141 pos[2] = 5;
00142 R[0] = 1; R[1] = 0; R[2] = 0;
00143 R[4] = 0; R[5] = 1; R[6] = 0;
00144 R[8] = 0; R[9] = 0; R[10] = 1;
00145
00146 side[0] = 30; side[1] = 30; side[2] = 30;
00147
00148
00149 rutz::shared_ptr<WorkThreadServer> itsThreadServer;
00150 itsThreadServer.reset(new WorkThreadServer("ViewPort",1));
00151 itsThreadServer->setFlushBeforeStopping(false);
00152 rutz::shared_ptr<ViewPortLoop> j(new ViewPortLoop());
00153 itsThreadServer->enqueueJob(j);
00154
00155
00156 frame = Image<PixRGB<byte> >(255, 255, ZEROS);
00157 int run=1;
00158 while(run){
00159 ofs->writeRGB(frame, "viewport", FrameInfo("ViewPort", SRC_POS));
00160 usleep(1000);
00161 }
00162
00163 exit(0);
00164
00165 }
00166
00167