Compare commits
16
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c044d711ef | ||
|
|
f2132f6a7d | ||
|
|
69871b15ff | ||
|
|
f4ec02a592 | ||
|
|
53f7743678 | ||
|
|
15893bc558 | ||
|
|
73b974f1b5 | ||
|
|
0e7bdc208b | ||
|
|
e0a07b7a92 | ||
|
|
4da58e8846 | ||
|
|
966b9e5c2b | ||
|
|
1625192c81 | ||
|
|
c5e8c6603c | ||
|
|
37e541d326 | ||
|
|
862a827fe6 | ||
|
|
b96c5c9e4b |
@@ -22,7 +22,7 @@ PROJECT_NAME = SimGear
|
||||
# This could be handy for archiving the generated documentation or
|
||||
# if some version control system is used.
|
||||
|
||||
PROJECT_NUMBER = 1.99.5
|
||||
PROJECT_NUMBER = 1.9.0
|
||||
|
||||
# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute)
|
||||
# base path where the generated documentation will be put.
|
||||
|
||||
@@ -1,5 +1,13 @@
|
||||
Version 1.99.5
|
||||
* October 30, 2008 (sourcecode snapshot release)
|
||||
Version 1.9.0
|
||||
* Thu Dec 18 15:12:15 CST 2008
|
||||
|
||||
|
||||
Version 1.8.6
|
||||
* Mon Dec 1 14:02:47 CST 2008
|
||||
|
||||
|
||||
Version 1.8.5
|
||||
* October 30, 2008 (source code snapshot release)
|
||||
|
||||
|
||||
New in 0.3.10
|
||||
|
||||
+5
-2
@@ -3,16 +3,19 @@
|
||||
You *must* have OpenSceneGraph (OSG) installed to build this version of
|
||||
FlightGear.
|
||||
|
||||
Notice that FlightGear 1.9.0 requires at least version 2.7.8. Using earlier
|
||||
versions of OSG will yield serious rendering bugs.
|
||||
|
||||
You can get the latest version of OSG from:
|
||||
|
||||
http://www.openscenegraph.org/
|
||||
|
||||
Build notes:
|
||||
|
||||
Unzip the file OpenSceneGraph-2.4.zip and install using the following
|
||||
Unzip the file OpenSceneGraph-x.x.zip and install using the following
|
||||
commands:
|
||||
|
||||
unzip OpenSceneGraph-2.4
|
||||
unzip OpenSceneGraph-x.x
|
||||
cd OpenSceneGraph
|
||||
ccmake .
|
||||
|
||||
|
||||
+10
-10
@@ -3,27 +3,27 @@
|
||||
You *must* have the development components of OpenAL installed on your system
|
||||
to build FlightGear!" You can get a copy here:
|
||||
|
||||
http://www.openal.org
|
||||
http://connect.creativelabs.com/openal/default.aspx
|
||||
|
||||
Build notes:
|
||||
|
||||
You can download a versioned release of the openal library from
|
||||
http://www.openal.org/downloads.html. Download the openal source,
|
||||
release 0.0.8 (dated February 11, 2006) and run:
|
||||
tar xzvf openal-0.0.8.tar.gz
|
||||
cd openal-0.0.8
|
||||
./configure
|
||||
make
|
||||
sudo make install
|
||||
tar xjvf openal-soft-1.5.304.tar.bz2
|
||||
cd openal-soft-1.5.304/
|
||||
ccmake .
|
||||
|
||||
[ While running ccmake: press 'c' to configure, press 'c' once more, and
|
||||
then press 'g' to generate and exit ]
|
||||
|
||||
|
||||
The alut library is also required, but comes separately in the package
|
||||
freelut-1.1.0.tar.gz. This package can be downloaded from the same page
|
||||
(http://www.openal.org/downloads.html). Download and run:
|
||||
(http://connect.creativelabs.com/openal/default.aspx). Download and run:
|
||||
tar xzvf freelut-1.1.0.tar.gz
|
||||
cd freelut-1.1.0
|
||||
cd freealut-1.1.0
|
||||
./configure
|
||||
make
|
||||
sudo make install
|
||||
|
||||
Alternatively, you can use the CVS version (follow the instructions at
|
||||
the OpenAL web site) and build/install that one.
|
||||
|
||||
+224
@@ -460,3 +460,227 @@ pushdef([AC_PROG_INSTALL],
|
||||
INSTALL_PROGRAM='${INSTALL} $(INSTALL_STRIP_FLAG)'
|
||||
INSTALL_SCRIPT='${INSTALL}'
|
||||
])dnl
|
||||
|
||||
# ===========================================================================
|
||||
# http://autoconf-archive.cryp.to/ax_boost_base.html
|
||||
# ===========================================================================
|
||||
#
|
||||
# SYNOPSIS
|
||||
#
|
||||
# AX_BOOST_BASE([MINIMUM-VERSION])
|
||||
#
|
||||
# DESCRIPTION
|
||||
#
|
||||
# Test for the Boost C++ libraries of a particular version (or newer)
|
||||
#
|
||||
# If no path to the installed boost library is given the macro searchs
|
||||
# under /usr, /usr/local, /opt and /opt/local and evaluates the
|
||||
# $BOOST_ROOT environment variable. Further documentation is available at
|
||||
# <http://randspringer.de/boost/index.html>.
|
||||
#
|
||||
# This macro calls:
|
||||
#
|
||||
# AC_SUBST(BOOST_CPPFLAGS) / AC_SUBST(BOOST_LDFLAGS)
|
||||
#
|
||||
# And sets:
|
||||
#
|
||||
# HAVE_BOOST
|
||||
#
|
||||
# LAST MODIFICATION
|
||||
#
|
||||
# 2008-04-12
|
||||
#
|
||||
# COPYLEFT
|
||||
#
|
||||
# Copyright (c) 2008 Thomas Porschberg <thomas@randspringer.de>
|
||||
#
|
||||
# Copying and distribution of this file, with or without modification, are
|
||||
# permitted in any medium without royalty provided the copyright notice
|
||||
# and this notice are preserved.
|
||||
|
||||
AC_DEFUN([AX_BOOST_BASE],
|
||||
[
|
||||
AC_ARG_WITH([boost],
|
||||
AS_HELP_STRING([--with-boost@<:@=DIR@:>@], [use boost (default is yes) - it is possible to specify the root directory for boost (optional)]),
|
||||
[
|
||||
if test "$withval" = "no"; then
|
||||
want_boost="no"
|
||||
elif test "$withval" = "yes"; then
|
||||
want_boost="yes"
|
||||
ac_boost_path=""
|
||||
else
|
||||
want_boost="yes"
|
||||
ac_boost_path="$withval"
|
||||
fi
|
||||
],
|
||||
[want_boost="yes"])
|
||||
|
||||
|
||||
AC_ARG_WITH([boost-libdir],
|
||||
AS_HELP_STRING([--with-boost-libdir=LIB_DIR],
|
||||
[Force given directory for boost libraries. Note that this will overwrite library path detection, so use this parameter only if default library detection fails and you know exactly where your boost libraries are located.]),
|
||||
[
|
||||
if test -d $withval
|
||||
then
|
||||
ac_boost_lib_path="$withval"
|
||||
else
|
||||
AC_MSG_ERROR(--with-boost-libdir expected directory name)
|
||||
fi
|
||||
],
|
||||
[ac_boost_lib_path=""]
|
||||
)
|
||||
|
||||
if test "x$want_boost" = "xyes"; then
|
||||
boost_lib_version_req=ifelse([$1], ,1.20.0,$1)
|
||||
boost_lib_version_req_shorten=`expr $boost_lib_version_req : '\([[0-9]]*\.[[0-9]]*\)'`
|
||||
boost_lib_version_req_major=`expr $boost_lib_version_req : '\([[0-9]]*\)'`
|
||||
boost_lib_version_req_minor=`expr $boost_lib_version_req : '[[0-9]]*\.\([[0-9]]*\)'`
|
||||
boost_lib_version_req_sub_minor=`expr $boost_lib_version_req : '[[0-9]]*\.[[0-9]]*\.\([[0-9]]*\)'`
|
||||
if test "x$boost_lib_version_req_sub_minor" = "x" ; then
|
||||
boost_lib_version_req_sub_minor="0"
|
||||
fi
|
||||
WANT_BOOST_VERSION=`expr $boost_lib_version_req_major \* 100000 \+ $boost_lib_version_req_minor \* 100 \+ $boost_lib_version_req_sub_minor`
|
||||
AC_MSG_CHECKING(for boostlib >= $boost_lib_version_req)
|
||||
succeeded=no
|
||||
|
||||
dnl first we check the system location for boost libraries
|
||||
dnl this location ist chosen if boost libraries are installed with the --layout=system option
|
||||
dnl or if you install boost with RPM
|
||||
if test "$ac_boost_path" != ""; then
|
||||
BOOST_LDFLAGS="-L$ac_boost_path/lib"
|
||||
BOOST_CPPFLAGS="-I$ac_boost_path/include"
|
||||
else
|
||||
for ac_boost_path_tmp in /usr /usr/local /opt /opt/local ; do
|
||||
if test -d "$ac_boost_path_tmp/include/boost" && test -r "$ac_boost_path_tmp/include/boost"; then
|
||||
BOOST_LDFLAGS="-L$ac_boost_path_tmp/lib"
|
||||
BOOST_CPPFLAGS="-I$ac_boost_path_tmp/include"
|
||||
break;
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
dnl overwrite ld flags if we have required special directory with
|
||||
dnl --with-boost-libdir parameter
|
||||
if test "$ac_boost_lib_path" != ""; then
|
||||
BOOST_LDFLAGS="-L$ac_boost_lib_path"
|
||||
fi
|
||||
|
||||
CPPFLAGS_SAVED="$CPPFLAGS"
|
||||
CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
|
||||
export CPPFLAGS
|
||||
|
||||
LDFLAGS_SAVED="$LDFLAGS"
|
||||
LDFLAGS="$LDFLAGS $BOOST_LDFLAGS"
|
||||
export LDFLAGS
|
||||
|
||||
AC_LANG_PUSH(C++)
|
||||
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
|
||||
@%:@include <boost/version.hpp>
|
||||
]], [[
|
||||
#if BOOST_VERSION >= $WANT_BOOST_VERSION
|
||||
// Everything is okay
|
||||
#else
|
||||
# error Boost version is too old
|
||||
#endif
|
||||
]])],[
|
||||
AC_MSG_RESULT(yes)
|
||||
succeeded=yes
|
||||
found_system=yes
|
||||
],[
|
||||
])
|
||||
AC_LANG_POP([C++])
|
||||
|
||||
|
||||
|
||||
dnl if we found no boost with system layout we search for boost libraries
|
||||
dnl built and installed without the --layout=system option or for a staged(not installed) version
|
||||
if test "x$succeeded" != "xyes"; then
|
||||
_version=0
|
||||
if test "$ac_boost_path" != ""; then
|
||||
if test -d "$ac_boost_path" && test -r "$ac_boost_path"; then
|
||||
for i in `ls -d $ac_boost_path/include/boost-* 2>/dev/null`; do
|
||||
_version_tmp=`echo $i | sed "s#$ac_boost_path##" | sed 's/\/include\/boost-//' | sed 's/_/./'`
|
||||
V_CHECK=`expr $_version_tmp \> $_version`
|
||||
if test "$V_CHECK" = "1" ; then
|
||||
_version=$_version_tmp
|
||||
fi
|
||||
VERSION_UNDERSCORE=`echo $_version | sed 's/\./_/'`
|
||||
BOOST_CPPFLAGS="-I$ac_boost_path/include/boost-$VERSION_UNDERSCORE"
|
||||
done
|
||||
fi
|
||||
else
|
||||
for ac_boost_path in /usr /usr/local /opt /opt/local ; do
|
||||
if test -d "$ac_boost_path" && test -r "$ac_boost_path"; then
|
||||
for i in `ls -d $ac_boost_path/include/boost-* 2>/dev/null`; do
|
||||
_version_tmp=`echo $i | sed "s#$ac_boost_path##" | sed 's/\/include\/boost-//' | sed 's/_/./'`
|
||||
V_CHECK=`expr $_version_tmp \> $_version`
|
||||
if test "$V_CHECK" = "1" ; then
|
||||
_version=$_version_tmp
|
||||
best_path=$ac_boost_path
|
||||
fi
|
||||
done
|
||||
fi
|
||||
done
|
||||
|
||||
VERSION_UNDERSCORE=`echo $_version | sed 's/\./_/'`
|
||||
BOOST_CPPFLAGS="-I$best_path/include/boost-$VERSION_UNDERSCORE"
|
||||
if test "$ac_boost_lib_path" = ""
|
||||
then
|
||||
BOOST_LDFLAGS="-L$best_path/lib"
|
||||
fi
|
||||
|
||||
if test "x$BOOST_ROOT" != "x"; then
|
||||
if test -d "$BOOST_ROOT" && test -r "$BOOST_ROOT" && test -d "$BOOST_ROOT/stage/lib" && test -r "$BOOST_ROOT/stage/lib"; then
|
||||
version_dir=`expr //$BOOST_ROOT : '.*/\(.*\)'`
|
||||
stage_version=`echo $version_dir | sed 's/boost_//' | sed 's/_/./g'`
|
||||
stage_version_shorten=`expr $stage_version : '\([[0-9]]*\.[[0-9]]*\)'`
|
||||
V_CHECK=`expr $stage_version_shorten \>\= $_version`
|
||||
if test "$V_CHECK" = "1" -a "$ac_boost_lib_path" = "" ; then
|
||||
AC_MSG_NOTICE(We will use a staged boost library from $BOOST_ROOT)
|
||||
BOOST_CPPFLAGS="-I$BOOST_ROOT"
|
||||
BOOST_LDFLAGS="-L$BOOST_ROOT/stage/lib"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
|
||||
export CPPFLAGS
|
||||
LDFLAGS="$LDFLAGS $BOOST_LDFLAGS"
|
||||
export LDFLAGS
|
||||
|
||||
AC_LANG_PUSH(C++)
|
||||
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
|
||||
@%:@include <boost/version.hpp>
|
||||
]], [[
|
||||
#if BOOST_VERSION >= $WANT_BOOST_VERSION
|
||||
// Everything is okay
|
||||
#else
|
||||
# error Boost version is too old
|
||||
#endif
|
||||
]])],[
|
||||
AC_MSG_RESULT(yes)
|
||||
succeeded=yes
|
||||
found_system=yes
|
||||
],[
|
||||
])
|
||||
AC_LANG_POP([C++])
|
||||
fi
|
||||
|
||||
if test "$succeeded" != "yes" ; then
|
||||
if test "$_version" = "0" ; then
|
||||
AC_MSG_ERROR([[We could not detect the boost libraries (version $boost_lib_version_req_shorten or higher). If you have a staged boost library (still not installed) please specify \$BOOST_ROOT in your environment and do not give a PATH to --with-boost option. If you are sure you have boost installed, then check your version number looking in <boost/version.hpp>. See http://randspringer.de/boost for more documentation.]])
|
||||
else
|
||||
AC_MSG_NOTICE([Your boost libraries seems to old (version $_version).])
|
||||
fi
|
||||
else
|
||||
AC_SUBST(BOOST_CPPFLAGS)
|
||||
AC_SUBST(BOOST_LDFLAGS)
|
||||
AC_DEFINE(HAVE_BOOST,,[define if the Boost library is available])
|
||||
fi
|
||||
|
||||
CPPFLAGS="$CPPFLAGS_SAVED"
|
||||
LDFLAGS="$LDFLAGS_SAVED"
|
||||
fi
|
||||
|
||||
])
|
||||
|
||||
+16
-1
@@ -8,7 +8,7 @@ dnl Require at least automake 2.52
|
||||
AC_PREREQ(2.52)
|
||||
|
||||
dnl Initialize the automake stuff
|
||||
AM_INIT_AUTOMAKE(SimGear, 1.99.5-rc2)
|
||||
AM_INIT_AUTOMAKE(SimGear, 1.9.0)
|
||||
|
||||
dnl Specify KAI C++ compiler and flags.
|
||||
dnl Borrowed with slight modification from blitz distribution.
|
||||
@@ -37,6 +37,11 @@ AC_PROG_CXX
|
||||
AC_PROG_RANLIB
|
||||
AC_PROG_INSTALL
|
||||
AC_PROG_LN_S
|
||||
AX_BOOST_BASE([1.34.0])
|
||||
|
||||
if test "x$BOOST_CPPFLAGS" != "x-I/usr/include" ; then
|
||||
CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
|
||||
fi
|
||||
|
||||
dnl set the $host variable based on local machine/os
|
||||
AC_CANONICAL_HOST
|
||||
@@ -398,6 +403,16 @@ if test "x$ac_cv_header_osg_Version" != "xyes"; then
|
||||
exit
|
||||
fi
|
||||
|
||||
AC_CHECK_HEADER(boost/version.hpp)
|
||||
if test "x$ac_cv_header_boost_version_hpp" != "xyes"; then
|
||||
echo
|
||||
echo "You *must* have the Boost library installed on your system"
|
||||
echo "to build this version of SimGear!"
|
||||
echo
|
||||
echo "configure aborted."
|
||||
exit
|
||||
fi
|
||||
|
||||
AC_LANG_POP
|
||||
|
||||
dnl Check for system installed zlib
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
InlineFunctionExpansion="1"
|
||||
AdditionalIncludeDirectories="..\..;..\..\simgear;..\..\..;..\..\..\install\msvc71\OpenSceneGraph\include;..\..\..\3rdparty\include;"..\..\..\pthreads-w32-2-7-0-release""
|
||||
AdditionalIncludeDirectories="..\..;..\..\simgear;..\..\..;..\..\..\install\msvc71\OpenSceneGraph\include;..\..\..\3rdparty\include;"..\..\..\pthreads-w32-2-7-0-release";..\..\..\boost_1_36_0"
|
||||
PreprocessorDefinitions="HAVE_CONFIG_H,NDEBUG,WIN32;_USE_MATH_DEFINES;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_WARNINGS"
|
||||
StringPooling="TRUE"
|
||||
RuntimeLibrary="2"
|
||||
@@ -75,7 +75,7 @@
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="..\..;..\..\simgear;..\..\..;..\..\..\install\msvc71\OpenSceneGraph\include;..\..\..\3rdparty\include;"..\..\..\pthreads-w32-2-7-0-release""
|
||||
AdditionalIncludeDirectories="..\..;..\..\simgear;..\..\..;..\..\..\install\msvc71\OpenSceneGraph\include;..\..\..\3rdparty\include;"..\..\..\pthreads-w32-2-7-0-release";..\..\..\boost_1_36_0"
|
||||
PreprocessorDefinitions="HAVE_CONFIG_H,_DEBUG,WIN32;_USE_MATH_DEFINES;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_WARNINGS"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="3"
|
||||
|
||||
@@ -113,6 +113,10 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
inline int current_index() const {
|
||||
return current_wp;
|
||||
}
|
||||
|
||||
/** Increment the current waypoint pointer. */
|
||||
inline void increment_current() {
|
||||
if ( current_wp < (int)route.size() - 1 ) {
|
||||
|
||||
@@ -29,7 +29,6 @@
|
||||
|
||||
#include <string.h>
|
||||
#include <map>
|
||||
using std::map;
|
||||
|
||||
#include <plib/ul.h>
|
||||
|
||||
@@ -45,9 +44,13 @@ using std::map;
|
||||
#include <simgear/misc/sgstream.hxx>
|
||||
|
||||
#include <simgear/scene/model/model.hxx>
|
||||
#include <simgear/scene/util/StateAttributeFactory.hxx>
|
||||
|
||||
#include "mat.hxx"
|
||||
|
||||
using std::map;
|
||||
using namespace simgear;
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// Constructors and destructor.
|
||||
@@ -249,20 +252,15 @@ SGMaterial::get_state (int n)
|
||||
void
|
||||
SGMaterial::build_state( bool defer_tex_load )
|
||||
{
|
||||
StateAttributeFactory *attrFact = StateAttributeFactory::instance();
|
||||
for (unsigned int i = 0; i < _status.size(); i++)
|
||||
{
|
||||
osg::StateSet *stateSet = new osg::StateSet;
|
||||
stateSet->setUserData(new SGMaterialUserData(this));
|
||||
|
||||
// Set up the textured state
|
||||
osg::ShadeModel* shadeModel = new osg::ShadeModel;
|
||||
shadeModel->setMode(osg::ShadeModel::SMOOTH);
|
||||
stateSet->setAttribute(shadeModel);
|
||||
|
||||
osg::CullFace* cullFace = new osg::CullFace;
|
||||
cullFace->setMode(osg::CullFace::BACK);
|
||||
stateSet->setMode(GL_CULL_FACE, osg::StateAttribute::ON);
|
||||
stateSet->setAttribute(cullFace);
|
||||
stateSet->setAttribute(attrFact->getSmoothShadeModel());
|
||||
stateSet->setAttributeAndModes(attrFact->getCullFaceBack());
|
||||
|
||||
stateSet->setMode(GL_LIGHTING, osg::StateAttribute::ON);
|
||||
|
||||
|
||||
@@ -473,16 +473,6 @@ ModelRegistry::addNodeCallbackForExtension(const string& extension,
|
||||
nodeCallbackMap.insert(CallbackMap::value_type(extension, callback));
|
||||
}
|
||||
|
||||
ref_ptr<ModelRegistry> ModelRegistry::instance;
|
||||
|
||||
ModelRegistry* ModelRegistry::getInstance()
|
||||
|
||||
{
|
||||
if (!instance.valid())
|
||||
instance = new ModelRegistry;
|
||||
return instance.get();
|
||||
}
|
||||
|
||||
ReaderWriter::ReadResult
|
||||
ModelRegistry::readNode(const string& fileName,
|
||||
const ReaderWriter::Options* opt)
|
||||
@@ -516,7 +506,7 @@ public:
|
||||
registry->setOptions(options);
|
||||
registry->getOrCreateSharedStateManager()->
|
||||
setShareMode(SharedStateManager::SHARE_STATESETS);
|
||||
registry->setReadFileCallback(ModelRegistry::getInstance());
|
||||
registry->setReadFileCallback(ModelRegistry::instance());
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#include <osgDB/Registry>
|
||||
|
||||
#include <simgear/compiler.h>
|
||||
#include <simgear/structure/Singleton.hxx>
|
||||
|
||||
#include <string>
|
||||
#include <map>
|
||||
@@ -200,7 +201,8 @@ typedef ModelRegistryCallback<DefaultProcessPolicy, DefaultCachePolicy,
|
||||
OSGSubstitutePolicy> DefaultCallback;
|
||||
|
||||
// The manager for the callbacks
|
||||
class ModelRegistry : public osgDB::Registry::ReadFileCallback {
|
||||
class ModelRegistry : public osgDB::Registry::ReadFileCallback,
|
||||
public ReferencedSingleton<ModelRegistry> {
|
||||
public:
|
||||
ModelRegistry();
|
||||
virtual osgDB::ReaderWriter::ReadResult
|
||||
@@ -215,10 +217,8 @@ public:
|
||||
void addNodeCallbackForExtension(const std::string& extension,
|
||||
osgDB::Registry::ReadFileCallback*
|
||||
callback);
|
||||
static ModelRegistry* getInstance();
|
||||
virtual ~ModelRegistry() {}
|
||||
protected:
|
||||
static osg::ref_ptr<ModelRegistry> instance;
|
||||
typedef std::map<std::string, osg::ref_ptr<osgDB::Registry::ReadFileCallback> >
|
||||
CallbackMap;
|
||||
CallbackMap imageCallbackMap;
|
||||
@@ -243,7 +243,7 @@ class ModelRegistryCallbackProxy
|
||||
public:
|
||||
ModelRegistryCallbackProxy(std::string extension)
|
||||
{
|
||||
ModelRegistry::getInstance()
|
||||
ModelRegistry::instance()
|
||||
->addNodeCallbackForExtension(extension, new T(extension));
|
||||
}
|
||||
};
|
||||
|
||||
@@ -375,8 +375,10 @@ SGMaterialAnimation::createAnimationGroup(osg::Group& parent)
|
||||
const SGPropertyNode* node = getConfig()->getChild("property-base");
|
||||
if (node)
|
||||
inputRoot = getModelRoot()->getNode(node->getStringValue(), true);
|
||||
if (getConfig()->hasChild("texture-prop"))
|
||||
if (getConfig()->hasChild("texture-prop")) {
|
||||
osg::StateSet* stateSet = group->getOrCreateStateSet();
|
||||
stateSet->setDataVariance(osg::Object::DYNAMIC);
|
||||
}
|
||||
if (getConfig()->hasChild("texture")) {
|
||||
std::string textureName = getConfig()->getStringValue("texture");
|
||||
std::string textureFile;
|
||||
|
||||
@@ -1820,6 +1820,7 @@ SGTexTransformAnimation::createAnimationGroup(osg::Group& parent)
|
||||
osg::Group* group = new osg::Group;
|
||||
group->setName("texture transform group");
|
||||
osg::StateSet* stateSet = group->getOrCreateStateSet();
|
||||
stateSet->setDataVariance(osg::Object::DYNAMIC);
|
||||
osg::TexMat* texMat = new osg::TexMat;
|
||||
UpdateCallback* updateCallback = new UpdateCallback(getCondition());
|
||||
// interpret the configs ...
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
|
||||
#include <osg/AlphaFunc>
|
||||
#include <osg/BlendFunc>
|
||||
#include <osg/CullFace>
|
||||
#include <osg/Geode>
|
||||
#include <osg/Geometry>
|
||||
#include <osg/Material>
|
||||
@@ -56,6 +57,8 @@
|
||||
#include "cloud.hxx"
|
||||
|
||||
using namespace simgear;
|
||||
using namespace osg;
|
||||
|
||||
#if defined(__MINGW32__)
|
||||
#define isnan(x) _isnan(x)
|
||||
#endif
|
||||
@@ -95,7 +98,6 @@ SGMakeState(const SGPath &path, const char* colorTexture,
|
||||
StateAttributeFactory* attribFactory = StateAttributeFactory::instance();
|
||||
stateSet->setAttributeAndModes(attribFactory->getSmoothShadeModel());
|
||||
stateSet->setMode(GL_LIGHTING, osg::StateAttribute::OFF);
|
||||
stateSet->setMode(GL_CULL_FACE, osg::StateAttribute::OFF);
|
||||
stateSet->setAttributeAndModes(attribFactory->getStandardAlphaFunc());
|
||||
stateSet->setAttributeAndModes(attribFactory->getStandardBlendFunc());
|
||||
|
||||
@@ -157,6 +159,7 @@ SGCloudLayer::SGCloudLayer( const string &tex_path ) :
|
||||
osg::StateSet *rootSet = layer_root->getOrCreateStateSet();
|
||||
rootSet->setRenderBinDetails(CLOUDS_BIN, "DepthSortedBin");
|
||||
rootSet->setTextureAttribute(0, new osg::TexMat);
|
||||
rootSet->setMode(GL_CULL_FACE, osg::StateAttribute::ON);
|
||||
// Combiner for fog color and cloud alpha
|
||||
osg::TexEnvCombine* combine0 = new osg::TexEnvCombine;
|
||||
osg::TexEnvCombine* combine1 = new osg::TexEnvCombine;
|
||||
@@ -191,7 +194,6 @@ SGCloudLayer::SGCloudLayer( const string &tex_path ) :
|
||||
rootSet->setDataVariance(osg::Object::DYNAMIC);
|
||||
|
||||
base = osg::Vec2(sg_random(), sg_random());
|
||||
|
||||
group_top->addChild(layer_transform.get());
|
||||
group_bottom->addChild(layer_transform.get());
|
||||
|
||||
@@ -304,6 +306,15 @@ SGCloudLayer::setTextureOffset(const osg::Vec2& offset)
|
||||
texMat->setMatrix(osg::Matrix::translate(offset[0], offset[1], 0.0));
|
||||
}
|
||||
|
||||
// colors for debugging the cloud layers
|
||||
#ifdef CLOUD_DEBUG
|
||||
Vec3 cloudColors[] = {Vec3(1.0f, 1.0f, 1.0f), Vec3(1.0f, 0.0f, 0.0f),
|
||||
Vec3(0.0f, 1.0f, 0.0f), Vec3(0.0f, 0.0f, 1.0f)};
|
||||
#else
|
||||
Vec3 cloudColors[] = {Vec3(1.0f, 1.0f, 1.0f), Vec3(1.0f, 1.0f, 1.0f),
|
||||
Vec3(1.0f, 1.0f, 1.0f), Vec3(1.0f, 1.0f, 1.0f)};
|
||||
#endif
|
||||
|
||||
// build the cloud object
|
||||
void
|
||||
SGCloudLayer::rebuild()
|
||||
@@ -470,6 +481,19 @@ SGCloudLayer::rebuild()
|
||||
|
||||
layer_states[SG_CLOUD_CLEAR] = 0;
|
||||
layer_states2[SG_CLOUD_CLEAR] = 0;
|
||||
osg::CopyOp copyOp;
|
||||
for (int i = 0; i < SG_MAX_CLOUD_COVERAGES; ++i) {
|
||||
StateAttributeFactory *saf = StateAttributeFactory::instance();
|
||||
if (layer_states[i].valid()) {
|
||||
if (layer_states[i] == layer_states2[i])
|
||||
layer_states2[i] = static_cast<osg::StateSet*>(layer_states[i]->clone(copyOp));
|
||||
layer_states[i]->setAttribute(saf ->getCullFaceFront());
|
||||
layer_states2[i]->setAttribute(saf ->getCullFaceBack());
|
||||
}
|
||||
}
|
||||
// OSGFIXME
|
||||
// SGNewCloud::loadTextures(texture_path.str());
|
||||
// layer3D->buildTestLayer();
|
||||
}
|
||||
|
||||
scale = 4000.0;
|
||||
@@ -503,7 +527,7 @@ SGCloudLayer::rebuild()
|
||||
osg::Vec3 vertex(layer_span*(i-2)/2, -layer_span,
|
||||
alt_diff * (sin(i*mpi) - 2));
|
||||
osg::Vec2 tc(layer_scale * i/4, 0.0f);
|
||||
osg::Vec4 color(1.0f, 1.0f, 1.0f, (i == 0) ? 0.0f : 0.15f);
|
||||
osg::Vec4 color(cloudColors[0], (i == 0) ? 0.0f : 0.15f);
|
||||
|
||||
cl[i]->push_back(color);
|
||||
vl[i]->push_back(vertex);
|
||||
@@ -513,7 +537,7 @@ SGCloudLayer::rebuild()
|
||||
vertex = osg::Vec3(layer_span*(i-1)/2, layer_span*(j-2)/2,
|
||||
alt_diff * (sin((i+1)*mpi) + sin(j*mpi) - 2));
|
||||
tc = osg::Vec2(layer_scale * (i+1)/4, layer_scale * j/4);
|
||||
color = osg::Vec4(1.0f, 1.0f, 1.0f,
|
||||
color = osg::Vec4(cloudColors[0],
|
||||
( (j == 0) || (i == 3)) ?
|
||||
( (j == 0) && (i == 3)) ? 0.0f : 0.15f : 1.0f );
|
||||
|
||||
@@ -524,7 +548,7 @@ SGCloudLayer::rebuild()
|
||||
vertex = osg::Vec3(layer_span*(i-2)/2, layer_span*(j-1)/2,
|
||||
alt_diff * (sin(i*mpi) + sin((j+1)*mpi) - 2) );
|
||||
tc = osg::Vec2(layer_scale * i/4, layer_scale * (j+1)/4 );
|
||||
color = osg::Vec4(1.0f, 1.0f, 1.0f,
|
||||
color = osg::Vec4(cloudColors[0],
|
||||
((j == 3) || (i == 0)) ?
|
||||
((j == 3) && (i == 0)) ? 0.0f : 0.15f : 1.0f );
|
||||
cl[i]->push_back(color);
|
||||
@@ -537,7 +561,7 @@ SGCloudLayer::rebuild()
|
||||
|
||||
tc = osg::Vec2(layer_scale * (i+1)/4, layer_scale);
|
||||
|
||||
color = osg::Vec4(1.0f, 1.0f, 1.0f, (i == 3) ? 0.0f : 0.15f );
|
||||
color = osg::Vec4(cloudColors[0], (i == 3) ? 0.0f : 0.15f );
|
||||
|
||||
cl[i]->push_back( color );
|
||||
vl[i]->push_back( vertex );
|
||||
@@ -568,7 +592,7 @@ SGCloudLayer::rebuild()
|
||||
osg::StateSet* stateSet = static_cast<osg::StateSet*>(layer_states2[layer_coverage]->clone(copyOp));
|
||||
stateSet->setDataVariance(osg::Object::DYNAMIC);
|
||||
group_top->setStateSet(stateSet);
|
||||
stateSet = static_cast<osg::StateSet*>(layer_states2[layer_coverage]->clone(copyOp));
|
||||
stateSet = static_cast<osg::StateSet*>(layer_states[layer_coverage]->clone(copyOp));
|
||||
stateSet->setDataVariance(osg::Object::DYNAMIC);
|
||||
group_bottom->setStateSet(stateSet);
|
||||
}
|
||||
|
||||
@@ -24,8 +24,10 @@
|
||||
# include <simgear_config.h>
|
||||
#endif
|
||||
|
||||
#include <osg/Fog>
|
||||
#include <osg/Texture2D>
|
||||
#include <osg/PositionAttitudeTransform>
|
||||
#include <osg/Vec4f>
|
||||
|
||||
#include <simgear/compiler.h>
|
||||
|
||||
@@ -66,7 +68,6 @@ using namespace simgear;
|
||||
#endif
|
||||
|
||||
float SGCloudField::fieldSize = 50000.0f;
|
||||
float SGCloudField::coverage = 1.0f;
|
||||
double SGCloudField::timer_dt = 0.0;
|
||||
float SGCloudField::view_distance = 20000.0f;
|
||||
sgVec3 SGCloudField::view_vec, SGCloudField::view_X, SGCloudField::view_Y;
|
||||
@@ -78,6 +79,10 @@ bool SGCloudField::reposition( const SGVec3f& p, const SGVec3f& up, double lon,
|
||||
{
|
||||
osg::Matrix T, LON, LAT;
|
||||
|
||||
// Always update the altitude transform, as this allows
|
||||
// the clouds to rise and fall smoothly depending on environment updates.
|
||||
altitude_transform->setPosition(osg::Vec3d(0.0, 0.0, (double) asl));
|
||||
|
||||
// Calculating the reposition information is expensive.
|
||||
// Only perform the reposition every 60 frames.
|
||||
reposition_count = (reposition_count + 1) % 60;
|
||||
@@ -137,45 +142,24 @@ bool SGCloudField::reposition( const SGVec3f& p, const SGVec3f& up, double lon,
|
||||
return true;
|
||||
}
|
||||
|
||||
struct threeDCloudsFogUpdater : public osg::NodeCallback {
|
||||
threeDCloudsFogUpdater() {};
|
||||
|
||||
virtual void operator()(osg::Node* node, osg::NodeVisitor* nv) {
|
||||
SGUpdateVisitor* updateVisitor = static_cast<SGUpdateVisitor*>(nv);
|
||||
//running at 5 times frame
|
||||
SGCloudField::StateSetMap::iterator iter;
|
||||
osg::Fog * fog;
|
||||
for( iter = SGCloudField::cloudTextureMap.begin(); iter != SGCloudField::cloudTextureMap.end(); ++iter) {
|
||||
fog = static_cast<osg::Fog*>(iter->second->getAttribute( osg::StateAttribute::FOG, 0 ));
|
||||
fog->setMode(osg::Fog::EXP);
|
||||
osg::Vec4f fogC = updateVisitor->getFogColor().osg();
|
||||
fogC[3] = 0.0;
|
||||
fog->setColor(fogC);
|
||||
fog->setDensity(updateVisitor->getFogExpDensity());
|
||||
}
|
||||
|
||||
if (node->getNumChildrenRequiringUpdateTraversal()>0)
|
||||
traverse(node,nv);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
SGCloudField::SGCloudField() :
|
||||
field_root(new osg::Group),
|
||||
field_transform(new osg::MatrixTransform),
|
||||
altitude_transform(new osg::PositionAttitudeTransform),
|
||||
deltax(0.0),
|
||||
deltay(0.0),
|
||||
last_course(0.0),
|
||||
last_coverage(0.0),
|
||||
coverage(0.0),
|
||||
defined3D(false),
|
||||
reposition_count(0)
|
||||
{
|
||||
cld_pos = SGGeoc();
|
||||
field_root->setUpdateCallback( new threeDCloudsFogUpdater() );
|
||||
field_root->addChild(field_transform.get());
|
||||
field_root->setName("3D Cloud field root");
|
||||
osg::StateSet *rootSet = field_root->getOrCreateStateSet();
|
||||
rootSet->setRenderBinDetails(CLOUDS_BIN, "DepthSortedBin");
|
||||
rootSet->setAttributeAndModes(getFog());
|
||||
|
||||
osg::ref_ptr<osg::Group> quad_root = new osg::Group();
|
||||
|
||||
@@ -200,7 +184,9 @@ SGCloudField::SGCloudField() :
|
||||
quad[i][j]->addChild(field_group[x][y].get(), 0.0f, view_distance);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
field_transform->addChild(altitude_transform.get());
|
||||
|
||||
// We duplicate the defined field group in a 3x3 array. This way,
|
||||
// we can simply shift entire groups around.
|
||||
// TODO: "Bend" the edge groups so when shifted they line up.
|
||||
@@ -212,7 +198,7 @@ SGCloudField::SGCloudField() :
|
||||
transform->addChild(quad_root.get());
|
||||
transform->setPosition(osg::Vec3(x*fieldSize, y * fieldSize, 0.0));
|
||||
|
||||
field_transform->addChild(transform.get());
|
||||
altitude_transform->addChild(transform.get());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -225,10 +211,7 @@ void SGCloudField::clear(void) {
|
||||
for (int x = 0; x < QUADTREE_SIZE; x++) {
|
||||
for (int y = 0; y < QUADTREE_SIZE; y++) {
|
||||
int num_children = field_group[x][y]->getNumChildren();
|
||||
|
||||
for (int i = 0; i < num_children; i++) {
|
||||
field_group[x][y]->removeChild(i);
|
||||
}
|
||||
field_group[x][y]->removeChildren(0, num_children);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -253,7 +236,7 @@ static int densTable[][10] = {
|
||||
void SGCloudField::applyCoverage(void) {
|
||||
|
||||
int row = (int) (coverage * 10.0);
|
||||
if (row > 10) row = 9;
|
||||
if (row > 9) row = 9;
|
||||
int col = 0;
|
||||
|
||||
if (coverage != last_coverage) {
|
||||
@@ -309,3 +292,17 @@ void SGCloudField::applyVisRange(void) {
|
||||
}
|
||||
}
|
||||
|
||||
SGCloudField::CloudFog::CloudFog()
|
||||
{
|
||||
fog = new osg::Fog;
|
||||
fog->setMode(osg::Fog::EXP2);
|
||||
fog->setDataVariance(osg::Object::DYNAMIC);
|
||||
}
|
||||
|
||||
void SGCloudField::updateFog(double visibility, const osg::Vec4f& color)
|
||||
{
|
||||
const double sqrt_m_log01 = sqrt(-log(0.01));
|
||||
osg::Fog* fog = CloudFog::instance()->fog.get();
|
||||
fog->setColor(color);
|
||||
fog->setDensity(sqrt_m_log01 / visibility);
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
#include <plib/sg.h>
|
||||
#include <simgear/compiler.h>
|
||||
#include <vector>
|
||||
#include <osgSim/Impostor>
|
||||
|
||||
#include <osgDB/ReaderWriter>
|
||||
|
||||
#include <osg/ref_ptr>
|
||||
@@ -34,9 +34,16 @@
|
||||
#include <osg/Geometry>
|
||||
#include <osg/Group>
|
||||
#include <osg/Switch>
|
||||
#include <osg/Billboard>
|
||||
|
||||
namespace osg
|
||||
{
|
||||
class Fog;
|
||||
class StateSet;
|
||||
class Vec4f;
|
||||
}
|
||||
|
||||
#include <simgear/misc/sg_path.hxx>
|
||||
#include <simgear/structure/Singleton.hxx>
|
||||
|
||||
using std::vector;
|
||||
|
||||
@@ -67,6 +74,7 @@ private:
|
||||
|
||||
osg::ref_ptr<osg::Group> field_root;
|
||||
osg::ref_ptr<osg::MatrixTransform> field_transform;
|
||||
osg::ref_ptr<osg::PositionAttitudeTransform> altitude_transform;
|
||||
osg::ref_ptr<osg::Switch> field_group[QUADTREE_SIZE][QUADTREE_SIZE];
|
||||
osg::ref_ptr<osg::LOD> quad[BRANCH_SIZE][BRANCH_SIZE];
|
||||
|
||||
@@ -75,9 +83,15 @@ private:
|
||||
double deltax, deltay, alt;
|
||||
double last_course;
|
||||
sgSphere field_sphere;
|
||||
float last_coverage;
|
||||
float last_coverage;
|
||||
float coverage;
|
||||
SGGeoc cld_pos;
|
||||
int reposition_count;
|
||||
struct CloudFog : public simgear::Singleton<CloudFog>
|
||||
{
|
||||
CloudFog();
|
||||
osg::ref_ptr<osg::Fog> fog;
|
||||
};
|
||||
public:
|
||||
|
||||
SGCloudField();
|
||||
@@ -108,15 +122,14 @@ public:
|
||||
|
||||
static sgVec3 view_vec, view_X, view_Y;
|
||||
|
||||
static float coverage;
|
||||
static float view_distance;
|
||||
static double timer_dt;
|
||||
static float fieldSize;
|
||||
|
||||
bool defined3D;
|
||||
|
||||
static float getCoverage(void) { return coverage; }
|
||||
static void setCoverage(float coverage) { coverage = coverage; }
|
||||
float getCoverage(void) { return coverage; }
|
||||
void setCoverage(float c) { coverage = c; }
|
||||
|
||||
static float getVisRange(void) { return view_distance; }
|
||||
static void setVisRange(float d) { view_distance = d; }
|
||||
@@ -126,6 +139,12 @@ public:
|
||||
|
||||
typedef std::map<std::string, osg::ref_ptr<osg::StateSet> > StateSetMap;
|
||||
static StateSetMap cloudTextureMap;
|
||||
|
||||
static osg::Fog* getFog()
|
||||
{
|
||||
return CloudFog::instance()->fog.get();
|
||||
}
|
||||
static void updateFog(double visibility, const osg::Vec4f& color);
|
||||
};
|
||||
|
||||
#endif // _CLOUDFIELD_HXX
|
||||
|
||||
+75
-126
@@ -48,7 +48,9 @@
|
||||
#include <simgear/scene/util/SGUpdateVisitor.hxx>
|
||||
|
||||
#include <algorithm>
|
||||
#include <osg/BlendFunc>
|
||||
#include <osg/GLU>
|
||||
#include <osg/ShadeModel>
|
||||
|
||||
#include "cloudfield.hxx"
|
||||
#include "newcloud.hxx"
|
||||
@@ -58,13 +60,9 @@ using namespace simgear;
|
||||
using namespace osg;
|
||||
|
||||
typedef std::map<std::string, osg::ref_ptr<osg::StateSet> > StateSetMap;
|
||||
typedef std::vector< osg::ref_ptr<osg::Geode> > GeodeList;
|
||||
typedef std::map<std::string, GeodeList*> CloudMap;
|
||||
|
||||
StateSetMap cloudTextureMap;
|
||||
static CloudMap cloudMap;
|
||||
double SGNewCloud::sprite_density = 1.0;
|
||||
unsigned int SGNewCloud::num_flavours = 10;
|
||||
|
||||
static char vertexShaderSource[] =
|
||||
"#version 120\n"
|
||||
@@ -111,8 +109,8 @@ static char vertexShaderSource[] =
|
||||
" vec4 backlight = 0.9 * gl_LightSource[0].ambient + 0.1 * gl_LightSource[0].diffuse;\n"
|
||||
" gl_FrontColor = mix(backlight, gl_LightSource[0].diffuse, n);\n"
|
||||
" gl_FrontColor += gl_FrontLightModelProduct.sceneColor;\n"
|
||||
// As we get within 100m of the sprite, it is faded out
|
||||
" gl_FrontColor.a = smoothstep(10.0, 100.0, fogCoord);\n"
|
||||
// As we get within 100m of the sprite, it is faded out. Equally at large distances it also fades out.
|
||||
" gl_FrontColor.a = min(smoothstep(10.0, 100.0, fogCoord), 1 - smoothstep(15000.0, 20000.0, fogCoord));\n"
|
||||
" gl_BackColor = gl_FrontColor;\n"
|
||||
// Fog doesn't affect clouds as much as other objects.
|
||||
" fogFactor = exp( -gl_Fog.density * fogCoord * 0.5);\n"
|
||||
@@ -127,21 +125,10 @@ static char fragmentShaderSource[] =
|
||||
"{\n"
|
||||
" vec4 base = texture2D( baseTexture, gl_TexCoord[0].st);\n"
|
||||
" vec4 finalColor = base * gl_Color;\n"
|
||||
" gl_FragColor = mix(gl_Fog.color, finalColor, fogFactor );\n"
|
||||
" gl_FragColor.rgb = mix(gl_Fog.color.rgb, finalColor.rgb, fogFactor );\n"
|
||||
" gl_FragColor.a = finalColor.a;\n"
|
||||
"}\n";
|
||||
|
||||
class SGCloudFogUpdateCallback : public osg::StateAttribute::Callback {
|
||||
public:
|
||||
virtual void operator () (osg::StateAttribute* sa, osg::NodeVisitor* nv)
|
||||
{
|
||||
SGUpdateVisitor* updateVisitor = static_cast<SGUpdateVisitor*>(nv);
|
||||
osg::Fog* fog = static_cast<osg::Fog*>(sa);
|
||||
fog->setMode(osg::Fog::EXP);
|
||||
fog->setColor(updateVisitor->getFogColor().osg());
|
||||
fog->setDensity(updateVisitor->getFogExpDensity());
|
||||
}
|
||||
};
|
||||
|
||||
SGNewCloud::SGNewCloud(string type,
|
||||
const SGPath &tex_path,
|
||||
string tex,
|
||||
@@ -191,11 +178,6 @@ SGNewCloud::SGNewCloud(string type,
|
||||
stateSet->setMode(GL_CULL_FACE, osg::StateAttribute::OFF);
|
||||
|
||||
// Fog handling
|
||||
osg::Fog* fog = new osg::Fog;
|
||||
fog->setUpdateCallback(new SGCloudFogUpdateCallback);
|
||||
stateSet->setAttributeAndModes(fog);
|
||||
stateSet->setDataVariance(osg::Object::DYNAMIC);
|
||||
|
||||
stateSet->setAttributeAndModes(attribFactory->getSmoothShadeModel());
|
||||
stateSet->setAttributeAndModes(attribFactory->getStandardBlendFunc());
|
||||
|
||||
@@ -210,7 +192,7 @@ SGNewCloud::SGNewCloud(string type,
|
||||
// Generate the shader etc, if we don't already have one.
|
||||
if (!program.valid()) {
|
||||
alphaFunc = new AlphaFunc;
|
||||
alphaFunc->setFunction(AlphaFunc::GREATER,0.001f);
|
||||
alphaFunc->setFunction(AlphaFunc::GREATER,0.05f);
|
||||
program = new Program;
|
||||
baseTextureSampler = new osg::Uniform("baseTexture", 0);
|
||||
Shader* vertex_shader = new Shader(Shader::VERTEX, vertexShaderSource);
|
||||
@@ -299,119 +281,86 @@ static float Rnd(float n) {
|
||||
|
||||
osg::ref_ptr<Geode> SGNewCloud::genCloud() {
|
||||
|
||||
CloudMap::iterator iter = cloudMap.find(name);
|
||||
osg::ref_ptr<osg::Geode> geode;
|
||||
osg::ref_ptr<osg::Geode> geode = new Geode;
|
||||
|
||||
CloudShaderGeometry* sg = new CloudShaderGeometry(num_textures_x, num_textures_y, max_width, max_height);
|
||||
|
||||
// We generate up to num_flavours of different versions
|
||||
// of the same cloud before we start re-using them. This
|
||||
// allows us to strike a balance between performance and
|
||||
// visual complexity.
|
||||
// Determine how big this specific cloud instance is. Note that we subtract
|
||||
// the sprite size because the width/height is used to define the limits of
|
||||
// the center of the sprites, not their edges.
|
||||
float width = min_width + sg_random() * (max_width - min_width) - min_sprite_width;
|
||||
float height = min_height + sg_random() * (max_height - min_height) - min_sprite_height;
|
||||
|
||||
if (iter == cloudMap.end() || (*iter).second->size() < num_flavours)
|
||||
// Determine the cull distance. This is used to remove sprites that are too close together.
|
||||
// The value is squared as we use vector calculations.
|
||||
float cull_distance_squared = min_sprite_height * min_sprite_height * 0.1f;
|
||||
|
||||
// The number of sprites we actually used is a function of the (user-controlled) density
|
||||
int n_sprites = num_sprites * sprite_density;
|
||||
|
||||
for (int i = 0; i < n_sprites; i++)
|
||||
{
|
||||
// Determine the position of the sprite. Rather than being completely random,
|
||||
// we place them on the surface of a distorted sphere. However, we place
|
||||
// the first and second sprites on the top and bottom, and the third in the
|
||||
// center of the sphere (and at maximum size) to ensure good coverage and
|
||||
// reduce the chance of there being "holes" in our cloud.
|
||||
float x, y, z;
|
||||
|
||||
geode = new Geode;
|
||||
|
||||
CloudShaderGeometry* sg = new CloudShaderGeometry(num_textures_x, num_textures_y, max_width, max_height);
|
||||
|
||||
// Determine how big this specific cloud instance is. Note that we subtract
|
||||
// the sprite size because the width/height is used to define the limits of
|
||||
// the center of the sprites, not their edges.
|
||||
float width = min_width + sg_random() * (max_width - min_width) - min_sprite_width;
|
||||
float height = min_height + sg_random() * (max_height - min_height) - min_sprite_height;
|
||||
|
||||
// Determine the cull distance. This is used to remove sprites that are too close together.
|
||||
// The value is squared as we use vector calculations.
|
||||
float cull_distance_squared = min_sprite_height * min_sprite_height * 0.1f;
|
||||
|
||||
// The number of sprites we actually used is a function of the (user-controlled) density
|
||||
int n_sprites = num_sprites * sprite_density;
|
||||
|
||||
for (int i = 0; i < n_sprites; i++)
|
||||
{
|
||||
// Determine the position of the sprite. Rather than being completely random,
|
||||
// we place them on the surface of a distorted sphere. However, we place
|
||||
// the first and second sprites on the top and bottom, and the third in the
|
||||
// center of the sphere (and at maximum size) to ensure good coverage and
|
||||
// reduce the chance of there being "holes" in our cloud.
|
||||
float x, y, z;
|
||||
|
||||
if (i == 0) {
|
||||
x = 0;
|
||||
y = 0;
|
||||
z = height * 0.5f;
|
||||
} else if (i == 1) {
|
||||
x = 0;
|
||||
y = 0;
|
||||
z = - height * 0.5f;
|
||||
} else if (i == 2) {
|
||||
x = 0;
|
||||
y = 0;
|
||||
z = 0;
|
||||
} else {
|
||||
double theta = sg_random() * SGD_2PI;
|
||||
double elev = sg_random() * SGD_PI;
|
||||
x = width * cos(theta) * 0.5f * sin(elev);
|
||||
y = width * sin(theta) * 0.5f * sin(elev);
|
||||
z = height * cos(elev) * 0.5f;
|
||||
}
|
||||
|
||||
SGVec3f *pos = new SGVec3f(x, y, z);
|
||||
|
||||
// Determine the height and width as scaling factors on the minimum size (used to create the quad)
|
||||
float sprite_width = 1.0f + sg_random() * (max_sprite_width - min_sprite_width) / min_sprite_width;
|
||||
float sprite_height = 1.0f + sg_random() * (max_sprite_height - min_sprite_height) / min_sprite_height;
|
||||
|
||||
if (i == 2) {
|
||||
// The center sprite is always maximum size to fill up any holes.
|
||||
sprite_width = 1.0f + (max_sprite_width - min_sprite_width) / min_sprite_width;
|
||||
sprite_height = 1.0f + (max_sprite_height - min_sprite_height) / min_sprite_height;
|
||||
}
|
||||
|
||||
// Determine the sprite texture indexes;
|
||||
int index_x = (int) floor(sg_random() * num_textures_x);
|
||||
if (index_x == num_textures_x) { index_x--; }
|
||||
|
||||
int index_y = (int) floor(sg_random() * num_textures_y);
|
||||
if (index_y == num_textures_y) { index_y--; }
|
||||
|
||||
sg->addSprite(*pos,
|
||||
index_x,
|
||||
index_y,
|
||||
sprite_width,
|
||||
sprite_height,
|
||||
bottom_shade,
|
||||
cull_distance_squared,
|
||||
height * 0.5f);
|
||||
if (i == 0) {
|
||||
x = 0;
|
||||
y = 0;
|
||||
z = height * 0.5f;
|
||||
} else if (i == 1) {
|
||||
x = 0;
|
||||
y = 0;
|
||||
z = - height * 0.5f;
|
||||
} else if (i == 2) {
|
||||
x = 0;
|
||||
y = 0;
|
||||
z = 0;
|
||||
} else {
|
||||
double theta = sg_random() * SGD_2PI;
|
||||
double elev = sg_random() * SGD_PI;
|
||||
x = width * cos(theta) * 0.5f * sin(elev);
|
||||
y = width * sin(theta) * 0.5f * sin(elev);
|
||||
z = height * cos(elev) * 0.5f;
|
||||
}
|
||||
|
||||
SGVec3f *pos = new SGVec3f(x, y, z);
|
||||
|
||||
// Determine the height and width as scaling factors on the minimum size (used to create the quad)
|
||||
float sprite_width = 1.0f + sg_random() * (max_sprite_width - min_sprite_width) / min_sprite_width;
|
||||
float sprite_height = 1.0f + sg_random() * (max_sprite_height - min_sprite_height) / min_sprite_height;
|
||||
|
||||
sg->setGeometry(quad);
|
||||
geode->addDrawable(sg);
|
||||
geode->setName("3D cloud");
|
||||
geode->setStateSet(stateSet.get());
|
||||
|
||||
if (iter == cloudMap.end())
|
||||
{
|
||||
// This is the first of this cloud to be generated.
|
||||
GeodeList* geodelist = new GeodeList;
|
||||
geodelist->push_back(geode);
|
||||
cloudMap.insert(CloudMap::value_type(name, geodelist));
|
||||
if (i == 2) {
|
||||
// The center sprite is always maximum size to fill up any holes.
|
||||
sprite_width = 1.0f + (max_sprite_width - min_sprite_width) / min_sprite_width;
|
||||
sprite_height = 1.0f + (max_sprite_height - min_sprite_height) / min_sprite_height;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Add the new cloud to the list of geodes
|
||||
(*iter).second->push_back(geode);
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
int index = sg_random() * num_flavours;
|
||||
if (index == num_flavours) index--;
|
||||
// Determine the sprite texture indexes;
|
||||
int index_x = (int) floor(sg_random() * num_textures_x);
|
||||
if (index_x == num_textures_x) { index_x--; }
|
||||
|
||||
geode = iter->second->at(index);
|
||||
int index_y = (int) floor(sg_random() * num_textures_y);
|
||||
if (index_y == num_textures_y) { index_y--; }
|
||||
|
||||
sg->addSprite(*pos,
|
||||
index_x,
|
||||
index_y,
|
||||
sprite_width,
|
||||
sprite_height,
|
||||
bottom_shade,
|
||||
cull_distance_squared,
|
||||
height * 0.5f);
|
||||
}
|
||||
|
||||
sg->setGeometry(quad);
|
||||
geode->addDrawable(sg);
|
||||
geode->setName("3D cloud");
|
||||
geode->setStateSet(stateSet.get());
|
||||
|
||||
return geode;
|
||||
}
|
||||
|
||||
|
||||
@@ -72,19 +72,6 @@ public:
|
||||
sprite_density = d;
|
||||
}
|
||||
|
||||
static int getNumFlavours(void)
|
||||
{
|
||||
return num_flavours;
|
||||
}
|
||||
|
||||
// Set the number of flavours of this cloud.
|
||||
// This is the number of different instances
|
||||
// to generate.
|
||||
static void setNumFlavours(int d)
|
||||
{
|
||||
num_flavours = d;
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
|
||||
@@ -105,7 +92,6 @@ private:
|
||||
osg::Geometry* quad;
|
||||
osg::ref_ptr<osg::StateSet> stateSet;
|
||||
static double sprite_density;
|
||||
static unsigned int num_flavours;
|
||||
|
||||
osg::Geometry* createOrthQuad(float w, float h, int varieties_x, int varieties_y);
|
||||
|
||||
|
||||
+13
-14
@@ -25,13 +25,16 @@
|
||||
# include <simgear_config.h>
|
||||
#endif
|
||||
|
||||
#include <simgear/math/sg_random.h>
|
||||
#include <simgear/scene/util/RenderConstants.hxx>
|
||||
|
||||
#include "sky.hxx"
|
||||
#include "cloudfield.hxx"
|
||||
#include "newcloud.hxx"
|
||||
|
||||
#include <simgear/math/sg_random.h>
|
||||
#include <simgear/scene/util/RenderConstants.hxx>
|
||||
|
||||
#include <osg/StateSet>
|
||||
#include <osg/Depth>
|
||||
|
||||
// Constructor
|
||||
SGSky::SGSky( void ) {
|
||||
effective_visibility = visibility = 10000.0;
|
||||
@@ -50,8 +53,12 @@ SGSky::SGSky( void ) {
|
||||
|
||||
pre_root = new osg::Group;
|
||||
pre_root->setNodeMask(simgear::BACKGROUND_BIT);
|
||||
osg::StateSet* preStateSet = new osg::StateSet;
|
||||
preStateSet->setAttribute(new osg::Depth(osg::Depth::LESS, 0.0, 1.0,
|
||||
false));
|
||||
pre_root->setStateSet(preStateSet);
|
||||
cloud_root = new osg::Group;
|
||||
cloud_root->setNodeMask(simgear::BACKGROUND_BIT | simgear::MODEL_BIT);
|
||||
cloud_root->setNodeMask(simgear::MODEL_BIT);
|
||||
|
||||
pre_selector = new osg::Switch;
|
||||
|
||||
@@ -121,7 +128,8 @@ bool SGSky::repaint( const SGSkyColor &sc )
|
||||
// turn off sky
|
||||
disable();
|
||||
}
|
||||
|
||||
SGCloudField::updateFog((double)effective_visibility,
|
||||
osg::Vec4f(sc.fog_color.osg(), 1.0f));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -208,15 +216,6 @@ void SGSky::set_3dCloudVisRange(float vis)
|
||||
}
|
||||
}
|
||||
|
||||
float SGSky::get_3dCloudNumFlavours() const {
|
||||
return (float) SGNewCloud::getNumFlavours();
|
||||
}
|
||||
|
||||
void SGSky::set_3dCloudNumFlavours(float n)
|
||||
{
|
||||
SGNewCloud::setNumFlavours((int) n);
|
||||
}
|
||||
|
||||
void SGSky::texture_path( const string& path ) {
|
||||
tex_path = SGPath( path );
|
||||
}
|
||||
|
||||
@@ -430,14 +430,6 @@ public:
|
||||
*/
|
||||
virtual void set_3dCloudVisRange(float vis);
|
||||
|
||||
/** Get 3D cloud number of flavours*/
|
||||
virtual float get_3dCloudNumFlavours() const;
|
||||
|
||||
/** Set 3D cloud number of flavours
|
||||
* @param density 3D cloud number of flavours
|
||||
*/
|
||||
virtual void set_3dCloudNumFlavours(float n);
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -30,12 +30,6 @@ GroundLightManager::GroundLightManager()
|
||||
groundLightSS = makeLightSS();
|
||||
}
|
||||
|
||||
GroundLightManager* GroundLightManager::instance()
|
||||
{
|
||||
static ref_ptr<GroundLightManager> manager = new GroundLightManager;
|
||||
return manager.get();
|
||||
}
|
||||
|
||||
void GroundLightManager::update(const SGUpdateVisitor* updateVisitor)
|
||||
{
|
||||
osg::Fog* fog;
|
||||
|
||||
@@ -22,11 +22,14 @@
|
||||
#include <osg/Vec4>
|
||||
#include <osg/Referenced>
|
||||
#include <osg/StateSet>
|
||||
|
||||
|
||||
#include <simgear/structure/Singleton.hxx>
|
||||
#include <simgear/scene/util/SGUpdateVisitor.hxx>
|
||||
|
||||
namespace simgear
|
||||
{
|
||||
class GroundLightManager : public osg::Referenced {
|
||||
class GroundLightManager : public ReferencedSingleton<GroundLightManager> {
|
||||
public:
|
||||
GroundLightManager();
|
||||
osg::StateSet* getRunwayLightStateSet() { return runwayLightSS.get(); }
|
||||
@@ -36,7 +39,6 @@ public:
|
||||
// so use it.
|
||||
void update (const SGUpdateVisitor* updateVisitor);
|
||||
unsigned getLightNodeMask(const SGUpdateVisitor* updateVisitor);
|
||||
static GroundLightManager* instance();
|
||||
protected:
|
||||
osg::ref_ptr<osg::StateSet> runwayLightSS;
|
||||
osg::ref_ptr<osg::StateSet> taxiLightSS;
|
||||
|
||||
@@ -18,11 +18,17 @@
|
||||
* MA 02110-1301, USA.
|
||||
*
|
||||
*/
|
||||
#include "StateAttributeFactory.hxx"
|
||||
|
||||
#include <OpenThreads/ScopedLock>
|
||||
#include <osg/AlphaFunc>
|
||||
#include <osg/Array>
|
||||
#include <osg/BlendFunc>
|
||||
#include <osg/CullFace>
|
||||
#include <osg/ShadeModel>
|
||||
#include <osg/Texture2D>
|
||||
#include <osg/TexEnv>
|
||||
|
||||
#include <osg/Image>
|
||||
#include "StateAttributeFactory.hxx"
|
||||
|
||||
using namespace osg;
|
||||
|
||||
@@ -60,19 +66,10 @@ StateAttributeFactory::StateAttributeFactory()
|
||||
_white = new Vec4Array(1);
|
||||
(*_white)[0].set(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
_white->setDataVariance(Object::STATIC);
|
||||
_cullFaceFront = new CullFace(CullFace::FRONT);
|
||||
_cullFaceFront->setDataVariance(Object::STATIC);
|
||||
_cullFaceBack = new CullFace(CullFace::BACK);
|
||||
_cullFaceBack->setDataVariance(Object::STATIC);
|
||||
}
|
||||
|
||||
osg::ref_ptr<StateAttributeFactory> StateAttributeFactory::_theInstance;
|
||||
OpenThreads::Mutex StateAttributeFactory::_instanceMutex;
|
||||
|
||||
StateAttributeFactory* StateAttributeFactory::instance()
|
||||
{
|
||||
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_instanceMutex);
|
||||
if (!_theInstance.valid()) {
|
||||
_theInstance = new StateAttributeFactory;
|
||||
}
|
||||
return _theInstance.get();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,18 +24,25 @@
|
||||
|
||||
#include <OpenThreads/Mutex>
|
||||
#include <osg/ref_ptr>
|
||||
#include <osg/AlphaFunc>
|
||||
#include <osg/Array>
|
||||
#include <osg/BlendFunc>
|
||||
#include <osg/CullFace>
|
||||
#include <osg/ShadeModel>
|
||||
#include <osg/Texture2D>
|
||||
#include <osg/TexEnv>
|
||||
|
||||
namespace osg
|
||||
{
|
||||
class AlphaFunc;
|
||||
class BlendFunc;
|
||||
class CullFace;
|
||||
class ShadeModel;
|
||||
class Texture2D;
|
||||
class TexEnv;
|
||||
}
|
||||
|
||||
#include <simgear/structure/Singleton.hxx>
|
||||
|
||||
// Return read-only instances of common OSG state attributes.
|
||||
namespace simgear
|
||||
{
|
||||
class StateAttributeFactory : public osg::Referenced {
|
||||
class StateAttributeFactory :
|
||||
public ReferencedSingleton<StateAttributeFactory> {
|
||||
public:
|
||||
// Alpha test > .01
|
||||
osg::AlphaFunc* getStandardAlphaFunc() { return _standardAlphaFunc.get(); }
|
||||
@@ -49,12 +56,11 @@ public:
|
||||
osg::Texture2D* getWhiteTexture() { return _whiteTexture.get(); }
|
||||
// White color
|
||||
osg::Vec4Array* getWhiteColor() {return _white.get(); }
|
||||
// cull back facing polygons
|
||||
// cull front and back facing polygons
|
||||
osg::CullFace* getCullFaceFront() { return _cullFaceFront.get(); }
|
||||
osg::CullFace* getCullFaceBack() { return _cullFaceBack.get(); }
|
||||
|
||||
static StateAttributeFactory* instance();
|
||||
StateAttributeFactory();
|
||||
protected:
|
||||
StateAttributeFactory();
|
||||
osg::ref_ptr<osg::AlphaFunc> _standardAlphaFunc;
|
||||
osg::ref_ptr<osg::ShadeModel> _smooth;
|
||||
osg::ref_ptr<osg::ShadeModel> _flat;
|
||||
@@ -62,9 +68,8 @@ protected:
|
||||
osg::ref_ptr<osg::TexEnv> _standardTexEnv;
|
||||
osg::ref_ptr<osg::Texture2D> _whiteTexture;
|
||||
osg::ref_ptr<osg::Vec4Array> _white;
|
||||
osg::ref_ptr<osg::CullFace> _cullFaceFront;
|
||||
osg::ref_ptr<osg::CullFace> _cullFaceBack;
|
||||
static osg::ref_ptr<StateAttributeFactory> _theInstance;
|
||||
static OpenThreads::Mutex _instanceMutex;
|
||||
};
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -145,6 +145,7 @@ SGSoundSample::SGSoundSample( const char *path, const char *file, bool _no_Doppl
|
||||
alBufferData( buffer, format, data, size, freq );
|
||||
|
||||
if ( print_openal_error("constructor (alBufferData)") ) {
|
||||
SG_LOG( SG_GENERAL, SG_ALERT, "Trying to use file " << file );
|
||||
throw sg_exception("Failed to buffer data.");
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,8 @@ include_HEADERS = \
|
||||
SGReferenced.hxx \
|
||||
SGSharedPtr.hxx \
|
||||
SGSmplhist.hxx \
|
||||
SGSmplstat.hxx
|
||||
SGSmplstat.hxx \
|
||||
Singleton.hxx
|
||||
|
||||
libsgstructure_a_SOURCES = \
|
||||
commands.cxx \
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
#ifndef SIMGEAR_SINGLETON_HXX
|
||||
#define SIMGEAR_SINGLETON_HXX 1
|
||||
|
||||
#include <boost/pool/detail/singleton.hpp>
|
||||
|
||||
#include <osg/Referenced>
|
||||
#include <osg/ref_ptr>
|
||||
|
||||
namespace simgear
|
||||
{
|
||||
/**
|
||||
* Class that supplies the address of a singleton instance. This class
|
||||
* can be inherited by its Class argument in order to support the
|
||||
* instance() method in that class.
|
||||
*/
|
||||
template <typename Class>
|
||||
class Singleton
|
||||
{
|
||||
protected:
|
||||
Singleton() {}
|
||||
public:
|
||||
static Class* instance()
|
||||
{
|
||||
Class& singleton
|
||||
= boost::details::pool::singleton_default<Class>::instance();
|
||||
return &singleton;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename RefClass>
|
||||
class SingletonRefPtr
|
||||
{
|
||||
public:
|
||||
SingletonRefPtr()
|
||||
{
|
||||
ptr = new RefClass;
|
||||
}
|
||||
static RefClass* instance()
|
||||
{
|
||||
SingletonRefPtr& singleton
|
||||
= boost::details::pool::singleton_default<SingletonRefPtr>::instance();
|
||||
return singleton.ptr.get();
|
||||
}
|
||||
private:
|
||||
osg::ref_ptr<RefClass> ptr;
|
||||
};
|
||||
|
||||
template <typename RefClass>
|
||||
class ReferencedSingleton : public virtual osg::Referenced
|
||||
{
|
||||
public:
|
||||
static RefClass* instance()
|
||||
{
|
||||
return SingletonRefPtr<RefClass>::instance();
|
||||
}
|
||||
};
|
||||
}
|
||||
#endif
|
||||
Reference in New Issue
Block a user