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:
torcs-ng 2012-10-19 11:56:32 +00:00
parent 73c0a2c3d2
commit 54ddca5b25
5 changed files with 34 additions and 21 deletions

View file

@ -32,6 +32,7 @@
//#include "grcar.h"
//#include "grscreen.h"
//#include "grscene.h"
#include "OsgScene.h"
//#include "grsound.h"
//#include "grloadac.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_sceneViewer = new osgViewer::Viewer();
setViewer(m_sceneViewer);
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.
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)
{
int i;
//int i;
m_sceneViewer->frame();
}
GfProfStartProfile("refresh");
/*GfProfStartProfile("refresh");
// Compute FPS indicators every second.
frameInfo.nInstFrames++;
@ -685,29 +689,31 @@ shutdownCars(void)
if (nFPSTotalSeconds > 0)
GfLogTrace("Average frame rate: %.2f F/s\n",
(double)frameInfo.nTotalFrames/((double)nFPSTotalSeconds + GfTimeClock() - fFPSPrevInstTime));
}
}*/
int
initTrack(tTrack *track)
{
// 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.
grContext.makeCurrent();
//grContext.makeCurrent();
setupOpenGLFeatures();
grssgSetCurrentOptions(&options);
//grssgSetCurrentOptions(&options);
// Now, do the real track loading job.
grTrackHandle = GfParmReadFile(track->filename, GFPARM_RMODE_STD | GFPARM_RMODE_CREAT);
if (grNbActiveScreens > 0)
/*if (grNbActiveScreens > 0)
return grLoadScene(track);
return -1;
return -1;*/
//m_sceneViewer->setSceneData();
return grLoadScene(track);
}
void
/*void
shutdownTrack(void)
{
// Do the real track termination job.
@ -723,9 +729,9 @@ shutdownTrack(void)
options.endLoad();
grShutdownState();
}
}*/
void
/*void
shutdownView(void)
{
for (int i = 0; i < GR_NB_MAX_SCREEN; i++)

View file

@ -167,6 +167,11 @@ OsgInitScene(void)
//static ssgLoaderOptionsEx options;
void setViewer(osg::ref_ptr<osgViewer::Viewer> msV)
{
m_sceneViewer = msV;
}
bool LoadTrack(std::string strTrack)
{
osgLoader loader;
@ -211,9 +216,9 @@ grLoadScene(tTrack *track)
grHandle = GfParmReadFile(buf, GFPARM_RMODE_STD | GFPARM_RMODE_REREAD);
}//if grHandle
skydynamic = GfParmGetNum(grHandle, GR_SCT_GRAPHIC, GR_ATT_SKYDOME, (char*)NULL, skydynamic);
TimeDyn = GfParmGetNum(grHandle, GR_SCT_GRAPHIC, GR_ATT_DYNAMICTIME, (char*)NULL, TimeDyn);
WeatherDyn = GfParmGetNum(grHandle, GR_SCT_GRAPHIC, GR_ATT_DYNAMICWEATHER, (char*)NULL, WeatherDyn);
//skydynamic = GfParmGetNum(grHandle, GR_SCT_GRAPHIC, GR_ATT_SKYDOME, (char*)NULL, skydynamic);
//TimeDyn = GfParmGetNum(grHandle, GR_SCT_GRAPHIC, GR_ATT_DYNAMICTIME, (char*)NULL, TimeDyn);
//WeatherDyn = GfParmGetNum(grHandle, GR_SCT_GRAPHIC, GR_ATT_DYNAMICWEATHER, (char*)NULL, WeatherDyn);
//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
@ -227,11 +232,12 @@ grLoadScene(tTrack *track)
}
std::string strTPath = GetDataDir();
strTPath+="data/textures";
SetTexturePaths(strTPath.c_str());
sprintf(buf, "tracks/%s/%s;data/textures;data/img;.", grTrack->category, grTrack->internalname);
strTPath+=buf;
SetTexturePaths(strTPath.c_str());
//ssgTexturePath(buf);
sprintf(buf, "tracks/%s/%s", grTrack->category, grTrack->internalname);
//sprintf(buf, "tracks/%s/%s", grTrack->category, grTrack->internalname);
//ssgModelPath(buf);
std::string strPath = GetDataDir();

View file

@ -74,6 +74,7 @@ extern void grShutdownScene(void);
extern void grCustomizePits(void);
//extern void grDrawBackground(class cGrCamera *, class cGrBackgroundCam *bgCam);
extern void grUpdateTime(tSituation *s);
extern void setViewer(osg::ref_ptr<osgViewer::Viewer> msV);
//TODO: What is this??? kilo
#ifdef GUIONS

View file

@ -1,4 +1,4 @@
#pragma once
#include <string.h> // to remove with OSG 3.2
#include <osgDB/FileNameUtils>
#include <osgDB/Registry>

View file

@ -85,7 +85,7 @@ OsgGraph::~OsgGraph()
bool OsgGraph::loadTrack(tTrack* pTrack)
{
//GfLogDebug("SsgGraph::loadTrack\n");
return true;//return ::initTrack(pTrack) == 0;
return ::initTrack(pTrack) == 0;
}
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)
{
//::refresh(pSituation);
::refresh(pSituation);
}
// void OsgGraph::bendCar(int index, sgVec3 poc, sgVec3 force, int count)