update osggraph
git-svn-id: https://svn.code.sf.net/p/speed-dreams/code/trunk@5013 30fe4595-0a0c-4342-8851-515496e4dcbd Former-commit-id: 44632cc4ec3a08c70aaabeac8b2d2c82c31b47d2 Former-commit-id: 4a868ca9447834a02b367fd933daaddaa51c0df2
This commit is contained in:
parent
583453ec33
commit
11a09bafa6
4 changed files with 43 additions and 9 deletions
|
@ -42,7 +42,8 @@
|
|||
//#include "grbackground.h"
|
||||
|
||||
|
||||
//extern osg::ref_ptr<osgViewer::Viewer> m_sceneViewer;
|
||||
//osg::ref_ptr<osgViewer::Viewer> m_sceneViewer;
|
||||
//osg::ref_ptr<osg::Group> m_sceneroot;
|
||||
//extern osg::Timer m_timer;
|
||||
//extern osg::Timer_t m_start_tick;
|
||||
|
||||
|
@ -445,6 +446,9 @@ initView(int x, int y, int width, int height, int /* flag */, void *screen)
|
|||
frameInfo.nTotalFrames = 0;
|
||||
fFPSPrevInstTime = GfTimeClock();
|
||||
nFPSTotalSeconds = 0;
|
||||
//osg::Vec3 eye, center, up;
|
||||
//eye = { 10.0f, 10.0f, 0.5f};
|
||||
//center = { 50.0f, 20.0f, 0.05f};
|
||||
|
||||
//tdble grLodFactorValue = 1.0;
|
||||
|
||||
|
@ -453,7 +457,15 @@ initView(int x, int y, int width, int height, int /* flag */, void *screen)
|
|||
m_sceneViewer = new osgViewer::Viewer();
|
||||
setViewer(m_sceneViewer);
|
||||
osg::ref_ptr<osgViewer::GraphicsWindowEmbedded> gw = m_sceneViewer->setUpViewerAsEmbeddedInWindow(0, 0, grWinw, grWinh);
|
||||
m_sceneViewer->getCamera()->setName("Cam one");
|
||||
//m_sceneViewer->getCamera()->setViewMatrix( viewMatrix );
|
||||
//m_sceneViewer->getCamera()->setProjectionMatrix( projectionMatrix );
|
||||
m_sceneViewer->getCamera()->setViewport(new osg::Viewport(0, 0, grWinw, grWinh));
|
||||
//m_sceneViewer->getCamera()->getViewMatrixAsLookAt(eye, center, up);
|
||||
m_sceneViewer->getCamera()->setGraphicsContext(gw.get());
|
||||
m_sceneViewer->realize();
|
||||
|
||||
//m_sceneViewer->setThreadingModel(osgViewer::Viewer::CullThreadPerCameraDrawThreadPerContext);
|
||||
|
||||
/*// Create the screens and initialize each board.
|
||||
for (i = 0; i < GR_NB_MAX_SCREEN; i++) {
|
||||
|
@ -499,7 +511,7 @@ initView(int x, int y, int width, int height, int /* flag */, void *screen)
|
|||
|
||||
GfLogInfo("Current screen is #%d (out of %d)\n", nCurrentScreenIndex, grNbActiveScreens);
|
||||
|
||||
//grInitScene();
|
||||
OsgInitScene();
|
||||
|
||||
//grLodFactorValue = GfParmGetNum(grHandle, GR_SCT_GRAPHIC, GR_ATT_LODFACTOR, NULL, 1.0);
|
||||
|
||||
|
@ -512,6 +524,8 @@ refresh(tSituation *s)
|
|||
{
|
||||
//int i;
|
||||
m_sceneViewer->frame();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*GfProfStartProfile("refresh");
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#define _OSGMAIN_H_
|
||||
|
||||
#include <osgViewer/Viewer>
|
||||
#include <osg/Camera>
|
||||
|
||||
#include <graphic.h>
|
||||
#include <raceman.h> //tSituation
|
||||
|
|
|
@ -29,6 +29,9 @@
|
|||
#include <osgDB/ReadFile>
|
||||
#include <osgDB/WriteFile>
|
||||
#include <osgDB/Registry>
|
||||
#include <osg/Light>
|
||||
#include <osg/LightSource>
|
||||
#include <osg/Camera>
|
||||
|
||||
#include "OsgLoader.h"
|
||||
#include "OsgMain.h"
|
||||
|
@ -78,6 +81,8 @@ osg::Timer_t m_start_tick;
|
|||
osg::Matrix m_ModelMat;
|
||||
osg::Matrix m_ProjMat;
|
||||
|
||||
osg::Vec3 eye,center,up;
|
||||
|
||||
/*ssgStateSelector *grEnvSelector = NULL;
|
||||
grMultiTexState *grEnvState = NULL;
|
||||
grMultiTexState *grEnvShadowState = NULL;
|
||||
|
@ -160,7 +165,20 @@ int
|
|||
OsgInitScene(void)
|
||||
{
|
||||
void *hndl = grTrackHandle;
|
||||
|
||||
|
||||
// create a local light.
|
||||
osg::Light* myLight2 = new osg::Light;
|
||||
myLight2->setLightNum(1);
|
||||
myLight2->setPosition(osg::Vec4(0.0f, 0.0f, 0.0f,1.0f));
|
||||
myLight2->setAmbient(osg::Vec4(0.0f, 1.0f, 1.0f, 1.0f));
|
||||
myLight2->setDiffuse(osg::Vec4(0.0f, 1.0f, 1.0f, 1.0f));
|
||||
myLight2->setConstantAttenuation(1.0f);
|
||||
|
||||
|
||||
//myLight2->setLinearAttenuation(2.0f/m_sceneroot);
|
||||
|
||||
m_sceneViewer->setSceneData( m_sceneroot.get() );
|
||||
m_sceneViewer->getCamera()->setCullingMode( m_sceneViewer->getCamera()->getCullingMode() & ~osg::CullStack::SMALL_FEATURE_CULLING);
|
||||
return 0;
|
||||
}//grInitScene
|
||||
|
||||
|
@ -198,11 +216,12 @@ bool LoadTrack(std::string strTrack)
|
|||
optimizer.optimize(pTrack);
|
||||
osg::Matrixf mat;
|
||||
//Rotate track model 90 degrees to match the way plib loader works
|
||||
mat = mat.rotate(osg::inDegrees(90.0), osg::X_AXIS);
|
||||
osg::MatrixTransform *pTrans = new osg::MatrixTransform(mat);
|
||||
pTrans->addChild(pTrack);
|
||||
pTrans->getOrCreateStateSet()->setRenderBinDetails(TRACKBIN,"RenderBin");
|
||||
m_sceneroot->addChild(pTrans);
|
||||
//mat = mat.rotate(osg::inDegrees(90.0), osg::X_AXIS);
|
||||
//osg::MatrixTransform *pTrans = new osg::MatrixTransform(mat);
|
||||
//pTrans->addChild(pTrack);
|
||||
//pTrans->getOrCreateStateSet()->setRenderBinDetails(TRACKBIN,"RenderBin");
|
||||
pTrack->getOrCreateStateSet()->setRenderBinDetails(TRACKBIN,"RenderBin");
|
||||
m_sceneroot->addChild(pTrack);
|
||||
|
||||
}
|
||||
else
|
||||
|
|
|
@ -67,7 +67,7 @@ extern grMultiTexState *grEnvShadowStateOnCars;*/
|
|||
|
||||
|
||||
//!Public interface
|
||||
extern int grInitScene(void);
|
||||
extern int OsgInitScene(void);
|
||||
extern int grLoadScene(tTrack *track);
|
||||
extern void grDrawScene(float speedcar, tSituation *s);
|
||||
extern void SetTexturePaths(const char *pszPath);
|
||||
|
|
Loading…
Reference in a new issue