update osggraph by Gaetan
git-svn-id: https://svn.code.sf.net/p/speed-dreams/code/trunk@5004 30fe4595-0a0c-4342-8851-515496e4dcbd Former-commit-id: 176871cac813d25f7094c536b7bf62f81fc18f28 Former-commit-id: caaaf1a868ef254a8a538474e607d1133e30816b
This commit is contained in:
parent
73c0a2c3d2
commit
54ddca5b25
5 changed files with 34 additions and 21 deletions
|
@ -32,6 +32,7 @@
|
||||||
//#include "grcar.h"
|
//#include "grcar.h"
|
||||||
//#include "grscreen.h"
|
//#include "grscreen.h"
|
||||||
//#include "grscene.h"
|
//#include "grscene.h"
|
||||||
|
#include "OsgScene.h"
|
||||||
//#include "grsound.h"
|
//#include "grsound.h"
|
||||||
//#include "grloadac.h"
|
//#include "grloadac.h"
|
||||||
//#include "grutil.h"
|
//#include "grutil.h"
|
||||||
|
@ -450,8 +451,9 @@ initView(int x, int y, int width, int height, int /* flag */, void *screen)
|
||||||
//m_start_tick = m_timer.tick();
|
//m_start_tick = m_timer.tick();
|
||||||
|
|
||||||
m_sceneViewer = new osgViewer::Viewer();
|
m_sceneViewer = new osgViewer::Viewer();
|
||||||
|
setViewer(m_sceneViewer);
|
||||||
osg::ref_ptr<osgViewer::GraphicsWindowEmbedded> gw = m_sceneViewer->setUpViewerAsEmbeddedInWindow(0, 0, grWinw, grWinh);
|
osg::ref_ptr<osgViewer::GraphicsWindowEmbedded> gw = m_sceneViewer->setUpViewerAsEmbeddedInWindow(0, 0, grWinw, grWinh);
|
||||||
//m_sceneViewer->realize();
|
m_sceneViewer->realize();
|
||||||
|
|
||||||
/*// Create the screens and initialize each board.
|
/*// Create the screens and initialize each board.
|
||||||
for (i = 0; i < GR_NB_MAX_SCREEN; i++) {
|
for (i = 0; i < GR_NB_MAX_SCREEN; i++) {
|
||||||
|
@ -505,12 +507,14 @@ initView(int x, int y, int width, int height, int /* flag */, void *screen)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*int
|
int
|
||||||
refresh(tSituation *s)
|
refresh(tSituation *s)
|
||||||
{
|
{
|
||||||
int i;
|
//int i;
|
||||||
|
m_sceneViewer->frame();
|
||||||
|
}
|
||||||
|
|
||||||
GfProfStartProfile("refresh");
|
/*GfProfStartProfile("refresh");
|
||||||
|
|
||||||
// Compute FPS indicators every second.
|
// Compute FPS indicators every second.
|
||||||
frameInfo.nInstFrames++;
|
frameInfo.nInstFrames++;
|
||||||
|
@ -685,29 +689,31 @@ shutdownCars(void)
|
||||||
if (nFPSTotalSeconds > 0)
|
if (nFPSTotalSeconds > 0)
|
||||||
GfLogTrace("Average frame rate: %.2f F/s\n",
|
GfLogTrace("Average frame rate: %.2f F/s\n",
|
||||||
(double)frameInfo.nTotalFrames/((double)nFPSTotalSeconds + GfTimeClock() - fFPSPrevInstTime));
|
(double)frameInfo.nTotalFrames/((double)nFPSTotalSeconds + GfTimeClock() - fFPSPrevInstTime));
|
||||||
}
|
}*/
|
||||||
|
|
||||||
int
|
int
|
||||||
initTrack(tTrack *track)
|
initTrack(tTrack *track)
|
||||||
{
|
{
|
||||||
// The inittrack does as well init the context, that is highly inconsistent, IMHO.
|
// The inittrack does as well init the context, that is highly inconsistent, IMHO.
|
||||||
// TODO: Find a solution to init the graphics first independent of objects.
|
// TODO: Find a solution to init the graphics first independent of objects.
|
||||||
grContext.makeCurrent();
|
//grContext.makeCurrent();
|
||||||
|
|
||||||
setupOpenGLFeatures();
|
setupOpenGLFeatures();
|
||||||
|
|
||||||
grssgSetCurrentOptions(&options);
|
//grssgSetCurrentOptions(&options);
|
||||||
|
|
||||||
// Now, do the real track loading job.
|
// Now, do the real track loading job.
|
||||||
grTrackHandle = GfParmReadFile(track->filename, GFPARM_RMODE_STD | GFPARM_RMODE_CREAT);
|
grTrackHandle = GfParmReadFile(track->filename, GFPARM_RMODE_STD | GFPARM_RMODE_CREAT);
|
||||||
if (grNbActiveScreens > 0)
|
/*if (grNbActiveScreens > 0)
|
||||||
return grLoadScene(track);
|
return grLoadScene(track);
|
||||||
|
|
||||||
return -1;
|
return -1;*/
|
||||||
|
//m_sceneViewer->setSceneData();
|
||||||
|
return grLoadScene(track);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
/*void
|
||||||
shutdownTrack(void)
|
shutdownTrack(void)
|
||||||
{
|
{
|
||||||
// Do the real track termination job.
|
// Do the real track termination job.
|
||||||
|
@ -723,9 +729,9 @@ shutdownTrack(void)
|
||||||
options.endLoad();
|
options.endLoad();
|
||||||
|
|
||||||
grShutdownState();
|
grShutdownState();
|
||||||
}
|
}*/
|
||||||
|
|
||||||
void
|
/*void
|
||||||
shutdownView(void)
|
shutdownView(void)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < GR_NB_MAX_SCREEN; i++)
|
for (int i = 0; i < GR_NB_MAX_SCREEN; i++)
|
||||||
|
|
|
@ -167,6 +167,11 @@ OsgInitScene(void)
|
||||||
|
|
||||||
//static ssgLoaderOptionsEx options;
|
//static ssgLoaderOptionsEx options;
|
||||||
|
|
||||||
|
void setViewer(osg::ref_ptr<osgViewer::Viewer> msV)
|
||||||
|
{
|
||||||
|
m_sceneViewer = msV;
|
||||||
|
}
|
||||||
|
|
||||||
bool LoadTrack(std::string strTrack)
|
bool LoadTrack(std::string strTrack)
|
||||||
{
|
{
|
||||||
osgLoader loader;
|
osgLoader loader;
|
||||||
|
@ -211,9 +216,9 @@ grLoadScene(tTrack *track)
|
||||||
grHandle = GfParmReadFile(buf, GFPARM_RMODE_STD | GFPARM_RMODE_REREAD);
|
grHandle = GfParmReadFile(buf, GFPARM_RMODE_STD | GFPARM_RMODE_REREAD);
|
||||||
}//if grHandle
|
}//if grHandle
|
||||||
|
|
||||||
skydynamic = GfParmGetNum(grHandle, GR_SCT_GRAPHIC, GR_ATT_SKYDOME, (char*)NULL, skydynamic);
|
//skydynamic = GfParmGetNum(grHandle, GR_SCT_GRAPHIC, GR_ATT_SKYDOME, (char*)NULL, skydynamic);
|
||||||
TimeDyn = GfParmGetNum(grHandle, GR_SCT_GRAPHIC, GR_ATT_DYNAMICTIME, (char*)NULL, TimeDyn);
|
//TimeDyn = GfParmGetNum(grHandle, GR_SCT_GRAPHIC, GR_ATT_DYNAMICTIME, (char*)NULL, TimeDyn);
|
||||||
WeatherDyn = GfParmGetNum(grHandle, GR_SCT_GRAPHIC, GR_ATT_DYNAMICWEATHER, (char*)NULL, WeatherDyn);
|
//WeatherDyn = GfParmGetNum(grHandle, GR_SCT_GRAPHIC, GR_ATT_DYNAMICWEATHER, (char*)NULL, WeatherDyn);
|
||||||
|
|
||||||
//acname = GfParmGetStr(hndl, TRK_SECT_GRAPH, TRK_ATT_3DDESC, "track.ac");
|
//acname = GfParmGetStr(hndl, TRK_SECT_GRAPH, TRK_ATT_3DDESC, "track.ac");
|
||||||
/*if ((grTrack->Timeday == 1) && (grTrack->skyversion > 0)) // If night in quickrace, practice or network mode
|
/*if ((grTrack->Timeday == 1) && (grTrack->skyversion > 0)) // If night in quickrace, practice or network mode
|
||||||
|
@ -227,11 +232,12 @@ grLoadScene(tTrack *track)
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string strTPath = GetDataDir();
|
std::string strTPath = GetDataDir();
|
||||||
strTPath+="data/textures";
|
|
||||||
SetTexturePaths(strTPath.c_str());
|
|
||||||
sprintf(buf, "tracks/%s/%s;data/textures;data/img;.", grTrack->category, grTrack->internalname);
|
sprintf(buf, "tracks/%s/%s;data/textures;data/img;.", grTrack->category, grTrack->internalname);
|
||||||
|
strTPath+=buf;
|
||||||
|
SetTexturePaths(strTPath.c_str());
|
||||||
|
|
||||||
//ssgTexturePath(buf);
|
//ssgTexturePath(buf);
|
||||||
sprintf(buf, "tracks/%s/%s", grTrack->category, grTrack->internalname);
|
//sprintf(buf, "tracks/%s/%s", grTrack->category, grTrack->internalname);
|
||||||
//ssgModelPath(buf);
|
//ssgModelPath(buf);
|
||||||
|
|
||||||
std::string strPath = GetDataDir();
|
std::string strPath = GetDataDir();
|
||||||
|
|
|
@ -74,6 +74,7 @@ extern void grShutdownScene(void);
|
||||||
extern void grCustomizePits(void);
|
extern void grCustomizePits(void);
|
||||||
//extern void grDrawBackground(class cGrCamera *, class cGrBackgroundCam *bgCam);
|
//extern void grDrawBackground(class cGrCamera *, class cGrBackgroundCam *bgCam);
|
||||||
extern void grUpdateTime(tSituation *s);
|
extern void grUpdateTime(tSituation *s);
|
||||||
|
extern void setViewer(osg::ref_ptr<osgViewer::Viewer> msV);
|
||||||
|
|
||||||
//TODO: What is this??? kilo
|
//TODO: What is this??? kilo
|
||||||
#ifdef GUIONS
|
#ifdef GUIONS
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#pragma once
|
#include <string.h> // to remove with OSG 3.2
|
||||||
|
|
||||||
#include <osgDB/FileNameUtils>
|
#include <osgDB/FileNameUtils>
|
||||||
#include <osgDB/Registry>
|
#include <osgDB/Registry>
|
||||||
|
|
|
@ -85,7 +85,7 @@ OsgGraph::~OsgGraph()
|
||||||
bool OsgGraph::loadTrack(tTrack* pTrack)
|
bool OsgGraph::loadTrack(tTrack* pTrack)
|
||||||
{
|
{
|
||||||
//GfLogDebug("SsgGraph::loadTrack\n");
|
//GfLogDebug("SsgGraph::loadTrack\n");
|
||||||
return true;//return ::initTrack(pTrack) == 0;
|
return ::initTrack(pTrack) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool OsgGraph::loadCars(tSituation* pSituation)
|
bool OsgGraph::loadCars(tSituation* pSituation)
|
||||||
|
@ -102,7 +102,7 @@ bool OsgGraph::setupView(int x, int y, int width, int height, void* pMenuScreen)
|
||||||
|
|
||||||
void OsgGraph::redrawView(tSituation* pSituation)
|
void OsgGraph::redrawView(tSituation* pSituation)
|
||||||
{
|
{
|
||||||
//::refresh(pSituation);
|
::refresh(pSituation);
|
||||||
}
|
}
|
||||||
|
|
||||||
// void OsgGraph::bendCar(int index, sgVec3 poc, sgVec3 force, int count)
|
// void OsgGraph::bendCar(int index, sgVec3 poc, sgVec3 force, int count)
|
||||||
|
|
Loading…
Reference in a new issue