forked from speed-dreams/speed-dreams-code
OSGGRAPH :added HUD DEBUG, an helper for later visual debugging of rendered textures
git-svn-id: https://svn.code.sf.net/p/speed-dreams/code/trunk@5495 30fe4595-0a0c-4342-8851-515496e4dcbd Former-commit-id: 812c4eb6e6442b079cd96ef821df5c9adb0dbffb Former-commit-id: 91858c3341f459839337e5ebf8d159cefe92bac4
This commit is contained in:
parent
fb07556993
commit
a311e61420
6 changed files with 92 additions and 0 deletions
|
@ -28,6 +28,7 @@ SET(OSGGRAPH_HEADERS OsgUtil/OsgVectorArrayAdapter.h
|
|||
OsgView/OsgView.h
|
||||
OsgView/OsgScreens.h
|
||||
OsgView/OsgCamera.h
|
||||
OsgView/OsgDebugHUD.h
|
||||
|
||||
OsgCar/OsgCar.h
|
||||
OsgCar/OsgWheel.h
|
||||
|
@ -61,6 +62,7 @@ SET(OSGGRAPH_SOURCES OsgUtil/OsgSphere.cpp
|
|||
OsgView/OsgView.cpp
|
||||
OsgView/OsgScreens.cpp
|
||||
OsgView/OsgCamera.cpp
|
||||
OsgView/OsgDebugHUD.cpp
|
||||
|
||||
OsgCar/OsgCar.cpp
|
||||
OsgCar/OsgWheel.cpp
|
||||
|
|
|
@ -182,6 +182,11 @@ void SDChangeScreen(void * vp)
|
|||
screens->changeScreen(t);
|
||||
}
|
||||
|
||||
void SDToggleHUD(void * vp)
|
||||
{
|
||||
screens->toggleDebugHUD();
|
||||
}
|
||||
|
||||
int initView(int x, int y, int width, int height, int /* flag */, void *screen)
|
||||
{
|
||||
//render = new SDRender();
|
||||
|
@ -228,6 +233,8 @@ int initView(int x, int y, int width, int height, int /* flag */, void *screen)
|
|||
GfuiAddKey(screen, GFUIK_F10, "Follow Car Zoomed", (void*)8, SDSelectCamera, NULL);
|
||||
GfuiAddKey(screen, GFUIK_F11, "TV Director View", (void*)9, SDSelectCamera, NULL);
|
||||
|
||||
GfuiAddKey(screen, GFUIK_F12, "Activate DEBUG HUD", (void*)9, SDToggleHUD, NULL);
|
||||
|
||||
/*GfuiAddKey(screen, '5', "Debug Info", (void*)3, grSelectBoard, NULL);
|
||||
GfuiAddKey(screen, '4', "G/Cmd Graph", (void*)4, grSelectBoard, NULL);
|
||||
GfuiAddKey(screen, '3', "Leaders Board", (void*)2, grSelectBoard, NULL);
|
||||
|
|
29
src/modules/graphic/osggraph/OsgView/OsgDebugHUD.cpp
Executable file
29
src/modules/graphic/osggraph/OsgView/OsgDebugHUD.cpp
Executable file
|
@ -0,0 +1,29 @@
|
|||
#include <osgDB/ReadFile>
|
||||
#include <osg/Geometry>
|
||||
#include <osg/Geode>
|
||||
|
||||
#include "OsgDebugHUD.h"
|
||||
|
||||
SDDebugHUD::SDDebugHUD(){
|
||||
|
||||
osg::Geometry* geom = osg::createTexturedQuadGeometry(
|
||||
osg::Vec3(), osg::Vec3(0.5f,0.0f,0.0f), osg::Vec3(0.0f,0.7f,0.0f),
|
||||
0.0f, 0.0f, -1.0f, 1.0f );
|
||||
osg::ref_ptr<osg::Geode> quad = new osg::Geode;
|
||||
quad->addDrawable( geom );
|
||||
|
||||
HUD_camera = new osg::Camera;
|
||||
HUD_camera->setClearMask( GL_DEPTH_BUFFER_BIT );
|
||||
HUD_camera->setRenderOrder( osg::Camera::POST_RENDER );
|
||||
HUD_camera->setProjectionMatrix(osg::Matrix::ortho2D(-1, 1, -1, 1));
|
||||
HUD_camera->setReferenceFrame( osg::Camera::ABSOLUTE_RF );
|
||||
HUD_camera->addChild( quad );
|
||||
HUD_camera->setNodeMask(0);
|
||||
}
|
||||
|
||||
void SDDebugHUD::toggleHUD(){
|
||||
HUD_camera->setNodeMask(1-HUD_camera->getNodeMask());
|
||||
}
|
||||
|
||||
SDDebugHUD::~SDDebugHUD(){
|
||||
}
|
41
src/modules/graphic/osggraph/OsgView/OsgDebugHUD.h
Executable file
41
src/modules/graphic/osggraph/OsgView/OsgDebugHUD.h
Executable file
|
@ -0,0 +1,41 @@
|
|||
/***************************************************************************
|
||||
|
||||
file : OsgScreens.h
|
||||
created : Sat Feb 2013 15:52:19 CEST 2013
|
||||
copyright : (C) 2013 by Gaëtan André
|
||||
email : gaetan.andre@gmail.com
|
||||
version : $Id$
|
||||
***************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* *
|
||||
* 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. *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef _OSGDEBUGHUD_H_
|
||||
#define _OSGDEBUGHUD_H_
|
||||
|
||||
#include<osg/ref_ptr>
|
||||
#include<osg/Camera>
|
||||
|
||||
class SDDebugHUD
|
||||
{
|
||||
private:
|
||||
osg::ref_ptr<osg::Camera> HUD_camera;
|
||||
|
||||
public:
|
||||
void toggleHUD();
|
||||
SDDebugHUD();
|
||||
~SDDebugHUD();
|
||||
|
||||
inline osg::ref_ptr<osg::Camera> getRootCamera(){
|
||||
return HUD_camera;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#endif //_OSGDEBUGHUD_H_
|
|
@ -32,6 +32,7 @@
|
|||
SDScreens::SDScreens()
|
||||
:m_CurrentScreenIndex(0)
|
||||
{
|
||||
debugHUD = new SDDebugHUD();
|
||||
viewer = new osgViewer::Viewer();
|
||||
viewer->setSceneData(new osg::Group());
|
||||
}
|
||||
|
@ -108,6 +109,8 @@ void SDScreens::Init(int x,int y, int width, int height, osg::ref_ptr<osg::Node>
|
|||
root->addChild(mirrorCam.get());
|
||||
}
|
||||
|
||||
root->addChild(debugHUD->getRootCamera());
|
||||
|
||||
viewer->setSceneData(root.get());
|
||||
viewer->realize();
|
||||
}
|
||||
|
@ -496,6 +499,11 @@ void SDScreens::changeCamera(long p)
|
|||
}
|
||||
}
|
||||
|
||||
void SDScreens::toggleDebugHUD(){
|
||||
debugHUD->toggleHUD();
|
||||
}
|
||||
|
||||
|
||||
SDScreens::~SDScreens()
|
||||
{
|
||||
root->removeChildren(0, root->getNumChildren());
|
||||
|
@ -510,5 +518,6 @@ SDScreens::~SDScreens()
|
|||
//delete viewer->getSceneData();
|
||||
|
||||
delete viewer;
|
||||
delete debugHUD;
|
||||
viewer = NULL;
|
||||
}
|
||||
|
|
|
@ -24,6 +24,8 @@
|
|||
#include <vector>
|
||||
#include "OsgView.h"
|
||||
|
||||
#include "OsgDebugHUD.h"
|
||||
|
||||
#define SD_SPLIT_ADD 0
|
||||
#define SD_SPLIT_REM 1
|
||||
#define SD_SPLIT_ARR 2
|
||||
|
@ -39,6 +41,7 @@ class SDScreens
|
|||
osgViewer::Viewer* viewer;
|
||||
std::vector<SDView *> Screens;
|
||||
osg::ref_ptr<osg::Group> root;
|
||||
SDDebugHUD * debugHUD;
|
||||
|
||||
int m_Winx;
|
||||
int m_Winy;
|
||||
|
@ -64,6 +67,7 @@ class SDScreens
|
|||
void splitScreen(long p);
|
||||
void changeScreen(long p);
|
||||
void changeCamera(long p);
|
||||
void toggleDebugHUD();
|
||||
|
||||
inline SDView * getActiveView(){return Screens[m_CurrentScreenIndex];}
|
||||
|
||||
|
|
Loading…
Reference in a new issue