Fixed a bug in the Optimizer where BIND_PER_PRIMITIVE_SET primitives where being eroneously merged.
Added missing support for reading geometry indices from the .osg format. Added handling of geometry indices into the primitive functor in osg::Geometry. Moved the method implementions of AnimationPathManipulator into src/osgGA and added extra convinience methods for setting the manipulator with an hand built AnimationPath. FCVS: VisualStudio/osgPlugins/iv/iv.dsp
This commit is contained in:
parent
bfedea5636
commit
c59fc9a2b7
@ -1,392 +1,204 @@
|
||||
# Microsoft Developer Studio Project File - Name="Core osgGA" - Package Owner=<4>
|
||||
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
|
||||
|
||||
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
|
||||
|
||||
|
||||
|
||||
CFG=Core osgGA - Win32 Release
|
||||
|
||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
||||
|
||||
!MESSAGE use the Export Makefile command and run
|
||||
|
||||
!MESSAGE
|
||||
|
||||
!MESSAGE NMAKE /f "osgGA.mak".
|
||||
|
||||
!MESSAGE
|
||||
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
|
||||
!MESSAGE
|
||||
|
||||
!MESSAGE NMAKE /f "osgGA.mak" CFG="Core osgGA - Win32 Release"
|
||||
|
||||
!MESSAGE
|
||||
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
|
||||
!MESSAGE
|
||||
|
||||
!MESSAGE "Core osgGA - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
|
||||
|
||||
!MESSAGE "Core osgGA - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
|
||||
|
||||
!MESSAGE
|
||||
|
||||
|
||||
|
||||
# Begin Project
|
||||
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
|
||||
# PROP Scc_ProjName ""
|
||||
|
||||
# PROP Scc_LocalPath ""
|
||||
|
||||
CPP=cl.exe
|
||||
|
||||
MTL=midl.exe
|
||||
|
||||
RSC=rc.exe
|
||||
|
||||
|
||||
|
||||
!IF "$(CFG)" == "Core osgGA - Win32 Release"
|
||||
|
||||
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
|
||||
# PROP BASE Output_Dir "../../lib"
|
||||
|
||||
# PROP BASE Intermediate_Dir "Release"
|
||||
|
||||
# PROP BASE Target_Dir ""
|
||||
|
||||
# PROP Use_MFC 0
|
||||
|
||||
# PROP Use_Debug_Libraries 0
|
||||
|
||||
# PROP Output_Dir "../../lib"
|
||||
|
||||
# PROP Intermediate_Dir "Release"
|
||||
|
||||
# PROP Ignore_Export_Lib 0
|
||||
|
||||
# PROP Target_Dir ""
|
||||
|
||||
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /YX /FD /c
|
||||
|
||||
# ADD CPP /nologo /MD /W3 /GR /GX /O2 /I "../../include" /D "NDEBUG" /D "_MBCS" /D "_USRDLL" /D "OSGGA_LIBRARY" /D "WIN32" /D "_WINDOWS" /YX /FD /c
|
||||
|
||||
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
|
||||
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
|
||||
# ADD BASE RSC /l 0x809 /d "NDEBUG"
|
||||
|
||||
# ADD RSC /l 0x809 /d "NDEBUG"
|
||||
|
||||
BSC32=bscmake.exe
|
||||
|
||||
# ADD BASE BSC32 /nologo
|
||||
|
||||
# ADD BSC32 /nologo
|
||||
|
||||
LINK32=link.exe
|
||||
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
|
||||
|
||||
# ADD LINK32 glu32.lib opengl32.lib /nologo /dll /pdb:none /machine:I386 /out:"../../bin/osgGA.dll" /libpath:"../../lib"
|
||||
|
||||
|
||||
|
||||
!ELSEIF "$(CFG)" == "Core osgGA - Win32 Debug"
|
||||
|
||||
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
|
||||
# PROP BASE Output_Dir "Debug"
|
||||
|
||||
# PROP BASE Intermediate_Dir "Debug"
|
||||
|
||||
# PROP BASE Target_Dir ""
|
||||
|
||||
# PROP Use_MFC 0
|
||||
|
||||
# PROP Use_Debug_Libraries 1
|
||||
|
||||
# PROP Output_Dir "../../lib"
|
||||
|
||||
# PROP Intermediate_Dir "Debug"
|
||||
|
||||
# PROP Ignore_Export_Lib 0
|
||||
|
||||
# PROP Target_Dir ""
|
||||
|
||||
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /YX /FD /GZ /c
|
||||
|
||||
# ADD CPP /nologo /MDd /W3 /Gm /vmg /vd0 /GR /GX /Zi /Od /I "../../include" /D "OSGGA_LIBRARY" /D "_WINDOWS" /D "WIN32" /D "_DEBUG" /YX /FD /GZ /c
|
||||
|
||||
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
|
||||
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
|
||||
# ADD BASE RSC /l 0x809 /d "_DEBUG"
|
||||
|
||||
# ADD RSC /l 0x809 /d "_DEBUG"
|
||||
|
||||
BSC32=bscmake.exe
|
||||
|
||||
# ADD BASE BSC32 /nologo
|
||||
|
||||
# ADD BSC32 /nologo
|
||||
|
||||
LINK32=link.exe
|
||||
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
|
||||
|
||||
# ADD LINK32 glu32.lib opengl32.lib /nologo /dll /debug /machine:I386 /out:"../../bin/osgGAd.dll" /pdbtype:sept /libpath:"../../lib"
|
||||
|
||||
# SUBTRACT LINK32 /pdb:none
|
||||
|
||||
|
||||
|
||||
!ENDIF
|
||||
|
||||
|
||||
|
||||
# Begin Target
|
||||
|
||||
|
||||
|
||||
# Name "Core osgGA - Win32 Release"
|
||||
|
||||
# Name "Core osgGA - Win32 Debug"
|
||||
|
||||
# Begin Group "Source Files"
|
||||
|
||||
|
||||
|
||||
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
|
||||
|
||||
# Begin Source File
|
||||
|
||||
|
||||
SOURCE=..\..\src\osgGA\AnimationPathManipulator.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\src\osgGA\CameraManipulator.cpp
|
||||
|
||||
# End Source File
|
||||
|
||||
# Begin Source File
|
||||
|
||||
|
||||
|
||||
SOURCE=..\..\src\osgGA\DriveManipulator.cpp
|
||||
|
||||
# End Source File
|
||||
|
||||
# Begin Source File
|
||||
|
||||
|
||||
|
||||
SOURCE=..\..\src\osgGA\FlightManipulator.cpp
|
||||
|
||||
# End Source File
|
||||
|
||||
# Begin Source File
|
||||
|
||||
|
||||
|
||||
SOURCE=..\..\src\osgGA\GUIEventHandler.cpp
|
||||
|
||||
# End Source File
|
||||
|
||||
# Begin Source File
|
||||
|
||||
|
||||
|
||||
SOURCE=..\..\src\osgGA\GUIEventHandlerVisitor.cpp
|
||||
|
||||
# End Source File
|
||||
|
||||
# Begin Source File
|
||||
|
||||
|
||||
|
||||
SOURCE=..\..\src\osgGA\KeySwitchCameraManipulator.cpp
|
||||
|
||||
# End Source File
|
||||
|
||||
# Begin Source File
|
||||
|
||||
|
||||
|
||||
SOURCE=..\..\src\osgGA\SetSceneViewVisitor.cpp
|
||||
|
||||
# End Source File
|
||||
|
||||
# Begin Source File
|
||||
|
||||
|
||||
|
||||
SOURCE=..\..\src\osgGA\StateSetManipulator.cpp
|
||||
|
||||
# End Source File
|
||||
|
||||
# Begin Source File
|
||||
|
||||
|
||||
|
||||
SOURCE=..\..\src\osgGA\TrackballManipulator.cpp
|
||||
|
||||
# End Source File
|
||||
|
||||
# Begin Source File
|
||||
|
||||
|
||||
|
||||
SOURCE=..\..\src\osgGA\Version.cpp
|
||||
|
||||
# End Source File
|
||||
|
||||
# End Group
|
||||
|
||||
# Begin Group "Header Files"
|
||||
|
||||
|
||||
|
||||
# PROP Default_Filter ";h;hpp;hxx;hm;inl"
|
||||
|
||||
# Begin Source File
|
||||
|
||||
|
||||
SOURCE=..\..\Include\osgGA\AnimationPathManipulator
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Include\osgGA\CameraManipulator
|
||||
|
||||
# End Source File
|
||||
|
||||
# Begin Source File
|
||||
|
||||
|
||||
|
||||
SOURCE=..\..\Include\osgGA\DriveManipulator
|
||||
|
||||
# End Source File
|
||||
|
||||
# Begin Source File
|
||||
|
||||
|
||||
|
||||
SOURCE=..\..\Include\osgGA\Export
|
||||
|
||||
# End Source File
|
||||
|
||||
# Begin Source File
|
||||
|
||||
|
||||
|
||||
SOURCE=..\..\Include\osgGA\FlightManipulator
|
||||
|
||||
# End Source File
|
||||
|
||||
# Begin Source File
|
||||
|
||||
|
||||
|
||||
SOURCE=..\..\Include\osgGA\GUIActionAdapter
|
||||
|
||||
# End Source File
|
||||
|
||||
# Begin Source File
|
||||
|
||||
|
||||
|
||||
SOURCE=..\..\Include\osgGA\GUIEventAdapter
|
||||
|
||||
# End Source File
|
||||
|
||||
# Begin Source File
|
||||
|
||||
|
||||
|
||||
SOURCE=..\..\Include\osgGA\GUIEventHandler
|
||||
|
||||
# End Source File
|
||||
|
||||
# Begin Source File
|
||||
|
||||
|
||||
|
||||
SOURCE=..\..\Include\osgGA\GUIEventHandlerVisitor
|
||||
|
||||
# End Source File
|
||||
|
||||
# Begin Source File
|
||||
|
||||
|
||||
|
||||
SOURCE=..\..\Include\osgGA\KeySwitchCameraManipulator
|
||||
|
||||
# End Source File
|
||||
|
||||
# Begin Source File
|
||||
|
||||
|
||||
|
||||
SOURCE=..\..\Include\osgGA\SetSceneViewVisitor
|
||||
|
||||
# End Source File
|
||||
|
||||
# Begin Source File
|
||||
|
||||
|
||||
|
||||
SOURCE=..\..\Include\osgGA\StateSetManipulator
|
||||
|
||||
# End Source File
|
||||
|
||||
# Begin Source File
|
||||
|
||||
|
||||
|
||||
SOURCE=..\..\Include\osgGA\TrackballManipulator
|
||||
|
||||
# End Source File
|
||||
|
||||
# Begin Source File
|
||||
|
||||
|
||||
|
||||
SOURCE=..\..\Include\osgGA\Version
|
||||
|
||||
# End Source File
|
||||
|
||||
# End Group
|
||||
|
||||
# Begin Group "Resource Files"
|
||||
|
||||
|
||||
|
||||
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
|
||||
|
||||
# End Group
|
||||
|
||||
# End Target
|
||||
|
||||
# End Project
|
||||
|
||||
|
@ -22,85 +22,32 @@ namespace osgGA{
|
||||
// px py pz = World position in catesian coordinates
|
||||
// ax ay az aw = Orientation (attitude) defined as a quaternion
|
||||
|
||||
class AnimationPathManipulator : public osgGA::CameraManipulator
|
||||
class OSGGA_EXPORT AnimationPathManipulator : public CameraManipulator
|
||||
{
|
||||
public:
|
||||
AnimationPathManipulator( std::string filename )
|
||||
{
|
||||
_animationPath = new osg::AnimationPath;
|
||||
_animationPath->setLoopMode(osg::AnimationPath::LOOP);
|
||||
|
||||
AnimationPathManipulator( osg::AnimationPath* animationPath=0 );
|
||||
|
||||
FILE *fp = fopen( filename.c_str(), "r" );
|
||||
if( fp == NULL )
|
||||
{
|
||||
osg::notify(osg::WARN) << "AnimationPathManipulator: Cannot open animation path file \"" << filename << "\".\n";
|
||||
_valid = false;
|
||||
return;
|
||||
}
|
||||
while( !feof( fp ))
|
||||
{
|
||||
double time;
|
||||
osg::Vec3 position;
|
||||
osg::Quat rotation;
|
||||
fscanf( fp, "%lf %f %f %f %f %f %f %f\n",
|
||||
&time, &position[0], &position[1], &position[2],
|
||||
&rotation[0], &rotation[1], &rotation[2], &rotation[3] );
|
||||
AnimationPathManipulator( const std::string& filename );
|
||||
|
||||
|
||||
void setAnimationPath( osg::AnimationPath* animationPath ) { _animationPath=animationPath; }
|
||||
|
||||
osg::AnimationPath* getAnimationPath() { return _animationPath.get(); }
|
||||
|
||||
const osg::AnimationPath* getAnimationPath() const { return _animationPath.get(); }
|
||||
|
||||
if( !feof(fp))
|
||||
_animationPath->insert(time,osg::AnimationPath::ControlPoint(position,rotation));
|
||||
}
|
||||
fclose(fp);
|
||||
_valid = true;
|
||||
}
|
||||
bool valid() const { return _animationPath.valid(); }
|
||||
|
||||
bool valid() { return _valid; }
|
||||
|
||||
virtual bool handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionAdapter& us)
|
||||
{
|
||||
if( !_valid ) return false;
|
||||
|
||||
us = us;
|
||||
|
||||
bool retval = false;
|
||||
switch( ea.getEventType() )
|
||||
{
|
||||
case GUIEventAdapter::FRAME:
|
||||
handleFrame( ea.time() );
|
||||
|
||||
break;
|
||||
case GUIEventAdapter::KEYBOARD:
|
||||
switch( ea.getKey())
|
||||
{
|
||||
default:
|
||||
retval = false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
virtual bool handle(const GUIEventAdapter& ea,GUIActionAdapter& us);
|
||||
|
||||
private:
|
||||
|
||||
bool _valid;
|
||||
|
||||
void handleFrame( double time )
|
||||
{
|
||||
osg::AnimationPath::ControlPoint cp;
|
||||
_animationPath->getInterpolatedControlPoint( time, cp );
|
||||
void handleFrame( double time );
|
||||
|
||||
osg::Matrix mat;
|
||||
cp.getMatrix( mat );
|
||||
|
||||
osg::Vec3 eye(mat(3,0), mat(3,1), mat(3,2));
|
||||
mat(3,0) = 0.0;
|
||||
mat(3,1) = 0.0;
|
||||
mat(3,2) = 0.0;
|
||||
osg::Vec3 look = eye + (osg::Vec3(0,1,0) * mat);
|
||||
osg::Vec3 up = osg::Vec3(0,0,1) * mat;
|
||||
if( _camera.valid() )
|
||||
_camera->setView( eye, look, up );
|
||||
}
|
||||
|
||||
osg::AnimationPath *_animationPath;
|
||||
osg::ref_ptr<osg::AnimationPath> _animationPath;
|
||||
|
||||
};
|
||||
|
||||
|
@ -857,15 +857,123 @@ void Geometry::accept(PrimitiveFunctor& functor)
|
||||
{
|
||||
if (!_vertexArray.valid() || _vertexArray->empty()) return;
|
||||
|
||||
functor.setVertexArray(_vertexArray->size(),&(_vertexArray->front()));
|
||||
|
||||
for(PrimitiveSetList::iterator itr=_primitives.begin();
|
||||
itr!=_primitives.end();
|
||||
++itr)
|
||||
if (!_vertexIndices.valid())
|
||||
{
|
||||
(*itr)->accept(functor);
|
||||
functor.setVertexArray(_vertexArray->size(),&(_vertexArray->front()));
|
||||
|
||||
for(PrimitiveSetList::iterator itr=_primitives.begin();
|
||||
itr!=_primitives.end();
|
||||
++itr)
|
||||
{
|
||||
(*itr)->accept(functor);
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
for(PrimitiveSetList::iterator itr=_primitives.begin();
|
||||
itr!=_primitives.end();
|
||||
++itr)
|
||||
{
|
||||
PrimitiveSet* primitiveset = itr->get();
|
||||
GLenum mode=primitiveset->getMode();
|
||||
switch(primitiveset->getType())
|
||||
{
|
||||
case(PrimitiveSet::DrawArraysPrimitiveType):
|
||||
{
|
||||
const DrawArrays* drawArray = static_cast<const DrawArrays*>(primitiveset);
|
||||
functor.begin(mode);
|
||||
|
||||
unsigned int indexEnd = drawArray->getFirst()+drawArray->getCount();
|
||||
for(unsigned int vindex=drawArray->getFirst();
|
||||
vindex<indexEnd;
|
||||
++vindex)
|
||||
{
|
||||
functor.vertex((*_vertexArray)[_vertexIndices->index(vindex)]);
|
||||
}
|
||||
|
||||
functor.end();
|
||||
break;
|
||||
}
|
||||
case(PrimitiveSet::DrawArrayLengthsPrimitiveType):
|
||||
{
|
||||
|
||||
const DrawArrayLengths* drawArrayLengths = static_cast<const DrawArrayLengths*>(primitiveset);
|
||||
unsigned int vindex=drawArrayLengths->getFirst();
|
||||
for(DrawArrayLengths::const_iterator primItr=drawArrayLengths->begin();
|
||||
primItr!=drawArrayLengths->end();
|
||||
++primItr)
|
||||
{
|
||||
|
||||
functor.begin(mode);
|
||||
|
||||
for(GLsizei primCount=0;primCount<*primItr;++primCount)
|
||||
{
|
||||
functor.vertex((*_vertexArray)[_vertexIndices->index(vindex)]);
|
||||
++vindex;
|
||||
}
|
||||
|
||||
functor.end();
|
||||
|
||||
}
|
||||
break;
|
||||
}
|
||||
case(PrimitiveSet::DrawElementsUBytePrimitiveType):
|
||||
{
|
||||
const DrawElementsUByte* drawElements = static_cast<const DrawElementsUByte*>(primitiveset);
|
||||
functor.begin(mode);
|
||||
|
||||
unsigned int primCount=0;
|
||||
for(DrawElementsUByte::const_iterator primItr=drawElements->begin();
|
||||
primItr!=drawElements->end();
|
||||
++primCount,++primItr)
|
||||
{
|
||||
unsigned int vindex=*primItr;
|
||||
functor.vertex((*_vertexArray)[_vertexIndices->index(vindex)]);
|
||||
}
|
||||
|
||||
functor.end();
|
||||
break;
|
||||
}
|
||||
case(PrimitiveSet::DrawElementsUShortPrimitiveType):
|
||||
{
|
||||
const DrawElementsUShort* drawElements = static_cast<const DrawElementsUShort*>(primitiveset);
|
||||
functor.begin(mode);
|
||||
|
||||
for(DrawElementsUShort::const_iterator primItr=drawElements->begin();
|
||||
primItr!=drawElements->end();
|
||||
++primItr)
|
||||
{
|
||||
unsigned int vindex=*primItr;
|
||||
functor.vertex((*_vertexArray)[_vertexIndices->index(vindex)]);
|
||||
}
|
||||
|
||||
functor.end();
|
||||
break;
|
||||
}
|
||||
case(PrimitiveSet::DrawElementsUIntPrimitiveType):
|
||||
{
|
||||
const DrawElementsUInt* drawElements = static_cast<const DrawElementsUInt*>(primitiveset);
|
||||
functor.begin(mode);
|
||||
|
||||
for(DrawElementsUInt::const_iterator primItr=drawElements->begin();
|
||||
primItr!=drawElements->end();
|
||||
++primItr)
|
||||
{
|
||||
unsigned int vindex=*primItr;
|
||||
functor.vertex((*_vertexArray)[_vertexIndices->index(vindex)]);
|
||||
}
|
||||
|
||||
functor.end();
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool Geometry::verifyBindings() const
|
||||
|
80
src/osgGA/AnimationPathManipulator.cpp
Normal file
80
src/osgGA/AnimationPathManipulator.cpp
Normal file
@ -0,0 +1,80 @@
|
||||
#include <osgGA/AnimationPathManipulator>
|
||||
#include <stdio.h>
|
||||
|
||||
using namespace osgGA;
|
||||
|
||||
AnimationPathManipulator::AnimationPathManipulator(osg::AnimationPath* animationPath)
|
||||
{
|
||||
_animationPath = animationPath;
|
||||
}
|
||||
|
||||
AnimationPathManipulator::AnimationPathManipulator( const std::string& filename )
|
||||
{
|
||||
_animationPath = osgNew osg::AnimationPath;
|
||||
_animationPath->setLoopMode(osg::AnimationPath::LOOP);
|
||||
|
||||
FILE *fp = fopen( filename.c_str(), "r" );
|
||||
if( fp == NULL )
|
||||
{
|
||||
osg::notify(osg::WARN) << "AnimationPathManipulator: Cannot open animation path file \"" << filename << "\".\n";
|
||||
_valid = false;
|
||||
return;
|
||||
}
|
||||
while( !feof( fp ))
|
||||
{
|
||||
double time;
|
||||
osg::Vec3 position;
|
||||
osg::Quat rotation;
|
||||
fscanf( fp, "%lf %f %f %f %f %f %f %f\n",
|
||||
&time, &position[0], &position[1], &position[2],
|
||||
&rotation[0], &rotation[1], &rotation[2], &rotation[3] );
|
||||
|
||||
if( !feof(fp))
|
||||
_animationPath->insert(time,osg::AnimationPath::ControlPoint(position,rotation));
|
||||
}
|
||||
fclose(fp);
|
||||
}
|
||||
|
||||
bool AnimationPathManipulator::handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionAdapter& us)
|
||||
{
|
||||
if( !valid() ) return false;
|
||||
|
||||
us = us;
|
||||
|
||||
bool retval = false;
|
||||
switch( ea.getEventType() )
|
||||
{
|
||||
case GUIEventAdapter::FRAME:
|
||||
handleFrame( ea.time() );
|
||||
|
||||
break;
|
||||
case GUIEventAdapter::KEYBOARD:
|
||||
switch( ea.getKey())
|
||||
{
|
||||
default:
|
||||
retval = false;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
void AnimationPathManipulator::handleFrame( double time )
|
||||
{
|
||||
osg::AnimationPath::ControlPoint cp;
|
||||
_animationPath->getInterpolatedControlPoint( time, cp );
|
||||
|
||||
osg::Matrix mat;
|
||||
cp.getMatrix( mat );
|
||||
|
||||
osg::Vec3 eye(mat(3,0), mat(3,1), mat(3,2));
|
||||
mat(3,0) = 0.0;
|
||||
mat(3,1) = 0.0;
|
||||
mat(3,2) = 0.0;
|
||||
osg::Vec3 look = eye + (osg::Vec3(0,1,0) * mat);
|
||||
osg::Vec3 up = osg::Vec3(0,0,1) * mat;
|
||||
if( _camera.valid() )
|
||||
_camera->setView( eye, look, up );
|
||||
}
|
@ -3,6 +3,7 @@ include $(TOPDIR)/Make/makedefs
|
||||
|
||||
|
||||
CXXFILES = \
|
||||
AnimationPathManipulator.cpp\
|
||||
CameraManipulator.cpp\
|
||||
DriveManipulator.cpp\
|
||||
FlightManipulator.cpp\
|
||||
|
@ -99,6 +99,18 @@ bool Geometry_readLocalData(Object& obj, Input& fr)
|
||||
|
||||
}
|
||||
|
||||
if (fr.matchSequence("VertexIndices %w %i {"))
|
||||
{
|
||||
++fr;
|
||||
IndexArray* indices = dynamic_cast<IndexArray*>(Array_readLocalData(fr));
|
||||
if (indices)
|
||||
{
|
||||
geom.setVertexIndices(indices);
|
||||
iteratorAdvanced = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Geometry::AttributeBinding normalBinding=Geometry::BIND_OFF;
|
||||
if (fr[0].matchWord("NormalBinding") && Geometry_matchBindingTypeStr(fr[1].getStr(),normalBinding))
|
||||
{
|
||||
@ -138,6 +150,16 @@ bool Geometry_readLocalData(Object& obj, Input& fr)
|
||||
iteratorAdvanced = true;
|
||||
++fr;
|
||||
}
|
||||
if (fr.matchSequence("NormalIndices %w %i {"))
|
||||
{
|
||||
++fr;
|
||||
IndexArray* indices = dynamic_cast<IndexArray*>(Array_readLocalData(fr));
|
||||
if (indices)
|
||||
{
|
||||
geom.setNormalIndices(indices);
|
||||
iteratorAdvanced = true;
|
||||
}
|
||||
}
|
||||
|
||||
Geometry::AttributeBinding colorBinding=Geometry::BIND_OFF;
|
||||
if (fr[0].matchWord("ColorBinding") && Geometry_matchBindingTypeStr(fr[1].getStr(),colorBinding))
|
||||
@ -158,6 +180,18 @@ bool Geometry_readLocalData(Object& obj, Input& fr)
|
||||
}
|
||||
}
|
||||
|
||||
if (fr.matchSequence("ColorIndices %w %i {"))
|
||||
{
|
||||
++fr;
|
||||
IndexArray* indices = dynamic_cast<IndexArray*>(Array_readLocalData(fr));
|
||||
if (indices)
|
||||
{
|
||||
geom.setColorIndices(indices);
|
||||
iteratorAdvanced = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Geometry::AttributeBinding secondaryColorBinding=Geometry::BIND_OFF;
|
||||
if (fr[0].matchWord("SecondaryColorBinding") && Geometry_matchBindingTypeStr(fr[1].getStr(),secondaryColorBinding))
|
||||
{
|
||||
@ -177,6 +211,16 @@ bool Geometry_readLocalData(Object& obj, Input& fr)
|
||||
}
|
||||
}
|
||||
|
||||
if (fr.matchSequence("SecondaryColorIndices %w %i {"))
|
||||
{
|
||||
++fr;
|
||||
IndexArray* indices = dynamic_cast<IndexArray*>(Array_readLocalData(fr));
|
||||
if (indices)
|
||||
{
|
||||
geom.setSecondaryColorIndices(indices);
|
||||
iteratorAdvanced = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Geometry::AttributeBinding fogCoordBinding=Geometry::BIND_OFF;
|
||||
@ -219,6 +263,18 @@ bool Geometry_readLocalData(Object& obj, Input& fr)
|
||||
++fr;
|
||||
}
|
||||
|
||||
if (fr.matchSequence("FogCoordIndices %w %i {"))
|
||||
{
|
||||
++fr;
|
||||
IndexArray* indices = dynamic_cast<IndexArray*>(Array_readLocalData(fr));
|
||||
if (indices)
|
||||
{
|
||||
geom.setFogCoordIndices(indices);
|
||||
iteratorAdvanced = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (fr.matchSequence("TexCoordArray %i %w %i {"))
|
||||
{
|
||||
int unit=0;
|
||||
@ -234,6 +290,20 @@ bool Geometry_readLocalData(Object& obj, Input& fr)
|
||||
|
||||
}
|
||||
|
||||
if (fr.matchSequence("TexCoordIndices %i %w %i {"))
|
||||
{
|
||||
int unit=0;
|
||||
fr[1].getInt(unit);
|
||||
|
||||
fr+=2;
|
||||
IndexArray* indices = dynamic_cast<IndexArray*>(Array_readLocalData(fr));
|
||||
if (indices)
|
||||
{
|
||||
geom.setTexCoordIndices(unit,indices);
|
||||
iteratorAdvanced = true;
|
||||
}
|
||||
}
|
||||
|
||||
return iteratorAdvanced;
|
||||
}
|
||||
|
||||
@ -479,6 +549,40 @@ void Array_writeLocalData(Output& fw, Iterator first, Iterator last,int noItemsP
|
||||
|
||||
}
|
||||
|
||||
template<class Iterator>
|
||||
void Array_writeLocalDataAsInts(Output& fw, Iterator first, Iterator last,int noItemsPerLine=8)
|
||||
{
|
||||
fw.indent() << "{"<<std::endl;
|
||||
fw.moveIn();
|
||||
|
||||
int column=0;
|
||||
|
||||
for(Iterator itr=first;
|
||||
itr!=last;
|
||||
++itr)
|
||||
{
|
||||
if (column==0) fw.indent();
|
||||
|
||||
fw << (int)*itr;
|
||||
|
||||
++column;
|
||||
if (column==noItemsPerLine)
|
||||
{
|
||||
fw << std::endl;
|
||||
column = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
fw << " ";
|
||||
}
|
||||
}
|
||||
if (column!=0) fw << std::endl;
|
||||
|
||||
fw.moveOut();
|
||||
fw.indent()<<"}"<<std::endl;
|
||||
|
||||
}
|
||||
|
||||
bool Array_writeLocalData(const Array& array,Output& fw)
|
||||
{
|
||||
switch(array.getType())
|
||||
@ -487,7 +591,7 @@ bool Array_writeLocalData(const Array& array,Output& fw)
|
||||
{
|
||||
const ByteArray& carray = static_cast<const ByteArray&>(array);
|
||||
fw<<array.className()<<" "<<carray.size()<<std::endl;
|
||||
Array_writeLocalData(fw,carray.begin(),carray.end());
|
||||
Array_writeLocalDataAsInts(fw,carray.begin(),carray.end());
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
@ -511,7 +615,7 @@ bool Array_writeLocalData(const Array& array,Output& fw)
|
||||
{
|
||||
const UByteArray& carray = static_cast<const UByteArray&>(array);
|
||||
fw<<array.className()<<" "<<carray.size()<<std::endl;
|
||||
Array_writeLocalData(fw,carray.begin(),carray.end());
|
||||
Array_writeLocalDataAsInts(fw,carray.begin(),carray.end());
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
|
@ -1045,12 +1045,18 @@ struct LessGeometry
|
||||
if (lhs->getStateSet()<rhs->getStateSet()) return true;
|
||||
if (rhs->getStateSet()<lhs->getStateSet()) return false;
|
||||
|
||||
if (lhs->getNormalBinding()<rhs->getNormalBinding()) return true;
|
||||
if (rhs->getNormalBinding()<lhs->getNormalBinding()) return false;
|
||||
|
||||
if (lhs->getColorBinding()<rhs->getColorBinding()) return true;
|
||||
if (rhs->getColorBinding()<lhs->getColorBinding()) return false;
|
||||
|
||||
if (lhs->getNormalBinding()<rhs->getNormalBinding()) return true;
|
||||
if (rhs->getNormalBinding()<lhs->getNormalBinding()) return false;
|
||||
|
||||
if (lhs->getSecondaryColorBinding()<rhs->getSecondaryColorBinding()) return true;
|
||||
if (rhs->getSecondaryColorBinding()<lhs->getSecondaryColorBinding()) return false;
|
||||
|
||||
if (lhs->getFogCoordBinding()<rhs->getFogCoordBinding()) return true;
|
||||
if (rhs->getFogCoordBinding()<lhs->getFogCoordBinding()) return false;
|
||||
|
||||
if (lhs->getNumTexCoordArrays()<rhs->getNumTexCoordArrays()) return true;
|
||||
if (rhs->getNumTexCoordArrays()<lhs->getNumTexCoordArrays()) return false;
|
||||
|
||||
@ -1205,7 +1211,11 @@ bool Optimizer::MergeGeometryVisitor::mergeGeode(osg::Geode& geode)
|
||||
osg::Geometry* geom = dynamic_cast<osg::Geometry*>(geode.getDrawable(i));
|
||||
if (geom)
|
||||
{
|
||||
if (geom->getNumPrimitiveSets()>0)
|
||||
if (geom->getNumPrimitiveSets()>0 &&
|
||||
geom->getNormalBinding()!=osg::Geometry::BIND_PER_PRIMITIVE_SET &&
|
||||
geom->getColorBinding()!=osg::Geometry::BIND_PER_PRIMITIVE_SET &&
|
||||
geom->getSecondaryColorBinding()!=osg::Geometry::BIND_PER_PRIMITIVE_SET &&
|
||||
geom->getFogCoordBinding()!=osg::Geometry::BIND_PER_PRIMITIVE_SET)
|
||||
{
|
||||
osg::Geometry::PrimitiveSetList& primitives = geom->getPrimitiveSetList();
|
||||
unsigned int primNo=0;
|
||||
@ -1312,6 +1322,10 @@ bool Optimizer::MergeGeometryVisitor::mergeGeometry(osg::Geometry& lhs,osg::Geom
|
||||
lhs.setColorArray(rhs.getColorArray());
|
||||
}
|
||||
|
||||
// need to implement handle secondary color array.
|
||||
|
||||
// need to implement handle fog coord array.
|
||||
|
||||
for(unsigned int unit=0;unit<lhs.getNumTexCoordArrays();++unit)
|
||||
{
|
||||
// we need to add the handling of the other array types...
|
||||
|
Loading…
Reference in New Issue
Block a user