|
From: <eg...@us...> - 2007-11-18 11:15:05
|
Revision: 842
http://opengate.svn.sourceforge.net/opengate/?rev=842&view=rev
Author: egore
Date: 2007-11-18 03:15:08 -0800 (Sun, 18 Nov 2007)
Log Message:
-----------
configure.ac: add some missing things gathered from running autoscan
Modified Paths:
--------------
trunk/ChangeLog
trunk/configure.ac
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2007-11-17 19:07:16 UTC (rev 841)
+++ trunk/ChangeLog 2007-11-18 11:15:08 UTC (rev 842)
@@ -1,4 +1,7 @@
-2007-11-14 hristoph Brill <eg...@us...>
+2007-11-18 Christoph Brill <ego...@eg...>
+ * configure.ac: add some missing things gathered from running autoscan
+
+2007-11-14 Christoph Brill <eg...@us...>
* src/networkServerUser.h: fix build with boost 1.34
2007-09-26 Christoph Brill <eg...@us...>
Modified: trunk/configure.ac
===================================================================
--- trunk/configure.ac 2007-11-17 19:07:16 UTC (rev 841)
+++ trunk/configure.ac 2007-11-18 11:15:08 UTC (rev 842)
@@ -15,7 +15,27 @@
AM_PROG_CC_STDC
AC_HEADER_STDC
AM_PROG_CC_C_O
+AC_C_CONST
+AC_C_INLINE
+AC_C_VOLATILE
+AC_FUNC_STAT
+AC_FUNC_STRTOD
+AC_HEADER_STDBOOL
+AC_PROG_RANLIB
+AC_STRUCT_TM
+AC_TYPE_SIGNAL
+AC_TYPE_SIZE_T
+# Check for header files
+AC_CHECK_HEADERS([float.h stddef.h sys/timeb.h])
+
+# Checks for library functions.
+AC_CHECK_FUNCS([floor ftime memmove memset pow rint socket sqrt strchr \
+ strerror])
+
+# Check for defines
+AC_CHECK_TYPES([ptrdiff_t])
+
# TODO: remove this part
OGSECTOR_PATH=$PWD
AC_PREFIX_DEFAULT($OGSECTOR_PATH)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <eg...@us...> - 2007-11-18 13:57:13
|
Revision: 844
http://opengate.svn.sourceforge.net/opengate/?rev=844&view=rev
Author: egore
Date: 2007-11-18 05:57:18 -0800 (Sun, 18 Nov 2007)
Log Message:
-----------
remove externals
Modified Paths:
--------------
trunk/ChangeLog
trunk/configure.ac
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2007-11-18 13:21:07 UTC (rev 843)
+++ trunk/ChangeLog 2007-11-18 13:57:18 UTC (rev 844)
@@ -1,5 +1,6 @@
2007-11-18 Christoph Brill <ego...@eg...>
- * configure.ac: add some missing things gathered from running autoscan
+ * configure.ac: add some missing things gathered from running
+ autoscan, drop externals stuff
2007-11-14 Christoph Brill <eg...@us...>
* src/networkServerUser.h: fix build with boost 1.34
Modified: trunk/configure.ac
===================================================================
--- trunk/configure.ac 2007-11-18 13:21:07 UTC (rev 843)
+++ trunk/configure.ac 2007-11-18 13:57:18 UTC (rev 844)
@@ -36,20 +36,14 @@
# Check for defines
AC_CHECK_TYPES([ptrdiff_t])
-# TODO: remove this part
-OGSECTOR_PATH=$PWD
-AC_PREFIX_DEFAULT($OGSECTOR_PATH)
-OGSECTOR_EXTERNALS_PATH=$OGSECTOR_PATH/externals
-AC_SUBST(OGSECTOR_EXTERNALS_PATH)
-AC_SUBST(PKG_CONFIG_PATH, "$OGSECTOR_EXTERNALS_PATH/lib/pkgconfig:$PKG_CONFIG_PATH")
-# TODO: end remove
-
-AM_PROG_LIBTOOL
-
PKG_CHECK_MODULES(OGRE, [OGRE >= 1.4.0])
AC_SUBST(OGRE_CFLAGS)
AC_SUBST(OGRE_LIBS)
+PKG_CHECK_MODULES(ogreopcode, [ogreopcode >= 0.1.0])
+AC_SUBST(ogreopcode_CFLAGS)
+AC_SUBST(ogreopcode_LIBS)
+
PKG_CHECK_MODULES(CEGUI, [CEGUI >= 0.5.0])
AC_SUBST(CEGUI_CFLAGS)
AC_SUBST(CEGUI_LIBS)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <eg...@us...> - 2007-11-18 13:59:20
|
Revision: 846
http://opengate.svn.sourceforge.net/opengate/?rev=846&view=rev
Author: egore
Date: 2007-11-18 05:59:24 -0800 (Sun, 18 Nov 2007)
Log Message:
-----------
drop externals stuff
Modified Paths:
--------------
trunk/ChangeLog
trunk/src/Makefile.am
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2007-11-18 13:58:08 UTC (rev 845)
+++ trunk/ChangeLog 2007-11-18 13:59:24 UTC (rev 846)
@@ -1,6 +1,7 @@
2007-11-18 Christoph Brill <ego...@eg...>
* configure.ac: add some missing things gathered from running
autoscan, drop externals stuff
+ * src/Makefile.am: drop externals stuff
2007-11-14 Christoph Brill <eg...@us...>
* src/networkServerUser.h: fix build with boost 1.34
Modified: trunk/src/Makefile.am
===================================================================
--- trunk/src/Makefile.am 2007-11-18 13:58:08 UTC (rev 845)
+++ trunk/src/Makefile.am 2007-11-18 13:59:24 UTC (rev 846)
@@ -79,13 +79,12 @@
$(freealut_LIBS) \
$(vorbisfile_LIBS) \
$(OIS_LIBS) \
- $(OgreOpcode_LIBS)
-# -L$(OGSECTOR_EXTERNALS_PATH)/lib/
+ $(ogreopcode_LIBS)
opengateclient_CXXFLAGS = \
$(OGRE_CFLAGS) \
$(CEGUI_CFLAGS) \
- $(OgreOpcode_CFLAGS)
+ $(ogreopcode_CFLAGS)
opengateserver_SOURCES = \
opengateserver.cpp \
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <eg...@us...> - 2007-11-18 14:00:25
|
Revision: 847
http://opengate.svn.sourceforge.net/opengate/?rev=847&view=rev
Author: egore
Date: 2007-11-18 06:00:29 -0800 (Sun, 18 Nov 2007)
Log Message:
-----------
2007-11-18 Christoph Brill <ego...@eg...>
* runServer.sh, runClient.sh: drop unnecessary run-wrappers
Modified Paths:
--------------
trunk/ChangeLog
Removed Paths:
-------------
trunk/runClient.sh
trunk/runServer.sh
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2007-11-18 13:59:24 UTC (rev 846)
+++ trunk/ChangeLog 2007-11-18 14:00:29 UTC (rev 847)
@@ -2,6 +2,7 @@
* configure.ac: add some missing things gathered from running
autoscan, drop externals stuff
* src/Makefile.am: drop externals stuff
+ * runServer.sh, runClient.sh: drop unnecessary run-wrappers
2007-11-14 Christoph Brill <eg...@us...>
* src/networkServerUser.h: fix build with boost 1.34
Deleted: trunk/runClient.sh
===================================================================
--- trunk/runClient.sh 2007-11-18 13:59:24 UTC (rev 846)
+++ trunk/runClient.sh 2007-11-18 14:00:29 UTC (rev 847)
@@ -1,13 +0,0 @@
-#!/bin/bash
-
-USERNAME='player'
-
-HOSTNAME='localhost'
-
-[ $# -gt 0 ] && USERNAME=$1
-
-[ $# -gt 1 ] && HOSTNAME=$2
-
-export LD_LIBRARY_PATH=./externals/lib:$LD_LIBRARY_PATH
-
-./src/opengateclient --no-config $*
Deleted: trunk/runServer.sh
===================================================================
--- trunk/runServer.sh 2007-11-18 13:59:24 UTC (rev 846)
+++ trunk/runServer.sh 2007-11-18 14:00:29 UTC (rev 847)
@@ -1,4 +0,0 @@
-#!/bin/bash
-export LD_LIBRARY_PATH=./externals/lib:$LD_LIBRARY_PATH
-
-./src/opengateserver
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ult...@us...> - 2007-11-18 16:21:16
|
Revision: 852
http://opengate.svn.sourceforge.net/opengate/?rev=852&view=rev
Author: ultrasick
Date: 2007-11-18 08:21:21 -0800 (Sun, 18 Nov 2007)
Log Message:
-----------
small changes on sectors
Modified Paths:
--------------
trunk/TODO.gluck
trunk/data/misc/sectors.xml
Modified: trunk/TODO.gluck
===================================================================
--- trunk/TODO.gluck 2007-11-18 14:55:13 UTC (rev 851)
+++ trunk/TODO.gluck 2007-11-18 16:21:21 UTC (rev 852)
@@ -1,4 +1,3 @@
before first release:
* metaserver f\xFCr die sektorverwaltung vorbereiten
-* sektoren in opacma aufnehmen (asteroiden fehlen + random bilder fehlen)
-* werbung f\xFCr dark raus
\ No newline at end of file
+* sektoren in opacma aufnehmen (asteroiden fehlen + random bilder fehlen)
\ No newline at end of file
Modified: trunk/data/misc/sectors.xml
===================================================================
(Binary files differ)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <spo...@us...> - 2007-11-21 17:16:55
|
Revision: 854
http://opengate.svn.sourceforge.net/opengate/?rev=854&view=rev
Author: spom_spom
Date: 2007-11-21 09:16:39 -0800 (Wed, 21 Nov 2007)
Log Message:
-----------
hopefully fixed some network issues
Modified Paths:
--------------
trunk/configure.ac
trunk/src/Entity.cpp
trunk/src/Entity.h
trunk/src/EntityManager.cpp
trunk/src/EntityManager.h
trunk/src/Makefile.am
trunk/src/MarketDialog.cpp
trunk/src/MarketDialog.h
trunk/src/OpcodeWrapper.cpp
trunk/src/Projectile.cpp
trunk/src/Projectile.h
trunk/src/Sector.cpp
trunk/src/SectorObjects.cpp
trunk/src/SectorObjects.h
trunk/src/networkProtocol.cpp
trunk/src/networkProtocol.h
Modified: trunk/configure.ac
===================================================================
--- trunk/configure.ac 2007-11-18 19:03:10 UTC (rev 853)
+++ trunk/configure.ac 2007-11-21 17:16:39 UTC (rev 854)
@@ -36,6 +36,8 @@
# Check for defines
AC_CHECK_TYPES([ptrdiff_t])
+AM_PROG_LIBTOOL
+
PKG_CHECK_MODULES(OGRE, [OGRE >= 1.4.0])
AC_SUBST(OGRE_CFLAGS)
AC_SUBST(OGRE_LIBS)
@@ -87,7 +89,6 @@
echo "You can get them from http://sourceforge.net/projects/asio/"
exit 1
],[])
-# TODO: end fix
AC_OUTPUT([
Makefile
Modified: trunk/src/Entity.cpp
===================================================================
--- trunk/src/Entity.cpp 2007-11-18 19:03:10 UTC (rev 853)
+++ trunk/src/Entity.cpp 2007-11-21 17:16:39 UTC (rev 854)
@@ -71,9 +71,7 @@
if ( imageFileName_ == "unknown" ) imageFileName_ = name_;
if ( !initialiseImage( imageFileName_ + "_small.png", imageFileName_ + "Small" ) ){
- if ( !initialiseImage( imageFileName_ + "_76x76.png", imageFileName_ + "Small" ) ){
- haveSmall = false;
- }
+ haveSmall = false;
}
if ( haveSmall ){
@@ -81,11 +79,8 @@
}
if ( !initialiseImage( imageFileName_ + "_big.png", imageFileName_ ) ){
- //**fallback to 290x290
- if ( !initialiseImage( imageFileName_ + "_290x290.png", imageFileName_ ) ){
- //**fallback
- initialiseImage( imageFileName_ + ".png", imageFileName_, true );
- }
+ //**fallback;
+ initialiseImage( imageFileName_ + ".png", imageFileName_, true );
}
if ( !haveSmall ) {
Modified: trunk/src/Entity.h
===================================================================
--- trunk/src/Entity.h 2007-11-18 19:03:10 UTC (rev 853)
+++ trunk/src/Entity.h 2007-11-21 17:16:39 UTC (rev 854)
@@ -139,7 +139,7 @@
std::set < Commodity * > requieredComponents_;
/*! A unique ID to find this object \todo maybe push to a string and merge with Commodity.commodityID_ */
- int id_;
+ Uint16 id_;
/*! The required tech level to interact with this object */
int techLevel_;
/*! The mass of this entity. */
Modified: trunk/src/EntityManager.cpp
===================================================================
--- trunk/src/EntityManager.cpp 2007-11-18 19:03:10 UTC (rev 853)
+++ trunk/src/EntityManager.cpp 2007-11-21 17:16:39 UTC (rev 854)
@@ -29,7 +29,7 @@
namespace OpenGate {
EntityManager::~EntityManager(){
- for ( std::map< int, Entity * >::iterator it = templatesByID_.begin(); it != templatesByID_.end(); it ++ ){
+ for ( std::map< Uint16, Entity * >::iterator it = templatesByID_.begin(); it != templatesByID_.end(); it ++ ){
delete it->second;
}
templatesByID_.end();
@@ -348,7 +348,7 @@
pElem = hRoot.ChildElement( "fire_delay", 0 ).Element();
if ( pElem ) dynamic_cast< Gun * >( entity )->setFireDelay( toDouble( pElem->FirstChild()->Value() ) );
- pElem = hRoot.ChildElement( "energy_per_shot", 0 ).Element();
+ pElem = hRoot.ChildElement( "power_per_shot", 0 ).Element();
if ( pElem ) dynamic_cast< Gun * >( entity )->setEnergy( toInt( pElem->FirstChild()->Value() ) );
pElem = hRoot.ChildElement( "damage", 0 ).Element();
Modified: trunk/src/EntityManager.h
===================================================================
--- trunk/src/EntityManager.h 2007-11-18 19:03:10 UTC (rev 853)
+++ trunk/src/EntityManager.h 2007-11-21 17:16:39 UTC (rev 854)
@@ -84,6 +84,16 @@
}
}
+ Entity * entity( Uint16 ID ){
+ if ( templatesByID_.count( ID ) ){
+ return templatesByID_[ ID ];
+ } else {
+ LogManager::getSingleton().warn( ("Request for entity id: ") + toStr(ID) + " unknown" );
+ return NULL;
+ }
+ }
+
+
protected:
/*! \brief This loads enities from there definition files, called from load()
@@ -103,7 +113,7 @@
std::map < std::string, Entity * > templatesByName_;
- std::map < int, Entity * > templatesByID_;
+ std::map < Uint16, Entity * > templatesByID_;
std::set < std::string > factions_;
};
Modified: trunk/src/Makefile.am
===================================================================
--- trunk/src/Makefile.am 2007-11-18 19:03:10 UTC (rev 853)
+++ trunk/src/Makefile.am 2007-11-21 17:16:39 UTC (rev 854)
@@ -79,12 +79,12 @@
$(freealut_LIBS) \
$(vorbisfile_LIBS) \
$(OIS_LIBS) \
- $(ogreopcode_LIBS)
+ $(ogreopcode_LIBS)
opengateclient_CXXFLAGS = \
$(OGRE_CFLAGS) \
$(CEGUI_CFLAGS) \
- $(ogreopcode_CFLAGS)
+ $(ogreopcode_CFLAGS)
opengateserver_SOURCES = \
opengateserver.cpp \
Modified: trunk/src/MarketDialog.cpp
===================================================================
--- trunk/src/MarketDialog.cpp 2007-11-18 19:03:10 UTC (rev 853)
+++ trunk/src/MarketDialog.cpp 2007-11-21 17:16:39 UTC (rev 854)
@@ -112,6 +112,8 @@
CEGUI::PushButton::EventClicked, MarketDialog::handleMarketItemWindowUpButton );
BIND_CEGUI_EVENT( wmgr.getWindow( (CEGUI::utf8*)"MarketWindow/DownButton"),
CEGUI::PushButton::EventClicked, MarketDialog::handleMarketItemWindowDownButton );
+ BIND_CEGUI_EVENT( wmgr.getWindow( (CEGUI::utf8*)"MarketWindow"),
+ CEGUI::PushButton::EventMouseWheel, MarketDialog::handleMouseWheelChanged );
BIND_CEGUI_EVENT( wmgr.getWindow( (CEGUI::utf8*)"MarketItemDetailedView/NotNowButton"),
CEGUI::PushButton::EventClicked, MarketDialog::handleMarketItemViewNotNowButton );
@@ -136,6 +138,7 @@
BIND_CEGUI_EVENT( wmgr.getWindow( (CEGUI::utf8*)"InventoryWindow/DownButton"),
CEGUI::PushButton::EventClicked, MarketDialog::handleInventItemWindowDownButton );
+
for ( unsigned int i = 0; i < marketItems_.size(); i ++ ){
BIND_CEGUI_EVENT( marketItems_[ i ], CEGUI::Window::EventMouseEnters, MarketDialog::handleMarketItemMouseEnters );
BIND_CEGUI_EVENT( marketItems_[ i ], CEGUI::Window::EventMouseLeaves, MarketDialog::handleMarketItemMouseLeaves );
@@ -703,5 +706,10 @@
return true;
}
+bool MarketDialog::handleMouseWheelChanged( const CEGUI::EventArgs & e ){
+ std::cout << "handleMouseWheelChanged" << std::endl;
+ return true;
+}
+
} // namespace OpenGate
Modified: trunk/src/MarketDialog.h
===================================================================
--- trunk/src/MarketDialog.h 2007-11-18 19:03:10 UTC (rev 853)
+++ trunk/src/MarketDialog.h 2007-11-21 17:16:39 UTC (rev 854)
@@ -62,12 +62,12 @@
bool handeMainWindowShown( const CEGUI::EventArgs & e );
- bool handleMarketItemSortAlphaAscend( const CEGUI::EventArgs & e ){ sortBy_ = Alphanumeric; updateSortIcons(); return true; }
- bool handleMarketItemSortAlphaDescend( const CEGUI::EventArgs & e ){ sortBy_ = Alphanumeric; updateSortIcons(); return true; }
- bool handleMarketItemSortCost( const CEGUI::EventArgs & e ){ sortBy_ = Cost; updateSortIcons(); return true; }
- bool handleMarketItemSortSizeAscend( const CEGUI::EventArgs & e ){ sortBy_ = Size; updateSortIcons(); return true; }
- bool handleMarketItemSortSizeDescend( const CEGUI::EventArgs & e ){ sortBy_ = Size; updateSortIcons(); return true; }
- bool handleMarketItemSortRank( const CEGUI::EventArgs & e ){ sortBy_ = Rank; updateSortIcons(); return true; }
+ bool handleMarketItemSortAlphaAscend( const CEGUI::EventArgs & e ){ sortBy_ = Alphanumeric; updateSortIcons(); return true; }
+ bool handleMarketItemSortAlphaDescend( const CEGUI::EventArgs & e ){ sortBy_ = Alphanumeric; updateSortIcons(); return true; }
+ bool handleMarketItemSortCost( const CEGUI::EventArgs & e ){ sortBy_ = Cost; updateSortIcons(); return true; }
+ bool handleMarketItemSortSizeAscend( const CEGUI::EventArgs & e ){ sortBy_ = Size; updateSortIcons(); return true; }
+ bool handleMarketItemSortSizeDescend( const CEGUI::EventArgs & e ){ sortBy_ = Size; updateSortIcons(); return true; }
+ bool handleMarketItemSortRank( const CEGUI::EventArgs & e ){ sortBy_ = Rank; updateSortIcons(); return true; }
bool handleMarketItemSortAmountAscend( const CEGUI::EventArgs & e ){ sortBy_ = Amount; updateSortIcons(); return true; }
bool handleMarketItemSortAmountDescend( const CEGUI::EventArgs & e ){ sortBy_ = Amount; updateSortIcons(); return true; }
@@ -88,6 +88,8 @@
bool handleMarketItemViewAcceptButton( const CEGUI::EventArgs & e );
bool handleMarketItemChangeAmount( const CEGUI::EventArgs & e );
+ bool handleMouseWheelChanged( const CEGUI::EventArgs & e );
+
std::string selectedCategory_;
std::vector < CEGUI::Window * > marketItems_;
std::vector < CEGUI::Window * > inventItems_;
Modified: trunk/src/OpcodeWrapper.cpp
===================================================================
--- trunk/src/OpcodeWrapper.cpp 2007-11-18 19:03:10 UTC (rev 853)
+++ trunk/src/OpcodeWrapper.cpp 2007-11-21 17:16:39 UTC (rev 854)
@@ -50,7 +50,6 @@
OgreOpcode::CollisionManager::getSingletonPtr()->addCollType( "DockPad", "SectorObject", OgreOpcode::COLLTYPE_EXACT );
// OgreOpcode::CollisionManager::getSingletonPtr()->addCollType( "SectorObject", "SectorObject", OgreOpcode::COLLTYPE_CONTACT );
// OgreOpcode::CollisionManager::getSingletonPtr()->addCollType( "SectorObject", "SectorObject", OgreOpcode::COLLTYPE_QUICK );
-
collideInSectorContext_ = OgreOpcode::CollisionManager::getSingletonPtr()->getDefaultContext();
}
Modified: trunk/src/Projectile.cpp
===================================================================
--- trunk/src/Projectile.cpp 2007-11-18 19:03:10 UTC (rev 853)
+++ trunk/src/Projectile.cpp 2007-11-21 17:16:39 UTC (rev 854)
@@ -30,35 +30,57 @@
namespace OpenGate{
+ Projectile::Projectile( BaseObject * parent, long shotCount, Gun & gun, const Ogre::Vector3 & pos, const Ogre::Vector3 & vel )
+ : BaseObject( parent->name() + "_" + toStr( shotCount ), parent->sector() ), parent_( parent ),
+ shotCount_( shotCount ), gun_( &gun ), damage_( gun.damage() ), maxLifeTime_( gun.lifeTime() ), vel_( vel ){
+
+ selectable_ = false;
+ beam_ = NULL;
+ bullet_ = NULL;
+ shape_ = NULL;
+ trail_ = NULL;
+
+ maxRange_ = gun.speed() * maxLifeTime_;
+
+ fire( pos );
+}
+
Projectile::Projectile( BaseObject * parent, long shotCounter, const GunObject & gun, const Ogre::Vector3 & mountPoint )
- : BaseObject( parent->name() + "_" + toStr( shotCounter ), parent->sector() ), parent_( parent ),
- shotCount_( shotCounter), damage_( gun.gun()->damage() ), maxLifeTime_( gun.gun()->lifeTime() ){
+ : BaseObject( parent->name() + "_" + toStr( shotCounter ), parent->sector() ), parent_( parent ),
+ shotCount_( shotCounter), gun_( gun.gun() ), damage_( gun.gun()->damage() ), maxLifeTime_( gun.gun()->lifeTime() ){
selectable_ = false;
- Ogre::String bulletName( name_ + "_" + toStr( shotCounter ) );
-
beam_ = NULL;
bullet_ = NULL;
shape_ = NULL;
trail_ = NULL;
+ maxRange_ = gun.gun()->speed() * maxLifeTime_;
+
Ogre::Quaternion direction( parent_->mainNode()->getOrientation() );
+ vel_ = gun.gun()->speed() * -direction.zAxis().normalisedCopy() + parent->velocity();
+
Ogre::Vector3 relGunPos( ( gun.sceneNode().getParentSceneNode()->getOrientation() * gun.sceneNode().getPosition() ) *
- gun.sceneNode().getParentSceneNode()->getParentSceneNode()->getScale() );
-
+ gun.sceneNode().getParentSceneNode()->getParentSceneNode()->getScale() );
- maxRange_ = gun.gun()->speed() * maxLifeTime_;
+ Ogre::Vector3 pos( gun.sceneNode().getWorldPosition() - direction.zAxis() * relGunPos[ 2 ] );
+ fire( pos, relGunPos );
+}
+
+void Projectile::fire( const Ogre::Vector3 & pos, const Ogre::Vector3 & relGunPos ){
+ Ogre::String bulletName( name_ + "_" + toStr( shotCount_ ) );
+
+ Ogre::Quaternion direction( parent_->mainNode()->getOrientation() );
mainNode_->setOrientation( direction );
- mainNode_->setPosition( gun.sceneNode().getWorldPosition() - direction.zAxis() * relGunPos[ 2 ] );
+ mainNode_->setPosition( pos );
mainNode_->_update( true, true );
lifeTime_ = 0.0;
oldTime_ = 0.0;
ammoHit_ = false;
- vel_ = gun.gun()->speed() * -direction.zAxis().normalisedCopy() + parent->velocity();
- switch ( gun.gun()->type() ){
+ switch ( gun_->type() ){
case BULLET:{
int maxBB = 20;
bullet_ = sceneMgr_->createBillboardSet( bulletName + "_BBS", maxBB );
@@ -112,10 +134,10 @@
case MININGLASER: {
} break;
case UNKNOWN: {
- LogManager::getSingleton().warn( "guntype unknown: " + toStr( gun.gun()->type() ) + " Forced bullet." );
- }break;
+ LogManager::getSingleton().warn( "guntype unknown: " + toStr( gun_->type() ) + " Forced bullet." );
+ } break;
- }
+ } //switch gun_->type
}
Projectile::~Projectile() {
Modified: trunk/src/Projectile.h
===================================================================
--- trunk/src/Projectile.h 2007-11-18 19:03:10 UTC (rev 853)
+++ trunk/src/Projectile.h 2007-11-21 17:16:39 UTC (rev 854)
@@ -28,10 +28,14 @@
class Projectile : public BaseObject {
public:
+ Projectile( BaseObject * parent, long shotCount, Gun & gun, const Ogre::Vector3 & pos, const Ogre::Vector3 & vel );
+
Projectile( BaseObject * parent, long shotCount, const GunObject & gun, const Ogre::Vector3 & mountPoint );
virtual ~Projectile();
+ void fire( const Ogre::Vector3 & pos, const Ogre::Vector3 & relGunPos = Ogre::Vector3::ZERO);
+
inline virtual long getTypeID() const { return PROJECTILE_RTTI; }
virtual void collide( BaseObject * object );
@@ -50,11 +54,15 @@
Uint16 shotCount() const { return shotCount_; }
+ Gun * gun() const { return gun_; }
+
protected:
BaseObject * parent_;
Uint16 shotCount_;
Uint32 damage_;
+ Gun * gun_;
+
// Ogre::BillboardChain * chain_;
Ogre::BillboardSet * bullet_;
Ogre::ManualObject * beam_;
Modified: trunk/src/Sector.cpp
===================================================================
--- trunk/src/Sector.cpp 2007-11-18 19:03:10 UTC (rev 853)
+++ trunk/src/Sector.cpp 2007-11-21 17:16:39 UTC (rev 854)
@@ -27,6 +27,7 @@
#include "Station.h"
#include <OgreManualObject.h>
+#include <OgreMaterialManager.h>
#include <OgreOverlayManager.h>
#include <OgreOverlayContainer.h>
#include <OgreSceneNode.h>
@@ -92,7 +93,7 @@
// myManualObject->position(Ogre::Vector3(Ogre::Math::RangeRandom(-1,1),
// Ogre::Math::RangeRandom(-1,1),
// Ogre::Math::RangeRandom(-1,1)).normalisedCopy() *
-// Ogre::Math::RangeRandom(10000,40000) );
+// Ogre::Math::RangeRandom(100000,400000) );
// }
// myManualObject->end();
// myManualObjectNode->attachObject(myManualObject);
@@ -216,7 +217,7 @@
pElem = hRoot.ChildElement( "skybox", 0 ).Element();
if ( pElem ){
- sceneMgr_->setSkyBox( true, pElem->FirstChild()->Value() );
+ sceneMgr_->setSkyBox( true, pElem->FirstChild()->Value(), 10000 );
} else{
// sceneMgr_->setSkyBox( true, "OpenGate/SimpleSkyBox1" );
}
@@ -555,7 +556,7 @@
}
}
- void Sector::destructMoveableObject( SectorObjectMoveable * obj ){
+void Sector::destructMoveableObject( SectorObjectMoveable * obj ){
selectNextTarget( obj );
sectorObjects_.erase( obj );
@@ -949,10 +950,8 @@
std::cout << "Send: Projectile from " << projectile.name() << " collide with: " << victim->name()
<< " " << victim->userID() << " " << victim->childID() << std::endl;
- if ( network_->online() ){
- MessageBodyShipAmmoHit msg( projectile.parent().childID(), victim->userID(), victim->childID(), projectile.damage() );
- network_->send( msg );
- }
+ MessageBodyShipAmmoHit msg( projectile.parent().childID(), victim->userID(), victim->childID(), projectile.damage() );
+ network_->send( msg );
victim->hitByAmmo( projectile.damage() );
}
}
@@ -981,12 +980,10 @@
}
void Sector::sendProjectile( const Projectile & projectile ){
- if ( network_->online() ){
- MessageBodyShipProjectileFired msg( projectile.parent().childID(), projectile.shotCount(),
- projectile.position().ptr(), projectile.velocity().ptr(),
- projectile.damage(), projectile.lifeTime() );
- network_->send( msg );
- }
+ MessageBodyShipProjectileFired msg( projectile.parent().childID(), projectile.shotCount(),
+ projectile.position().ptr(), projectile.velocity().ptr(),
+ projectile.gun()->id(), projectile.damage(), projectile.lifeTime() );
+ network_->send( msg );
}
void Sector::receiveProjectile( const MessageBodyShipProjectileFired & msg ){
@@ -994,8 +991,15 @@
std::map< long, SectorObjectMoveable * >::iterator it;
if ( ( it = movableObjects_.find( createGlobalID( msg.senderID(), msg.childID() ) ) ) != movableObjects_.end() ){
-// Projectile * pro = new Projectile( it->second, msg.shotCount(), msg.velocity().length(), msg.damage(), msg.liveTime() );
-// it->second->addProjectile( pro );
+ Gun * gun = dynamic_cast < Gun * >(EquipmentManager::getSingleton().entity( msg.gunID() ) );
+ if ( gun->entityType() == GUN ){
+ Projectile * pro = new Projectile( it->second, msg.shotCount(), *gun,
+ toOgreVec( msg.position() ),
+ toOgreVec( msg.velocity() ) );
+ it->second->addProjectile( pro );
+ } else {
+ log_->warn( "Unknown projectile type: " + toStr( msg.gunID() ) );
+ }
} else {
log_->warn( "Unknown shooter" );
}
Modified: trunk/src/SectorObjects.cpp
===================================================================
--- trunk/src/SectorObjects.cpp 2007-11-18 19:03:10 UTC (rev 853)
+++ trunk/src/SectorObjects.cpp 2007-11-21 17:16:39 UTC (rev 854)
@@ -236,6 +236,7 @@
}
explosion_ = NULL;
+ armor_ = vessel_->armor();
setThrust( 0 );
updateThruster();
}
@@ -470,15 +471,14 @@
void SectorObjectMoveable::inititializeVesselStats_(){
- armor_ = maxArmor();
yaw_ = 0;
roll_ = 0;
pitch_ = 0;
mass_ = 1;
+ armor_ = 1;
thrust_ = 0;
- maxThrust_ = 0;
- armor_ = 1;
+ maxThrust_ = 0;
shield_ = 0;
maxShield_ = 0;
@@ -854,7 +854,7 @@
bool SectorObjectAvatar::update( Ogre::Real elapsedTime ){
updatePowerGrid( elapsedTime );
- thrustRate_ += (thrustChange_ *0.5f*elapsedTime);
+ thrustRate_ += (thrustChange_ * 0.5f * elapsedTime);
thrustRate_ = max( thrustRate_, 0.0f );
thrustRate_ = min( 1.0f, thrustRate_ );
if ( thrustChange_ != 0.0 ) updateThruster();
Modified: trunk/src/SectorObjects.h
===================================================================
--- trunk/src/SectorObjects.h 2007-11-18 19:03:10 UTC (rev 853)
+++ trunk/src/SectorObjects.h 2007-11-21 17:16:39 UTC (rev 854)
@@ -70,12 +70,12 @@
inline Ogre::SceneNode & sceneNode() const { return *mountPoint_; }
protected:
- Gun * gun_;
- SectorObject * parent_;
- Ogre::SceneNode * mountPoint_;
- Uint32 * capacity_;
- Ogre::Real delayTime_;
- Ogre::Vector3 mountPosition_;
+ Gun * gun_;
+ SectorObject * parent_;
+ Ogre::SceneNode * mountPoint_;
+ Uint32 * capacity_;
+ Ogre::Real delayTime_;
+ Ogre::Vector3 mountPosition_;
OpenALSoundSource * gunSound_;
};
@@ -276,7 +276,6 @@
/*! Returns the current relative armor. */
inline Ogre::Real armorRate() const { if ( maxArmor() > 0 ) return (float)armor_ / maxArmor(); else return 0.0; }
-
/*! Set the current shield. */
inline void setShield( Uint32 shield ) { shield_ = shield; }
Modified: trunk/src/networkProtocol.cpp
===================================================================
--- trunk/src/networkProtocol.cpp 2007-11-18 19:03:10 UTC (rev 853)
+++ trunk/src/networkProtocol.cpp 2007-11-21 17:16:39 UTC (rev 854)
@@ -119,8 +119,8 @@
MessageBodyShipProjectileFired::MessageBodyShipProjectileFired( Uint8 childID, Uint16 shotCount, const Float * pos,
- const Float * vel, Uint32 damage, Float liveTime )
- : MessageBodyShipBase( childID ), shotCount_( shotCount ), damage_( damage ), liveTime_( liveTime ) {
+ const Float * vel, Uint16 gunID, Uint32 damage, Float liveTime )
+ : MessageBodyShipBase( childID ), shotCount_( shotCount ), gunID_( gunID ), damage_( damage ), liveTime_( liveTime ) {
type_ = (Uint8)PROTO_SHIP_PROJECTILEFIRED;
pos_.v[ 0 ] = pos[ 0 ]; pos_.v[ 1 ] = pos[ 1 ]; pos_.v[ 2 ] = pos[ 2 ];
vel_.v[ 0 ] = vel[ 0 ]; vel_.v[ 1 ] = vel[ 1 ]; vel_.v[ 2 ] = vel[ 2 ];
@@ -133,6 +133,7 @@
readFromData( shotCount_, data, count );
readFromData( pos_, data, count );
readFromData( vel_, data, count );
+ readFromData( gunID_, data, count );
readFromData( damage_, data, count );
readFromData( liveTime_, data, count );
}
@@ -142,6 +143,7 @@
writeToOut( out_, shotCount_ );
writeToOut( out_, pos_ );
writeToOut( out_, vel_ );
+ writeToOut( out_, gunID_ );
writeToOut( out_, damage_ );
writeToOut( out_, liveTime_ );
}
Modified: trunk/src/networkProtocol.h
===================================================================
--- trunk/src/networkProtocol.h 2007-11-18 19:03:10 UTC (rev 853)
+++ trunk/src/networkProtocol.h 2007-11-21 17:16:39 UTC (rev 854)
@@ -507,7 +507,7 @@
class MessageBodyShipProjectileFired : public MessageBodyShipBase {
public:
MessageBodyShipProjectileFired( Uint8 childID, Uint16 shotCount, const Float * pos, const Float * vel,
- Uint32 damage, Float liveTime );
+ Uint16 gunID, Uint32 damage, Float liveTime );
MessageBodyShipProjectileFired( const char * data );
@@ -515,17 +515,19 @@
void createOutStream();
- Uint16 shotCount() const { return shotCount_ ; }
+ Uint16 shotCount() const { return shotCount_ ; }
FVector3 position() const;
FVector3 velocity() const;
- Uint32 damage() const { return damage_; }
- Float liveTime() const { return liveTime_; }
+ Uint16 gunID() const { return gunID_; }
+ Uint32 damage() const { return damage_; }
+ Float liveTime() const { return liveTime_; }
protected:
- Uint16 shotCount_;
+ Uint16 shotCount_;
FVector3 pos_;
FVector3 vel_;
- Uint32 damage_;
+ Uint16 gunID_;
+ Uint32 damage_;
Float liveTime_;
};
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <spo...@us...> - 2007-11-21 22:56:30
|
Revision: 856
http://opengate.svn.sourceforge.net/opengate/?rev=856&view=rev
Author: spom_spom
Date: 2007-11-21 14:56:35 -0800 (Wed, 21 Nov 2007)
Log Message:
-----------
try to fix strange network problem
Modified Paths:
--------------
trunk/src/Sector.cpp
trunk/src/metaserver.cpp
trunk/src/networkProtocol.h
trunk/src/opengateserver.cpp
Removed Paths:
-------------
trunk/win32/ogsectorclient/OgreOpcode.dll
trunk/win32/ogsectorclient/Opcode.dll
Modified: trunk/src/Sector.cpp
===================================================================
--- trunk/src/Sector.cpp 2007-11-21 19:52:10 UTC (rev 855)
+++ trunk/src/Sector.cpp 2007-11-21 22:56:35 UTC (rev 856)
@@ -912,7 +912,8 @@
it->second->setFlightProperties( (*i->second) );
} else {
std::cerr << "Requested non existant object for shipmovement: "
- << network_->userName( i->second->senderID() ) << " at: "
+ << network_->userName( i->second->senderID() )
+ << " child: " << (int)i->second->childID() << " at: "
<< i->second->position() << " this should not happen." << std::endl;
}
}
Modified: trunk/src/metaserver.cpp
===================================================================
--- trunk/src/metaserver.cpp 2007-11-21 19:52:10 UTC (rev 855)
+++ trunk/src/metaserver.cpp 2007-11-21 22:56:35 UTC (rev 856)
@@ -413,12 +413,7 @@
asio::write( socket_, request );
// Read the response status line.
-#ifdef WIN32
- // we dont have boost:regex within win32, i will fix this later (carsten)
- //asio::read_until(socket_, response, "\n");
-#else
asio::read_until( socket_, response, boost::regex("\r\n") );
-#endif
// Check that response is OK.
std::istream response_stream( &response );
@@ -429,21 +424,15 @@
std::string status_message;
std::getline(response_stream, status_message);
if ( !response_stream || http_version.substr(0, 5) != "HTTP/" ) {
- std::cout << "Invalid response\n";
+ log_->fatal( "Metaserver: invalid response" );
return -51;
}
if ( status_code != 200 ) {
- std::cout << "Response returned with status code " << status_code << "\n";
+ log_->fatal( "Metaserver: response returned with status code " + toStr( status_code ) );
return -52;
}
- // Read the response headers, which are terminated by a blank line.
-#ifdef WIN32
- // we dont have boost:regex within win32, i will fix this later (carsten)
- //asio::read_until(socket_, response, "\n");
-#else
asio::read_until( socket_, response, boost::regex( "\r\n\r\n" ) );
-#endif
// Process the response headers. (to get the crap of the response before reading the body!)
std::string header;
Modified: trunk/src/networkProtocol.h
===================================================================
--- trunk/src/networkProtocol.h 2007-11-21 19:52:10 UTC (rev 855)
+++ trunk/src/networkProtocol.h 2007-11-21 22:56:35 UTC (rev 856)
@@ -114,27 +114,27 @@
/*! Destructor */
virtual ~MessageBodyBase(){ }
- virtual char * data() {
+ inline virtual char * data() {
out_.str( "" );
createOutStream();
outData_ = out_.str();
return (char*)&outData_[ 0 ];
}
- virtual void createOutStream() {
+ inline virtual void createOutStream() {
writeToOut( out_, type_ );
writeToOut( out_, senderID_ );
}
- int length() const { return outData_.length(); }
+ inline int length() const { return outData_.length(); }
- Uint8 type() const { return (int)type_; }
+ inline Uint8 type() const { return type_; }
- Uint32 senderID( ) const { return senderID_; }
+ inline Uint32 senderID( ) const { return senderID_; }
- void setSenderID( Uint32 senderID ) { senderID_ = senderID; }
+ inline void setSenderID( Uint32 senderID ) { senderID_ = senderID; }
- virtual int dataSize() const { return sizeof( Uint8 ) + sizeof( Uint32 ); }
+ inline virtual int dataSize() const { return sizeof( Uint8 ) + sizeof( Uint32 ); }
friend std::ostream & operator << ( std::ostream & str, const MessageBodyBase & msg ){
str << "Type: " << (int)( msg.type() ) << " senderID: " << msg.senderID() ;
@@ -171,9 +171,9 @@
writeToOut( out_, userID_ );
}
- virtual int dataSize() const { return MessageBodyBase::dataSize() + sizeof( Uint32 ); }
+ inline virtual int dataSize() const { return MessageBodyBase::dataSize() + sizeof( Uint32 ); }
- Uint32 userID( ) const { return userID_; }
+ inline Uint32 userID( ) const { return userID_; }
protected:
Uint32 userID_;
@@ -223,7 +223,7 @@
out_.write( ( char* )( username_.c_str() ), sizeof( char ) * nameLength_ );
}
- std::string userName( ) const { return username_; }
+ inline std::string userName( ) const { return username_; }
protected:
Uint8 nameLength_;
@@ -252,7 +252,7 @@
writeToOut( out_, reason_ );
}
- Uint8 reason( ) const { return reason_; }
+ inline Uint8 reason( ) const { return reason_; }
protected:
Uint8 reason_;
@@ -287,9 +287,9 @@
out_.write( ( char* )( message_.c_str() ), sizeof( char ) * messageLength_ );
}
- void setMessage( const std::string & message ){ message_ = message; }
+ inline void setMessage( const std::string & message ){ message_ = message; }
- std::string message( ) const { return message_; }
+ inline std::string message( ) const { return message_; }
protected:
mutable Uint16 messageLength_;
@@ -314,14 +314,14 @@
virtual ~MessageBodyShipBase( ){ }
- void createOutStream() {
+ inline void createOutStream() {
MessageBodyBase::createOutStream();
writeToOut( out_, childID_ );
}
- Uint8 childID( ) const { return (int)childID_; }
+ inline Uint8 childID( ) const { return childID_; }
- virtual int dataSize() const { return MessageBodyBase::dataSize() + sizeof( Uint8 ); }
+ inline virtual int dataSize() const { return MessageBodyBase::dataSize() + sizeof( Uint8 ); }
protected:
Uint8 childID_;
@@ -341,14 +341,10 @@
inline std::string name() const { return name_; }
- FVector3 position() const;
-
- inline Uint16 vesselID() const { return vesselID_; }
-
- inline Uint32 mass() const { return mass_; }
-
+ FVector3 position() const;
+ inline Uint16 vesselID() const { return vesselID_; }
+ inline Uint32 mass() const { return mass_; }
inline Uint32 maxShield() const { return maxShield_; }
-
inline Uint32 maxThrust() const { return maxThrust_; }
protected:
@@ -375,9 +371,7 @@
virtual ~MessageBodyShipDeRegister( ){ }
- void createOutStream() {
- MessageBodyShipBase::createOutStream();
- }
+ inline void createOutStream() { MessageBodyShipBase::createOutStream(); }
friend std::ostream & operator << ( std::ostream & str, const MessageBodyShipDeRegister & msg ){
str << "Type: " << (int)( msg.type() ) << " senderID: " << msg.senderID() << " childID: " << msg.childID();
@@ -398,9 +392,7 @@
virtual ~MessageBodyShipDied( ){ }
- void createOutStream() {
- MessageBodyShipBase::createOutStream();
- }
+ inline void createOutStream() { MessageBodyShipBase::createOutStream(); }
friend std::ostream & operator << ( std::ostream & str, const MessageBodyShipDied & msg ){
str << "Type: " << (int)( msg.type() ) << " senderID: " << msg.senderID() << " childID: " << msg.childID();
@@ -421,20 +413,13 @@
void createOutStream();
- FVector3 velocity() const;
-
- FVector3 position() const;
-
- FVector4 orientation() const;
-
- inline Uint32 thrust() const { return thrust_; }
-
- inline float yaw() const { return yaw_; }
-
- inline float pitch() const { return pitch_; }
-
- inline float roll() const { return roll_; }
-
+ FVector3 velocity() const;
+ FVector3 position() const;
+ FVector4 orientation() const;
+ inline Uint32 thrust() const { return thrust_; }
+ inline float yaw() const { return yaw_; }
+ inline float pitch() const { return pitch_; }
+ inline float roll() const { return roll_; }
inline Uint16 sequenceNr( ) const { return seqNr_; }
friend std::ostream & operator << ( std::ostream & str, const MessageBodyShipMovement & msg );
@@ -484,16 +469,12 @@
tmp = ( Uint8 )break_; writeToOut( out_, tmp );
}
- Uint32 shield( ) const { return shield_; }
+ inline Uint32 shield( ) const { return shield_; }
+ inline Uint32 armor( ) const { return armor_; }
+ inline bool firePressed( ) const { return fire_; }
+ inline bool afterburnerPressed( ) const { return afterburner_; }
+ inline bool breakPressed( ) const { return break_; }
- Uint32 armor( ) const { return armor_; }
-
- bool firePressed( ) const { return fire_; }
-
- bool afterburnerPressed( ) const { return afterburner_; }
-
- bool breakPressed( ) const { return break_; }
-
protected:
Uint32 shield_;
Uint32 armor_;
@@ -515,12 +496,12 @@
void createOutStream();
- Uint16 shotCount() const { return shotCount_ ; }
- FVector3 position() const;
- FVector3 velocity() const;
- Uint16 gunID() const { return gunID_; }
- Uint32 damage() const { return damage_; }
- Float liveTime() const { return liveTime_; }
+ inline Uint16 shotCount() const { return shotCount_ ; }
+ FVector3 position() const;
+ FVector3 velocity() const;
+ inline Uint16 gunID() const { return gunID_; }
+ inline Uint32 damage() const { return damage_; }
+ inline Float liveTime() const { return liveTime_; }
protected:
Uint16 shotCount_;
@@ -555,12 +536,10 @@
writeToOut( out_, damage_ );
}
- Uint32 targetID() const { return targetID_; }
+ inline Uint32 targetID() const { return targetID_; }
+ inline Uint8 targetChildID() const { return targetChildID_; }
+ inline Uint32 damage() const { return damage_; }
- Uint8 targetChildID() const { return targetChildID_; }
-
- Uint32 damage() const { return damage_; }
-
protected:
Uint32 targetID_;
@@ -601,14 +580,11 @@
return true;
}
- Uint16 length() const { return HeaderLength + bodyLength_; }
+ inline Uint16 length() const { return HeaderLength + bodyLength_; }
+ inline const char * body() const { return data_ + HeaderLength; }
+ inline char * body() { return data_ + HeaderLength; }
+ inline Uint16 bodyLength() const { return bodyLength_; }
- const char * body() const { return data_ + HeaderLength; }
-
- char * body() { return data_ + HeaderLength; }
-
- Uint16 bodyLength() const { return bodyLength_; }
-
protected:
char data_[ HeaderLength + MaxBodyLength ];
Uint16 bodyLength_;
Modified: trunk/src/opengateserver.cpp
===================================================================
--- trunk/src/opengateserver.cpp 2007-11-21 19:52:10 UTC (rev 855)
+++ trunk/src/opengateserver.cpp 2007-11-21 22:56:35 UTC (rev 856)
@@ -83,7 +83,7 @@
//** ein bissle mehr verbose output, kommt sp\xE4ter wieder weg.;
//** das k\xF6nnte mal vielleicht als option rausreichen, das man wie beim clienten die Wahl hat;
//** -M = (withMetaServer = true);
- bool withMetaServer = false;
+ bool withMetaServer = true;
std::string servername( "testserver Sim 1" );
try {
asio::io_service io_service;
Deleted: trunk/win32/ogsectorclient/OgreOpcode.dll
===================================================================
(Binary files differ)
Deleted: trunk/win32/ogsectorclient/Opcode.dll
===================================================================
(Binary files differ)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <spo...@us...> - 2007-12-02 17:25:28
|
Revision: 873
http://opengate.svn.sourceforge.net/opengate/?rev=873&view=rev
Author: spom_spom
Date: 2007-12-02 09:25:31 -0800 (Sun, 02 Dec 2007)
Log Message:
-----------
upgrade to asio-0.3.8, fixed miscellaneous minor and major bugs
Modified Paths:
--------------
trunk/configure.ac
trunk/data/materials/advancedMaterials.material
trunk/data/materials/advancedMaterials.program
trunk/plugins.cfg
trunk/src/DockedState.cpp
trunk/src/GameStateManager.cpp
trunk/src/OpcodeWrapper.cpp
trunk/src/OpcodeWrapper.h
trunk/src/OpenALSoundManager.cpp
trunk/src/OpenALSoundManager.h
trunk/src/Projectile.cpp
trunk/src/Projectile.h
trunk/src/Sector.cpp
trunk/src/Sector.h
trunk/src/SectorObjects.cpp
trunk/src/SectorObjects.h
trunk/src/Station.h
trunk/src/common.cpp
trunk/src/common.h
trunk/src/metaserver.cpp
trunk/src/metaserver.h
trunk/src/networkClient.cpp
trunk/src/networkClient.h
trunk/src/networkProtocol.cpp
trunk/src/networkProtocol.h
trunk/src/networkServer.cpp
trunk/src/networkServer.h
trunk/src/networkServerUser.cpp
trunk/src/networkServerUser.h
trunk/src/opengateserver.cpp
Added Paths:
-----------
trunk/data/materials/simpleshield.cg
trunk/data/materials/simpleshield.material
Removed Paths:
-------------
trunk/ogre.cfg
trunk/win32/ogsectorclient/ogre.cfg
Modified: trunk/configure.ac
===================================================================
--- trunk/configure.ac 2007-11-27 23:37:55 UTC (rev 872)
+++ trunk/configure.ac 2007-12-02 17:25:31 UTC (rev 873)
@@ -85,7 +85,7 @@
# TODO: fix this part
AC_CHECK_HEADER([asio.hpp],,
[
- echo "Can't find asio headers. Please install the asio development packages."
+ echo "Can't find asio headers-0.3.8. Please install the asio development packages."
echo "You can get them from http://sourceforge.net/projects/asio/"
exit 1
],[])
Modified: trunk/data/materials/advancedMaterials.material
===================================================================
--- trunk/data/materials/advancedMaterials.material 2007-11-27 23:37:55 UTC (rev 872)
+++ trunk/data/materials/advancedMaterials.material 2007-12-02 17:25:31 UTC (rev 873)
@@ -21,7 +21,6 @@
// be an issue
vertex_program_ref BasicVertexPrograms/AmbientOneTextureUnified
{
- param_named_auto worldViewProj worldviewproj_matrix
param_named_auto ambient ambient_light_colour
}
@@ -43,7 +42,6 @@
vertex_program_ref BumpMapVP
{
param_named_auto lightPosition light_position_object_space 0
- param_named_auto worldViewProj worldviewproj_matrix
}
// Fragment program
@@ -79,7 +77,6 @@
// be an issue
vertex_program_ref BasicVertexPrograms/AmbientOneTextureUnified
{
- param_named_auto worldViewProj worldviewproj_matrix
param_named ambient float4 1 1 1 1
}
scene_blend dest_colour zero
@@ -110,7 +107,6 @@
// be an issue
vertex_program_ref BasicVertexPrograms/AmbientOneTextureUnified
{
- param_named_auto worldViewProj worldviewproj_matrix
param_named_auto ambient ambient_light_colour
}
@@ -132,7 +128,6 @@
vertex_program_ref BumpMapVP
{
param_named_auto lightPosition light_position_object_space 0
- param_named_auto worldViewProj worldviewproj_matrix
}
// Base bump map
@@ -162,7 +157,6 @@
// be an issue
vertex_program_ref BasicVertexPrograms/AmbientOneTextureUnified
{
- param_named_auto worldViewProj worldviewproj_matrix
param_named ambient float4 1 1 1 1
}
scene_blend dest_colour zero
Modified: trunk/data/materials/advancedMaterials.program
===================================================================
--- trunk/data/materials/advancedMaterials.program 2007-11-27 23:37:55 UTC (rev 872)
+++ trunk/data/materials/advancedMaterials.program 2007-12-02 17:25:31 UTC (rev 873)
@@ -2,46 +2,37 @@
{
source Example_BumpMapping.cg
entry_point main_vp
- profiles vs_1_1 arbvp1
+ profiles arbvp1 vp20 vs_1_1
+ default_params
+ {
+ param_named_auto worldViewProj worldviewproj_matrix
+ }
}
-// Bump map fragment program, support for this is optional
-fragment_program BumpMapFP cg
-{
- source Example_BumpMapping.cg
- entry_point main_fp
- profiles vs_1_1 arbfp1 fp20
-}
-
// Bump map with specular vertex program, support for this is required
vertex_program BumpMapVPSpecular cg
{
source Example_BumpMapping.cg
entry_point specular_vp
- profiles vs_1_1 arbvp1
+ profiles arbvp1 vp20 vs_1_1
+ default_params
+ {
+ param_named_auto worldViewProj worldviewproj_matrix
+ }
}
-// Bump map fragment program, support for this is optional
-fragment_program BumpMapFPSpecular cg
-{
- source Example_BumpMapping.cg
- entry_point specular_fp
- profiles vs_1_1 arbfp1 fp20
-}
-
// A really basic ambient pass program, support for one texture coodinate set
vertex_program BasicVertexPrograms/AmbientOneTextureCG cg
{
source Example_Basic.cg
entry_point ambientOneTexture_vp
- profiles vs_1_1 arbvp1
+ profiles arbvp1 vp20 vs_1_1
default_params
{
param_named_auto worldViewProj worldviewproj_matrix
param_named_auto ambient ambient_light_colour
}
-
}
// A really basic ambient pass program, support for one texture coodinate set
@@ -49,7 +40,7 @@
{
source Example_Basic.hlsl
entry_point ambientOneTexture_vp
- target vs_1_1 arbvp1
+ target arbvp1 vp20 vs_1_1
default_params
{
@@ -73,4 +64,20 @@
delegate BasicVertexPrograms/AmbientOneTextureGLSL
delegate BasicVertexPrograms/AmbientOneTextureHLSL
delegate BasicVertexPrograms/AmbientOneTextureCG
+}
+
+// Bump map fragment program, support for this is optional
+fragment_program BumpMapFP cg
+{
+ source Example_BumpMapping.cg
+ entry_point main_fp
+ profiles arbfp1 fp20 ps_1_1
+}
+
+// Bump map fragment program, support for this is optional
+fragment_program BumpMapFPSpecular cg
+{
+ source Example_BumpMapping.cg
+ entry_point specular_fp
+ profiles arbfp1 fp20 ps_1_1
}
\ No newline at end of file
Added: trunk/data/materials/simpleshield.cg
===================================================================
--- trunk/data/materials/simpleshield.cg (rev 0)
+++ trunk/data/materials/simpleshield.cg 2007-12-02 17:25:31 UTC (rev 873)
@@ -0,0 +1,9 @@
+float4 main_fp( uniform float4 customParamColour,
+ uniform float time
+ ) : COLOR
+{
+ float4 outColor;
+ outColor = customParamColour;
+// outColor.w = customParamColour.w * ( 1 - time );
+ return outColor;
+}
Added: trunk/data/materials/simpleshield.material
===================================================================
--- trunk/data/materials/simpleshield.material (rev 0)
+++ trunk/data/materials/simpleshield.material 2007-12-02 17:25:31 UTC (rev 873)
@@ -0,0 +1,24 @@
+fragment_program shader_fp/simpleshield_cg cg
+{
+ source simpleshield.cg
+ entry_point main_fp
+ profiles arbfp1 ps_1_1
+}
+
+material simpleshield
+{
+ technique
+ {
+ pass
+ {
+ scene_blend alpha_blend
+ depth_check off
+ lighting off
+ fragment_program_ref shader_fp/simpleshield_cg
+ {
+ param_named_auto customParamColour custom 0
+ param_named_auto time time_0_x 1
+ }
+ }
+ }
+}
Deleted: trunk/ogre.cfg
===================================================================
--- trunk/ogre.cfg 2007-11-27 23:37:55 UTC (rev 872)
+++ trunk/ogre.cfg 2007-12-02 17:25:31 UTC (rev 873)
@@ -1,7 +0,0 @@
-Render System=OpenGL Rendering Subsystem
-
-[OpenGL Rendering Subsystem]
-FSAA=6
-Full Screen=No
-RTT Preferred Mode=FBO
-Video Mode=1024 x 768
Modified: trunk/plugins.cfg
===================================================================
--- trunk/plugins.cfg 2007-11-27 23:37:55 UTC (rev 872)
+++ trunk/plugins.cfg 2007-12-02 17:25:31 UTC (rev 873)
@@ -6,7 +6,5 @@
# Define D3D rendering implementation plugin
Plugin=RenderSystem_GL.so
Plugin=Plugin_ParticleFX.so
-Plugin=Plugin_BSPSceneManager.so
-Plugin=Plugin_OctreeSceneManager.so
Plugin=Plugin_CgProgramManager.so
Modified: trunk/src/DockedState.cpp
===================================================================
--- trunk/src/DockedState.cpp 2007-11-27 23:37:55 UTC (rev 872)
+++ trunk/src/DockedState.cpp 2007-12-02 17:25:31 UTC (rev 873)
@@ -129,12 +129,16 @@
exitToUndockedState_ = false;
quitAllStates_ = false;
+ std::cout << "soundManager->listener "<< std::endl;
if ( resources_->soundManager->listener() ){ resources_->soundManager->listener()->reset(); }
- if ( backgroundSound_ ) backgroundSound_->play();
+ std::cout << "backgroundSound_ "<< backgroundSound_ << std::endl;
+
+ backgroundSound_->play();
+ std::cout << "backgroundSound_ "<< std::endl;
}
void DockedState::exit(){
- if ( backgroundSound_ ) backgroundSound_->stop();
+ backgroundSound_->stop();
CEGUI::WindowManager::getSingleton().getWindow( (CEGUI::utf8*)"Config/BackButton" )->removeEvent(
CEGUI::PushButton::EventClicked );
Modified: trunk/src/GameStateManager.cpp
===================================================================
--- trunk/src/GameStateManager.cpp 2007-11-27 23:37:55 UTC (rev 872)
+++ trunk/src/GameStateManager.cpp 2007-12-02 17:25:31 UTC (rev 873)
@@ -20,6 +20,7 @@
#include "GameStateManager.h"
+#include <OgreGpuProgramManager.h>
#include <OgreRoot.h>
#include <OgreRenderWindow.h>
#include <OgreConfigFile.h>
@@ -335,7 +336,21 @@
resources_.ogreRoot->removeFrameListener( state );
}
+bool GameStateManager::initialiseBootstrap( bool dialog ){
+ resources_.ogreRoot = new Ogre::Root;
+ resources_.gameStateRoot = this;
+
+ if ( !initialiseOgreEngine_( dialog ) ) {
+ log_->fatal( "Cannot initialize ogre engine." );
+ return false;
+ }
+ initialiseBootstrapResources();
+ initLoadingVector();
+ return true;
+}
+
bool GameStateManager::initialiseBootstrapResources( ) {
+ log_->info( "load bootstrap resources." );
Ogre::ConfigFile cf; cf.load( "resources.cfg" );
// Go through all sections & settings in the file
@@ -362,16 +377,6 @@
return true;
}
-bool GameStateManager::initialiseBootstrap( bool dialog ){
- resources_.ogreRoot = new Ogre::Root;
- resources_.gameStateRoot = this;
-
- if ( !initialiseOgreEngine_( dialog ) ) return false;
- initialiseBootstrapResources();
- initLoadingVector();
- return true;
-}
-
void GameStateManager::initLoadingVector(){
loadResourcesVector_.push_back( std::pair< bool (GameStateManager::*)( ),
@@ -426,6 +431,13 @@
}
bool GameStateManager::checkRenderSystemCapabilities( ){
+
+ log_->info("checkRenderSystemCapabilities: Your card support the following shader syntax: ");
+ std::set< Ogre::String> syntaxCodes = Ogre::GpuProgramManager::getSingleton().getSupportedSyntax();
+ for ( std::set< Ogre::String>::iterator it = syntaxCodes.begin(); it != syntaxCodes.end(); it ++ ){
+ log_->info( *it );
+ }
+
const Ogre::RenderSystemCapabilities * caps = ResourceManager::getSingleton().ogreRoot->getRenderSystem()->getCapabilities();
if ( !caps->hasCapability( Ogre::RSC_VERTEX_PROGRAM ) ) {
@@ -514,6 +526,10 @@
}
bool GameStateManager::initialiseOgreEngine_( bool dialog ){
+ if ( !fileExist( "ogre.cfg" ) ) {
+ dialog = true;
+ }
+
if ( !dialog ){
resources_.ogreRoot->restoreConfig();
resources_.renderWindow = resources_.ogreRoot->initialise( true, "OpenGate" );
@@ -522,8 +538,6 @@
if ( resources_.ogreRoot->showConfigDialog() ) {
resources_.renderWindow = resources_.ogreRoot->initialise( true, "OpenGate" );
return true;
- } else {
- return false;
}
}
return false;
Modified: trunk/src/OpcodeWrapper.cpp
===================================================================
--- trunk/src/OpcodeWrapper.cpp 2007-11-27 23:37:55 UTC (rev 872)
+++ trunk/src/OpcodeWrapper.cpp 2007-12-02 17:25:31 UTC (rev 873)
@@ -58,7 +58,6 @@
}
bool OpcodeCollisionDetection::update( Ogre::Real elapsedTime ){
- collideInSectorContext_->collide( 0.0 );
collideInSectorContext_->collide( elapsedTime );
OgreOpcode::CollisionReporter report( collideInSectorContext_->getCollisionReport() );
@@ -105,52 +104,49 @@
}
OgreOpcode::CollisionObject * OpcodeCollisionDetection::createObject( SectorObject * obj ){
+ return createObject( obj->entity(), obj, "SectorObject" );
+}
- OgreOpcode::EntityCollisionShape * collShape = OgreOpcode::CollisionManager::getSingletonPtr()
- ->createEntityCollisionShape( obj->name() + "/CollShape" );
- collShape->load( obj->entity() );
+void OpcodeCollisionDetection::destroyObject( OgreOpcode::CollisionObject * obj ){
- OgreOpcode::CollisionObject * collObj = collideInSectorContext_->createObject( obj->name() + "/CollObj" );
- collObj->setCollClass( OgreOpcode::CollisionManager::getSingletonPtr()->queryCollClass( "SectorObject" ) );
- collObj->setShape( collShape );
+ OgreOpcode::ICollisionShape *shape = obj->getShape();
+ OgreOpcode::CollisionManager::getSingletonPtr()->detachShape(shape);
+ OgreOpcode::CollisionManager::getSingletonPtr()->destroyShape(shape);
- collideInSectorContext_->addObject( collObj );
- collObj->setClientData( obj );
- return collObj;
-}
-void OpcodeCollisionDetection::destroyObject( OgreOpcode::CollisionObject * obj ){
collideInSectorContext_->destroyObject( obj );
- OgreOpcode::CollisionManager::getSingletonPtr()->destroyShape( obj->getShape() );
+ // OgreOpcode::CollisionManager::getSingletonPtr()->destroyShape( obj->getShape() );
}
bool OpcodeCollisionDetection::checkCollideRay( BaseObject * obj, const Ogre::Ray & ray, double rayLength){
- OgreOpcode::CollisionPair ** rayPickReport;
- uint nColl = collideInSectorContext_->rayCheck( ray, rayLength, OgreOpcode::COLLTYPE_EXACT,
- OgreOpcode::COLLTYPE_ALWAYS_EXACT, rayPickReport );
-
-// std::cout << "checkCollideRay: " << " " << rayLength << " " << nColl <<std::endl;
-
- for ( uint i = 0; i < nColl; i ++ ){
- OgreOpcode::CollisionObject* col1 = rayPickReport[ i ]->this_object;
- OgreOpcode::CollisionObject* col2 = rayPickReport[ i ]->other_object;
+ if ( !obj->isSetDestroyRequest() ){
+ OgreOpcode::CollisionPair ** rayPickReport;
+ uint nColl = collideInSectorContext_->rayCheck( ray, rayLength, OgreOpcode::COLLTYPE_EXACT,
+ OgreOpcode::COLLTYPE_ALWAYS_EXACT, rayPickReport );
-// std::cout << "checkCollideRay: " << i << " "
-// << static_cast< BaseObject * >( col1->getClientData() )->name() << "<->"
-// << static_cast< BaseObject * >( col2->getClientData() )->name() << std::endl;
-
- if ( obj->getTypeID() == PROJECTILE_RTTI ){
- if ( dynamic_cast< Projectile * >( obj )->parent() != static_cast< BaseObject * >( col1->getClientData() ) ){
- obj->mainNode()->setPosition( rayPickReport[ i ]->contact );
+ // std::cout << "checkCollideRay: " << " " << rayLength << " " << nColl <<std::endl;
+
+ for ( uint i = 0; i < nColl; i ++ ){
+ OgreOpcode::CollisionObject* col1 = rayPickReport[ i ]->this_object;
+ OgreOpcode::CollisionObject* col2 = rayPickReport[ i ]->other_object;
+
+ // std::cout << "checkCollideRay: " << i << " "
+ // << static_cast< BaseObject * >( col1->getClientData() )->name() << "<->"
+ // << static_cast< BaseObject * >( col2->getClientData() )->name() << std::endl;
+
+ if ( obj->getTypeID() == PROJECTILE_RTTI ){
+ if ( dynamic_cast< Projectile * >( obj )->parent() != static_cast< BaseObject * >( col1->getClientData() ) ){
+ obj->mainNode()->setPosition( rayPickReport[ i ]->contact );
+ obj->collide( static_cast< BaseObject * >( col2->getClientData() ) );
+ static_cast< BaseObject * >( col1->getClientData() )->collide( obj );
+ return true;
+ }
+ } else if ( obj != col1->getClientData() ){
obj->collide( static_cast< BaseObject * >( col2->getClientData() ) );
static_cast< BaseObject * >( col1->getClientData() )->collide( obj );
- return true;
}
- } else if ( obj != col1->getClientData() ){
- obj->collide( static_cast< BaseObject * >( col2->getClientData() ) );
- static_cast< BaseObject * >( col1->getClientData() )->collide( obj );
- }
- }
+ }
+ }
return false;
}
Modified: trunk/src/OpcodeWrapper.h
===================================================================
--- trunk/src/OpcodeWrapper.h 2007-11-27 23:37:55 UTC (rev 872)
+++ trunk/src/OpcodeWrapper.h 2007-12-02 17:25:31 UTC (rev 873)
@@ -43,16 +43,13 @@
bool update( Ogre::Real elapsedTime );
+ OgreOpcode::CollisionObject * createObject( Ogre::Entity * entity, BaseObject * obj, const std::string & collClass );
OgreOpcode::CollisionObject * createObject( SectorObject * obj );
- OgreOpcode::CollisionObject * createObject( Ogre::Entity * entity, BaseObject * obj, const std::string & collClass = "SectorObject" );
-
void destroyObject( OgreOpcode::CollisionObject * obj );
- bool checkCollideRay( BaseObject * obj, const Ogre::Ray & bulletRay, double rayLength );
+ bool checkCollideRay( BaseObject * obj, const Ogre::Ray & ray, double rayLength );
- OgreOpcode::CollisionContext * collideInSectorContext(){ return collideInSectorContext_; }
-
void changeCollClass( OgreOpcode::CollisionObject * collObj, const std::string & collClass );
static OpcodeCollisionDetection & getSingleton( );
Modified: trunk/src/OpenALSoundManager.cpp
===================================================================
--- trunk/src/OpenALSoundManager.cpp 2007-11-27 23:37:55 UTC (rev 872)
+++ trunk/src/OpenALSoundManager.cpp 2007-12-02 17:25:31 UTC (rev 873)
@@ -187,9 +187,7 @@
return true;
}
-bool OpenALSoundSource::setDirection( float x, float y, float z ){
- return setDirection( Ogre::Vector3( x, y, z ) ); }
-
+bool OpenALSoundSource::setDirection( float x, float y, float z ){ return setDirection( Ogre::Vector3( x, y, z ) ); }
bool OpenALSoundSource::setDirection( const Ogre::Vector3 & dir ){
direction_ = dir;
alSourcefv( source_, AL_DIRECTION, direction_.ptr() );
@@ -227,7 +225,6 @@
return false;
}
-
OpenALOggStreamSource::OpenALOggStreamSource( OpenALSoundManager * soundMgr, const std::string & name)
: OpenALSoundSource( soundMgr, name ){
}
@@ -392,7 +389,7 @@
return true;
}
-OpenALListener::OpenALListener( OpenALSoundManager * soundMgr ) : soundMgr_( soundMgr ){
+ OpenALListener::OpenALListener( OpenALSoundManager * soundMgr, bool dummy ) : soundMgr_( soundMgr ), dummy_( dummy ){
reset();
}
@@ -407,18 +404,22 @@
bool OpenALListener::setPosition( float x, float y, float z ){ return setPosition( Ogre::Vector3( x, y, z ) ); }
bool OpenALListener::setPosition( const Ogre::Vector3 & pos){
- position_ = pos;
- alListenerfv( AL_POSITION, position_.ptr() );
- if ( soundMgr_->checkOpenALError( "OpenALListener::alListenerfv:AL_POSITION" ) ) return false;
+ if ( !dummy_ ){
+ position_ = pos;
+ alListenerfv( AL_POSITION, position_.ptr() );
+ if ( soundMgr_->checkOpenALError( "OpenALListener::alListenerfv:AL_POSITION" ) ) return false;
+ }
return true;
}
bool OpenALListener::setVelocity( float x, float y, float z ){ return setVelocity( Ogre::Vector3( x, y, z ) ); }
bool OpenALListener::setVelocity( const Ogre::Vector3 & vel){
- velocity_ = vel;
- alListenerfv( AL_VELOCITY, position_.ptr() );
- if ( soundMgr_->checkOpenALError( "OpenALListener::alListenerfv:AL_VELOCITY" ) ) return false;
+ if ( !dummy_ ){
+ velocity_ = vel;
+ alListenerfv( AL_VELOCITY, position_.ptr() );
+ if ( soundMgr_->checkOpenALError( "OpenALListener::alListenerfv:AL_VELOCITY" ) ) return false;
+ }
return true;
}
@@ -426,12 +427,14 @@
return setOrientation( Ogre::Vector3( xf, yf, zf ), Ogre::Vector3( xu, yu, zu ) ); }
bool OpenALListener::setOrientation( const Ogre::Vector3 & front, const Ogre::Vector3 & up){
- directionFront_ = front; directionUp_ = up;
- orientation_[ 0 ] = front[ 0 ]; orientation_[ 1 ] = front[ 1 ]; orientation_[ 2 ] = front[ 2 ];
- orientation_[ 3 ] = up[ 0 ]; orientation_[ 4 ] = up[ 1 ]; orientation_[ 5 ] = up[ 2 ];
-
- alListenerfv( AL_ORIENTATION, orientation_ );
- if ( soundMgr_->checkOpenALError( "OpenALListener::alListenerfv:AL_ORIENTATION" ) ) return false;
+ if ( !dummy_ ){
+ directionFront_ = front; directionUp_ = up;
+ orientation_[ 0 ] = front[ 0 ]; orientation_[ 1 ] = front[ 1 ]; orientation_[ 2 ] = front[ 2 ];
+ orientation_[ 3 ] = up[ 0 ]; orientation_[ 4 ] = up[ 1 ]; orientation_[ 5 ] = up[ 2 ];
+
+ alListenerfv( AL_ORIENTATION, orientation_ );
+ if ( soundMgr_->checkOpenALError( "OpenALListener::alListenerfv:AL_ORIENTATION" ) ) return false;
+ }
return true;
}
@@ -460,11 +463,13 @@
if ( listener_ ) delete listener_;
- ALCcontext *context = alcGetCurrentContext();
- ALCdevice *device = alcGetContextsDevice( context );
- alcMakeContextCurrent( NULL );
- alcDestroyContext( context );
- alcCloseDevice( device );
+ if ( haveSoundDevice_ ){
+ ALCcontext *context = alcGetCurrentContext();
+ ALCdevice *device = alcGetContextsDevice( context );
+ alcMakeContextCurrent( NULL );
+ alcDestroyContext( context );
+ alcCloseDevice( device );
+ }
}
bool OpenALSoundManager::frameStarted( const Ogre::FrameEvent & evt ){
@@ -535,26 +540,25 @@
if ( !device ){
log_->warn( "No sound device detected." );
haveSoundDevice_ = false;
- return false;
}
- log_->info( "Choosing: " + Ogre::String( alcGetString( device, ALC_DEVICE_SPECIFIER) ) );
- ALCcontext * context = alcCreateContext( device, NULL );
- if ( !context ){
- log_->warn( "Can not create sound context." );
- return false;
- }
+ if ( haveSoundDevice_ ){
+ log_->info( "Choosing: " + Ogre::String( alcGetString( device, ALC_DEVICE_SPECIFIER) ) );
+ ALCcontext * context = alcCreateContext( device, NULL );
- alcMakeContextCurrent( context );
- if ( checkOpenALError( "OpenALSoundManager::init::alcMakeContextCurrent" ) ) return false;
+ if ( !context ){
+ log_->warn( "Can not create sound context." );
+ return false;
+ }
- maxSources_ = getMaxSources_();
- listener_ = new OpenALListener( this );
- if ( !context ){
- log_->warn( "Can not create sound context." );
- return false;
+ alcMakeContextCurrent( context );
+ if ( checkOpenALError( "OpenALSoundManager::init::alcMakeContextCurrent" ) ) return false;
+
+ maxSources_ = getMaxSources_();
}
+ listener_ = new OpenALListener( this, !haveSoundDevice_ );
+
return true;
}
@@ -600,23 +604,25 @@
bool loop, bool stream ){
OpenALSoundSource * sound = NULL;
+ if ( mapSoundSources_.count( name ) ){
+ log_->warn( "Sound with name: " + name + " allready registered." );
+ mapSoundSources_[ name ];
+ }
+
if ( haveSoundDevice_ ){
- if ( mapSoundSources_.count( name ) ){
- log_->warn( "Sound with name: " + name + " allready registered." );
- return NULL;
- }
-
if ( stream ){
log_->info( "create sound stream: " + name );
sound = new OpenALOggStreamSource( this, name );
} else {
sound = new OpenALSoundSource( this, name );
}
+ } else {
+ sound = new OpenALSoundSourceDummy( this, name );
+ }
- sound->open( fileName );
- sound->showInfos( );
- mapSoundSources_[ name ] = sound;
- }
+ sound->open( fileName );
+ sound->showInfos( );
+ mapSoundSources_[ name ] = sound;
return sound;
}
Modified: trunk/src/OpenALSoundManager.h
===================================================================
--- trunk/src/OpenALSoundManager.h 2007-11-27 23:37:55 UTC (rev 872)
+++ trunk/src/OpenALSoundManager.h 2007-12-02 17:25:31 UTC (rev 873)
@@ -60,35 +60,33 @@
virtual void showInfos();
- virtual bool update(){
- return true;
- }
+ virtual bool update(){ return true; }
//** check if the source is playing
bool isPlaying();
bool setPosition( float x, float y, float z );
- bool setPosition( const Ogre::Vector3 & pos );
+ virtual bool setPosition( const Ogre::Vector3 & pos );
bool setVelocity( float x, float y, float z );
- bool setVelocity( const Ogre::Vector3 & vel);
+ virtual bool setVelocity( const Ogre::Vector3 & vel);
bool setDirection( float x, float y, float z );
- bool setDirection( const Ogre::Vector3 & dir);
+ virtual bool setDirection( const Ogre::Vector3 & dir);
uint * refSound( ){ return &source_; }
std::string name () const { return name_; }
- bool setRelative( bool rel );
+ virtual bool setRelative( bool rel );
- bool setRolloff( float rolloff );
+ virtual bool setRolloff( float rolloff );
- bool setGain( float gain );
+ virtual bool setGain( float gain );
- bool setPitch( float pitch );
+ virtual bool setPitch( float pitch );
- bool setLoop( bool loop );
+ virtual bool setLoop( bool loop );
protected:
@@ -104,7 +102,33 @@
int format_;
int size_;
float freq_;
+};
+class OpenALSoundSourceDummy : public OpenALSoundSource {
+public:
+ OpenALSoundSourceDummy( OpenALSoundManager * soundMgr, const std::string & name)
+ : OpenALSoundSource( soundMgr, name ){ }
+ virtual ~OpenALSoundSourceDummy(){ };
+
+ virtual bool play(){ return true; }
+ virtual bool stop(){ return true; }
+
+ virtual bool release(){ return true; }
+ virtual bool open( const std::string & fileName ){ return true; }
+ virtual void showInfos(){ LogManager::getSingleton().info( "Audio info: dummy " + name_ + " installed " ); }
+
+ virtual bool update(){ return true; }
+ virtual bool setPosition( const Ogre::Vector3 & pos ){ return true; }
+ virtual bool setVelocity( const Ogre::Vector3 & vel ){ return true; }
+ virtual bool setDirection( const Ogre::Vector3 & dir ){ return true; }
+ virtual bool setLoop( bool loop ) { return true; }
+ virtual bool setGain( float gain ) { return true; }
+ virtual bool setPitch( float pitch ) { return true; }
+ virtual bool setRelative( bool rel ) { return true; }
+ virtual bool setRolloff( float rolloff ){ return true; }
+
+protected:
+
};
//! Based on: http://www.devmaster.net/articles/openal-tutorials/lesson8.php
@@ -151,7 +175,7 @@
/*! OpenALListener, there is just one. YOU! respectivly your avatar. */
class OpenALListener{
public:
- OpenALListener( OpenALSoundManager * soundMgr );
+ OpenALListener( OpenALSoundManager * soundMgr, bool dummy = false);
~OpenALListener();
bool setPosition( float x, float y, float z );
@@ -172,6 +196,7 @@
Ogre::Vector3 directionFront_;
Ogre::Vector3 directionUp_;
float orientation_[ 6 ];
+ bool dummy_;
};
Modified: trunk/src/Projectile.cpp
===================================================================
--- trunk/src/Projectile.cpp 2007-11-27 23:37:55 UTC (rev 872)
+++ trunk/src/Projectile.cpp 2007-12-02 17:25:31 UTC (rev 873)
@@ -123,7 +123,7 @@
} else {
trail_ = sceneMgr_->createRibbonTrail( bulletName + "_RibbonTrail");
trail_->setMaterialName( "BeamGreen" );
- trail_->setTrailLength( maxRange_ / 2.0 );
+ trail_->setTrailLength( maxRange_ );
trail_->setWidthChange( 0, 2.0 );
trail_->setMaxChainElements( 1000 );
trail_->setInitialWidth( 0, 1.0 );
Modified: trunk/src/Projectile.h
===================================================================
--- trunk/src/Projectile.h 2007-11-27 23:37:55 UTC (rev 872)
+++ trunk/src/Projectile.h 2007-12-02 17:25:31 UTC (rev 873)
@@ -56,6 +56,8 @@
Gun * gun() const { return gun_; }
+ virtual void destroyRequest(){}
+
protected:
BaseObject * parent_;
Modified: trunk/src/Sector.cpp
===================================================================
--- trunk/src/Sector.cpp 2007-11-27 23:37:55 UTC (rev 872)
+++ trunk/src/Sector.cpp 2007-12-02 17:25:31 UTC (rev 873)
@@ -152,7 +152,7 @@
for ( std::map< long, SectorObjectMoveable * >::iterator it = movableObjects_.begin(); it != movableObjects_.end();){
// log_->info( "Destructing: " + it->second->name() );
- destructMoveableObject( (it++)->second );
+ destructMoveableObject_( (it++)->second );
// log_->info( "done: " );
}
@@ -444,25 +444,29 @@
for ( std::map< long, SectorObjectMoveable * >::iterator it = movableObjects_.begin(); it != movableObjects_.end(); ){
- if ( !it->second->update( elapsedTime ) ) { //** object died;
- if ( it->second == avatar_ ) {
- if ( avatarDeathSequenceTime_ == 0.0 ){
- avatarDeathSequenceTime_ = 1.0;
- } else {
- avatarDeathSequenceTime_ -= elapsedTime;
- if ( avatarDeathSequenceTime_ < 0 ){
- avatarDeathSequenceTime_ = 0.0;
- listener_->avatarDeathSequence( false );
+ if ( !it->second ){
+ log_->info( "update request for invalid object id: " + toStr( it->first ) );
+ } else {
+ if ( !it->second->update( elapsedTime ) ) { //** object died;
+ if ( it->second == avatar_ ) {
+ if ( avatarDeathSequenceTime_ == 0.0 ){
+ avatarDeathSequenceTime_ = 1.0;
+ } else {
+ avatarDeathSequenceTime_ -= elapsedTime;
+ if ( avatarDeathSequenceTime_ < 0 ){
+ avatarDeathSequenceTime_ = 0.0;
+ listener_->avatarDeathSequence( false );
+ }
}
+ it++;
+ } else { //** died object is not avatar;
+ log_->info( "Destructing: " + it->second->name() );
+ destructSectorObject_( (it++)->second );
+ log_->info( "done: " );
}
- it++;
- } else { //** died object is not avatar;
- log_->info( "Destructing: " + it->second->name() );
- destructSectorObject( (it++)->second );
- log_->info( "done: " );
- }
- } else ++it;
- }
+ } else ++it;
+ }
+ }
}
void Sector::avatarDied( ){
@@ -518,78 +522,87 @@
return obj;
}
-void Sector::destructSectorObject( SectorObject * obj ){
- selectNextTarget( obj );
- sectorObjects_.erase( obj );
+void Sector::destructSectorObject_( SectorObject * obj ){
+ if ( obj ){
+ selectNextTarget( obj );
+ sectorObjects_.erase( obj );
- if ( obj->isOnRadar() && radar_ ){
- Ogre::Overlay * radar = Ogre::OverlayManager::getSingleton().getByName( "Radar" );
- Ogre::OverlayContainer * radarMap = radar->getChild( "Radar/Map" );
- radarMap->removeChild( obj->dotA()->getName() );
- radarMap->removeChild( obj->dotB()->getName() );
- }
-
- for ( std::map< long, SectorObjectMoveableAi * >::iterator it = localAi...
[truncated message content] |
|
From: <eg...@us...> - 2007-12-08 12:40:10
|
Revision: 878
http://opengate.svn.sourceforge.net/opengate/?rev=878&view=rev
Author: egore
Date: 2007-12-08 04:40:12 -0800 (Sat, 08 Dec 2007)
Log Message:
-----------
* data/Makefile.am, configure.ac: add some parts of the data to the
build system
Modified Paths:
--------------
trunk/ChangeLog
trunk/Makefile.am
trunk/configure.ac
trunk/src/Makefile.am
Added Paths:
-----------
trunk/data/Makefile.am
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2007-12-03 20:34:06 UTC (rev 877)
+++ trunk/ChangeLog 2007-12-08 12:40:12 UTC (rev 878)
@@ -1,3 +1,7 @@
+2007-12-08 Christoph Brill <ego...@eg...>
+ * data/Makefile.am, configure.ac: add some parts of the data to the
+ build system
+
2007-11-18 Christoph Brill <ego...@eg...>
* configure.ac: add some missing things gathered from running
autoscan, drop externals stuff
Modified: trunk/Makefile.am
===================================================================
--- trunk/Makefile.am 2007-12-03 20:34:06 UTC (rev 877)
+++ trunk/Makefile.am 2007-12-08 12:40:12 UTC (rev 878)
@@ -1,5 +1,8 @@
-SUBDIRS = src
+AUTOMAKE_OPTIONS = dist-bzip2
+SUBDIRS = src \
+ data
+
distclean: maintainer-clean
rm -rf *~
rm -rf autom4te.cache
Modified: trunk/configure.ac
===================================================================
--- trunk/configure.ac 2007-12-03 20:34:06 UTC (rev 877)
+++ trunk/configure.ac 2007-12-08 12:40:12 UTC (rev 878)
@@ -21,7 +21,7 @@
AC_FUNC_STAT
AC_FUNC_STRTOD
AC_HEADER_STDBOOL
-AC_PROG_RANLIB
+#AC_PROG_RANLIB
AC_STRUCT_TM
AC_TYPE_SIGNAL
AC_TYPE_SIZE_T
@@ -92,6 +92,7 @@
AC_OUTPUT([
Makefile
+data/Makefile
src/Makefile
])
Added: trunk/data/Makefile.am
===================================================================
--- trunk/data/Makefile.am (rev 0)
+++ trunk/data/Makefile.am 2007-12-08 12:40:12 UTC (rev 878)
@@ -0,0 +1,382 @@
+
+asteroids_DATA = \
+ asteroids/asteroid.material\
+ asteroids/asteroid.png \
+ asteroids/asteroid01.mesh \
+ asteroids/asteroidBump.png \
+ asteroids/ice_oval.material \
+ asteroids/ice_oval.png \
+ asteroids/ice_oval_6.mesh \
+ asteroids/ice_oval_7.mesh \
+ asteroids/ice_oval_8.mesh \
+ asteroids/ice_oval_9.mesh \
+ asteroids/ice_oval_10.mesh \
+ asteroids/normal_oval.material \
+ asteroids/normal_oval.png \
+ asteroids/normal_oval_1.mesh \
+ asteroids/normal_oval_2.mesh \
+ asteroids/normal_oval_3.mesh \
+ asteroids/normal_oval_4.mesh \
+ asteroids/normal_oval_5.mesh
+
+EXTRA_DIST = \
+ $(asteroids_DATA)\
+ $(capacitors_DATA) \
+ $(commodities_DATA) \
+ $(ecms_DATA) \
+ $(engines_DATA) \
+ $(power_plants_DATA) \
+ $(rankings_DATA) \
+ $(radars_DATA) \
+ $(guns_DATA) \
+ $(shields_DATA) \
+ $(stations_DATA)
+
+asteroidsdir = \
+ $(pkgdatadir)/asteroids
+
+capacitors_DATA = \
+ capacitors/alembic.xml\
+ capacitors/alembic_big.png \
+ capacitors/alembic_small.png \
+ capacitors/deepol.xml \
+ capacitors/deepol_big.png \
+ capacitors/deepol_small.png \
+ capacitors/germ.xml \
+ capacitors/germ_big.png \
+ capacitors/germ_small.png \
+ capacitors/jar.xml \
+ capacitors/jar_big.png \
+ capacitors/jar_small.png \
+ capacitors/lifeline.xml \
+ capacitors/lifeline_big.png \
+ capacitors/lifeline_small.png \
+ capacitors/Makefile.am \
+ capacitors/mantra.xml \
+ capacitors/mantra_big.png \
+ capacitors/mantra_small.png \
+ capacitors/outlet.xml \
+ capacitors/outlet_big.png \
+ capacitors/outlet_small.png \
+ capacitors/quadro.xml \
+ capacitors/quadro_big.png \
+ capacitors/quadro_small.png \
+ capacitors/sponge.xml \
+ capacitors/sponge_big.png \
+ capacitors/sponge_small.png \
+ capacitors/summoner.xml \
+ capacitors/summoner_big.png \
+ capacitors/summoner_small.png \
+ capacitors/tank.xml \
+ capacitors/tank_big.png \
+ capacitors/tank_small.png \
+ capacitors/t-c-15.xml \
+ capacitors/t-c-15_big.png \
+ capacitors/t-c-15_small.png
+
+commodities_DATA = \
+ commodities/aluminium.xml\
+ commodities/aluminium_big.png \
+ commodities/aluminium_small.png \
+ commodities/ammunition.xml \
+ commodities/ammunition_big.png \
+ commodities/ammunition_small.png \
+ commodities/antimony.xml \
+ commodities/antimony_big.png \
+ commodities/antimony_small.png \
+ commodities/armor.xml \
+ commodities/armor_big.png \
+ commodities/armor_small.png \
+ commodities/barium.png \
+ commodities/barium.xml \
+ commodities/boron.xml \
+ commodities/boron_big.png \
+ commodities/boron_small.png \
+ commodities/cesium.xml \
+ commodities/cesium_big.png \
+ commodities/cesium_small.png \
+ commodities/chemicals.xml \
+ commodities/chemicals_big.png \
+ commodities/chemicals_small.png \
+ commodities/chromium.xml \
+ commodities/chromium_big.png \
+ commodities/chromium_small.png \
+ commodities/copper.xml \
+ commodities/copper_big.png \
+ commodities/copper_small.png \
+ commodities/cpus.xml \
+ commodities/cpus_big.png \
+ commodities/cpus_small.png \
+ commodities/electronics.xml \
+ commodities/electronics_big.png \
+ commodities/electronics_small.png \
+ commodities/fiber_optics.xml \
+ commodities/fiber_optics_big.png \
+ commodities/fiber_optics_small.png \
+ commodities/fuel_cells.xml \
+ commodities/fuel_cells_big.png \
+ commodities/fuel_cells_small.png \
+ commodities/gold.xml \
+ commodities/gold_big.png \
+ commodities/gold_small.png \
+ commodities/helium.xml \
+ commodities/helium_big.png \
+ commodities/helium_small.png \
+ commodities/ice.xml \
+ commodities/ice_big.png \
+ commodities/ice_small.png \
+ commodities/iron.xml \
+ commodities/iron_big.png \
+ commodities/iron_small.png \
+ commodities/laser_components.xml \
+ commodities/laser_components_big.png \
+ commodities/laser_components_small.png \
+ commodities/lumber.xml \
+ commodities/lumber_big.png \
+ commodities/lumber_small.png \
+ commodities/magnetic_components.png \
+ commodities/magnetic_components.xml \
+ commodities/manufactured_foods.xml \
+ commodities/manufactured_foods_big.png \
+ commodities/manufactured_foods_small.png \
+ commodities/medical_supplies.xml \
+ commodities/medical_supplies_big.png \
+ commodities/medical_supplies_small.png \
+ commodities/nitrogen.xml \
+ commodities/nitrogen_big.png \
+ commodities/nitrogen_small.png \
+ commodities/octavia_light.xml \
+ commodities/octavia_light_big.png \
+ commodities/octavia_light_small.png \
+ commodities/organic_foods.xml \
+ commodities/organic_foods_big.png \
+ commodities/organic_foods_small.png \
+ commodities/plutonium.xml \
+ commodities/plutonium_big.png \
+ commodities/plutonium_small.png \
+ commodities/power_converters.xml \
+ commodities/power_converters_big.png \
+ commodities/power_converters_small.png \
+ commodities/prostheses.xml \
+ commodities/prostheses_big.png \
+ commodities/prostheses_small.png \
+ commodities/ram.xml \
+ commodities/ram_big.png \
+ commodities/ram_small.png \
+ commodities/rubber.xml \
+ commodities/rubber_big.png \
+ commodities/rubber_small.png \
+ commodities/squadrok_biomass.xml \
+ commodities/squadrok_biomass_big.png \
+ commodities/squadrok_biomass_small.png \
+ commodities/tauseti_flashback.xml \
+ commodities/tauseti_flashback_big.png \
+ commodities/tauseti_flashback_small.png \
+ commodities/unsigned_box.xml \
+ commodities/unsigned_box_big.png \
+ commodities/unsigned_box_small.png \
+ commodities/uranium.xml \
+ commodities/uranium_big.png \
+ commodities/uranium_small.png \
+ commodities/water.xml \
+ commodities/water_big.png \
+ commodities/water_small.png \
+ commodities/xenon.xml \
+ commodities/xenon_big.png \
+ commodities/xenon_small.png \
+ commodities/zinc.xml \
+ commodities/zinc_big.png \
+ commodities/zinc_small.png
+
+commoditiesdir = \
+ $(pkgdatadir)/commodities
+
+capacitorsdir = \
+ $(pkgdatadir)/capacitors
+
+ecms_DATA = \
+ ecms/ghost.xml
+
+engines_DATA = \
+ engines/money.xml\
+ engines/money_big.png \
+ engines/money_small.png \
+ engines/t-e-15.xml \
+ engines/t-e-15_big.png \
+ engines/t-e-15_small.png
+
+power_plants_DATA = \
+ power_plants/contender.xml\
+ power_plants/contender_big.png \
+ power_plants/contender_small.png \
+ power_plants/contender_xl.xml \
+ power_plants/contender_xl_big.png \
+ power_plants/contender_xl_small.png \
+ power_plants/contender_xpr.xml \
+ power_plants/contender_xpr_big.png \
+ power_plants/contender_xpr_small.png \
+ power_plants/gatherer.xml \
+ power_plants/gatherer_big.png \
+ power_plants/gatherer_small.png \
+ power_plants/spud.xml \
+ power_plants/spud_big.png \
+ power_plants/spud_small.png \
+ power_plants/t-p-16.xml \
+ power_plants/t-p-16_big.png \
+ power_plants/t-p-16_small.png
+
+rankings_DATA = \
+ rankings/00.png\
+ rankings/01.png \
+ rankings/02.png \
+ rankings/03.png \
+ rankings/04.png \
+ rankings/05.png \
+ rankings/06.png \
+ rankings/07.png \
+ rankings/08.png \
+ rankings/09.png \
+ rankings/10.png \
+ rankings/11.png \
+ rankings/12.png \
+ rankings/13.png \
+ rankings/14.png \
+ rankings/15.png \
+ rankings/16.png \
+ rankings/17.png \
+ rankings/18.png \
+ rankings/19.png \
+ rankings/20.png \
+ rankings/21.png \
+ rankings/22.png \
+ rankings/23.png \
+ rankings/24.png \
+ rankings/25.png \
+ rankings/26.png \
+ rankings/27.png \
+ rankings/28.png \
+ rankings/29.png \
+ rankings/30.png \
+ rankings/31.png \
+ rankings/32.png \
+ rankings/33.png \
+ rankings/34.png \
+ rankings/35.png \
+ rankings/36.png \
+ rankings/37.png \
+ rankings/38.png \
+ rankings/39.png \
+ rankings/40.png \
+ rankings/41.png \
+ rankings/42.png \
+ rankings/43.png \
+ rankings/44.png \
+ rankings/45.png \
+ rankings/46.png \
+ rankings/47.png \
+ rankings/48.png \
+ rankings/49.png \
+ rankings/50.png
+
+radars_DATA = \
+ radars/chime.xml\
+ radars/chime_big.png \
+ radars/chime_small.png \
+ radars/cyclops.xml \
+ radars/cyclops_big.png \
+ radars/cyclops_small.png \
+ radars/hall_monitor.xml \
+ radars/hall_monitor_big.png \
+ radars/hall_monitor_small.png \
+ radars/knocker.xml \
+ radars/knocker_big.png \
+ radars/knocker_small.png \
+ radars/night_watchman.xml \
+ radars/night_watchman_big.png \
+ radars/night_watchman_small.png \
+ radars/outlook.xml \
+ radars/outlook_big.png \
+ radars/outlook_small.png \
+ radars/t-r-9.xml \
+ radars/t-r-9_big.png \
+ radars/t-r-9_small.png
+
+guns_DATA = \
+ guns/bender.xml\
+ guns/bender_big.png \
+ guns/bender_small.png \
+ guns/duster.xml \
+ guns/duster_big.png \
+ guns/duster_small.png \
+ guns/excavator.xml \
+ guns/excavator_big.png \
+ guns/excavator_small.png \
+ guns/liar.xml \
+ guns/liar_big.png \
+ guns/liar_small.png \
+ guns/t-g-28.xml \
+ guns/t-g-28_big.png \
+ guns/t-g-28_small.png
+
+shields_DATA = \
+ shields/alpaa.xml\
+ shields/alpaa_big.png \
+ shields/alpaa_small.png \
+ shields/flatiron.xml \
+ shields/flatiron_big.png \
+ shields/flatiron_small.png \
+ shields/himelea.xml \
+ shields/himelea_big.png \
+ shields/himelea_small.png \
+ shields/kydango.xml \
+ shields/kydango_big.png \
+ shields/kydango_small.png \
+ shields/pod.xml \
+ shields/pod_big.png \
+ shields/pod_small.png \
+ shields/shelter.xml \
+ shields/shelter_big.png \
+ shields/shelter_small.png \
+ shields/t-s-13.xml \
+ shields/t-s-13_big.png \
+ shields/t-s-13_small.png
+
+stations_DATA = \
+ stations/octavius_core.xml\
+ stations/tauseti_core.xml \
+ stations/TausetiStationBackground.png \
+ stations/TausetiStationBackground.xcf \
+ stations/TausetiStationBackgroundBM.png \
+ stations/TausetiStationBackgroundPlain.png \
+ stations/TausetiStationWindow.png \
+ stations/TausetiStationWindow.xcf \
+ stations/TausetiStationWindowBM.png \
+ stations/tauseti_wake.mesh \
+ stations/tauseti_wake.xml
+
+enginesdir = \
+ $(pkgdatadir)/engines
+
+radarsdir = \
+ $(pkgdatadir)/radars
+
+rankingsdir = \
+ $(pkgdatadir)/rankings
+
+shieldsdir = \
+ $(pkgdatadir)/shields
+
+power_plantsdir = \
+ $(pkgdatadir)/power_plants
+
+gunsdir = \
+ $(pkgdatadir)/guns
+
+stationsdir = \
+ $(pkgdatadir)/stations
+
+ecmsdir = \
+ $(pkgdatadir)/ecms
+
+## File created by the gnome-build tools
+
Modified: trunk/src/Makefile.am
===================================================================
--- trunk/src/Makefile.am 2007-12-03 20:34:06 UTC (rev 877)
+++ trunk/src/Makefile.am 2007-12-08 12:40:12 UTC (rev 878)
@@ -1,7 +1,6 @@
bin_PROGRAMS = \
opengateclient \
opengateserver
-# testopenalmanager
opengateclient_SOURCES = \
opengateclient.cpp \
@@ -72,17 +71,17 @@
metaserver.h \
metaserver.cpp
-opengateclient_LDFLAGS = \
- $(OGRE_LIBS) \
- $(CEGUI_LIBS) \
- $(CEGUIOGRE_LIBS) \
- $(freealut_LIBS) \
- $(vorbisfile_LIBS) \
- $(OIS_LIBS) \
+opengateclient_LDFLAGS = \
+ $(OGRE_LIBS) \
+ $(CEGUI_LIBS) \
+ $(CEGUIOGRE_LIBS) \
+ $(freealut_LIBS) \
+ $(vorbisfile_LIBS) \
+ $(OIS_LIBS) \
$(ogreopcode_LIBS)
opengateclient_CXXFLAGS = \
- $(OGRE_CFLAGS) \
+ $(OGRE_CFLAGS) \
$(CEGUI_CFLAGS) \
$(ogreopcode_CFLAGS)
@@ -101,12 +100,11 @@
metaserver.h \
metaserver.cpp
-opengateserver_LDFLAGS =
-# $(OGRE_LIBS) \
-# $(OIS_LIBS)
+opengateserver_LDFLAGS = \
+ $(ogreopcode_LIBS)
-opengateserver_CXXFLAGS =
-# $(OGRE_CFLAGS)
+opengateserver_CXXFLAGS = \
+ $(ogreopcode_CFLAGS)
#testopenalmanager_SOURCES = \
# testopenalmanager.cpp \
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <spo...@us...> - 2007-12-28 12:05:38
|
Revision: 881
http://opengate.svn.sourceforge.net/opengate/?rev=881&view=rev
Author: spom_spom
Date: 2007-12-28 04:05:37 -0800 (Fri, 28 Dec 2007)
Log Message:
-----------
add forgotten files
Modified Paths:
--------------
trunk/data/materials/advancedMaterials.program
trunk/data/materials/simpleshield.material
trunk/data/skybox/skybox.material
trunk/resources.cfg
Added Paths:
-----------
trunk/data/materials/planet.cg
trunk/data/materials/planet.material
trunk/data/textures/clouds_2500x1250.jpg
trunk/data/textures/nm_bk.png
trunk/data/textures/nm_dn.png
trunk/data/textures/nm_fr.png
trunk/data/textures/nm_lf.png
trunk/data/textures/nm_rt.png
trunk/data/textures/nm_up.png
trunk/data/textures/terrainnormal_1024.jpg
trunk/data/textures/terrainspec_1024.jpg
trunk/data/textures/terrainsurface_1024.jpg
Removed Paths:
-------------
trunk/data/MediaFromOgre/AdvancedMaterials/nm_bk.png
trunk/data/MediaFromOgre/AdvancedMaterials/nm_dn.png
trunk/data/MediaFromOgre/AdvancedMaterials/nm_fr.png
trunk/data/MediaFromOgre/AdvancedMaterials/nm_lf.png
trunk/data/MediaFromOgre/AdvancedMaterials/nm_rt.png
trunk/data/MediaFromOgre/AdvancedMaterials/nm_up.png
trunk/data/materials/simpleSkybox.material
trunk/data/skybox/skybox.zip
Deleted: trunk/data/MediaFromOgre/AdvancedMaterials/nm_bk.png
===================================================================
(Binary files differ)
Deleted: trunk/data/MediaFromOgre/AdvancedMaterials/nm_dn.png
===================================================================
(Binary files differ)
Deleted: trunk/data/MediaFromOgre/AdvancedMaterials/nm_fr.png
===================================================================
(Binary files differ)
Deleted: trunk/data/MediaFromOgre/AdvancedMaterials/nm_lf.png
===================================================================
(Binary files differ)
Deleted: trunk/data/MediaFromOgre/AdvancedMaterials/nm_rt.png
===================================================================
(Binary files differ)
Deleted: trunk/data/MediaFromOgre/AdvancedMaterials/nm_up.png
===================================================================
(Binary files differ)
Modified: trunk/data/materials/advancedMaterials.program
===================================================================
--- trunk/data/materials/advancedMaterials.program 2007-12-27 19:07:56 UTC (rev 880)
+++ trunk/data/materials/advancedMaterials.program 2007-12-28 12:05:37 UTC (rev 881)
@@ -35,34 +35,8 @@
}
}
-// A really basic ambient pass program, support for one texture coodinate set
-vertex_program BasicVertexPrograms/AmbientOneTextureHLSL hlsl
-{
- source Example_Basic.hlsl
- entry_point ambientOneTexture_vp
- target arbvp1 vp20 vs_1_1
-
- default_params
- {
- param_named_auto worldViewProj worldviewproj_matrix
- param_named_auto ambient ambient_light_colour
- }
-}
-// A really basic ambient pass program, support for one texture coodinate set
-vertex_program BasicVertexPrograms/AmbientOneTextureGLSL glsl
-{
- source AmbientOneTexture.glsl
-
- default_params
- {
- param_named_auto ambient ambient_light_colour
- }
-}
-
vertex_program BasicVertexPrograms/AmbientOneTextureUnified unified
{
- delegate BasicVertexPrograms/AmbientOneTextureGLSL
- delegate BasicVertexPrograms/AmbientOneTextureHLSL
delegate BasicVertexPrograms/AmbientOneTextureCG
}
Added: trunk/data/materials/planet.cg
===================================================================
--- trunk/data/materials/planet.cg (rev 0)
+++ trunk/data/materials/planet.cg 2007-12-28 12:05:37 UTC (rev 881)
@@ -0,0 +1,155 @@
+float3 expand( float3 v ) { return (v - 0.5) * 2; }
+
+struct vertexOutput {
+ float4 clipPos : POSITION;
+ float2 uv : TEXCOORD0;
+ float4 pos : TEXCOORD1;
+ float3 normal : TEXCOORD2;
+ float3 binormal : TEXCOORD3;
+ float3 tangent : TEXCOORD4;
+ float4 lightPos : TEXCOORD5;
+ float3 camPos : TEXCOORD6;
+ float3 tsLightDir : TEXCOORD7;
+};
+
+void atmos_vp( float4 objectPos : POSITION,
+ float3 normal : NORMAL,
+ out vertexOutput OUT,
+ uniform float4 lightPos,
+ uniform float3 camPos,
+ uniform float4x4 modelViewProjection )
+{
+ float4 pos = objectPos;
+ pos.xyz += normal * 700.0;
+ OUT.clipPos = mul( modelViewProjection, pos );
+ OUT.pos = pos;
+ OUT.normal = normal;
+ OUT.lightPos = lightPos;
+ OUT.camPos = camPos;
+}
+
+float4 atmos_fp( in vertexOutput IN,
+ uniform sampler2D decalTexture : TEXUNIT0,
+ uniform float4 lightDiffuse ) : COLOR {
+
+ float3 camDir = normalize( IN.camPos - IN.pos.xyz );
+ float3 nN = normalize( IN.normal );
+ float3 lightDir = normalize( IN.lightPos.xyz - ( IN.pos * IN.lightPos.w ) );
+
+ float rin = 15000;
+ float rout = 15000 + 700;
+ float atmLengthMax = 2.0 * rout * sqrt( 1- ( rin / rout ) );
+ float atmDens = 0.8 / atmLengthMax;
+ float atmLength = 2.0 * ( rout * dot( camDir, nN ) );
+
+ float4 oColor;
+
+ float dist = dot( camDir, camDir );
+ float pSQR = - dot( camDir, IN.camPos ) / dist;
+ float qSQR = ( dot( IN.camPos, IN.camPos ) - rin * rin ) / dist;
+ dist = pSQR * pSQR - qSQR;
+
+ oColor = atmDens * atmLength;
+
+ if ( dist > 0f ){
+ oColor -= atmDens * ( sqrt( 2 * dist ) )*1.5;
+ } else {
+ oColor *= atmLength / atmLengthMax / 1.5;
+ }
+
+ return saturate( oColor ) * ( dot( lightDir, nN ) );
+}
+
+void cloud_vp( float4 objectPos : POSITION,
+ float2 uv : TEXCOORD0,
+ float3 normal : NORMAL,
+ out vertexOutput OUT,
+ uniform float4 lightPos,
+ uniform float3 camPos,
+ uniform float4x4 modelViewProjection )
+{
+ OUT.clipPos = mul( modelViewProjection, objectPos );
+ OUT.uv = uv;
+ OUT.normal = normal;
+ OUT.lightPos = lightPos;
+}
+
+float4 cloud_fp( in vertexOutput IN,
+ uniform sampler2D decalTexture : TEXUNIT0,
+ uniform float4 lightDiffuse ) : COLOR {
+
+ float3 nN = normalize( IN.normal );
+ float3 lightDir = normalize( IN.lightPos.xyz - ( IN.pos * IN.lightPos.w ) );
+
+ float4 d = tex2D( decalTexture, IN.uv );
+ return d * ( dot( lightDir, nN ) );
+}
+
+void main_vp( float4 objectPos : POSITION,
+ float2 uv : TEXCOORD0,
+ float3 normal : NORMAL,
+ float3 tangent : TANGENT,
+ out vertexOutput OUT,
+ uniform float4 lightPos,
+ uniform float3 camPos,
+ uniform float4x4 modelViewProjection)
+{
+ OUT.clipPos = mul( modelViewProjection, objectPos ); // position (view space)
+ OUT.uv = uv;
+
+ OUT.pos = objectPos;
+ OUT.normal = normal;
+ OUT.tangent = tangent;
+ OUT.lightPos = lightPos;
+ OUT.camPos = camPos;
+
+ float3 lightDir = lightPos.xyz - ( objectPos * lightPos.w );
+ OUT.binormal = cross( tangent, normal );
+ float3x3 rotation = float3x3( tangent, OUT.binormal, normal );
+ OUT.tsLightDir = mul( rotation, lightDir );
+}
+
+float4 main_fp( vertexOutput IN,
+ uniform float exponent,
+ uniform float4 lightDiffuse,
+ uniform float4 lightSpecular,
+ uniform float4 lightAmbient,
+ uniform sampler2D decalTexture : TEXUNIT0,
+ uniform sampler2D normTexture : TEXUNIT1,
+ uniform sampler2D specTexture : TEXUNIT2,
+ uniform samplerCUBE normalCubeMap : TEXUNIT3 ) : COLOR {
+
+ float3 lightDir = normalize( IN.lightPos.xyz - ( IN.pos * IN.lightPos.w ) );
+ float3 camDir = normalize( IN.camPos - IN.pos.xyz );
+ float3 halfAngle = normalize( lightDir );
+
+ float3 nN = normalize( IN.normal );
+ float NdotL = dot( lightDir, nN );
+ float NdotH = dot( halfAngle, nN );
+
+ //cg docs say using their lit function is the fastest
+ float4 Lit = lit( NdotL, NdotH, exponent );
+
+ float3 lightVec = expand( texCUBE( normalCubeMap, IN.tsLightDir ).xyz );
+
+ float3 bumpVec = expand( tex2D( normTexture, IN.uv ).xyz);
+ float4 d = tex2D( decalTexture, IN.uv );
+ float4 s = tex2D( specTexture, IN.uv );
+
+// float KrMin = 0.05;
+// float Kr = 1.0;
+// float FresExp = 5.0;
+
+// float3 nT = normalize(IN.tangent);
+// float3 nB = normalize(IN.binormal);
+// // float3 Nb = nN + (bumpVec.x * Tn + bumpVec.y * Bn );
+// float3 Nb = nN;// + ( 0.001 * nT + 0.1 * nB );
+// float vdn = dot( camDir, Nb );
+
+// float fres = KrMin + (Kr-KrMin) * pow(1-abs(vdn),FresExp);
+// return fres + lightSpecular * Lit.z;
+// return float4(0.0, 0.0, 0.0, 0.0);
+ return lightDiffuse * Lit.y + lightSpecular * Lit.z * s + d * dot(bumpVec, lightVec);
+ // return lightDiffuse * Lit.y + lightSpecular * Lit.z * s + lightAmbient * d + d * saturate( dot(bumpVec, lightVec) );
+}
+
Added: trunk/data/materials/planet.material
===================================================================
--- trunk/data/materials/planet.material (rev 0)
+++ trunk/data/materials/planet.material 2007-12-28 12:05:37 UTC (rev 881)
@@ -0,0 +1,215 @@
+vertex_program VertexPrograms/PlanetNormSpec cg
+{
+ source planet.cg
+ entry_point main_vp
+ profiles arbvp1 vp20 vs_1_1
+
+ default_params
+ {
+ param_named_auto modelViewProjection worldviewproj_matrix
+ param_named_auto lightPos light_position_object_space 0
+ param_named_auto camPos camera_position_object_space
+ }
+}
+
+fragment_program FragmentPrograms/PlanetNormSpec cg
+{
+ source planet.cg
+ entry_point main_fp
+ profiles arbfp1 fp20 ps_1_1
+ default_params
+ {
+ }
+}
+
+vertex_program VertexPrograms/PlanetCloud cg
+{
+ source planet.cg
+ entry_point cloud_vp
+ profiles arbvp1 vp20 vs_1_1
+
+ default_params
+ {
+ param_named_auto modelViewProjection worldviewproj_matrix
+ param_named_auto lightPos light_position_object_space 0
+ param_named_auto camPos camera_position_object_space
+ }
+}
+
+fragment_program FragmentPrograms/PlanetCloud cg
+{
+ source planet.cg
+ entry_point cloud_fp
+ profiles arbfp1 fp20 ps_1_1
+ default_params
+ {
+ }
+}
+
+vertex_program VertexPrograms/PlanetAtmosphere cg
+{
+ source planet.cg
+ entry_point atmos_vp
+ profiles arbvp1 vp20 vs_1_1
+
+ default_params
+ {
+ param_named_auto modelViewProjection worldviewproj_matrix
+ param_named_auto lightPos light_position_object_space 0
+ param_named_auto camPos camera_position_object_space
+ }
+}
+
+fragment_program FragmentPrograms/PlanetAtmosphere cg
+{
+ source planet.cg
+ entry_point atmos_fp
+ profiles arbfp1 fp20 ps_1_1
+ default_params
+ {
+ }
+}
+
+material PlanetNormSpec
+{
+ technique vpfp
+ {
+ scheme vpfp
+ pass
+ {
+ vertex_program_ref VertexPrograms/PlanetNormSpec
+ {
+ }
+ fragment_program_ref FragmentPrograms/PlanetNormSpec
+ {
+ param_named_auto lightDiffuse light_diffuse_colour 0
+ param_named_auto lightSpecular light_specular_colour 0
+ param_named lightAmbient float4 0.05 0.05 0.05 0.1
+ param_named exponent float 10
+ }
+
+ texture_unit
+ {
+ texture_alias Image
+ tex_coord_set 0
+ }
+ texture_unit
+ {
+ texture_alias ImageNormMap
+ tex_coord_set 1
+ }
+ texture_unit
+ {
+ texture_alias ImageSpecMap
+ tex_coord_set 2
+ }
+ texture_unit
+ {
+ cubic_texture nm.png combinedUVW
+ tex_coord_set 3
+ tex_address_mode clamp
+ colour_op_ex dotproduct src_texture src_current
+ colour_op_multipass_fallback dest_colour zero
+ }
+ }
+ pass
+ {
+ depth_check on
+ depth_write off
+ scene_blend add
+ vertex_program_ref VertexPrograms/PlanetAtmosphere
+ {
+ }
+ fragment_program_ref FragmentPrograms/PlanetAtmosphere
+ {
+ param_named_auto lightDiffuse light_diffuse_colour 0
+ }
+ }
+ }
+ technique fallback
+ {
+ scheme Default
+ pass
+ {
+ ambient 0.500000 0.500000 0.500000 1.000000
+ diffuse 0.900000 0.900000 0.900000 1.000000
+ specular 0.900000 0.900000 0.900000 1.000000
+ emissive 0.500000 0.500000 0.500000 1.000000
+ texture_unit
+ {
+ texture_alias ImageFallback
+ tex_coord_set 0
+ }
+ }
+ }
+}
+
+material Planet/Cloud
+{
+ technique vpfp
+ {
+ scheme vpfp
+ pass
+ {
+ depth_check on
+ depth_write off
+ scene_blend add
+ vertex_program_ref VertexPrograms/PlanetCloud
+ {
+ }
+ fragment_program_ref FragmentPrograms/PlanetCloud
+ {
+ }
+ texture_unit
+ {
+ texture clouds_2500x1250.jpg
+ }
+ }
+ }
+ technique fallback
+ {
+ scheme Default
+ pass
+ {
+ specular 0.500000 0.500000 0.500000 0.5000000
+ emissive 1.000000 1.000000 1.000000 1.000000
+ depth_check on
+ depth_write off
+ scene_blend add
+ texture_unit
+ {
+ texture clouds_2500x1250.jpg
+ tex_coord_set 0
+ }
+ }
+ }
+
+}
+
+material Planet : PlanetNormSpec
+{
+// set_texture_alias Image terrainsurface_8192.bmp
+// set_texture_alias ImageNormMap terrainnormal_8192.bmp
+// set_texture_alias ImageSpecMap terrainspec_8192.bmp
+
+ set_texture_alias Image terrainsurface_1024.jpg
+ set_texture_alias ImageNormMap terrainnormal_1024.jpg
+ set_texture_alias ImageSpecMap terrainspec_1024.jpg
+ set_texture_alias ImageFallback terrainsurface_1024.jpg
+
+// set_texture_alias Image terrainsurface.bmp
+// set_texture_alias ImageNormMap terrainnormal.bmp
+// set_texture_alias ImageSpecMap terrainspec.bmp
+
+
+//http://www.oera.net/How2/TextureMaps.htm
+// set_texture_alias Image EarthMap_2500x1250.jpg
+// set_texture_alias ImageNormMap world.topo.200407Norm.png
+// set_texture_alias ImageSpecMap EarthMask_2500x1250.jpg
+// set_texture_alias ImageFallback EarthMapAtmos_2500x1250.jpg
+
+// set_texture_alias Image world.topo.200407.png
+// set_texture_alias ImageNormMap texture world.topo.200407Norm.png
+// set_texture_alias ImageSpecMap texture world.topo.200407Spec.png
+}
+
Deleted: trunk/data/materials/simpleSkybox.material
===================================================================
--- trunk/data/materials/simpleSkybox.material 2007-12-27 19:07:56 UTC (rev 880)
+++ trunk/data/materials/simpleSkybox.material 2007-12-28 12:05:37 UTC (rev 881)
@@ -1,56 +0,0 @@
-material OpenGate/SimpleSkyBox1
-{
- technique
- {
- pass
- {
- lighting off
- depth_write off
-// scene_blend add
-
- texture_unit
- {
- cubic_texture skybox1.png separateUV
-// cubic_texture skybox1_4096.png separateUV
-// cubic_texture skybox1_2048.png separateUV
-// cubic_texture skybox1_1024.png separateUV
-// cubic_texture skybox1_512.png separateUV
- tex_address_mode clamp
- }
- }
- }
-}
-material OpenGate/SimpleSkyBox2
-{
- technique
- {
- pass
- {
- lighting off
- depth_write off
-
- texture_unit
- {
- cubic_texture skybox2.png separateUV
- tex_address_mode clamp
- }
- }
- }
-}
-material OpenGate/SimpleSkyBox3
-{
- technique
- {
- pass
- {
- lighting off
- depth_write off
-
- texture_unit
- {
- cubic_texture skybox3.png separateUV
- tex_address_mode clamp
- }
- }
- }
-}
Modified: trunk/data/materials/simpleshield.material
===================================================================
--- trunk/data/materials/simpleshield.material 2007-12-27 19:07:56 UTC (rev 880)
+++ trunk/data/materials/simpleshield.material 2007-12-28 12:05:37 UTC (rev 881)
@@ -12,7 +12,7 @@
pass
{
scene_blend alpha_blend
- depth_check off
+ depth_check on
lighting off
fragment_program_ref shader_fp/simpleshield_cg
{
Modified: trunk/data/skybox/skybox.material
===================================================================
--- trunk/data/skybox/skybox.material 2007-12-27 19:07:56 UTC (rev 880)
+++ trunk/data/skybox/skybox.material 2007-12-28 12:05:37 UTC (rev 881)
@@ -1,4 +1,4 @@
-material Examples/SpaceSkyBox
+material OpenGate/SimpleSkyBox1
{
technique
{
@@ -6,12 +6,53 @@
{
lighting off
depth_write off
+// scene_blend add
texture_unit
{
- cubic_texture stevecube.jpg separateUV
+ cubic_texture skybox1.png separateUV
+// cubic_texture skybox1_4096.png separateUV
+// cubic_texture skybox1_2048.png separateUV
+// cubic_texture skybox1_1024.png separateUV
+// cubic_texture skybox1_512.png separateUV
tex_address_mode clamp
}
}
}
}
+
+material OpenGate/SimpleSkyBox2
+{
+ technique
+ {
+ pass
+ {
+ lighting off
+ depth_write off
+
+ texture_unit
+ {
+ cubic_texture skybox2.png separateUV
+ tex_address_mode clamp
+ }
+ }
+ }
+}
+
+material OpenGate/SimpleSkyBox3
+{
+ technique
+ {
+ pass
+ {
+ lighting off
+ depth_write off
+
+ texture_unit
+ {
+ cubic_texture skybox3.png separateUV
+ tex_address_mode clamp
+ }
+ }
+ }
+}
Deleted: trunk/data/skybox/skybox.zip
===================================================================
(Binary files differ)
Added: trunk/data/textures/clouds_2500x1250.jpg
===================================================================
(Binary files differ)
Property changes on: trunk/data/textures/clouds_2500x1250.jpg
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/data/textures/nm_bk.png
===================================================================
(Binary files differ)
Property changes on: trunk/data/textures/nm_bk.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/data/textures/nm_dn.png
===================================================================
(Binary files differ)
Property changes on: trunk/data/textures/nm_dn.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/data/textures/nm_fr.png
===================================================================
(Binary files differ)
Property changes on: trunk/data/textures/nm_fr.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/data/textures/nm_lf.png
===================================================================
(Binary files differ)
Property changes on: trunk/data/textures/nm_lf.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/data/textures/nm_rt.png
===================================================================
(Binary files differ)
Property changes on: trunk/data/textures/nm_rt.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/data/textures/nm_up.png
===================================================================
(Binary files differ)
Property changes on: trunk/data/textures/nm_up.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/data/textures/terrainnormal_1024.jpg
===================================================================
(Binary files differ)
Property changes on: trunk/data/textures/terrainnormal_1024.jpg
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/data/textures/terrainspec_1024.jpg
===================================================================
(Binary files differ)
Property changes on: trunk/data/textures/terrainspec_1024.jpg
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/data/textures/terrainsurface_1024.jpg
===================================================================
(Binary files differ)
Property changes on: trunk/data/textures/terrainsurface_1024.jpg
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: trunk/resources.cfg
===================================================================
--- trunk/resources.cfg 2007-12-27 19:07:56 UTC (rev 880)
+++ trunk/resources.cfg 2007-12-28 12:05:37 UTC (rev 881)
@@ -15,6 +15,7 @@
FileSystem=./data/ships/quantar/storm
FileSystem=./data/ships/tauseti/lady_kickstart
FileSystem=./data/ships/squadrok/squid
+FileSystem=./data/skybox
FileSystem=./data/stations
FileSystem=./data/materials
FileSystem=./data/textures
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <spo...@us...> - 2007-12-28 13:35:32
|
Revision: 882
http://opengate.svn.sourceforge.net/opengate/?rev=882&view=rev
Author: spom_spom
Date: 2007-12-28 05:35:37 -0800 (Fri, 28 Dec 2007)
Log Message:
-----------
cleaning planet destruction
Modified Paths:
--------------
trunk/data/materials/planet.material
trunk/src/Planet.cpp
trunk/src/Planet.h
trunk/src/Sector.cpp
trunk/src/UnDockedState.cpp
Modified: trunk/data/materials/planet.material
===================================================================
--- trunk/data/materials/planet.material 2007-12-28 12:05:37 UTC (rev 881)
+++ trunk/data/materials/planet.material 2007-12-28 13:35:37 UTC (rev 882)
@@ -7,7 +7,8 @@
default_params
{
param_named_auto modelViewProjection worldviewproj_matrix
- param_named_auto lightPos light_position_object_space 0
+ param_named lightPos float3 -50000.0 0.0 -40000.0
+// param_named_auto lightPos light_position_object_space 0
param_named_auto camPos camera_position_object_space
}
}
@@ -31,7 +32,8 @@
default_params
{
param_named_auto modelViewProjection worldviewproj_matrix
- param_named_auto lightPos light_position_object_space 0
+ param_named lightPos float4 -50000.0 0.0 -40000.0 0.0
+// param_named_auto lightPos light_position_object_space 0
param_named_auto camPos camera_position_object_space
}
}
@@ -55,7 +57,8 @@
default_params
{
param_named_auto modelViewProjection worldviewproj_matrix
- param_named_auto lightPos light_position_object_space 0
+ param_named lightPos float4 -50000.0 0.0 -40000.0 0.0
+// param_named_auto lightPos light_position_object_space 0
param_named_auto camPos camera_position_object_space
}
}
@@ -178,8 +181,7 @@
scene_blend add
texture_unit
{
- texture clouds_2500x1250.jpg
- tex_coord_set 0
+ texture clouds_1275.jpg
}
}
}
Modified: trunk/src/Planet.cpp
===================================================================
--- trunk/src/Planet.cpp 2007-12-28 12:05:37 UTC (rev 881)
+++ trunk/src/Planet.cpp 2007-12-28 13:35:37 UTC (rev 882)
@@ -26,36 +26,80 @@
#include <OgreMeshManager.h>
#include <OgreSubMesh.h>
#include <OgreVector3.h>
+#include <OgreLight.h>
namespace OpenGate{
Planet::Planet( const std::string & name, Ogre::SceneManager * SceneMgr, const Ogre::Vector3 & relPos,
Ogre::Real radius, int segments )
: name_( name ), sceneMgr_( SceneMgr ){
- createSphere_( name + "_Mesh", radius, segments, segments );
-
- Ogre::Entity * planetEntity = sceneMgr_->createEntity( name + "_Entity", name + "_Mesh" );
- planetNode_ = sceneMgr_->getRootSceneNode()->createChildSceneNode();
- planetEntity->setMaterialName( "Planet" );
- planetNode_->attachObject( planetEntity );
- planetNode_->setPosition( relPos );
+
+ planetNode_ = NULL;
+ planetCloudNode_ = NULL;
+ planetCloudEntity_ = NULL;
+ planetEntity_ = NULL;
+ light_ = NULL;
+
+ createSphere_( name + "/Mesh", radius, segments, segments );
+ planetNode_ = sceneMgr_->getRootSceneNode()->createChildSceneNode();
+
+ planetEntity_ = sceneMgr_->createEntity( name + "/Entity", name + "/Mesh" );
+ planetEntity_->setMaterialName( "Planet" );
+
+ planetNode_->attachObject( planetEntity_ );
+ planetNode_->setPosition( relPos );
//planetNode_->pitch( Ogre::Degree(30) );
+
+ planetCloudNode_ = planetNode_->createChildSceneNode();
- Ogre::Entity * planetCloudEntity = planetEntity->clone( planetEntity->getName() + "_Cloud" );
- planetCloudEntity->setMaterialName( "Planet/Cloud" );
- planetCloudNode_ = planetNode_->createChildSceneNode();
- planetCloudNode_->attachObject( planetCloudEntity );
- planetCloudNode_->scale(1.015, 1.015, 1.015);
+ planetCloudEntity_ = planetEntity_->clone( planetEntity_->getName() + "/Cloud" );
+ planetCloudEntity_->setMaterialName( "Planet/Cloud" );
+
+ planetCloudNode_->attachObject( planetCloudEntity_ );
+ planetCloudNode_->scale(1.015, 1.015, 1.015);
+
+ light_ = sceneMgr_->createLight( name + "/Light" );
+ light_->setDiffuseColour( 0.1, 0.1, 0.1 );
+ light_->setSpecularColour( 0.4, 0.4, 0.4 );
+ planetNode_->attachObject( light_ );
+
+ this->lighting( false );
+}
+
+Planet::~Planet( ){
+ if ( planetNode_ ) {
+ if ( light_ ){
+ planetNode_->detachObject( light_ );
+ sceneMgr_->destroyLight( light_->getName() );
+ }
+ if ( planetCloudNode_ ){
+ if ( planetCloudEntity_ ){
+ planetCloudNode_->detachObject( planetCloudEntity_ );
+ sceneMgr_->destroyEntity( planetCloudEntity_ );
+ }
+ planetNode_->removeAndDestroyChild( planetCloudNode_->getName() );
+ }
+ if ( planetEntity_ ){
+ Ogre::MeshManager::getSingleton().remove( name_ + "/Mesh" );
+ planetNode_->detachObject( planetEntity_ );
+ sceneMgr_->destroyEntity( planetEntity_ );
+ }
+ sceneMgr_->getRootSceneNode()->removeAndDestroyChild( planetNode_->getName() );
}
+}
void Planet::update( float elapsedTime ){
planetNode_->yaw( Ogre::Degree( 0.2 * elapsedTime ) );
planetCloudNode_->yaw( Ogre::Degree( 0.1 * elapsedTime ) );
}
+void Planet::lighting( bool on ){
+ light_->setVisible( on );
+}
+
void Planet::createSphere_( const std::string & strName, const float r, const int nRings, const int nSegments ){
Ogre::MeshPtr pSphere = Ogre::MeshManager::getSingleton().createManual(strName,
- Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
+ Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
Ogre::SubMesh *pSphereVertex = pSphere->createSubMesh();
pSphere->sharedVertexData = new Ogre::VertexData();
Modified: trunk/src/Planet.h
===================================================================
--- trunk/src/Planet.h 2007-12-28 12:05:37 UTC (rev 881)
+++ trunk/src/Planet.h 2007-12-28 13:35:37 UTC (rev 882)
@@ -29,6 +29,8 @@
public:
Planet( const std::string & name, Ogre::SceneManager * SceneMgr, const Ogre::Vector3 & relPos, Ogre::Real radius, int segments );
+ ~Planet( );
+ void lighting( bool on );
void update( float elapsedTime );
protected:
@@ -41,6 +43,9 @@
Ogre::SceneNode * planetNode_;
Ogre::SceneNode * planetCloudNode_;
+ Ogre::Entity * planetCloudEntity_;
+ Ogre::Entity * planetEntity_;
+ Ogre::Light * light_;
};
} // namespace OpenGate
Modified: trunk/src/Sector.cpp
===================================================================
--- trunk/src/Sector.cpp 2007-12-28 12:05:37 UTC (rev 881)
+++ trunk/src/Sector.cpp 2007-12-28 13:35:37 UTC (rev 882)
@@ -126,6 +126,7 @@
if ( 1 ) {
// planet_ = new Planet( "planet", sceneMgr_, Ogre::Vector3( 20000.0, 10000.0, 40000 ), 15000.0f, 32 );
planet_ = new Planet( "planet", sceneMgr_, Ogre::Vector3( 0000.0, 0000.0, 50000 ), 15000.0f, 64 );
+ planet_->lighting( true );
}
if ( !1 ) {
@@ -184,6 +185,10 @@
// log_->info( "done: " );
}
+ sceneMgr_->destroyLight("MainLight" );
+
+ if ( planet_ ) { delete planet_; }
+
if ( planetNode_ ){
sceneMgr_->destroyManualObject( "Planet" );
sceneMgr_->getRootSceneNode()->removeAndDestroyChild( planetNode_->getName() );
Modified: trunk/src/UnDockedState.cpp
===================================================================
--- trunk/src/UnDockedState.cpp 2007-12-28 12:05:37 UTC (rev 881)
+++ trunk/src/UnDockedState.cpp 2007-12-28 13:35:37 UTC (rev 882)
@@ -383,7 +383,7 @@
return false;
}
- myMSleep( (int)min( 0.0f, 1 - ( evt.timeSinceLastFrame ) ) );
+ //myMSleep( (int)min( 0.0f, 1 - ( evt.timeSinceLastFrame ) ) );
return true;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <spo...@us...> - 2008-04-24 19:46:31
|
Revision: 885
http://opengate.svn.sourceforge.net/opengate/?rev=885&view=rev
Author: spom_spom
Date: 2008-04-24 12:45:36 -0700 (Thu, 24 Apr 2008)
Log Message:
-----------
Add basic multi threading ai-manager, fixed several ugly bugs
Modified Paths:
--------------
trunk/ToDo
trunk/data/materials/advancedMaterials.material
trunk/data/materials/planet.material
trunk/data/materials/simpleshield.material
trunk/data/materials/station.material
trunk/data/misc/testsector.xml
trunk/src/Avatar.cpp
trunk/src/Avatar.h
trunk/src/GameStateManager.cpp
trunk/src/GameStateManager.h
trunk/src/InputManager.cpp
trunk/src/KeyMap.cpp
trunk/src/Makefile.am
trunk/src/OpcodeWrapper.cpp
trunk/src/OpcodeWrapper.h
trunk/src/OpenALSoundManager.cpp
trunk/src/Projectile.h
trunk/src/ResourceManager.cpp
trunk/src/ResourceManager.h
trunk/src/Sector.cpp
trunk/src/Sector.h
trunk/src/SectorObjects.cpp
trunk/src/SectorObjects.h
trunk/src/Station.cpp
trunk/src/Station.h
trunk/src/UnDockedState.cpp
trunk/src/UnDockedState.h
trunk/src/common.cpp
trunk/src/common.h
trunk/src/networkClient.cpp
trunk/src/networkClient.h
trunk/src/opengateclient.cpp
Added Paths:
-----------
trunk/data/textures/clouds_1275.jpg
trunk/src/AiManager.cpp
trunk/src/AiManager.h
trunk/src/AiObject.cpp
trunk/src/AiObject.h
Modified: trunk/ToDo
===================================================================
--- trunk/ToDo 2008-02-04 22:31:01 UTC (rev 884)
+++ trunk/ToDo 2008-04-24 19:45:36 UTC (rev 885)
@@ -197,5 +197,7 @@
9. Sonne
10. Plasma
11. Asche
-
- -Guns: Dazzler
\ No newline at end of file
+ 12. Candle
+ 13. Torch,Flambeau
+
+ -Guns: Dazzler
Modified: trunk/data/materials/advancedMaterials.material
===================================================================
--- trunk/data/materials/advancedMaterials.material 2008-02-04 22:31:01 UTC (rev 884)
+++ trunk/data/materials/advancedMaterials.material 2008-04-24 19:45:36 UTC (rev 885)
@@ -184,58 +184,10 @@
}
}
+//material Sta/TS/Background : OpenGate/BumpMapping
+//{
+// set_texture_alias Image TausetiStationBackgroundPlain.png
+// set_texture_alias ImageBumpMap TausetiStationBackgroundBM.png
+// set_texture_alias ImageFallback TausetiStationBackground.png
+//}
-material OpenGate/SingleTexture
-{
- receive_shadows on
- technique
- {
- pass
- {
-// ambient 0.500000 0.500000 0.500000 1.000000
-// diffuse 0.900000 0.900000 0.900000 1.000000
- emissive 0.500000 0.500000 0.500000 1.000000
- texture_unit
- {
- texture_alias Image
- }
- }
- }
-}
-
-material Sta/TS/Background : OpenGate/BumpMapping
-{
- set_texture_alias Image TausetiStationBackgroundPlain.png
- set_texture_alias ImageBumpMap TausetiStationBackgroundBM.png
- set_texture_alias ImageFallback TausetiStationBackground.png
-}
-
-material Sta/TS/Window : OpenGate/BumpMapping
-{
- set_texture_alias Image TausetiStationWindow.png
- set_texture_alias ImageBumpMap TausetiStationWindowBM.png
- set_texture_alias ImageFallback TausetiStationWindow.png
-}
-
-material Sta/TS/Plain : OpenGate/SingleTexture
-{
- set_texture_alias Image TausetiStationBackgroundPlain.png
-}
-
-material Flashlight/Red
-{
- technique
- {
- pass
- {
- lighting on
-// scene_blend alpha_blend
- scene_blend add
- emissive 1.000000 0.000000 0.000000 1.000000
- texture_unit
- {
- texture flare.png
- }
- }
- }
-}
Modified: trunk/data/materials/planet.material
===================================================================
--- trunk/data/materials/planet.material 2008-02-04 22:31:01 UTC (rev 884)
+++ trunk/data/materials/planet.material 2008-04-24 19:45:36 UTC (rev 885)
@@ -213,5 +213,4 @@
// set_texture_alias Image world.topo.200407.png
// set_texture_alias ImageNormMap texture world.topo.200407Norm.png
// set_texture_alias ImageSpecMap texture world.topo.200407Spec.png
-}
-
+}
\ No newline at end of file
Modified: trunk/data/materials/simpleshield.material
===================================================================
--- trunk/data/materials/simpleshield.material 2008-02-04 22:31:01 UTC (rev 884)
+++ trunk/data/materials/simpleshield.material 2008-04-24 19:45:36 UTC (rev 885)
@@ -16,8 +16,8 @@
lighting off
fragment_program_ref shader_fp/simpleshield_cg
{
- param_named_auto customParamColour custom 0
- param_named_auto time time_0_x 1
+ param_named_auto customParamColour custom 0
+ // param_named_auto time time_0_x 1
}
}
}
Modified: trunk/data/materials/station.material
===================================================================
--- trunk/data/materials/station.material 2008-02-04 22:31:01 UTC (rev 884)
+++ trunk/data/materials/station.material 2008-04-24 19:45:36 UTC (rev 885)
@@ -1,3 +1,101 @@
+vertex_program VertexPrograms/StationNormSpec cg
+{
+ source station.cg
+ entry_point main_vp
+ profiles arbvp1 vp20 vs_1_1
+
+ default_params
+ {
+ param_named_auto modelViewProjection worldviewproj_matrix
+ param_named_auto camPos camera_position_object_space
+ }
+}
+
+fragment_program FragmentPrograms/StationNormSpec cg
+{
+ source station.cg
+ entry_point main_fp
+ profiles arbfp1 fp20 ps_1_1
+ default_params
+ {
+ }
+}
+
+material StationNormSpec
+{
+ technique vpfp
+ {
+ scheme vpfp
+
+ pass
+ {
+ vertex_program_ref BasicVertexPrograms/AmbientOneTextureUnified
+ {
+ param_named_auto ambient ambient_light_colour
+ }
+ }
+ pass
+ {
+ scene_blend add
+
+ iteration once_per_light
+ vertex_program_ref VertexPrograms/StationNormSpec
+ {
+ param_named_auto lightPos light_position_object_space 0
+ }
+ fragment_program_ref FragmentPrograms/StationNormSpec
+ {
+ param_named_auto lightDiffuse light_diffuse_colour 0
+ param_named_auto lightSpecular light_specular_colour 0
+// param_named lightDiffuse float4 0.6 0.6 0.6 1.0
+// param_named lightSpecular float4 0.2 0.2 0.2 1.0
+ param_named lightAmbient float4 0.2 0.2 0.2 1.0
+ param_named exponent float 1
+ }
+
+ texture_unit
+ {
+ texture_alias Image
+ tex_coord_set 0
+ }
+ texture_unit
+ {
+ texture_alias ImageNormMap
+ tex_coord_set 1
+ }
+ texture_unit
+ {
+ texture_alias ImageSpecMap
+ tex_coord_set 2
+ }
+ texture_unit
+ {
+ cubic_texture nm.png combinedUVW
+ tex_coord_set 3
+ tex_address_mode clamp
+ colour_op_ex dotproduct src_texture src_current
+ colour_op_multipass_fallback dest_colour zero
+ }
+ }
+ }
+ technique fallback
+ {
+ scheme Default
+ pass
+ {
+ ambient 0.500000 0.500000 0.500000 1.000000
+ diffuse 0.900000 0.900000 0.900000 1.000000
+ specular 0.900000 0.900000 0.900000 1.000000
+ emissive 0.500000 0.500000 0.500000 1.000000
+ texture_unit
+ {
+ texture_alias ImageFallback
+ tex_coord_set 0
+ }
+ }
+ }
+}
+
material Station/Tube
{
receive_shadows on
@@ -16,7 +114,6 @@
}
}
-
material Station/DockPad
{
receive_shadows on
@@ -52,3 +149,61 @@
}
}
}
+
+material OpenGate/SingleTexture
+{
+ receive_shadows on
+ technique
+ {
+ pass
+ {
+// ambient 0.500000 0.500000 0.500000 1.000000
+// diffuse 0.900000 0.900000 0.900000 1.000000
+ emissive 0.500000 0.500000 0.500000 1.000000
+ texture_unit
+ {
+ texture_alias Image
+ }
+ }
+ }
+}
+
+material Sta/TS/Background : StationNormSpec
+{
+ set_texture_alias Image TausetiStationBackgroundPlain.png
+ set_texture_alias ImageNormMap TausetiStationBackgroundBM.png
+ set_texture_alias ImageSpecMap TausetiStationBackground.png
+ set_texture_alias ImageFallback TausetiStationBackground.png
+}
+
+material Sta/TS/Window : StationNormSpec
+{
+ set_texture_alias Image TausetiStationWindow.png
+ set_texture_alias ImageNormMap TausetiStationWindowBM.png
+ set_texture_alias ImageSpecMap TausetiStationWindow.png
+ set_texture_alias ImageFallback TausetiStationWindow.png
+}
+
+material Sta/TS/Plain : OpenGate/SingleTexture
+{
+ set_texture_alias Image TausetiStationBackgroundPlain.png
+}
+
+material Flashlight/Red
+{
+ technique
+ {
+ pass
+ {
+ lighting off
+ alpha_rejection greater_equal 128
+// scene_blend alpha_blend
+ scene_blend add
+ emissive 1.000000 0.000000 0.000000 1.000000
+ texture_unit
+ {
+ texture flare.png
+ }
+ }
+ }
+}
Modified: trunk/data/misc/testsector.xml
===================================================================
--- trunk/data/misc/testsector.xml 2008-02-04 22:31:01 UTC (rev 884)
+++ trunk/data/misc/testsector.xml 2008-04-24 19:45:36 UTC (rev 885)
@@ -16,7 +16,7 @@
<!-- <size>desired size of this object</size> -->
<!-- <scale>scaling factor for the ogre mesh</scale> -->
<!-- <direction>desired front direction</direction> -->
-<!-- <texture>desired front direction</texture> -->
+<!-- <texture>desired texture overide defaults</texture> -->
<!-- </sectorobject> -->
<!-- <station> -->
@@ -47,27 +47,10 @@
<scale>20, 20, 20</scale>
<material>Asteroid</material>
</sectorobject>
+
+
+
<!-- <sectorobject> -->
-<!-- <name>ogreheadStation1</name> -->
-<!-- <mesh>ogrehead</mesh> -->
-<!-- <position>5000.0, 1000.0, 0.0</position> -->
-<!-- <size>500, 500, 500</size> -->
-<!-- </sectorobject> -->
-<!-- <sectorobject> -->
-<!-- <name>ogrehead1</name> -->
-<!-- <mesh>ogrehead</mesh> -->
-<!-- <position>100,0,0</position> -->
-<!-- <size>10, 10, 10</size> -->
-<!-- <direction>1,0,0</direction> -->
-<!-- </sectorobject> -->
-<!-- <sectorobject> -->
-<!-- <name>ogrehead2</name> -->
-<!-- <mesh>ogrehead</mesh> -->
-<!-- <position>-100.0, 0, 0.0</position> -->
-<!-- <size>10, 10, 10</size> -->
-<!-- <direction>1,0,0</direction> -->
-<!-- </sectorobject> -->
-<!-- <sectorobject> -->
<!-- <name>astro6</name> -->
<!-- <mesh>ice_oval_6</mesh> -->
<!-- <position>0.0, -10, 0.0</position> -->
Added: trunk/data/textures/clouds_1275.jpg
===================================================================
(Binary files differ)
Property changes on: trunk/data/textures/clouds_1275.jpg
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/src/AiManager.cpp
===================================================================
--- trunk/src/AiManager.cpp (rev 0)
+++ trunk/src/AiManager.cpp 2008-04-24 19:45:36 UTC (rev 885)
@@ -0,0 +1,160 @@
+/***************************************************************************
+ * Copyright (C) 2008 by OpenGate development team *
+ * spo...@us... *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+
+#include "AiManager.h"
+#include "AiObject.h"
+
+#include "common.h"
+#include "ResourceManager.h"
+#include "SectorObjects.h"
+#include "Sector.h"
+#include "UnDockedState.h"
+#include "GameStateManager.h"
+#include "Avatar.h"
+
+#include <iostream>
+#include <iterator>
+#include <set>
+
+#include <boost/thread.hpp>
+
+namespace OpenGate{
+
+AiManager::AiManager( ResourceManager * resources ) : resources_( resources ){
+ eraseAiObjectCB_ = new AiManagerCB( this, &AiManager::eraseAiObject );
+ aiID_ = 1;
+}
+
+AiManager::~AiManager( ){
+ //std::cout << "AiManager::~AiManager( )" << std::endl;
+ killall();
+ //std::cout << "AiManager::~AiManager( )" << aiObjects_.size() << std::endl;
+
+ for_each( aiObjectHeap_.begin(), aiObjectHeap_.end(), deletePtr() );
+ delete eraseAiObjectCB_;
+}
+
+void AiManager::killall(){
+ //std::cout << "AiManager::killall():" << aiObjects_.size() << std::endl;
+ //** ugly, kill direkt auf aiObjects_ ist schlecht weil sich die ai selbst gleichzeitig austragen
+ std::set< AiObject * > toKillTmpSet( aiObjects_ );
+ for_each( toKillTmpSet.begin(), toKillTmpSet.end(), std::mem_fun( &AiObject::kill ) );
+ aiThreads_.join_all();
+}
+
+class RunAiObject{
+public:
+ RunAiObject( AiObject * ai, AiManagerCB * endThreadCallback = NULL )
+ : ai_( ai ), endThreadCallback_( endThreadCallback ) {
+ ai_->incReferenceCounter();
+ }
+ RunAiObject( const RunAiObject & aio )
+ : ai_( aio.ai() ), endThreadCallback_( aio.endThreadCallback() ) {
+ ai_->incReferenceCounter();
+ }
+ ~RunAiObject( ){
+ ai_->decReferenceCounter();
+ //std::cout << "endThreadCallback_ " << ai_->referenceCounter() << std::endl;
+ if ( ai_->referenceCounter() == 0 && endThreadCallback_ ) {
+ (*endThreadCallback_)( ai_ );
+ }
+ }
+ void operator()(){ ai_->run(); }
+
+ AiObject * ai() const { return ai_; }
+ AiManagerCB * endThreadCallback() const { return endThreadCallback_; }
+
+protected:
+ AiObject * ai_;
+ AiManagerCB * endThreadCallback_;
+};
+
+void AiManager::cmd( const std::vector < std::string > & argv ){
+ std::cout << "AiManager::cmd " << std::endl;
+ std::copy( argv.begin(), argv.end(), std::ostream_iterator< std::string >( std::cout, " " ) );
+ std::cout << std::endl;
+
+ AiObject * ai = spawnAi( );
+}
+
+AiObject * AiManager::spawnAi( ){
+ std::string name( "aiMan-" + resources_->avatar->name() );
+ AiObject * ai = createAiObject( name );
+
+ SectorObjectMoveableLocal *obj = NULL;
+ if ( resources_ ){
+ if ( resources_->gameStateRoot->activeState( )->name() == "UnDockedState" ){
+
+ obj = dynamic_cast < UnDockedState *>(resources_->gameStateRoot->activeState() )->sector()->
+ createMoveableObjectLocal( ai->name(),
+ resources_->network->userID(), ai->id(),
+ *VesselManager::getSingleton().vessel( "apteryx" ) );
+
+ std::cout << "Create " << obj->name() << " " << obj->thrust() << " " << obj->speed() << std::endl;
+ } else {
+ std::cout << "spawn only in undockedState" << std::endl;
+ }
+ }
+ ai->setSectorObject( obj );
+ Ogre::Real xmin = -100.0, xmax = 200.0;
+ Ogre::Real ymin = -100.0, ymax = 200.0;
+ Ogre::Real zmin = -1000.0, zmax = -2000.0;
+
+ obj->mainNode()->setPosition( Ogre::Math::RangeRandom( xmin, xmax ),
+ Ogre::Math::RangeRandom( ymin, ymax ),
+ Ogre::Math::RangeRandom( zmin, zmax ) );
+
+ return ai;
+}
+
+AiObject * AiManager::createAiObject( const std::string & name ){
+ AiObject *ai;
+ if ( aiObjectHeap_.size() ) {
+ ai = aiObjectHeap_.back();
+ ai->reset();
+ aiObjectHeap_.pop_back();
+ } else {
+ ai = new AiObject( this->aiID() );
+ aiID_ ++;
+ }
+ aiObjects_.insert( ai );
+ ai->setName( name + "-" + toStr( ai->id() ) );
+ std::cout << " creating starting:" << ai->name() << std::endl;
+ RunAiObject aio( ai, eraseAiObjectCB_ );
+ aiThreads_.create_thread( aio );
+ return ai;
+}
+
+void AiManager::eraseAiObject( AiObject * ai ){
+ boost::mutex::scoped_lock lock( eraseMutex_ );
+
+ SectorObjectMoveableLocal *obj = ai->sectorObject( );
+ if ( obj ){ __D( obj->name() )
+ obj->destroy();
+ }
+ aiObjects_.erase( ai );
+}
+
+void AiManager::recycle( AiObject * ai ){
+ aiObjectHeap_.push_back( ai );
+}
+
+} // namespace OpenGate{
+
Added: trunk/src/AiManager.h
===================================================================
--- trunk/src/AiManager.h (rev 0)
+++ trunk/src/AiManager.h 2008-04-24 19:45:36 UTC (rev 885)
@@ -0,0 +1,101 @@
+/***************************************************************************
+ * Copyright (C) 2008 by OpenGate development team *
+ * spo...@us... *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+
+#ifndef _OPENGATE_AIMANAGER__H
+#define _OPENGATE_AIMANAGER__H
+
+#include <string>
+#include <vector>
+#include <set>
+#include <queue>
+#include <iostream>
+
+#include <boost/thread.hpp>
+
+namespace OpenGate{
+
+class ResourceManager;
+class SectorObjectMoveableLocal;
+class AiManager;
+class AiObject;
+
+template < class Class, typename ReturnType, typename Parameter > class SingularCallBack{
+public:
+ typedef ReturnType ( Class::*Method )( Parameter );
+ SingularCallBack( Class * class_instance, Method method ) : class_instance_( class_instance ), method_( method ) { }
+
+ ReturnType operator()( Parameter parameter ) { return ( class_instance_->*method_ )( parameter ); }
+ ReturnType execute( Parameter parameter ){ return operator()( parameter ); }
+private:
+ Class * class_instance_;
+ Method method_;
+};
+
+typedef SingularCallBack< AiManager, void, AiObject * > AiManagerCB;
+
+//! Manager for artificial intelligence (ai) objects.
+/*! Manager for artificial intelligence (ai) objects. Communication with ai i.e. bots with this manager. Each ai runs in his own thread. */
+class AiManager{
+public:
+ AiManager( ResourceManager * resources = NULL );
+
+ ~AiManager( );
+
+ void cmd( const std::vector < std::string > & argv );
+
+ AiObject * spawnAi( );
+
+ /*! Create new ai an put to set of active ai, instance is taken from heap if available else create new*/
+ AiObject * createAiObject( const std::string & name );
+
+ /*! Erase ai from set of active ai's. The instance will not destroyd but put on a heap for the next usage*/
+ void eraseAiObject( AiObject * ai );
+
+ /*! The ai is dead and can be recycled. */
+ void recycle( AiObject * ai );
+
+ /*! Check for any active ai's. */
+ inline bool hasActiveObjects() const { return ( aiObjects_.size() > 0 ); }
+
+ /*!Send kill signal to all ai and join all threads. Mainly used for shutdown the manager.*/
+ void killall();
+
+ /*! ID of the last created ai */
+ uint aiID() const { return aiID_; }
+
+protected:
+ ResourceManager * resources_;
+
+ std::set< AiObject * > aiObjects_;
+ std::deque< AiObject * > aiObjectHeap_;
+
+ //! ID counter for the ai
+ uint aiID_;
+
+ boost::thread_group aiThreads_;
+ AiManagerCB * eraseAiObjectCB_;
+ boost::mutex eraseMutex_;
+
+};
+
+} // namespace OpenGate{
+
+
+#endif // _OPENGATE_AIMANAGER__H
Added: trunk/src/AiObject.cpp
===================================================================
--- trunk/src/AiObject.cpp (rev 0)
+++ trunk/src/AiObject.cpp 2008-04-24 19:45:36 UTC (rev 885)
@@ -0,0 +1,78 @@
+/***************************************************************************
+ * Copyright (C) 2008 by OpenGate development team *
+ * spo...@us... *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+
+#include "AiObject.h"
+
+#include "SectorObjects.h"
+
+#include "common.h"
+#include <iostream>
+
+namespace OpenGate{
+
+AiObject::AiObject( uint id ) : id_( id ), sectorObject_( NULL ){
+ reset();
+}
+
+AiObject::~AiObject(){
+}
+
+//** protected copy constructor
+AiObject::AiObject( const AiObject & ai ){
+ copy_( ai );
+}
+
+//** protected assigenment operator
+AiObject & AiObject::operator = ( const AiObject & ai ){
+ if ( this != &ai ){
+ copy_( ai );
+ } return *this;
+}
+
+void AiObject::copy_( const AiObject & ai ){
+
+}
+
+void AiObject::reset( ){
+ livetime_ = 0.0;
+ refCounter_ = 0;
+ name_ = "unknown";
+ isAlive_ = true;
+ die_ = false;
+}
+
+void AiObject::run(){ __D( name_ )
+ isAlive_ = true;
+ while ( isAlive_ ){
+ myMSleep( 300 );
+ livetime_ += 300.0;
+ if ( livetime_ > 5000 || die_ ) isAlive_ = false;
+ }
+}
+
+void AiObject::setSectorObject( SectorObjectMoveableLocal * obj ){
+ sectorObject_ = obj;
+ if ( obj ){
+ sectorObject_->setControler( this );
+ }
+}
+
+} // namespace OpenGate{
+
Added: trunk/src/AiObject.h
===================================================================
--- trunk/src/AiObject.h (rev 0)
+++ trunk/src/AiObject.h 2008-04-24 19:45:36 UTC (rev 885)
@@ -0,0 +1,106 @@
+/***************************************************************************
+ * Copyright (C) 2008 by OpenGate development team *
+ * spo...@us... *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+
+#ifndef _OPENGATE_AIOBJECT__H
+#define _OPENGATE_AIOBJECT__H
+
+#include <string>
+#include <vector>
+#include <set>
+#include <queue>
+#include <iostream>
+
+#include <boost/thread.hpp>
+
+namespace OpenGate{
+
+class ResourceManager;
+class SectorObjectMoveableLocal;
+class AiManager;
+
+class AiObject{
+public:
+ AiObject( uint id );
+
+ ~AiObject( );
+
+ /*! Functor to the livecyle */
+ void operator()(){ return run( ); }
+
+ /*! Main livecyle */
+ virtual void run();
+
+ /*! Set the instance which is controled by this ai */
+ void setSectorObject( SectorObjectMoveableLocal * obj );
+
+ /*! Get the instance which is controled by this ai */
+ SectorObjectMoveableLocal * sectorObject( ){ return sectorObject_; }
+
+ double livetime( ) const { return livetime_; }
+
+ bool isAlive() const { return isAlive_; }
+
+ void kill() { die_ = true; }
+
+ void reset();
+
+ void setName ( const std::string & name ){ name_ = name; }
+
+ std::string name() const { return name_; }
+
+ uint id() const { return id_;}
+
+ //! reference counting used for threading, prob. better using smart pointer
+ uint referenceCounter() const { return refCounter_; }
+ void incReferenceCounter() { refCounter_ ++; }
+ void decReferenceCounter() { refCounter_ --; }
+protected:
+ AiObject( const AiObject & ai );
+
+ AiObject & operator = ( const AiObject & ai );
+
+ void copy_( const AiObject & ai );
+
+ //! the graphical representation
+ SectorObjectMoveableLocal * sectorObject_;
+
+ //! holds objects live status
+ bool isAlive_;
+
+ //! prepare object to die
+ bool die_;
+
+ //! holds objects livetime
+ double livetime_;
+
+ //! objects name
+ std::string name_;
+
+ //! unique id
+ uint id_;
+
+ //! reference counter for threadholder
+ uint refCounter_;
+};
+
+} // namespace OpenGate{
+
+
+#endif // _OPENGATE_AIMANAGER__H
Modified: trunk/src/Avatar.cpp
===================================================================
--- trunk/src/Avatar.cpp 2008-02-04 22:31:01 UTC (rev 884)
+++ trunk/src/Avatar.cpp 2008-04-24 19:45:36 UTC (rev 885)
@@ -23,7 +23,7 @@
namespace OpenGate{
-Avatar::Avatar( const std::string & name, int ID ): name_( name ), id_( ID ) {
+Avatar::Avatar( const std::string & name, Uint32 ID ): name_( name ), id_( ID ) {
cargoHold_ = 0;
}
Modified: trunk/src/Avatar.h
===================================================================
--- trunk/src/Avatar.h 2008-02-04 22:31:01 UTC (rev 884)
+++ trunk/src/Avatar.h 2008-04-24 19:45:36 UTC (rev 885)
@@ -21,6 +21,8 @@
#ifndef _OPENGATE_AVATAR__H
#define _OPENGATE_AVATAR__H
+#include "common.h"
+
#include <string>
#include <list>
#include <vector>
@@ -35,15 +37,16 @@
/*! */
class Avatar{
public:
- Avatar( const std::string & name, int id );
+ Avatar( const std::string & name, Uint32 id );
~Avatar( );
std::string name() const { return name_; }
- int userID() const { return id_; }
+ Uint32 userID() const { return id_; }
void setVessel( Vessel & vessel );
+
Vessel * vessel() { return vessel_; }
void addCargoToFloor( const std::vector < Entity * > & item );
@@ -59,12 +62,12 @@
protected:
std::string name_;
- int id_;
+ Uint32 id_;
Vessel * vessel_;
- int maxCargoHold_;
- int cargoHold_;
+ Uint16 maxCargoHold_;
+ Uint16 cargoHold_;
std::list< std::deque < Entity * > > floorCargo_;
};
Modified: trunk/src/GameStateManager.cpp
===================================================================
--- trunk/src/GameStateManager.cpp 2008-02-04 22:31:01 UTC (rev 884)
+++ trunk/src/GameStateManager.cpp 2008-04-24 19:45:36 UTC (rev 885)
@@ -31,13 +31,16 @@
#include <OgreMesh.h>
#include <OgreMeshManager.h>
#include <OgreMaterialManager.h>
+
#include "LogManager.h"
#include "Console.h"
#include "Avatar.h"
#include "Sector.h"
#include "InputManager.h"
+#include "AiManager.h"
#include "VesselManager.h"
#include "OpenALSoundManager.h"
+#include "OpcodeWrapper.h"
#include "UnDockedState.h"
#include "ConfigDialog.h"
#include "EntityManager.h"
@@ -123,6 +126,11 @@
states_.pop_back();
}
+ if ( resources_.aiManager ) {
+ log_->info( "Shutdown ai manager." );
+ delete resources_.aiManager;
+ resources_.aiManager = NULL;
+ }
if ( resources_.console ){
log_->info( "Shutdown console." );
delete resources_.console;
@@ -153,7 +161,7 @@
delete resources_.inputManager;
resources_.inputManager = NULL;
}
-
+
log_->info( "Shutdown renderWindow." );
if ( resources_.renderWindow ) delete resources_.renderWindow;
log_->info( "Shutdown ogreRoot." );
@@ -408,8 +416,11 @@
"initialise commodity manager" ) );
loadResourcesVector_.push_back( std::pair< bool (Ga...
[truncated message content] |
|
From: <spo...@us...> - 2008-05-01 18:29:40
|
Revision: 887
http://opengate.svn.sourceforge.net/opengate/?rev=887&view=rev
Author: spom_spom
Date: 2008-05-01 11:29:14 -0700 (Thu, 01 May 2008)
Log Message:
-----------
Add some basic ai commands, e.i. dock at a station.
Modified Paths:
--------------
trunk/data/materials/station.material
trunk/data/stations/tauseti_wake.mesh
trunk/src/AiManager.cpp
trunk/src/AiObject.cpp
trunk/src/AiObject.h
trunk/src/Console.cpp
trunk/src/Console.h
trunk/src/GameStateManager.cpp
trunk/src/KeyMap.cpp
trunk/src/Makefile.am
trunk/src/OpcodeWrapper.cpp
trunk/src/Projectile.h
trunk/src/Sector.cpp
trunk/src/Sector.h
trunk/src/SectorObjects.cpp
trunk/src/SectorObjects.h
trunk/src/Station.cpp
trunk/src/Station.h
trunk/src/UnDockedState.cpp
trunk/src/UnDockedState.h
trunk/src/Vessel.h
trunk/src/common.h
trunk/src/networkProtocol.cpp
trunk/src/networkProtocol.h
trunk/src/opengateclient.cpp
Added Paths:
-----------
trunk/src/AiCommands.cpp
trunk/src/AiCommands.h
Modified: trunk/data/materials/station.material
===================================================================
--- trunk/data/materials/station.material 2008-04-24 20:30:07 UTC (rev 886)
+++ trunk/data/materials/station.material 2008-05-01 18:29:14 UTC (rev 887)
@@ -150,6 +150,22 @@
}
}
+material Station/LaunchPad.001 : Station/LaunchPad
+{
+}
+
+material Station/LaunchPad.002 : Station/LaunchPad
+{
+}
+
+material Station/LaunchPad.003 : Station/LaunchPad
+{
+}
+
+material Station/LaunchPad.004 : Station/LaunchPad
+{
+}
+
material OpenGate/SingleTexture
{
receive_shadows on
Modified: trunk/data/stations/tauseti_wake.mesh
===================================================================
(Binary files differ)
Added: trunk/src/AiCommands.cpp
===================================================================
--- trunk/src/AiCommands.cpp (rev 0)
+++ trunk/src/AiCommands.cpp 2008-05-01 18:29:14 UTC (rev 887)
@@ -0,0 +1,346 @@
+/***************************************************************************
+ * Copyright (C) 2008 by OpenGate development team *
+ * spo...@us... *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+
+
+#include "common.h"
+#include "AiObject.h"
+#include "AiCommands.h"
+#include "SectorObjects.h"
+
+#include <iostream>
+#include <string>
+
+namespace OpenGate{
+
+void AiCommandStop::start(){
+ std::cout << "AiCommandStop start" << std::endl;
+ if ( ai_->sectorObject( ) ) ai_->sectorObject( )->setThrustRate( 0.0 );
+ if ( turnaround_ ){
+ addCommand( new AiCommandPitch( ai_, 180.0 ) );
+ addCommand( new AiCommandAccelerate( ai_, -1.0, 1.0 ) );
+ addCommand( new AiCommandPitch( ai_, 180.0 ) );
+ addCommand( new AiCommandStop( ai_ ) );
+ } else {
+ if ( ai_->sectorObject( ) ) ai_->sectorObject( )->setBreakPressed( true );
+ std::cout << "braking speed: " << ai_->sectorObject( )->speed() << std::endl;
+ std::cout << "braking time est: " << ai_->brakingTime( ai_->sectorObject( )->speed() ) << std::endl;
+ std::cout << "braking way est: " << ai_->brakingDistance( ai_->sectorObject( )->speed() ) << std::endl;
+ startPos_ = ai_->sectorObject( )->mainNode()->getWorldPosition();
+ }
+}
+bool AiCommandStop::update( ) {
+ if ( ai_->sectorObject( ) ) {
+ if ( ai_->sectorObject( )->speed( ) < 0.01 ) return false;
+ }
+ return true;
+}
+void AiCommandStop::AiCommandStop::stop(){
+ std::cout << "AiCommandStop stop" << std::endl;
+ if ( ai_->sectorObject( ) ) {
+ ai_->sectorObject( )->setBreakPressed( false );
+ std::cout << "braking time real: " << runtime_ << std::endl;
+ std::cout << "braking way real: "
+ << ( ai_->sectorObject( )->mainNode()->getWorldPosition()- startPos_ ).length()
+ << std::endl;
+ }
+}
+
+
+void AiCommandSelfDestruct::stop(){ ai_->kill(); }
+
+
+void AiCommandYaw::start(){
+ if ( ai_->sectorObject() ){
+ Ogre::Quaternion q; q.FromAngleAxis( Ogre::Degree( degree_ ), Ogre::Vector3::UNIT_Y);
+ addCommand( new AiCommandLookAt( ai_,
+ ai_->sectorObject()->mainNode()->getWorldOrientation() * q * Ogre::Vector3::NEGATIVE_UNIT_Z ) );
+ }
+}
+
+
+void AiCommandPitch::start(){
+ if ( ai_->sectorObject() ){
+ Ogre::Quaternion q; q.FromAngleAxis( Ogre::Degree( degree_ ), Ogre::Vector3::UNIT_X);
+ addCommand( new AiCommandLookAt( ai_,
+ ai_->sectorObject()->mainNode()->getWorldOrientation() * q * Ogre::Vector3::NEGATIVE_UNIT_Z ) );
+ }
+}
+
+
+void AiCommandLookAt::start( ){
+ std::cout << "AiCommandLookAt::start()" << std::endl;
+ if ( ai_->sectorObject() ){
+ if ( isPosition_ ) {
+ std::cout << "ai pos: " << ai_->sectorObject()->mainNode()->getWorldPosition() << std::endl;
+ std::cout << "target: " << targetDir_ << std::endl;
+ targetDir_ = targetDir_ - ai_->sectorObject()->mainNode()->getWorldPosition();
+ }
+ targetDir_.normalise();
+ std::cout << "ai dir: " << ai_->sectorObject()->mainNode()->getWorldOrientation()
+ * Ogre::Vector3::NEGATIVE_UNIT_Z << std::endl;
+ std::cout << "target: " << targetDir_ << std::endl;
+ }
+}
+bool AiCommandLookAt::update( ){
+ if ( ai_->sectorObject() ){
+
+ if ( runtime_ > 5.0 * 360.0 / ai_->sectorObject()->vessel()->yaw() ){
+ //** maybee endless loop through gimbal ???, so look at fixed direction and try again
+ runtime_ = 0.0;
+ addCommand( new AiCommandLookAt( ai_, Ogre::Vector3( Ogre::Math::RangeRandom( -1.0, 1.0 ),
+ Ogre::Math::RangeRandom( -1.0, 1.0 ),
+ Ogre::Math::RangeRandom( -1.0, 1.0 ) ).normalisedCopy() ) );
+ return true;
+ }
+
+ Ogre::Quaternion currOrient( ai_->sectorObject()->mainNode()->getWorldOrientation() );
+ Ogre::Vector3 currDir = currOrient * Ogre::Vector3::NEGATIVE_UNIT_Z; currDir.normalise();
+ if ( ( targetDir_ - currDir).squaredLength() < 0.00005f ) return false;
+
+ Ogre::Quaternion targetOrient;
+ Ogre::Degree yawTo, pitchTo, rollTo;
+
+// if ( ( currDir + targetDir_ ).squaredLength() < 0.00005f ){
+// // Oops, a 180 degree turn (infinite possible rotation axes)
+// // Default to yaw i.e. use current UP
+// //targetOrient = Ogre::Quaternion(-currOrient.y, -currOrient.z, currOrient.w, currOrient.x);
+// ai_->sectorObject()->setScaledYaw( -1.0 );
+// return true;
+// } else {
+ // Derive shortest arc to new direction
+// Ogre::Quaternion rotQuat( currDir.getRotationTo( targetDir_ ) );
+// rotQuat.normalise();
+// targetOrient = rotQuat * currOrient;
+
+ /*if ( ( currDir + targetDir_ ).squaredLength() < 0.00005f ){
+ yawTo = -180;
+ } else*/ {
+
+ pitchTo = Ogre::Radian( std::asin( targetDir_.y ) - std::asin( currDir.y ) ).valueDegrees();
+ yawTo = Ogre::Radian( std::atan2( targetDir_.z, targetDir_.x )+Ogre::Math::PI/2.0
+ - std::atan2( currDir.z, currDir.x )+Ogre::Math::PI/2.0 ).valueDegrees();
+
+ }
+
+// std::cout << "Yawto : " << yawTo.valueDegrees()
+// << " " << currOrient.getYaw().valueDegrees()
+// << " " << targetOrient.getYaw().valueDegrees()
+// << " pitchto " << pitchTo.valueDegrees()
+// << " " << currOrient.getPitch().valueDegrees()
+// << " " << targetOrient.getPitch().valueDegrees()
+// << std::endl;
+
+
+ if ( yawTo > Ogre::Degree( 180.0 ) )
+ yawTo = Ogre::Degree( -360.0 ) + yawTo;
+ else if ( yawTo < Ogre::Degree( -180.0 ) )
+ yawTo = Ogre::Degree( 360.0 ) + yawTo;
+
+
+ Ogre::Real rotFric = ai_->sectorObject()->rotFriction();
+
+ Ogre::Real scaledYaw = yawTo.valueDegrees() / ( elapsedTime_ * rotFric *
+ ai_->sectorObject()->vessel()->yaw() );
+ Ogre::Real scaledPitch = pitchTo.valueDegrees() / ( elapsedTime_ * rotFric *
+ ai_->sectorObject()->vessel()->pitch() );
+ Ogre::Real scaledRoll = rollTo.valueDegrees() / ( elapsedTime_ * rotFric *
+ ai_->sectorObject()->vessel()->roll() );
+
+ double yaw = max( -1.0f, scaledYaw ); yaw = min( yaw, 1.0 );
+ double pitch = max( -1.0f, scaledPitch ); pitch = min( pitch, 1.0 );
+ double roll = max( -1.0f, scaledRoll ); roll = min( roll, 1.0 );
+
+// std::cout << nr_ << " t: " << elapsedTime_ << "/" << runtime_ << " y: " << yawTo.valueDegrees() << "/" << scaledYaw << " " << yaw << " p: " << pitchTo.valueDegrees() << "/" << scaledPitch << " " << pitch
+// << " sum: " << ( targetDir_ - currDir).squaredLength() << std::endl;
+// std::cout << targetDir_ << currDir << std::endl;
+
+// ai_->sectorObject()->setScaledPitch( pitch );
+// ai_->sectorObject()->setScaledYaw( yaw );
+
+ if ( fabs( pitchTo.valueDegrees() ) < 0.1 ) {
+ ai_->sectorObject()->setScaledPitch( 0.0 );
+ ai_->sectorObject()->setScaledYaw( yaw );
+ } else {
+ ai_->sectorObject()->setScaledPitch( pitch );
+ ai_->sectorObject()->setScaledYaw( 0.0 );
+ }
+// ai_->sectorObject()->setScaledRoll( roll );
+
+ }
+ return true;
+}
+void AiCommandLookAt::stop( ){
+ std::cout << "AiCommandLookAt::stop()" << std::endl;
+ if ( ai_->sectorObject( ) ) {
+ ai_->sectorObject()->setScaledYaw( 0.0 );
+ ai_->sectorObject()->setScaledPitch( 0.0 );
+ ai_->sectorObject()->setScaledRoll( 0.0 );
+ std::cout << "curr: " << ai_->sectorObject()->mainNode()->getWorldOrientation()
+ * Ogre::Vector3::NEGATIVE_UNIT_Z << std::endl;
+ }
+}
+
+
+void AiCommandRoll::start(){
+ if ( ai_->sectorObject( ) ) {
+ Ogre::Quaternion q; q.FromAngleAxis( Ogre::Radian( Ogre::Degree( degree_ ).valueRadians() ), Ogre::Vector3::UNIT_Z);
+ Ogre::Quaternion q2( ai_->sectorObject()->mainNode()->getWorldOrientation() );
+ targetDir_ = (q*q2) * Ogre::Vector3::NEGATIVE_UNIT_Z;
+ targetDir_.normalise();
+ }
+}
+bool AiCommandRoll::update(){
+ if ( ai_->sectorObject( ) ) {
+ Ogre::Vector3 thisDir( ai_->sectorObject()->mainNode()->getWorldOrientation() * Ogre::Vector3::NEGATIVE_UNIT_Z );
+ thisDir.normalise();
+ Ogre::Quaternion rot( thisDir.getRotationTo( targetDir_ ) ); rot.normalise();
+ Ogre::Degree valTo( rot.getRoll() );
+ Ogre::Real scaledVal = valTo.valueDegrees() /
+ ( elapsedTime_ * ai_->sectorObject()->rotFriction() * ai_->sectorObject()->vessel()->roll() );
+ float val = max( -1.0f, scaledVal ); val = min( val, 1.0f );
+ if ( fabs( val ) < 0.1 ) return false;
+
+ ai_->sectorObject()->setScaledRoll( val );
+
+ return true;
+ } else return false;
+}
+void AiCommandRoll::stop(){ if ( ai_->sectorObject( ) ) ai_->sectorObject()->setScaledPitch( 0.0 ); }
+
+void AiCommandSetThrust::start() {
+ if ( ai_->sectorObject( ) ) {
+ ai_->sectorObject( )->setThrustRate( thrustRate_ );
+ }
+}
+void AiCommandTimedAccelerate::start() {
+ std::cout << "AiCommandTimedAccelerate start" << std::endl;
+ if ( ai_->sectorObject( ) ) {
+ ai_->sectorObject( )->setThrustRate( rate_ );
+ initPos_ = ai_->sectorObject( )->mainNode()->getWorldPosition();
+ }
+}
+void AiCommandTimedAccelerate::stop() {
+ std::cout << "AiCommandTimedAccelerate stop" << std::endl;
+ if ( ai_->sectorObject( ) ){
+ ai_->sectorObject( )->setThrustRate( 0.0 );
+ std::cout << " reclined way(real): "
+ << (ai_->sectorObject( )->mainNode()->getWorldPosition()- initPos_).length() << std::endl;
+ std::cout << " reclined way(ana): "
+ << ai_->wayAfterTime( runtime_, rate_ ) << std::endl;
+ }
+}
+
+void AiCommandAccelerate::start(){
+ std::cout << "AiCommandAccelerate::start()" << std::endl;
+ if ( ai_->sectorObject( ) ) {
+ ai_->sectorObject( )->setThrustRate( thrustRate_ );
+ lastSpeed_ = ai_->sectorObject( )->speed();
+ initPos_ = ai_->sectorObject( )->mainNode()->getWorldPosition();
+ }
+}
+bool AiCommandAccelerate::update(){
+ if ( ai_->sectorObject( ) ) {
+// std::cout << "AiCommandAccelerate::update() "
+// << speed_ << " " << ai_->sectorObject( )->speed() << std::endl;
+ if ( speed_ < 0.0 &&
+ ( ai_->sectorObject( )->speed() < speed_ || ai_->sectorObject( )->speed() > lastSpeed_ ) ) {
+// std::cout << " - speed reached " <<std::endl;
+ return false;
+ }
+
+ if ( speed_ > 0.0 && ai_->sectorObject( )->speed() > speed_ ) {
+// std::cout << " + speed reached " <<std::endl;
+ return false;
+ }
+ lastSpeed_ = ai_->sectorObject( )->speed();
+ } else {
+ return false;
+ }
+ return true;
+}
+void AiCommandAccelerate::stop(){
+ std::cout << "AiCommandAccelerate::stop" << std::endl;
+ if ( ai_->sectorObject( ) ) ai_->sectorObject( )->setThrustRate( 0.0 );
+ std::cout << " reclined way(real): "
+ << (ai_->sectorObject( )->mainNode()->getWorldPosition()- initPos_).length() << std::endl;
+ std::cout << " reclined way(ana): "
+ << ai_->wayAfterTime( runtime_, thrustRate_ ) << std::endl;
+}
+
+
+void AiCommandApproach::start(){
+ std::cout << "AiCommandApproach::start():" << std::endl;
+ if ( ai_->sectorObject( ) ) {
+ startPos_ = ai_->sectorObject( )->mainNode()->getWorldPosition();
+ initDist_ = ( pos_ - ai_->sectorObject( )->mainNode()->getWorldPosition() ).length();
+ std::cout << "ai pos: " << startPos_ << std::endl;
+ std::cout << "dist: " << initDist_ << std::endl;
+ std::cout << "target: " << pos_ << std::endl;
+ }
+ addCommand( new AiCommandLookAt( ai_, pos_, true ) );
+ addCommand( new AiCommandSetThrust( ai_, 1.0 ) );
+ // addCommand( new AiCommandWait( ai_, 1.0 ) );
+// addCommand( new AiCommandAccelerate( ai_, 230.0, 1.0 ) );
+// addCommand( new AiCommandStop( ai_, true ) );
+// addCommand( new AiCommandWait( ai_, 10.0 ) );
+}
+bool AiCommandApproach::update(){
+ if ( ai_->sectorObject( ) ) {
+ double dist = ( pos_ - ai_->sectorObject( )->mainNode()->getWorldPosition() ).length();
+
+ if ( ai_->brakingDistance( ai_->sectorObject( )->speed() ) > dist ){
+ addCommand( new AiCommandStop( ai_, false ) );
+ return true;
+ }
+
+ if ( ai_->sectorObject( )->speed() < 0.05 ){
+ std::cout << "dist: " << dist << std::endl;
+ if ( dist < 10.0 ) { // 10m snapping
+ return false;
+ } else {
+ addCommand( new AiCommandWait( ai_, 1.0 ) );
+ addCommand( new AiCommandApproach( ai_, pos_, true ) );
+ return true;
+ }
+ }
+
+
+ return true;
+ } else {
+ return false;
+ }
+}
+
+void AiCommandApproach::stop(){
+ std::cout << "AiCommandApproach::stop():" << std::endl;
+ if ( ai_->sectorObject( ) ) {
+ ai_->sectorObject( )->setThrustRate( 0.0 );
+ std::cout << "ai pos: " << ai_->sectorObject( )->mainNode()->getWorldPosition() << std::endl;
+ std::cout << "dir: " << -ai_->sectorObject( )->mainNode()->getWorldOrientation().zAxis()
+ << std::endl;
+ std::cout << "pos: "
+ << startPos_ + initDist_ * -ai_->sectorObject( )->mainNode()->getWorldOrientation().zAxis()
+ << std::endl;
+ }
+
+}
+
+
+} // namespace OpenGate{
Added: trunk/src/AiCommands.h
===================================================================
--- trunk/src/AiCommands.h (rev 0)
+++ trunk/src/AiCommands.h 2008-05-01 18:29:14 UTC (rev 887)
@@ -0,0 +1,238 @@
+/***************************************************************************
+ * Copyright (C) 2008 by OpenGate development team *
+ * spo...@us... *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+
+#ifndef _OPENGATE_AICOMMANDS__H
+#define _OPENGATE_AICOMMANDS__H
+
+#include <string>
+#include <vector>
+#include <set>
+#include <queue>
+#include <iostream>
+
+namespace Ogre{
+ class Timer;
+ class Vector3;
+}
+#include <OgreVector3.h>
+
+namespace OpenGate{
+
+class SectorObjectMoveableLocal;
+class AiObject;
+class AiCommand;
+class AiCommandWait;
+class AiCommandStop;
+class AiCommandTimedAccelerate;
+
+class AiCommand {
+public:
+ AiCommand( AiObject * ai ) : ai_( ai ), abort_( false ), running_( false ), runtime_( 0.0 ), elapsedTime_ ( 0.0 ){}
+
+ virtual ~AiCommand(){}
+
+ virtual bool update( double elapsedTime ){
+ elapsedTime_ = elapsedTime;
+ runtime_ += elapsedTime;
+ if ( !running_ ) {
+ start();
+ running_ = true;
+ nr_ = 0;
+ }
+ nr_++;
+ if ( abort_ ){
+ if ( !cmds_.empty() ){
+ cmds_.front()->abort();
+ }
+ stop();
+ return false;
+ }
+
+ if ( !cmds_.empty() ){
+ if ( !cmds_.front()->update( elapsedTime_ ) ){
+ delete cmds_.front();
+ cmds_.pop_front();
+ }
+ } else if ( !update( ) ) {
+ stop();
+ return false;
+ }
+ return true;
+ }
+
+ bool abort( ) { abort_ = true; }
+
+ virtual void start() { std::cout << "AiCommand start" << std::endl; }
+ virtual bool update( ) { return false; }
+ virtual void stop() { std::cout << "AiCommand stop" << std::endl; }
+
+ void addCommand( AiCommand * cmd ) { cmds_.push_back( cmd ); }
+
+protected:
+ AiObject * ai_;
+ bool abort_;
+ bool running_;
+ double runtime_;
+ double elapsedTime_;
+ uint nr_;
+ std::deque< AiCommand * > cmds_;
+};
+
+class AiCommandSelfDestruct : public AiCommand {
+ public:
+ AiCommandSelfDestruct( AiObject * ai ) : AiCommand( ai ) { }
+ virtual ~AiCommandSelfDestruct(){ }
+ virtual bool update( ) { return false; }
+ virtual void stop();
+ protected:
+};
+
+class AiCommandStop : public AiCommand {
+public:
+ AiCommandStop( AiObject * ai, bool turnaround = false ) : AiCommand( ai ), turnaround_( turnaround ) { }
+ virtual ~AiCommandStop(){ }
+ virtual void start( );
+ virtual bool update( );
+ virtual void stop( );
+protected:
+ bool turnaround_;
+ Ogre::Vector3 startPos_;
+};
+
+/*!Look at a direction or at a position if flag set. */
+class AiCommandLookAt : public AiCommand {
+public:
+ AiCommandLookAt( AiObject * ai, const Ogre::Vector3 & dir, bool isPos = false)
+ : AiCommand( ai ), targetDir_( dir ), isPosition_( isPos ) { }
+ virtual ~AiCommandLookAt(){ }
+ virtual void start( );
+ virtual bool update( );
+ virtual void stop( );
+protected:
+ Ogre::Vector3 targetDir_;
+ bool isPosition_;
+};
+
+class AiCommandYaw : public AiCommand {
+public:
+ AiCommandYaw( AiObject * ai, double degree ) : AiCommand( ai ), degree_( degree ) { }
+ virtual ~AiCommandYaw(){ }
+ virtual void start( );
+protected:
+ double degree_;
+};
+
+class AiCommandPitch : public AiCommand {
+public:
+ AiCommandPitch( AiObject * ai, double degree ) : AiCommand( ai ), degree_( degree ) { }
+ virtual ~AiCommandPitch(){ }
+ virtual void start( );
+protected:
+ double degree_;
+};
+
+class AiCommandRoll : public AiCommand {
+public:
+ AiCommandRoll( AiObject * ai, double degree ) : AiCommand( ai ), degree_( degree ) { }
+ virtual ~AiCommandRoll(){ }
+ virtual void start( );
+ virtual bool update( );
+ virtual void stop( );
+protected:
+ double degree_;
+ Ogre::Vector3 targetDir_;
+};
+
+class AiCommandSetThrust : public AiCommand {
+public:
+ AiCommandSetThrust( AiObject * ai, double thrustRate )
+ : AiCommand( ai ), thrustRate_( thrustRate ){}
+ virtual void start();
+protected:
+ double thrustRate_;
+};
+
+
+/*! Accelerate to a given |speed|. The command finish if speed is greater or slower fabs( speed )
+depending on the sign of speed */
+class AiCommandAccelerate : public AiCommand {
+public:
+ AiCommandAccelerate( AiObject * ai, double speed, double thrustRate )
+ : AiCommand( ai ), speed_( speed ), thrustRate_( thrustRate ){ }
+
+ virtual ~AiCommandAccelerate(){ }
+ virtual void start();
+ virtual bool update( );
+ virtual void stop();
+protected:
+ double speed_;
+ double lastSpeed_;
+ double thrustRate_;
+ Ogre::Vector3 initPos_;
+};
+
+class AiCommandApproach : public AiCommand {
+public:
+ AiCommandApproach( AiObject * ai, const Ogre::Vector3 & pos, bool stop )
+ : AiCommand( ai ), pos_( pos ), stop_( stop ){}
+ ~AiCommandApproach(){}
+ virtual void start();
+ virtual bool update();
+ virtual void stop();
+protected:
+ Ogre::Vector3 pos_;
+ Ogre::Vector3 startPos_;
+ bool stop_;
+ double lastDist_;
+ double initDist_;
+};
+
+class AiCommandWait : public AiCommand {
+public:
+ AiCommandWait( AiObject * ai, double time ) : AiCommand( ai ), time_( time ){}
+ virtual ~AiCommandWait(){}
+
+ virtual void start() { std::cout << "AiCommandWait start" << std::endl;}
+ virtual bool update( ){
+ if ( runtime_ > time_ ) return false;
+ return true;
+ }
+ virtual void stop() { std::cout << "AiCommandWait stop: " << runtime_ << std::endl;}
+protected:
+ double time_;
+};
+
+class AiCommandTimedAccelerate : public AiCommandWait {
+public:
+ AiCommandTimedAccelerate( AiObject * ai, double time, double thrustRate )
+ : AiCommandWait( ai, time ), rate_( thrustRate ) { }
+
+ virtual ~AiCommandTimedAccelerate(){ }
+ virtual void start();
+ virtual void stop();
+protected:
+ double rate_;
+ Ogre::Vector3 initPos_;
+};
+
+} // namespace OpenGate{
+
+
+#endif // _OPENGATE_AICOMMANDS__H
Modified: trunk/src/AiManager.cpp
===================================================================
--- trunk/src/AiManager.cpp 2008-04-24 20:30:07 UTC (rev 886)
+++ trunk/src/AiManager.cpp 2008-05-01 18:29:14 UTC (rev 887)
@@ -28,6 +28,8 @@
#include "UnDockedState.h"
#include "GameStateManager.h"
#include "Avatar.h"
+#include "Station.h"
+#include "OgreSceneNode.h"
#include <iostream>
#include <iterator>
@@ -52,7 +54,7 @@
}
void AiManager::killall(){
- //std::cout << "AiManager::killall():" << aiObjects_.size() << std::endl;
+ std::cout << "AiManager::killall():" << aiObjects_.size() << std::endl;
//** ugly, kill direkt auf aiObjects_ ist schlecht weil sich die ai selbst gleichzeitig austragen
std::set< AiObject * > toKillTmpSet( aiObjects_ );
for_each( toKillTmpSet.begin(), toKillTmpSet.end(), std::mem_fun( &AiObject::kill ) );
@@ -95,7 +97,10 @@
}
AiObject * AiManager::spawnAi( ){
- std::string name( "aiMan-" + resources_->avatar->name() );
+ std::string name( "aiMan-" );
+ if ( resources_ ){
+ if ( resources_->avatar ) name += resources_->avatar->name();
+ }
AiObject * ai = createAiObject( name );
SectorObjectMoveableLocal *obj = NULL;
@@ -106,21 +111,44 @@
createMoveableObjectLocal( ai->name(),
resources_->network->userID(), ai->id(),
*VesselManager::getSingleton().vessel( "apteryx" ) );
-
- std::cout << "Create " << obj->name() << " " << obj->thrust() << " " << obj->speed() << std::endl;
+ obj->vessel( )->setPowerPlant( EquipmentManager::getSingleton().powerPlant( "Spud" ) );
+ obj->vessel( )->setEngine( EquipmentManager::getSingleton().engine( "T-E-15" ) );
+ obj->vessel( )->setRadar( EquipmentManager::getSingleton().radar( "Outlook" ) );
+ obj->vessel( )->setShield( EquipmentManager::getSingleton().shield( "Kydango" ) );
+ obj->vessel( )->setCapacitor( EquipmentManager::getSingleton().capacitor( "Sponge" ) );
+ std::cout << "Create " << obj->name() << std::endl;
} else {
std::cout << "spawn only in undockedState" << std::endl;
}
}
+ //-250, 0, 500
ai->setSectorObject( obj );
- Ogre::Real xmin = -100.0, xmax = 200.0;
- Ogre::Real ymin = -100.0, ymax = 200.0;
- Ogre::Real zmin = -1000.0, zmax = -2000.0;
+ Ogre::Real xmin = -150.0, xmax = -200.0;
+ Ogre::Real ymin = 0.0, ymax = 100.0;
+ Ogre::Real zmin = 300.0, zmax = 400.0;
- obj->mainNode()->setPosition( Ogre::Math::RangeRandom( xmin, xmax ),
+ if ( obj ) {
+ obj->mainNode()->setPosition( Ogre::Math::RangeRandom( xmin, xmax ),
Ogre::Math::RangeRandom( ymin, ymax ),
Ogre::Math::RangeRandom( zmin, zmax ) );
+// obj->mainNode()->setPosition(
+// dynamic_cast < UnDockedState *>(resources_->gameStateRoot->activeState()
+// )->sector()->station()->launchPadPosition() +
+// dynamic_cast < UnDockedState *>(resources_->gameStateRoot->activeState()
+// )->sector()->station()->launchPadOrientation().zAxis() * -100.0);
+//
+// obj->mainNode()->setOrientation(
+// dynamic_cast < UnDockedState *>(resources_->gameStateRoot->activeState()
+// )->sector()->station()->launchPadOrientation() );
+
+ ai->land( *dynamic_cast < UnDockedState *>(resources_->gameStateRoot->activeState() )->sector()->station() );
+ }
+
+ std::cout << "starting: " << ai->name() << std::endl;
+
+ RunAiObject aio( ai, eraseAiObjectCB_ );
+ aiThreads_.create_thread( aio );
return ai;
}
@@ -136,9 +164,7 @@
}
aiObjects_.insert( ai );
ai->setName( name + "-" + toStr( ai->id() ) );
- std::cout << " creating starting:" << ai->name() << std::endl;
- RunAiObject aio( ai, eraseAiObjectCB_ );
- aiThreads_.create_thread( aio );
+
return ai;
}
Modified: trunk/src/AiObject.cpp
===================================================================
--- trunk/src/AiObject.cpp 2008-04-24 20:30:07 UTC (rev 886)
+++ trunk/src/AiObject.cpp 2008-05-01 18:29:14 UTC (rev 887)
@@ -18,20 +18,30 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
+
+#include "common.h"
#include "AiObject.h"
-
+#include "AiCommands.h"
#include "SectorObjects.h"
+#include "Sector.h"
+#include "Station.h"
-#include "common.h"
+#include <OgreTimer.h>
+#include <OgreVector3.h>
+
#include <iostream>
+#include <string>
namespace OpenGate{
-
+
AiObje...
[truncated message content] |
|
From: <spo...@us...> - 2008-05-04 12:13:55
|
Revision: 888
http://opengate.svn.sourceforge.net/opengate/?rev=888&view=rev
Author: spom_spom
Date: 2008-05-04 05:13:52 -0700 (Sun, 04 May 2008)
Log Message:
-----------
Add support for missiles; you can try: F7 spawns autodocking ai -- select ai -- fire missile with mouse button 3; Start refactoring; The network is currently untested and marked as broken.
Modified Paths:
--------------
trunk/ToDo
trunk/resources.cfg
trunk/src/AiCommands.cpp
trunk/src/AiCommands.h
trunk/src/AiManager.cpp
trunk/src/AiManager.h
trunk/src/AiObject.cpp
trunk/src/AiObject.h
trunk/src/Avatar.cpp
trunk/src/Avatar.h
trunk/src/Entity.h
trunk/src/EntityManager.cpp
trunk/src/EntityManager.h
trunk/src/GameStateManager.cpp
trunk/src/Makefile.am
trunk/src/MarketDialog.cpp
trunk/src/OpcodeWrapper.cpp
trunk/src/OpenALSoundManager.cpp
trunk/src/OpenALSoundManager.h
trunk/src/Projectile.cpp
trunk/src/Projectile.h
trunk/src/ResourceManager.cpp
trunk/src/Sector.cpp
trunk/src/Sector.h
trunk/src/ShipConfigDialog.cpp
trunk/src/Station.cpp
trunk/src/Station.h
trunk/src/UnDockedState.cpp
trunk/src/UnDockedState.h
trunk/src/Vessel.cpp
trunk/src/Vessel.h
trunk/src/VesselManager.cpp
trunk/src/opengateclient.cpp
Added Paths:
-----------
trunk/data/missiles/
trunk/data/missiles/firefly.mesh
trunk/data/missiles/firefly_big.png
trunk/data/missiles/firefly_small.png
trunk/src/BaseObject.cpp
trunk/src/BaseObject.h
trunk/src/Equipment.h
trunk/src/GunObject.cpp
trunk/src/GunObject.h
trunk/src/Moveable.cpp
trunk/src/Moveable.h
trunk/src/SectorObject.cpp
trunk/src/SectorObject.h
trunk/src/SectorObjectAvatar.cpp
trunk/src/SectorObjectAvatar.h
trunk/src/SectorObjectMissile.cpp
trunk/src/SectorObjectMissile.h
trunk/src/SectorObjectMoveable.cpp
trunk/src/SectorObjectMoveable.h
trunk/src/SectorObjectVessel.cpp
trunk/src/SectorObjectVessel.h
Removed Paths:
-------------
trunk/src/SectorObjects.cpp
trunk/src/SectorObjects.h
Modified: trunk/ToDo
===================================================================
--- trunk/ToDo 2008-05-01 18:29:14 UTC (rev 887)
+++ trunk/ToDo 2008-05-04 12:13:52 UTC (rev 888)
@@ -31,7 +31,7 @@
- Speed/MaxSpeed
- Acceleration
- Mousecursor
- - Bullseye/VCT-1 (Duelist)
+# - Bullseye/VCT-1 (Duelist)
- JG-like Radar
- Simplest global chat
@@ -45,7 +45,6 @@
- global/code
- cleaning / refaktoring
- - integrate in currect OpenGate framework
# - add licence header
- mark third persons thingies (mousecursor, skybox)
#ALT-TAB - free mousepointer from widget contents
@@ -74,10 +73,10 @@
# - read nonmovable objects
# - read equipment and commodities
- global config
-
+ - keymap r/w
- openal
# - simplest testing
- - soundmanger
+# par - soundmanger
- input
- keymap
@@ -127,11 +126,19 @@
# - fired partikel
- station
- - landing rings on the big ogrehead-mouth
+# - landing rings on the big ogrehead-mouth
- ai
+# part - ai manager
+# - multi threading aiobject
+# part - set of ai commands that ca be combined
# - simple follow
- - calculate fireing solution
+# - docking
+ - trading
+ - mining
+ - hunting
+ - protecting
+ - calculate fireing solution
- rockets
- pathfinding
- genetic learning
@@ -151,7 +158,7 @@
# OIS disables autorepeat, fire `xset r on` to enable
- UTF support (\xFC\xF6\xE4)
- since Ogre1.4 Overlay only support Ogre::UTFString, which throws exception by using umlaut
+ since Ogre1.4 Overlay only support Ogre::UTFString and throws exception by using umlaut
IDEAS:
@@ -183,7 +190,7 @@
11. Flut
12. Tsunami
13. See
-
+ ...
Octavius (fire)
---------------
1. Funke
@@ -199,5 +206,7 @@
11. Asche
12. Candle
13. Torch,Flambeau
-
+ ...
+
-Guns: Dazzler
+ -Missiles: Firefly, Dragonfly, Mosquito, Bee, Hummel, Hornet
Added: trunk/data/missiles/firefly.mesh
===================================================================
(Binary files differ)
Property changes on: trunk/data/missiles/firefly.mesh
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/data/missiles/firefly_big.png
===================================================================
(Binary files differ)
Property changes on: trunk/data/missiles/firefly_big.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/data/missiles/firefly_small.png
===================================================================
(Binary files differ)
Property changes on: trunk/data/missiles/firefly_small.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: trunk/resources.cfg
===================================================================
--- trunk/resources.cfg 2008-05-01 18:29:14 UTC (rev 887)
+++ trunk/resources.cfg 2008-05-04 12:13:52 UTC (rev 888)
@@ -11,6 +11,7 @@
FileSystem=./data/ecms
FileSystem=./data/power_plants
FileSystem=./data/guns
+FileSystem=./data/missiles
FileSystem=./data/ships/octavius/apteryx
FileSystem=./data/ships/quantar/storm
FileSystem=./data/ships/tauseti/lady_kickstart
Modified: trunk/src/AiCommands.cpp
===================================================================
--- trunk/src/AiCommands.cpp 2008-05-01 18:29:14 UTC (rev 887)
+++ trunk/src/AiCommands.cpp 2008-05-04 12:13:52 UTC (rev 888)
@@ -22,7 +22,8 @@
#include "common.h"
#include "AiObject.h"
#include "AiCommands.h"
-#include "SectorObjects.h"
+#include "SectorObjectVessel.h"
+#include "Moveable.h"
#include <iostream>
#include <string>
@@ -31,33 +32,33 @@
void AiCommandStop::start(){
std::cout << "AiCommandStop start" << std::endl;
- if ( ai_->sectorObject( ) ) ai_->sectorObject( )->setThrustRate( 0.0 );
+ if ( ai_->vesselObject( ) ) ai_->vesselObject( )->setThrustRate( 0.0 );
if ( turnaround_ ){
addCommand( new AiCommandPitch( ai_, 180.0 ) );
addCommand( new AiCommandAccelerate( ai_, -1.0, 1.0 ) );
addCommand( new AiCommandPitch( ai_, 180.0 ) );
addCommand( new AiCommandStop( ai_ ) );
} else {
- if ( ai_->sectorObject( ) ) ai_->sectorObject( )->setBreakPressed( true );
- std::cout << "braking speed: " << ai_->sectorObject( )->speed() << std::endl;
- std::cout << "braking time est: " << ai_->brakingTime( ai_->sectorObject( )->speed() ) << std::endl;
- std::cout << "braking way est: " << ai_->brakingDistance( ai_->sectorObject( )->speed() ) << std::endl;
- startPos_ = ai_->sectorObject( )->mainNode()->getWorldPosition();
+ if ( ai_->vesselObject( ) ) ai_->vesselObject( )->setBreakPressed( true );
+ std::cout << "braking speed: " << ai_->vesselObject( )->speed() << std::endl;
+ std::cout << "braking time est: " << ai_->brakingTime( ai_->vesselObject( )->speed() ) << std::endl;
+ std::cout << "braking way est: " << ai_->brakingDistance( ai_->vesselObject( )->speed() ) << std::endl;
+ startPos_ = ai_->vesselObject( )->mainNode()->getWorldPosition();
}
}
bool AiCommandStop::update( ) {
- if ( ai_->sectorObject( ) ) {
- if ( ai_->sectorObject( )->speed( ) < 0.01 ) return false;
+ if ( ai_->vesselObject( ) ) {
+ if ( ai_->vesselObject( )->speed( ) < 0.01 ) return false;
}
return true;
}
void AiCommandStop::AiCommandStop::stop(){
std::cout << "AiCommandStop stop" << std::endl;
- if ( ai_->sectorObject( ) ) {
- ai_->sectorObject( )->setBreakPressed( false );
+ if ( ai_->vesselObject( ) ) {
+ ai_->vesselObject( )->setBreakPressed( false );
std::cout << "braking time real: " << runtime_ << std::endl;
std::cout << "braking way real: "
- << ( ai_->sectorObject( )->mainNode()->getWorldPosition()- startPos_ ).length()
+ << ( ai_->vesselObject( )->mainNode()->getWorldPosition()- startPos_ ).length()
<< std::endl;
}
}
@@ -67,41 +68,41 @@
void AiCommandYaw::start(){
- if ( ai_->sectorObject() ){
+ if ( ai_->vesselObject() ){
Ogre::Quaternion q; q.FromAngleAxis( Ogre::Degree( degree_ ), Ogre::Vector3::UNIT_Y);
addCommand( new AiCommandLookAt( ai_,
- ai_->sectorObject()->mainNode()->getWorldOrientation() * q * Ogre::Vector3::NEGATIVE_UNIT_Z ) );
+ ai_->vesselObject()->mainNode()->getWorldOrientation() * q * Ogre::Vector3::NEGATIVE_UNIT_Z ) );
}
}
void AiCommandPitch::start(){
- if ( ai_->sectorObject() ){
+ if ( ai_->vesselObject() ){
Ogre::Quaternion q; q.FromAngleAxis( Ogre::Degree( degree_ ), Ogre::Vector3::UNIT_X);
addCommand( new AiCommandLookAt( ai_,
- ai_->sectorObject()->mainNode()->getWorldOrientation() * q * Ogre::Vector3::NEGATIVE_UNIT_Z ) );
+ ai_->vesselObject()->mainNode()->getWorldOrientation() * q * Ogre::Vector3::NEGATIVE_UNIT_Z ) );
}
}
void AiCommandLookAt::start( ){
std::cout << "AiCommandLookAt::start()" << std::endl;
- if ( ai_->sectorObject() ){
+ if ( ai_->vesselObject() ){
if ( isPosition_ ) {
- std::cout << "ai pos: " << ai_->sectorObject()->mainNode()->getWorldPosition() << std::endl;
+ std::cout << "ai pos: " << ai_->vesselObject()->mainNode()->getWorldPosition() << std::endl;
std::cout << "target: " << targetDir_ << std::endl;
- targetDir_ = targetDir_ - ai_->sectorObject()->mainNode()->getWorldPosition();
+ targetDir_ = targetDir_ - ai_->vesselObject()->mainNode()->getWorldPosition();
}
targetDir_.normalise();
- std::cout << "ai dir: " << ai_->sectorObject()->mainNode()->getWorldOrientation()
+ std::cout << "ai dir: " << ai_->vesselObject()->mainNode()->getWorldOrientation()
* Ogre::Vector3::NEGATIVE_UNIT_Z << std::endl;
std::cout << "target: " << targetDir_ << std::endl;
}
}
bool AiCommandLookAt::update( ){
- if ( ai_->sectorObject() ){
+ if ( ai_->vesselObject() ){
- if ( runtime_ > 5.0 * 360.0 / ai_->sectorObject()->vessel()->yaw() ){
+ if ( runtime_ > 5.0 * 360.0 / ai_->vesselObject()->moveable()->yaw() ){
//** maybee endless loop through gimbal ???, so look at fixed direction and try again
runtime_ = 0.0;
addCommand( new AiCommandLookAt( ai_, Ogre::Vector3( Ogre::Math::RangeRandom( -1.0, 1.0 ),
@@ -110,7 +111,7 @@
return true;
}
- Ogre::Quaternion currOrient( ai_->sectorObject()->mainNode()->getWorldOrientation() );
+ Ogre::Quaternion currOrient( ai_->vesselObject()->mainNode()->getWorldOrientation() );
Ogre::Vector3 currDir = currOrient * Ogre::Vector3::NEGATIVE_UNIT_Z; currDir.normalise();
if ( ( targetDir_ - currDir).squaredLength() < 0.00005f ) return false;
@@ -121,7 +122,7 @@
// // Oops, a 180 degree turn (infinite possible rotation axes)
// // Default to yaw i.e. use current UP
// //targetOrient = Ogre::Quaternion(-currOrient.y, -currOrient.z, currOrient.w, currOrient.x);
-// ai_->sectorObject()->setScaledYaw( -1.0 );
+// ai_->vesselObject()->setScaledYaw( -1.0 );
// return true;
// } else {
// Derive shortest arc to new direction
@@ -154,14 +155,14 @@
yawTo = Ogre::Degree( 360.0 ) + yawTo;
- Ogre::Real rotFric = ai_->sectorObject()->rotFriction();
+ Ogre::Real rotFric = ai_->vesselObject()->rotFriction();
Ogre::Real scaledYaw = yawTo.valueDegrees() / ( elapsedTime_ * rotFric *
- ai_->sectorObject()->vessel()->yaw() );
+ ai_->vesselObject()->moveable()->yaw() );
Ogre::Real scaledPitch = pitchTo.valueDegrees() / ( elapsedTime_ * rotFric *
- ai_->sectorObject()->vessel()->pitch() );
+ ai_->vesselObject()->moveable()->pitch() );
Ogre::Real scaledRoll = rollTo.valueDegrees() / ( elapsedTime_ * rotFric *
- ai_->sectorObject()->vessel()->roll() );
+ ai_->vesselObject()->moveable()->roll() );
double yaw = max( -1.0f, scaledYaw ); yaw = min( yaw, 1.0 );
double pitch = max( -1.0f, scaledPitch ); pitch = min( pitch, 1.0 );
@@ -171,77 +172,77 @@
// << " sum: " << ( targetDir_ - currDir).squaredLength() << std::endl;
// std::cout << targetDir_ << currDir << std::endl;
-// ai_->sectorObject()->setScaledPitch( pitch );
-// ai_->sectorObject()->setScaledYaw( yaw );
+// ai_->vesselObject()->setScaledPitch( pitch );
+// ai_->vesselObject()->setScaledYaw( yaw );
if ( fabs( pitchTo.valueDegrees() ) < 0.1 ) {
- ai_->sectorObject()->setScaledPitch( 0.0 );
- ai_->sectorObject()->setScaledYaw( yaw );
+ ai_->vesselObject()->setScaledPitch( 0.0 );
+ ai_->vesselObject()->setScaledYaw( yaw );
} else {
- ai_->sectorObject()->setScaledPitch( pitch );
- ai_->sectorObject()->setScaledYaw( 0.0 );
+ ai_->vesselObject()->setScaledPitch( pitch );
+ ai_->vesselObject()->setScaledYaw( 0.0 );
}
-// ai_->sectorObject()->setScaledRoll( roll );
+// ai_->vesselObject()->setScaledRoll( roll );
}
return true;
}
void AiCommandLookAt::stop( ){
std::cout << "AiCommandLookAt::stop()" << std::endl;
- if ( ai_->sectorObject( ) ) {
- ai_->sectorObject()->setScaledYaw( 0.0 );
- ai_->sectorObject()->setScaledPitch( 0.0 );
- ai_->sectorObject()->setScaledRoll( 0.0 );
- std::cout << "curr: " << ai_->sectorObject()->mainNode()->getWorldOrientation()
+ if ( ai_->vesselObject( ) ) {
+ ai_->vesselObject()->setScaledYaw( 0.0 );
+ ai_->vesselObject()->setScaledPitch( 0.0 );
+ ai_->vesselObject()->setScaledRoll( 0.0 );
+ std::cout << "curr: " << ai_->vesselObject()->mainNode()->getWorldOrientation()
* Ogre::Vector3::NEGATIVE_UNIT_Z << std::endl;
}
}
void AiCommandRoll::start(){
- if ( ai_->sectorObject( ) ) {
+ if ( ai_->vesselObject( ) ) {
Ogre::Quaternion q; q.FromAngleAxis( Ogre::Radian( Ogre::Degree( degree_ ).valueRadians() ), Ogre::Vector3::UNIT_Z);
- Ogre::Quaternion q2( ai_->sectorObject()->mainNode()->getWorldOrientation() );
+ Ogre::Quaternion q2( ai_->vesselObject()->mainNode()->getWorldOrientation() );
targetDir_ = (q*q2) * Ogre::Vector3::NEGATIVE_UNIT_Z;
targetDir_.normalise();
}
}
bool AiCommandRoll::update(){
- if ( ai_->sectorObject( ) ) {
- Ogre::Vector3 thisDir( ai_->sectorObject()->mainNode()->getWorldOrientation() * Ogre::Vector3::NEGATIVE_UNIT_Z );
+ if ( ai_->vesselObject( ) ) {
+ Ogre::Vector3 thisDir( ai_->vesselObject()->mainNode()->getWorldOrientation() * Ogre::Vector3::NEGATIVE_UNIT_Z );
thisDir.normalise();
Ogre::Quaternion rot( thisDir.getRotationTo( targetDir_ ) ); rot.normalise();
Ogre::Degree valTo( rot.getRoll() );
Ogre::Real scaledVal = valTo.valueDegrees() /
- ( elapsedTime_ * ai_->sectorObject()->rotFriction() * ai_->sectorObject()->vessel()->roll() );
+ ( elapsedTime_ * ai_->vesselObject()->rotFriction() * ai_->vesselObject()->moveable()->roll() );
float val = max( -1.0f, scaledVal ); val = min( val, 1.0f );
if ( fabs( val ) < 0.1 ) return false;
- ai_->sectorObject()->setScaledRoll( val );
+ ai_->vesselObject()->setScaledRoll( val );
return true;
} else return false;
}
-void AiCommandRoll::stop(){ if ( ai_->sectorObject( ) ) ai_->sectorObject()->setScaledPitch( 0.0 ); }
+void AiCommandRoll::stop(){ if ( ai_->vesselObject( ) ) ai_->vesselObject()->setScaledPitch( 0.0 ); }
void AiCommandSetThrust::start() {
- if ( ai_->sectorObject( ) ) {
- ai_->sectorObject( )->setThrustRate( thrustRate_ );
+ if ( ai_->vesselObject( ) ) {
+ ai_->vesselObject( )->setThrustRate( thrustRate_ );
}
}
void AiCommandTimedAccelerate::start() {
std::cout << "AiCommandTimedAccelerate start" << std::endl;
- if ( ai_->sectorObject( ) ) {
- ai_->sectorObject( )->setThrustRate( rate_ );
- initPos_ = ai_->sectorObject( )->mainNode()->getWorldPosition();
+ if ( ai_->vesselObject( ) ) {
+ ai_->vesselObject( )->setThrustRate( rate_ );
+ initPos_ = ai_->vesselObject( )->mainNode()->getWorldPosition();
}
}
void AiCommandTimedAccelerate::stop() {
std::cout << "AiCommandTimedAccelerate stop" << std::endl;
- if ( ai_->sectorObject( ) ){
- ai_->sectorObject( )->setThrustRate( 0.0 );
+ if ( ai_->vesselObject( ) ){
+ ai_->vesselObject( )->setThrustRate( 0.0 );
std::cout << " reclined way(real): "
- << (ai_->sectorObject( )->mainNode()->getWorldPosition()- initPos_).length() << std::endl;
+ << (ai_->vesselObject( )->mainNode()->getWorldPosition()- initPos_).length() << std::endl;
std::cout << " reclined way(ana): "
<< ai_->wayAfterTime( runtime_, rate_ ) << std::endl;
}
@@ -249,27 +250,27 @@
void AiCommandAccelerate::start(){
std::cout << "AiCommandAccelerate::start()" << std::endl;
- if ( ai_->sectorObject( ) ) {
- ai_->sectorObject( )->setThrustRate( thrustRate_ );
- lastSpeed_ = ai_->sectorObject( )->speed();
- initPos_ = ai_->sectorObject( )->mainNode()->getWorldPosition();
+ if ( ai_->vesselObject( ) ) {
+ ai_->vesselObject( )->setThrustRate( thrustRate_ );
+ lastSpeed_ = ai_->vesselObject( )->speed();
+ initPos_ = ai_->vesselObject( )->mainNode()->getWorldPosition();
}
}
bool AiCommandAccelerate::update(){
- if ( ai_->sectorObject( ) ) {
+ if ( ai_->vesselObject( ) ) {
// std::cout << "AiCommandAccelerate::update() "
-// << speed_ << " " << ai_->sectorObject( )->speed() << std::endl;
+// << speed_ << " " << ai_->vesselObject( )->speed() << std::endl;
if ( speed_ < 0.0 &&
- ( ai_->sectorObject( )->speed() < speed_ || ai_->sectorObject( )->speed() > lastSpeed_ ) ) {
+ ( ai_->vesselObject( )->speed() < speed_ || ai_->vesselObject( )->speed() > lastSpeed_ ) ) {
// std::cout << " - speed reached " <<std::endl;
return false;
}
- if ( speed_ > 0.0 && ai_->sectorObject( )->speed() > speed_ ) {
+ if ( speed_ > 0.0 && ai_->vesselObject( )->speed() > speed_ ) {
// std::cout << " + speed reached " <<std::endl;
return false;
}
- lastSpeed_ = ai_->sectorObject( )->speed();
+ lastSpeed_ = ai_->vesselObject( )->speed();
} else {
return false;
}
@@ -277,9 +278,9 @@
}
void AiCommandAccelerate::stop(){
std::cout << "AiCommandAccelerate::stop" << std::endl;
- if ( ai_->sectorObject( ) ) ai_->sectorObject( )->setThrustRate( 0.0 );
+ if ( ai_->vesselObject( ) ) ai_->vesselObject( )->setThrustRate( 0.0 );
std::cout << " reclined way(real): "
- << (ai_->sectorObject( )->mainNode()->getWorldPosition()- initPos_).length() << std::endl;
+ << (ai_->vesselObject( )->mainNode()->getWorldPosition()- initPos_).length() << std::endl;
std::cout << " reclined way(ana): "
<< ai_->wayAfterTime( runtime_, thrustRate_ ) << std::endl;
}
@@ -287,9 +288,9 @@
void AiCommandApproach::start(){
std::cout << "AiCommandApproach::start():" << std::endl;
- if ( ai_->sectorObject( ) ) {
- startPos_ = ai_->sectorObject( )->mainNode()->getWorldPosition();
- initDist_ = ( pos_ - ai_->sectorObject( )->mainNode()->getWorldPosition() ).length();
+ if ( ai_->vesselObject( ) ) {
+ startPos_ = ai_->vesselObject( )->mainNode()->getWorldPosition();
+ initDist_ = ( pos_ - ai_->vesselObject( )->mainNode()->getWorldPosition() ).length();
std::cout << "ai pos: " << startPos_ << std::endl;
std::cout << "dist: " << initDist_ << std::endl;
std::cout << "target: " << pos_ << std::endl;
@@ -302,15 +303,15 @@
// addCommand( new AiCommandWait( ai_, 10.0 ) );
}
bool AiCommandApproach::update(){
- if ( ai_->sectorObject( ) ) {
- double dist = ( pos_ - ai_->sectorObject( )->mainNode()->getWorldPosition() ).length();
+ if ( ai_->vesselObject( ) ) {
+ double dist = ( pos_ - ai_->vesselObject( )->mainNode()->getWorldPosition() ).length();
- if ( ai_->brakingDistance( ai_->sectorObject( )->speed() ) > dist ){
+ if ( ai_->brakingDistance( ai_->vesselObject( )->speed() ) > dist ){
addCommand( new AiCommandStop( ai_, false ) );
return true;
}
- if ( ai_->sectorObject( )->speed() < 0.05 ){
+ if ( ai_->vesselObject( )->speed() < 0.05 ){
std::cout << "dist: " << dist << std::endl;
if ( dist < 10.0 ) { // 10m snapping
return false;
@@ -330,13 +331,13 @@
void AiCommandApproach::stop(){
std::cout << "AiCommandApproach::stop():" << std::endl;
- if ( ai_->sectorObject( ) ) {
- ai_->sectorObject( )->setThrustRate( 0.0 );
- std::cout << "ai pos: " << ai_->sectorObject( )->mainNode()->getWorldPosition() << std::endl;
- std::cout << "dir: " << -ai_->sectorObject( )->mainNode()->getWorldOrientation().zAxis()
+ if ( ai_->vesselObject( ) ) {
+ ai_->vesselObject( )->setThrustRate( 0.0 );
+ std::cout << "ai pos: " << ai_->vesselObject( )->mainNode()->getWorldPosition() << std::endl;
+ std::cout << "dir: " << -ai_->vesselObject( )->mainNode()->getWorldOrientation().zAxis()
<< std::endl;
std::cout << "pos: "
- << startPos_ + initDist_ * -ai_->sectorObject( )->mainNode()->getWorldOrientation().zAxis()
+ << startPos_ + initDist_ * -ai_->vesselObject( )->mainNode()->getWorldOrientation().zAxis()
<< std::endl;
}
Modified: trunk/src/AiCommands.h
===================================================================
--- trunk/src/AiCommands.h 2008-05-01 18:29:14 UTC (rev 887)
+++ trunk/src/AiCommands.h 2008-05-04 12:13:52 UTC (rev 888)
@@ -46,7 +46,9 @@
public:
AiCommand( AiObject * ai ) : ai_( ai ), abort_( false ), running_( false ), runtime_( 0.0 ), elapsedTime_ ( 0.0 ){}
- virtual ~AiCommand(){}
+ virtual ~AiCommand(){
+ for_each( cmdQueue_.begin(), cmdQueue_.end(), deletePtr() ); cmdQueue_.clear();
+ }
virtual bool update( double elapsedTime ){
elapsedTime_ = elapsedTime;
@@ -58,17 +60,17 @@
}
nr_++;
if ( abort_ ){
- if ( !cmds_.empty() ){
- cmds_.front()->abort();
+ if ( !cmdQueue_.empty() ){
+ cmdQueue_.front()->abort();
}
stop();
return false;
}
- if ( !cmds_.empty() ){
- if ( !cmds_.front()->update( elapsedTime_ ) ){
- delete cmds_.front();
- cmds_.pop_front();
+ if ( !cmdQueue_.empty() ){
+ if ( !cmdQueue_.front()->update( elapsedTime_ ) ){
+ delete cmdQueue_.front();
+ cmdQueue_.pop_front();
}
} else if ( !update( ) ) {
stop();
@@ -83,7 +85,7 @@
virtual bool update( ) { return false; }
virtual void stop() { std::cout << "AiCommand stop" << std::endl; }
- void addCommand( AiCommand * cmd ) { cmds_.push_back( cmd ); }
+ void addCommand( AiCommand * cmd ) { cmdQueue_.push_back( cmd ); }
protected:
AiObject * ai_;
@@ -92,7 +94,7 @@
double runtime_;
double elapsedTime_;
uint nr_;
- std::deque< AiCommand * > cmds_;
+ std::deque< AiCommand * > cmdQueue_;
};
class AiCommandSelfDestruct : public AiCommand {
Modified: trunk/src/AiManager.cpp
===================================================================
--- trunk/src/AiManager.cpp 2008-05-01 18:29:14 UTC (rev 887)
+++ trunk/src/AiManager.cpp 2008-05-04 12:13:52 UTC (rev 888)
@@ -23,7 +23,8 @@
#include "common.h"
#include "ResourceManager.h"
-#include "SectorObjects.h"
+#include "VesselManager.h"
+#include "SectorObjectVessel.h"
#include "Sector.h"
#include "UnDockedState.h"
#include "GameStateManager.h"
@@ -103,14 +104,15 @@
}
AiObject * ai = createAiObject( name );
- SectorObjectMoveableLocal *obj = NULL;
+ SectorObjectVessel *obj = NULL;
if ( resources_ ){
if ( resources_->gameStateRoot->activeState( )->name() == "UnDockedState" ){
obj = dynamic_cast < UnDockedState *>(resources_->gameStateRoot->activeState() )->sector()->
- createMoveableObjectLocal( ai->name(),
- resources_->network->userID(), ai->id(),
- *VesselManager::getSingleton().vessel( "apteryx" ) );
+ createVessel( ai->name(),
+ resources_->network->userID(), 0,
+ *VesselManager::getSingleton().vessel( "apteryx" ) );
+
obj->vessel( )->setPowerPlant( EquipmentManager::getSingleton().powerPlant( "Spud" ) );
obj->vessel( )->setEngine( EquipmentManager::getSingleton().engine( "T-E-15" ) );
obj->vessel( )->setRadar( EquipmentManager::getSingleton().radar( "Outlook" ) );
@@ -122,7 +124,7 @@
}
}
//-250, 0, 500
- ai->setSectorObject( obj );
+ ai->setVesselObject( obj );
Ogre::Real xmin = -150.0, xmax = -200.0;
Ogre::Real ymin = 0.0, ymax = 100.0;
Ogre::Real zmin = 300.0, zmax = 400.0;
@@ -171,7 +173,7 @@
void AiManager::eraseAiObject( AiObject * ai ){
boost::mutex::scoped_lock lock( eraseMutex_ );
- SectorObjectMoveableLocal *obj = ai->sectorObject( );
+ SectorObjectVessel *obj = ai->vesselObject( );
if ( obj ){ __D( obj->name() )
obj->destroy();
}
Modified: trunk/src/AiManager.h
===================================================================
--- trunk/src/AiManager.h 2008-05-01 18:29:14 UTC (rev 887)
+++ trunk/src/AiManager.h 2008-05-04 12:13:52 UTC (rev 888)
@@ -32,7 +32,7 @@
namespace OpenGate{
class ResourceManager;
-class SectorObjectMoveableLocal;
+class SectorObjectVessel;
class AiManager;
class AiObject;
Modified: trunk/src/AiObject.cpp
===================================================================
--- trunk/src/AiObject.cpp 2008-05-01 18:29:14 UTC (rev 887)
+++ trunk/src/AiObject.cpp 2008-05-04 12:13:52 UTC (rev 888)
@@ -22,7 +22,9 @@
#include "common.h"
#include "AiObject.h"
#include "AiCommands.h"
-#include "SectorObjects.h"
+#include "SectorObjectVessel.h"
+#include "Moveable.h"
+#include "Vessel.h"
#include "Sector.h"
#include "Station.h"
@@ -34,7 +36,7 @@
namespace OpenGate{
-AiObject::AiObject( uint id ) : id_( id ), sectorObject_( NULL ){
+AiObject::AiObject( uint id ) : id_( id ), vesselObject_( NULL ){
livetime_ = new Ogre::Timer();
reset();
}
@@ -67,12 +69,13 @@
isAlive_ = true;
die_ = false;
activeCmd_ = NULL;
+ for_each( cmdQueue_.begin(), cmdQueue_.end(), deletePtr() ); cmdQueue_.clear();
}
-void AiObject::setSectorObject( SectorObjectMoveableLocal * obj ){
- sectorObject_ = obj;
+void AiObject::setVesselObject( SectorObjectVessel * obj ){
+ vesselObject_ = obj;
if ( obj ){
- sectorObject_->setControler( this );
+ vesselObject_->setControler( this );
}
}
@@ -226,16 +229,16 @@
double AiObject::maxSpeed( double thrustRate ) const {
//** vmax(th,d):=sqrt( th/d ) ** P
- double d = sectorObject_->vessel()->dragFactor();
- double th = sectorObject_->maxThrust() * thrustRate;
+ double d = vesselObject_->moveable()->dragFactor();
+ double th = vesselObject_->maxThrust() * thrustRate;
return sqrt( th / d );
}
double AiObject::speedAfterTime( double time, double thrustRate ) const {
//** v[ t ] := vmax * tanh( th / m / vmax * t ) ** P
- double d = sectorObject_->vessel()->dragFactor();
- double m = sectorObject_->mass();
- double th = sectorObject_->maxThrust() * thrustRate;
+ double d = vesselObject_->vessel()->dragFactor();
+ double m = vesselObject_->mass();
+ double th = vesselObject_->maxThrust() * thrustRate;
double vmax = maxSpeed( thrustRate );
double v = vmax * std::tanh( th / m / vmax * time );
// std::cout << " th: " << th << "; m: " << m << "; d: " << d << "; vmax: " << vmax << "; t: " << time
@@ -247,9 +250,9 @@
//** v[ t ] := vmax * tanh( th / m / vmax * t )
//** s[t]:=integrate(v[t], t)
//** s = vmax^2/a * log( cosh( a / vmax * t ) ) ** P
- double d = sectorObject_->vessel()->dragFactor();
- double m = sectorObject_->mass();
- double th = sectorObject_->maxThrust() * thrustRate;
+ double d = vesselObject_->vessel()->dragFactor();
+ double m = vesselObject_->mass();
+ double th = vesselObject_->maxThrust() * thrustRate;
double vmax = maxSpeed( thrustRate );
double a = th / m;
double s = ( vmax * vmax ) / a * std::log( std::cosh( a / vmax * time ) );
@@ -258,9 +261,9 @@
return s;
}
double AiObject::brakingTime( double v ) const {
- double d = sectorObject_->vessel()->dragFactor();
- double m = sectorObject_->mass();
- double a = sectorObject_->brakingAcc();
+ double d = vesselObject_->vessel()->dragFactor();
+ double m = vesselObject_->mass();...
[truncated message content] |
|
From: <spo...@us...> - 2008-05-11 11:57:57
|
Revision: 890
http://opengate.svn.sourceforge.net/opengate/?rev=890&view=rev
Author: spom_spom
Date: 2008-05-11 04:58:03 -0700 (Sun, 11 May 2008)
Log Message:
-----------
Further refactoring: started merging the several entitymanager, fixed some evel bugs
Modified Paths:
--------------
trunk/data/MediaFromOgre/AdvancedMaterials/Examples-Advanced.material
trunk/data/ecms/ghost.xml
trunk/data/guns/duster.xml
trunk/data/guns/excavator.xml
trunk/data/materials/planet.material
trunk/data/misc/ids.xml
trunk/data/misc/testsector.xml
trunk/src/AiManager.cpp
trunk/src/BaseObject.cpp
trunk/src/BaseObject.h
trunk/src/Entity.cpp
trunk/src/Entity.h
trunk/src/EntityManager.cpp
trunk/src/EntityManager.h
trunk/src/Equipment.h
trunk/src/GameStateManager.cpp
trunk/src/Makefile.am
trunk/src/MarketDialog.cpp
trunk/src/Moveable.cpp
trunk/src/Moveable.h
trunk/src/OpcodeWrapper.cpp
trunk/src/OpcodeWrapper.h
trunk/src/Projectile.cpp
trunk/src/ResourceManager.cpp
trunk/src/ResourceManager.h
trunk/src/Sector.cpp
trunk/src/Sector.h
trunk/src/SectorObject.cpp
trunk/src/SectorObject.h
trunk/src/SectorObjectAvatar.cpp
trunk/src/SectorObjectAvatar.h
trunk/src/SectorObjectMissile.cpp
trunk/src/SectorObjectMissile.h
trunk/src/SectorObjectMoveable.cpp
trunk/src/SectorObjectMoveable.h
trunk/src/SectorObjectVessel.cpp
trunk/src/SectorObjectVessel.h
trunk/src/ShipConfigDialog.cpp
trunk/src/ShipConfigDialog.h
trunk/src/Station.cpp
trunk/src/UnDockedState.cpp
trunk/src/Vessel.cpp
trunk/src/Vessel.h
trunk/src/common.h
Added Paths:
-----------
trunk/data/materials/missiles.material
trunk/data/materials/station.cg
trunk/data/missiles/bee.xml
trunk/data/missiles/bee_big.png
trunk/data/missiles/bee_small.png
trunk/src/Equipment.cpp
Modified: trunk/data/MediaFromOgre/AdvancedMaterials/Examples-Advanced.material
===================================================================
--- trunk/data/MediaFromOgre/AdvancedMaterials/Examples-Advanced.material 2008-05-04 15:50:32 UTC (rev 889)
+++ trunk/data/MediaFromOgre/AdvancedMaterials/Examples-Advanced.material 2008-05-11 11:58:03 UTC (rev 890)
@@ -1,74 +1,4 @@
-// -------------------------------
-// Cel Shading Section
-// -------------------------------
-vertex_program Ogre/CelShadingVP cg
-{
- source Example_CelShading.cg
- entry_point main_vp
- profiles vs_1_1 arbvp1
- default_params
- {
- param_named_auto lightPosition light_position_object_space 0
- param_named_auto eyePosition camera_position_object_space
- param_named_auto worldViewProj worldviewproj_matrix
- param_named shininess float 10
- }
-}
-
-fragment_program Ogre/CelShadingFP cg
-{
- source Example_CelShading.cg
- entry_point main_fp
- profiles ps_1_1 arbfp1 fp20
-}
-
-
-material Examples/CelShading
-{
- technique
- {
- pass
- {
- vertex_program_ref Ogre/CelShadingVP
- {
- // map shininess from custom renderable param 1
- param_named_auto shininess custom 1
- }
- fragment_program_ref Ogre/CelShadingFP
- {
- // map diffuse from custom renderable param 2
- param_named_auto diffuse custom 2
- // map specular from custom renderable param 2
- param_named_auto specular custom 3
- }
- texture_unit
- {
- texture cel_shading_diffuse.png 1d
- tex_address_mode clamp
- filtering none
- }
- texture_unit
- {
- texture cel_shading_specular.png 1d
- tex_address_mode clamp
- filtering none
- tex_coord_set 1
- }
- texture_unit
- {
- texture cel_shading_edge.png 1d
- tex_address_mode clamp
- filtering none
- tex_coord_set 2
- }
- }
- }
-
-}
-
-
-
//------------------------
// Bump mapping section
//------------------------
@@ -620,154 +550,7 @@
}
-//----------------------------
-// Distortion effects
-//----------------------------
-vertex_program Examples/FresnelRefractReflectVP cg
-{
- source Example_Fresnel.cg
- entry_point main_vp
- profiles vs_1_1 arbvp1
-}
-vertex_program Examples/FresnelRefractReflectVPold cg
-{
- source Example_Fresnel.cg
- entry_point main_vp_old
- profiles vs_1_1 arbvp1
-}
-
-fragment_program Examples/FresnelRefractReflectFP cg
-{
- source Example_Fresnel.cg
- entry_point main_fp
- // sorry, ps_1_1 and fp20 can't do this
- profiles ps_2_0 arbfp1
-}
-
-fragment_program Examples/FresnelRefractReflectPS asm
-{
- source Example_FresnelPS.asm
- // sorry, only for ps_1_4 :)
- syntax ps_1_4
-
-}
-
-material Examples/FresnelReflectionRefraction
-{
- // ps_2_0 / arbfp1
- technique
- {
- pass
- {
-
- vertex_program_ref Examples/FresnelRefractReflectVP
- {
- param_named_auto worldViewProjMatrix worldviewproj_matrix
- param_named_auto eyePosition camera_position_object_space
- param_named_auto timeVal time 0.05
- param_named scroll float 1
- param_named scale float 1
- param_named noise float 1
- // scroll and noisePos will need updating per frame
- }
- fragment_program_ref Examples/FresnelRefractReflectFP
- {
- param_named fresnelBias float -0.1
- param_named fresnelScale float 1.8
- param_named fresnelPower float 8
- param_named tintColour float4 0 0.0.05 0.05 1
- param_named noiseScale float 0.05
- }
- // Noise
- texture_unit
- {
- // Perlin noise volume
- texture waves2.dds
- // min / mag filtering, no mip
- filtering linear linear none
- }
- // Reflection
- texture_unit
- {
- // Will be filled in at runtime
- texture Reflection
- tex_address_mode clamp
- // needed by ps.1.4
- tex_coord_set 1
- }
- // Refraction
- texture_unit
- {
- // Will be filled in at runtime
- texture Refraction
- tex_address_mode clamp
- // needed by ps.1.4
- tex_coord_set 2
- }
- }
-
-
- }
-
- // ATI 8500 +
- technique
- {
- pass
- {
- vertex_program_ref Examples/FresnelRefractReflectVPold
- {
- param_named_auto worldViewProjMatrix worldviewproj_matrix
- param_named_auto eyePosition camera_position_object_space
- param_named fresnelBias float -0.3
- param_named fresnelScale float 1.4
- param_named fresnelPower float 8
- param_named_auto timeVal time_0_1 20
- param_named scroll float 1
- param_named scale float 4
- param_named noise float 1
- // scroll and noisePos will need updating per frame
- }
-
- // for ATI RADEON 8500 - 9200
- fragment_program_ref Examples/FresnelRefractReflectPS
- {
- // distortionRange
- param_indexed 0 float 0.025
- // tintColour
- param_indexed 1 float4 0.05 0.12 0.15 1
- }
-
- // Noise
- texture_unit
- {
- // Perlin noise volume
- texture perlinvolume.dds 3d
- // min / mag filtering, no mip
- filtering linear linear none
- }
- // Reflection
- texture_unit
- {
- // Will be filled in at runtime
- texture Reflection
- tex_address_mode clamp
- // needed by ps.1.4
- tex_coord_set 1
- }
- // Refraction
- texture_unit
- {
- // Will be filled in at runtime
- texture Refraction
- tex_address_mode clamp
- // needed by ps.1.4
- tex_coord_set 2
- }
- }
- }
-}
-
// Normal-mapped Athene statue
material Examples/Athene/NormalMapped
{
Modified: trunk/data/ecms/ghost.xml
===================================================================
--- trunk/data/ecms/ghost.xml 2008-05-04 15:50:32 UTC (rev 889)
+++ trunk/data/ecms/ghost.xml 2008-05-11 11:58:03 UTC (rev 890)
@@ -20,7 +20,7 @@
<!-- Specific data -->
<sensorlevel>3</sensorlevel>
- <power>970000</power>
+ <power_input>970000</power_input>
<!-- Production Data -->
<manufacturer>Amananth</manufacturer>
Modified: trunk/data/guns/duster.xml
===================================================================
(Binary files differ)
Modified: trunk/data/guns/excavator.xml
===================================================================
(Binary files differ)
Added: trunk/data/materials/missiles.material
===================================================================
--- trunk/data/materials/missiles.material (rev 0)
+++ trunk/data/materials/missiles.material 2008-05-11 11:58:03 UTC (rev 890)
@@ -0,0 +1,42 @@
+material Missile/Thruster
+{
+ receive_shadows on
+ technique
+ {
+ pass
+ {
+ ambient 0.500000 0.500000 0.500000 1.000000
+ diffuse 0.000000 0.000000 0.000000 1.000000
+ specular 0.500000 0.500000 0.500000 1.000000 12.500000
+ emissive 0.000000 0.000000 0.000000 1.000000
+ }
+ }
+}
+material Missile/Nose
+{
+ receive_shadows on
+ technique
+ {
+ pass
+ {
+ ambient 0.500000 0.500000 0.500000 1.000000
+ diffuse 0.461176 0.018824 0.018824 1.000000
+ specular 0.500000 0.500000 0.500000 1.000000 12.500000
+ emissive 0.000000 0.000000 0.000000 1.000000
+ }
+ }
+}
+material Missile/Hull
+{
+ receive_shadows on
+ technique
+ {
+ pass
+ {
+ ambient 0.500000 0.500000 0.500000 1.000000
+// diffuse 0.480000 0.480000 0.480000 1.000000
+// specular 0.500000 0.500000 0.500000 1.000000 12.500000
+// emissive 0.000000 0.000000 0.000000 1.000000
+ }
+ }
+}
Modified: trunk/data/materials/planet.material
===================================================================
--- trunk/data/materials/planet.material 2008-05-04 15:50:32 UTC (rev 889)
+++ trunk/data/materials/planet.material 2008-05-11 11:58:03 UTC (rev 890)
@@ -165,7 +165,8 @@
}
texture_unit
{
- texture clouds_2500x1250.jpg
+ texture clouds_1275.jpg
+// texture clouds_2500x1250.jpg
}
}
}
@@ -213,4 +214,4 @@
// set_texture_alias Image world.topo.200407.png
// set_texture_alias ImageNormMap texture world.topo.200407Norm.png
// set_texture_alias ImageSpecMap texture world.topo.200407Spec.png
-}
\ No newline at end of file
+}
Added: trunk/data/materials/station.cg
===================================================================
--- trunk/data/materials/station.cg (rev 0)
+++ trunk/data/materials/station.cg 2008-05-11 11:58:03 UTC (rev 890)
@@ -0,0 +1,71 @@
+float3 expand( float3 v ) { return (v - 0.5) * 2; }
+
+struct vertexOutput {
+ float4 clipPos : POSITION;
+ float2 uv : TEXCOORD0;
+ float4 pos : TEXCOORD1;
+ float3 normal : TEXCOORD2;
+ float3 binormal : TEXCOORD3;
+ float3 tangent : TEXCOORD4;
+ float4 lightPos : TEXCOORD5;
+ float3 camPos : TEXCOORD6;
+ float3 tsLightDir : TEXCOORD7;
+};
+
+void main_vp( float4 objectPos : POSITION,
+ float2 uv : TEXCOORD0,
+ float3 normal : NORMAL,
+ float3 tangent : TANGENT,
+ out vertexOutput OUT,
+ uniform float4 lightPos,
+ uniform float3 camPos,
+ uniform float4x4 modelViewProjection)
+{
+ OUT.clipPos = mul( modelViewProjection, objectPos ); // position (view space)
+ OUT.uv = uv;
+
+ OUT.pos = objectPos;
+ OUT.normal = normal;
+ OUT.tangent = tangent;
+ OUT.lightPos = lightPos;
+ OUT.camPos = camPos;
+
+ float3 lightDir = lightPos.xyz - ( objectPos * lightPos.w );
+ OUT.binormal = cross( tangent, normal );
+ float3x3 rotation = float3x3( tangent, OUT.binormal, normal );
+ OUT.tsLightDir = mul( rotation, lightDir );
+}
+
+float4 main_fp( vertexOutput IN,
+ uniform float exponent,
+ uniform float4 lightDiffuse,
+ uniform float4 lightSpecular,
+ uniform float4 lightAmbient,
+ uniform sampler2D decalTexture : TEXUNIT0,
+ uniform sampler2D normTexture : TEXUNIT1,
+ uniform sampler2D specTexture : TEXUNIT2,
+ uniform samplerCUBE normalCubeMap : TEXUNIT3 ) : COLOR {
+
+ float3 lightDir = normalize( IN.lightPos.xyz - ( IN.pos * IN.lightPos.w ) );
+ float3 camDir = normalize( IN.camPos - IN.pos.xyz );
+ float3 halfAngle = normalize( lightDir );
+
+ float3 nN = normalize( IN.normal );
+ float NdotL = dot( lightDir, nN );
+ float NdotH = dot( halfAngle, nN );
+
+ //cg docs say using their lit function is the fastest
+ float4 Lit = lit( NdotL, NdotH, exponent );
+
+ float3 lightVec = expand( texCUBE( normalCubeMap, IN.tsLightDir ).xyz );
+
+ float3 n = expand( tex2D( normTexture, IN.uv ).xyz);
+ float4 d = tex2D( decalTexture, IN.uv );
+ float4 s = tex2D( specTexture, IN.uv );
+
+ //return lightDiffuse * saturate( dot(n, lightVec) );//bumpVec;
+ // return d * dot(bumpVec, lightVec);
+ // return lightDiffuse * Lit.y + lightSpecular * Lit.z * s + d * dot(bumpVec, lightVec);
+ return lightDiffuse * Lit.y + lightSpecular * Lit.z * s + lightAmbient * d + saturate( dot(n, lightVec) ) * d;
+}
+
Modified: trunk/data/misc/ids.xml
===================================================================
(Binary files differ)
Modified: trunk/data/misc/testsector.xml
===================================================================
--- trunk/data/misc/testsector.xml 2008-05-04 15:50:32 UTC (rev 889)
+++ trunk/data/misc/testsector.xml 2008-05-11 11:58:03 UTC (rev 890)
@@ -47,9 +47,28 @@
<scale>20, 20, 20</scale>
<material>Asteroid</material>
</sectorobject>
+ <sectorobject>
+ <name>beacon</name>
+ <mesh>beacon</mesh>
+ <position> -650, 0, 800</position>
+ <scale>20, 20, 20</scale>
+ <material>Sta/TS/Background</material>
+ </sectorobject>
+ <sectorobject>
+ <name>ring</name>
+ <mesh>ring</mesh>
+ <position> -650, 100, 800</position>
+ <scale>35, 35, 35</scale>
+ </sectorobject>
+
+<!-- <sectorobject>
+ <name>ring2</name>
+ <mesh>ring2</mesh>
+ <position> -650, 300, 800</position>
+ <scale>100, 100, 100</scale>
+ <material>Sta/TS/Background</material>
+ </sectorobject>-->
-
-
<!-- <sectorobject> -->
<!-- <name>astro6</name> -->
<!-- <mesh>ice_oval_6</mesh> -->
Added: trunk/data/missiles/bee.xml
===================================================================
--- trunk/data/missiles/bee.xml (rev 0)
+++ trunk/data/missiles/bee.xml 2008-05-11 11:58:03 UTC (rev 890)
@@ -0,0 +1,31 @@
+<?xml version="1.0"?>
+
+<container>
+ <object_id>10002</object_id>
+ <name_de>bee</name_de>
+ <name_en>bee</name_en>
+ <mesh>firefly</mesh>
+ <category_id>11</category_id>
+ <faction_id>3</faction_id>
+ <description_en>Offense anti vessel missile for small ships</description_en>
+<!-- <production_center>Octavius Great Pillars</production_center>
+ <production_center>Octavius Outpost</production_center>
+ <manufacturer>Octave Propulsion Laboratories</manufacturer>-->
+ <required_rank>2</required_rank>
+ <size>1</size>
+ <mass>150</mass>
+ <thrust>150000</thrust>
+ <damage>10400</damage>
+ <yaw>90</yaw>
+ <pitch>90</pitch>
+ <roll>90</roll>
+ <armor>90</armor>
+ <lifetime>22</lifetime>
+ <drag>1</drag>
+ <basesize>1</basesize>
+ <required_component>aluminium</required_component>
+ <required_component>magnesium</required_component>
+ <required_component>laser components</required_component>
+ <required_component>magnetic components</required_component>
+ <required_political_status>0</required_political_status>
+</container>
Added: trunk/data/missiles/bee_big.png
===================================================================
(Binary files differ)
Property changes on: trunk/data/missiles/bee_big.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/data/missiles/bee_small.png
===================================================================
(Binary files differ)
Property changes on: trunk/data/missiles/bee_small.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: trunk/src/AiManager.cpp
===================================================================
--- trunk/src/AiManager.cpp 2008-05-04 15:50:32 UTC (rev 889)
+++ trunk/src/AiManager.cpp 2008-05-11 11:58:03 UTC (rev 890)
@@ -113,11 +113,11 @@
resources_->network->userID(), 0,
*VesselManager::getSingleton().vessel( "apteryx" ) );
- obj->vessel( )->setPowerPlant( EquipmentManager::getSingleton().powerPlant( "Spud" ) );
- obj->vessel( )->setEngine( EquipmentManager::getSingleton().engine( "T-E-15" ) );
- obj->vessel( )->setRadar( EquipmentManager::getSingleton().radar( "Outlook" ) );
- obj->vessel( )->setShield( EquipmentManager::getSingleton().shield( "Kydango" ) );
- obj->vessel( )->setCapacitor( EquipmentManager::getSingleton().capacitor( "Sponge" ) );
+ obj->vessel( )->setPowerPlant( resources_->entityManager->powerPlant( "Spud" ) );
+ obj->vessel( )->setEngine( resources_->entityManager->engine( "T-E-15" ) );
+ obj->vessel( )->setRadar( resources_->entityManager->radar( "Outlook" ) );
+ obj->vessel( )->setShield( resources_->entityManager->shield( "Kydango" ) );
+ obj->vessel( )->setCapacitor( resources_->entityManager->capacitor( "Sponge" ) );
std::cout << "Create " << obj->name() << std::endl;
} else {
std::cout << "spawn only in undockedState" << std::endl;
Modified: trunk/src/BaseObject.cpp
===================================================================
--- trunk/src/BaseObject.cpp 2008-05-04 15:50:32 UTC (rev 889)
+++ trunk/src/BaseObject.cpp 2008-05-11 11:58:03 UTC (rev 890)
@@ -20,6 +20,7 @@
#include "BaseObject.h"
#include "Sector.h"
+#include "OpcodeWrapper.h"
#include <OgreEntity.h>
@@ -28,25 +29,38 @@
namespace OpenGate{
BaseObject::BaseObject( const Ogre::String & name, Sector * sector, Uint32 userID, Uint8 childID )
- : name_( name ), sector_( sector ), userID_( userID ), childID_( childID ), mainNode_( NULL ){
+ : name_( name ), sector_( sector ), userID_( userID ), childID_( childID ), mainNode_( NULL ), collObj_( NULL ){
globalID_ = createGlobalID( userID, childID );
- sceneMgr_ = sector_->sceneManager();
- try{
- mainNode_ = sceneMgr_->getRootSceneNode()->createChildSceneNode( name + "_MainNode" );
- } catch( Ogre::Exception & e ) {
- LogManager::getSingleton().fatal( e.getFullDescription() );
- }
+ sceneMgr_ = sector_->sceneManager();
+ try{
+ mainNode_ = sceneMgr_->getRootSceneNode()->createChildSceneNode( name + "_MainNode" );
+ } catch( Ogre::Exception & e ) {
+ LogManager::getSingleton().fatal( e.getFullDescription() );
+ }
- destroyRequest_ = false;
- lifeTime_ = 0.0;
- selectable_ = false;
- collObj_ = NULL;
+ lifeTime_ = 0.0;
+ selectable_ = false;
+ destroyRequest_ = false;
+ active_ = true;
}
BaseObject::~BaseObject(){
- sceneMgr_->getRootSceneNode()->removeAndDestroyChild( mainNode_->getName() );
+ sceneMgr_->getRootSceneNode()->removeAndDestroyChild( mainNode_->getName() );
}
+void BaseObject::setActive( bool activate ){
+ // std::cout << "BaseObject::setActive " << mainNode_->getName() << " " << activate << std::endl;
+ if ( active_ && !activate ){
+ setVisible( false );
+ active_ = false;
+ deactivate_();
+ } else if ( !active_ && activate ){
+ setVisible( true );
+ active_ = true;
+ destroyRequest_ = false;
+ lifeTime_ = 0.0;
+ }
+}
} // namespace OpenGate
Modified: trunk/src/BaseObject.h
===================================================================
--- trunk/src/BaseObject.h 2008-05-04 15:50:32 UTC (rev 889)
+++ trunk/src/BaseObject.h 2008-05-11 11:58:03 UTC (rev 890)
@@ -55,14 +55,20 @@
virtual void collide( BaseObject * object ) = 0;
- inline virtual Uint32 userID() const { return userID_; }
+ inline void setUserID( Uint32 ID ) { userID_ = ID; }
+
+ inline Uint32 userID() const { return userID_; }
- inline virtual Uint8 childID() const { return childID_; }
+ inline void setChildID( Uint8 ID ) { childID_ = ID; }
+
+ inline Uint8 childID() const { return childID_; }
inline virtual Uint32 globalID() const { return globalID_; }
virtual bool isChild() const { return childID_ > 0; }
+ void setName( const std::string & name ) { name_ = name; }
+
Ogre::String name() const { return name_; }
inline Ogre::SceneNode * mainNode() { return mainNode_; }
@@ -91,20 +97,29 @@
virtual void setVisible( bool visible ) { mainNode_->setVisible( visible ); }
+ virtual void setActive( bool active );
+
+ inline virtual bool isActive() const { return active_; }
+
protected:
- Ogre::String name_;
- Sector * sector_;
- Uint32 userID_;
- Uint8 childID_;
- Uint32 globalID_;
+
+ virtual void deactivate_(){ }
+
+ Ogre::String name_;
+ Sector * sector_;
+ Uint32 userID_;
+ Uint8 childID_;
+ Uint32 globalID_;
- Ogre::SceneNode * mainNode_;
-
- bool selectable_;
- Ogre::SceneManager * sceneMgr_;
- OgreOpcode::CollisionObject * collObj_;
- Ogre::Real lifeTime_;
- bool destroyRequest_;
+ Ogre::SceneNode * mainNode_;
+ Ogre::SceneManager * sceneMgr_;
+ Ogre::Real lifeTime_;
+
+ OgreOpcode::CollisionObject * collObj_;
+
+ bool selectable_;
+ bool destroyRequest_;
+ bool active_;
};
} //namespace OpenGate
Modified: trunk/src/Entity.cpp
===================================================================
--- trunk/src/Entity.cpp 2008-05-04 15:50:32 UTC (rev 889)
+++ trunk/src/Entity.cpp 2008-05-11 11:58:03 UTC (rev 890)
@@ -33,6 +33,12 @@
Entity::Entity()
: name_( "unknown" ), className_( "unknown" ),
description_("Please fill in description"), imageFileName_("unknown"), ceguiImageName_( "unknownEntityImageset") {
+ //** just an idea
+// addProperty< float >( "baseYaw", this, setBaseYaw, baseYaw, mandatory, default, description )
+ //Property * prop = new Property< Uint32 >( "mass", this, &OpenGate::Entity::setMass, &OpenGate::Entity::mass );
+ //properties_.push_back( new Property< Uint32 >( "mass", this, &OpenGate::Entity::setMass, &OpenGate::Entity::mass ) );
+
+
id_ = 0;
techLevel_ = 0;
mass_ = 1;
@@ -43,7 +49,7 @@
baseYaw_ = 0;
basePitch_ = 0;
baseRoll_ = 0;
-
+
imageInitialised_ = false;
setFactionName_( ResourceManager::getSingleton().factionName( factionID_ ) );
}
@@ -118,4 +124,47 @@
return !fail;
}
+bool Entity::readPropertiesFromXML( TiXmlHandle & hRoot ){
+ if ( !readXMLNode< std::string >( hRoot, "name_"+ ResourceManager::getSingleton().languageSuffix(),
+ this, &OpenGate::Entity::setName, false ) ){
+ readXMLNode< std::string >( hRoot, "name", this, &OpenGate::Entity::setName, true );
+ }
+ //readXMLNode< std::string >( hRoot, "name_de", entity, &OpenGate::Entity::setName, true );
+ readXMLNode< Uint16 >( hRoot, "object_id", this, &OpenGate::Entity::setID, true );
+ readXMLNode< Uint8 >( hRoot, "faction_id", this, &OpenGate::Entity::setFactionID, true );
+
+ readXMLNode< Uint8 >( hRoot, "class_id", this, &OpenGate::Entity::setClassID, false );
+ readXMLNode< Uint8 >( hRoot, "techlevel", this, &OpenGate::Entity::setTechLevel, false );
+ //readXMLNode< Uint8 >( hRoot, "required_rank", entity, &OpenGate::Entity::setRequieredRank, true );
+
+ readXMLNode< int >( hRoot, "size", this, &OpenGate::Entity::setSize, false );
+ readXMLNode< int >( hRoot, "mass", this, &OpenGate::Entity::setMass, false );
+
+ if ( !readXMLNode< std::string >( hRoot, "description_" + ResourceManager::getSingleton().languageSuffix(), this,
+ &OpenGate::Entity::setDescription, false ) ){
+ readXMLNode< std::string >( hRoot, "description", this, &OpenGate::Entity::setDescription, false );
+ }
+ readXMLNodes< std::string >( hRoot, "production-center", this, &OpenGate::Entity::addProductionCenter );
+ readXMLNode< float >( hRoot, "baseyaw", this, &OpenGate::Entity::setBaseYaw, false );
+ readXMLNode< float >( hRoot, "basepitch", this, &OpenGate::Entity::setBasePitch, false );
+ readXMLNode< float >( hRoot, "baseroll", this, &OpenGate::Entity::setBaseRoll, false );
+
+// Ogre::Real length = 0;
+// pElem = hRoot.ChildElement( "length", 0 ).Element();
+// if ( pElem ) length = toDouble( pElem->FirstChild()->Value() );
+//
+// Ogre::Real width = 0;
+// pElem = hRoot.ChildElement( "width", 0 ).Element();
+// if ( pElem ) width = toDouble( pElem->FirstChild()->Value() );
+//
+// Ogre::Real height = 0;
+// pElem = hRoot.ChildElement( "height", 0 ).Element();
+// if ( pElem ) height = toDouble( pElem->FirstChild()->Value() );
+// if ( length > 0 && width > 0 && height > 0 ) vessel->setBaseSize( width, height, length );
+
+
+ return true;
+}
+
+
} // namespace OpenGate
Modified: trunk/src/Entity.h
===================================================================
--- trunk/src/Entity.h 2008-05-04 15:50:32 UTC (rev 889)
+++ trunk/src/Entity.h 2008-05-11 11:58:03 UTC (rev 890)
@@ -31,8 +31,27 @@
namespace OpenGate{
+enum EntityType{NONE,ENTITY,VESSEL,COMMODITY,POWERPLANT,ENGINE,RADAR,ECM,CAPACITOR,SHIELD,GUN,MISSILE,MODX};
+
class Commodity;
+// class Property {
+// public:
+// template < class Class, class Setter, class Getter > Property( const std::string & name, Class * instance, Setter setter, Getter getter )
+// : name_( name ), instance_ ( instance ), setter_( &setter ), getter_( &getter ){
+// }
+//
+// void operator( )(){
+// (instance_->*setter_)( );
+// }
+// protected:
+// std::string name_;
+// void * instance_;
+// void * setter_;
+// void * getter_;
+//
+// };
+
/*!
* \brief This class definies the basic structure of all entity templates.
*
@@ -50,7 +69,9 @@
virtual ~Entity(){ }
virtual EntityType entityType() const { return rtti_; }
-
+
+ virtual bool readPropertiesFromXML( TiXmlHandle & hRoot );
+
inline std::string factionName( ) const { return factionName_; }
void setFactionID( int id );
@@ -58,7 +79,9 @@
inline void setName( const std::string & name ) { name_ = name; }
inline std::string name( ) const { return name_; }
-
+
+ inline void setClassID( Uint8 id ) { className_ = ResourceManager::getSingleton().className( id ); }
+
inline void setClassName( const std::string & name ) { className_ = name; }
inline std::string className( ) const { return className_; }
@@ -103,8 +126,9 @@
bool initialiseImage( const std::string & imageName, const std::string & targetName, bool verbose = false );
- inline void setProductionCenters( const std::set < std::string > & productionCenters ) {
- productionCenters_ = productionCenters; }
+ inline void addProductionCenter( const std::string & productionCenter ) {
+ productionCenters_.insert( productionCenter );
+ }
inline std::set < std::string > productionCenters( ) const { return productionCenters_; }
inline void setRequieredComponents( const std::set < Commodity * > & requieredComponents ) {
@@ -152,6 +176,8 @@
/*! For runtime identification of an entity item. */
EntityType rtti_;
+
+ //std::vector < Property< class ValueType > * > properties_;
};
} // namespace OpenGate
Modified: trunk/src/EntityManager.cpp
===================================================================
--- trunk/src/EntityManager.cpp 2008-05-04 15:50:32 UTC (rev 889)
+++ trunk/src/EntityManager.cpp 2008-05-11 11:58:03 UTC (rev 890)
@@ -29,13 +29,20 @@
#include <OgreFileSystem.h>
#include <OgreSharedPtr.h>
+#include <string>
+
namespace OpenGate {
+EntityManager::EntityManager() {
+ log_ = LogManager::getSingletonPtr();
+ resources_ = ResourceManager::getSingletonPtr();
+}
+
EntityManager::~EntityManager(){
- for ( std::map< Uint16, Entity * >::iterator it = templatesByID_.begin(); it != templatesByID_.end(); it ++ ){
- delete it->second;
- }
- templatesByID_.end();
+ for ( std::map< Uint16, Entity * >::iterator it = templatesByID_.begin(); it != templatesByID_.end(); it ++ ){
+ delete it->second;
+ }
+ templatesByID_.end();
}
EntityType EntityManager::categoryType( const std::string & category ){
@@ -45,17 +52,17 @@
category == "Powerplant" || category == "Powerplants" ||
category == "Power plant" || category == "Power plants" ||
category == "powerplant" || category == "powerplants" ) return POWERPLANT;
+ else if ( category == "Capacitor" || category == "Capacitors" ||
+ category == "capacitor" || category == "capacitors" ) return CAPACITOR;
else if ( category == "Engine" || category == "Engines" ||
category == "engine" || category == "engines" ) return ENGINE;
+ else if ( category == "Shield" || category == "Shields" ||
+ category == "shield" || category == "shields" ) return SHIELD;
else if ( category == "Radar" || category == "Radars" ||
category == "radar" || category == "radars" ) return RADAR;
else if ( category == "ECM" || category == "ECMs" ||
category == "Ecm" || category == "Ecms" ||
category == "ecm" || category == "ecms" ) return ECM;
- else if ( category == "Capacitor" || category == "Capacitors" ||
- category == "capacitor" || category == "capacitors" ) return CAPACITOR;
- else if ( category == "Shield" || category == "Shields" ||
- category == "shield" || category == "shields" ) return SHIELD;
else if ( category == "Gun" || category == "Guns" ||
category == "gun" || category == "guns" ...
[truncated message content] |
|
From: <spo...@us...> - 2008-05-11 22:19:51
|
Revision: 893
http://opengate.svn.sourceforge.net/opengate/?rev=893&view=rev
Author: spom_spom
Date: 2008-05-11 15:19:57 -0700 (Sun, 11 May 2008)
Log Message:
-----------
Fixed some problems that lead to segfault
Modified Paths:
--------------
trunk/data/ships/escape_capsule.xml
trunk/data/ships/octavius/apteryx/apteryx.xml
trunk/data/ships/octavius/condor/condor.xml
trunk/data/ships/octavius/phoenix/phoenix.xml
trunk/data/ships/quantar/storm/storm.xml
trunk/data/ships/quantar/typhoon/typhoon.xml
trunk/data/ships/squadrok/squid/s-1.xml
trunk/data/ships/squadrok/squid/s-2.xml
trunk/data/ships/squadrok/squid/s-3.xml
trunk/data/ships/squadrok/squid/squid.xml
trunk/src/AiManager.cpp
trunk/src/Avatar.cpp
trunk/src/Entity.cpp
trunk/src/Entity.h
trunk/src/EntityManager.cpp
trunk/src/EntityManager.h
trunk/src/GameStateManager.cpp
trunk/src/GameStateManager.h
trunk/src/Makefile.am
trunk/src/MarketDialog.cpp
trunk/src/Moveable.cpp
trunk/src/OpcodeWrapper.cpp
trunk/src/OpcodeWrapper.h
trunk/src/Planet.cpp
trunk/src/ResourceManager.cpp
trunk/src/Sector.cpp
trunk/src/Sector.h
trunk/src/SectorObject.cpp
trunk/src/SectorObject.h
trunk/src/SectorObjectMissile.cpp
trunk/src/SectorObjectMissile.h
trunk/src/SectorObjectMoveable.cpp
trunk/src/SectorObjectMoveable.h
trunk/src/SectorObjectVessel.cpp
trunk/src/SectorObjectVessel.h
trunk/src/ShipConfigDialog.cpp
trunk/src/Vessel.cpp
trunk/src/Vessel.h
trunk/src/common.h
Removed Paths:
-------------
trunk/src/VesselManager.cpp
trunk/src/VesselManager.h
Modified: trunk/data/ships/escape_capsule.xml
===================================================================
(Binary files differ)
Modified: trunk/data/ships/octavius/apteryx/apteryx.xml
===================================================================
--- trunk/data/ships/octavius/apteryx/apteryx.xml 2008-05-11 17:20:23 UTC (rev 892)
+++ trunk/data/ships/octavius/apteryx/apteryx.xml 2008-05-11 22:19:57 UTC (rev 893)
@@ -2,6 +2,7 @@
<ship>
<!-- Naming -->
+ <category_id>9</category_id>
<faction>octavius</faction>
<faction_id>3</faction_id>
<object_id>301</object_id>
Modified: trunk/data/ships/octavius/condor/condor.xml
===================================================================
--- trunk/data/ships/octavius/condor/condor.xml 2008-05-11 17:20:23 UTC (rev 892)
+++ trunk/data/ships/octavius/condor/condor.xml 2008-05-11 22:19:57 UTC (rev 893)
@@ -2,6 +2,7 @@
<ship>
<!-- Naming -->
+ <category_id>9</category_id>
<faction>Ocavius</faction>
<name>Condor</name>
@@ -32,4 +33,4 @@
<pitch>0.000681</pitch> <!-- 39.0 in jossh -->
<roll>0.000489</roll> <!-- 28.0 in jossh -->
<yaw>0.000489</yaw> <!-- 28.0 in jossh -->
-</ship>
\ No newline at end of file
+</ship>
Modified: trunk/data/ships/octavius/phoenix/phoenix.xml
===================================================================
--- trunk/data/ships/octavius/phoenix/phoenix.xml 2008-05-11 17:20:23 UTC (rev 892)
+++ trunk/data/ships/octavius/phoenix/phoenix.xml 2008-05-11 22:19:57 UTC (rev 893)
@@ -2,6 +2,7 @@
<!DOCTYPE ship SYSTEM "opengate.dtd">
<ship>
<!-- Naming -->
+ <category_id>9</category_id>
<name>Phoenix</name>
<class>Fighter</class>
<faction>Ocavius</faction>
@@ -32,4 +33,4 @@
<pitch>0.001134</pitch> <!-- 90.0 in jossh -->
<roll>0.001222</roll> <!-- 70.0 in jossh -->
<yaw>0.001047</yaw> <!-- 80.0 in jossh -->
-</ship>
\ No newline at end of file
+</ship>
Modified: trunk/data/ships/quantar/storm/storm.xml
===================================================================
--- trunk/data/ships/quantar/storm/storm.xml 2008-05-11 17:20:23 UTC (rev 892)
+++ trunk/data/ships/quantar/storm/storm.xml 2008-05-11 22:19:57 UTC (rev 893)
@@ -2,6 +2,7 @@
<ship>
<!-- Naming -->
+ <category_id>9</category_id>
<faction_id>2</faction_id>
<object_id>201</object_id>
<name>storm</name>
Modified: trunk/data/ships/quantar/typhoon/typhoon.xml
===================================================================
--- trunk/data/ships/quantar/typhoon/typhoon.xml 2008-05-11 17:20:23 UTC (rev 892)
+++ trunk/data/ships/quantar/typhoon/typhoon.xml 2008-05-11 22:19:57 UTC (rev 893)
@@ -2,6 +2,7 @@
<ship>
<!-- Naming -->
+ <category_id>9</category_id>
<faction>Quantar</faction>
<name>Typhoon</name>
Modified: trunk/data/ships/squadrok/squid/s-1.xml
===================================================================
(Binary files differ)
Modified: trunk/data/ships/squadrok/squid/s-2.xml
===================================================================
(Binary files differ)
Modified: trunk/data/ships/squadrok/squid/s-3.xml
===================================================================
(Binary files differ)
Modified: trunk/data/ships/squadrok/squid/squid.xml
===================================================================
--- trunk/data/ships/squadrok/squid/squid.xml 2008-05-11 17:20:23 UTC (rev 892)
+++ trunk/data/ships/squadrok/squid/squid.xml 2008-05-11 22:19:57 UTC (rev 893)
@@ -2,6 +2,7 @@
<ship>
<!-- Naming -->
+ <category_id>9</category_id>
<faction_id>4</faction_id>
<name>Squid</name>
<object_id>401</object_id>
Modified: trunk/src/AiManager.cpp
===================================================================
--- trunk/src/AiManager.cpp 2008-05-11 17:20:23 UTC (rev 892)
+++ trunk/src/AiManager.cpp 2008-05-11 22:19:57 UTC (rev 893)
@@ -23,7 +23,8 @@
#include "common.h"
#include "ResourceManager.h"
-#include "VesselManager.h"
+#include "EntityManager.h"
+#include "Vessel.h"
#include "SectorObjectVessel.h"
#include "Sector.h"
#include "UnDockedState.h"
@@ -109,18 +110,18 @@
if ( resources_->gameStateRoot->activeState( )->name() == "UnDockedState" ){
obj = dynamic_cast < UnDockedState *>(resources_->gameStateRoot->activeState() )->sector()->
- createVessel( ai->name(),
- resources_->network->userID(), 0,
- *VesselManager::getSingleton().vessel( "apteryx" ) );
+ createVessel( ai->name(),
+ resources_->network->userID(), 0,
+ *resources_->entityManager->vessel( "apteryx" ) );
obj->vessel( )->setPowerPlant( resources_->entityManager->powerPlant( "Spud" ) );
obj->vessel( )->setEngine( resources_->entityManager->engine( "T-E-15" ) );
obj->vessel( )->setRadar( resources_->entityManager->radar( "Outlook" ) );
obj->vessel( )->setShield( resources_->entityManager->shield( "Kydango" ) );
obj->vessel( )->setCapacitor( resources_->entityManager->capacitor( "Sponge" ) );
- std::cout << "Create " << obj->name() << std::endl;
+ std::cout << "AiManager::spawnAi( ): " << obj->name() << std::endl;
} else {
- std::cout << "spawn only in undockedState" << std::endl;
+ std::cout << "AiManager::spawnAi( ): spawn only in undockedState" << std::endl;
}
}
//-250, 0, 500
@@ -133,6 +134,7 @@
obj->mainNode()->setPosition( Ogre::Math::RangeRandom( xmin, xmax ),
Ogre::Math::RangeRandom( ymin, ymax ),
Ogre::Math::RangeRandom( zmin, zmax ) );
+ obj->launch();
// obj->mainNode()->setPosition(
// dynamic_cast < UnDockedState *>(resources_->gameStateRoot->activeState()
// )->sector()->station()->launchPadPosition() +
@@ -143,7 +145,7 @@
// dynamic_cast < UnDockedState *>(resources_->gameStateRoot->activeState()
// )->sector()->station()->launchPadOrientation() );
- ai->land( dynamic_cast < UnDockedState *>(resources_->gameStateRoot->activeState() )->sector()->station() );
+ ai->land( dynamic_cast < UnDockedState *>(resources_->gameStateRoot->activeState() )->sector()->station() );
}
startAiObject( ai );
Modified: trunk/src/Avatar.cpp
===================================================================
--- trunk/src/Avatar.cpp 2008-05-11 17:20:23 UTC (rev 892)
+++ trunk/src/Avatar.cpp 2008-05-11 22:19:57 UTC (rev 893)
@@ -19,7 +19,7 @@
***************************************************************************/
#include "Avatar.h"
-#include "VesselManager.h"
+#include "Vessel.h"
#include "Equipment.h"
namespace OpenGate{
Modified: trunk/src/Entity.cpp
===================================================================
--- trunk/src/Entity.cpp 2008-05-11 17:20:23 UTC (rev 892)
+++ trunk/src/Entity.cpp 2008-05-11 22:19:57 UTC (rev 893)
@@ -125,43 +125,47 @@
}
bool Entity::readPropertiesFromXML( TiXmlHandle & hRoot ){
- if ( !readXMLNode< std::string >( hRoot, "name_"+ ResourceManager::getSingleton().languageSuffix(),
- this, &OpenGate::Entity::setName, false ) ){
- readXMLNode< std::string >( hRoot, "name", this, &OpenGate::Entity::setName, true );
- }
- //readXMLNode< std::string >( hRoot, "name_de", entity, &OpenGate::Entity::setName, true );
+ readXMLNode< std::string >( hRoot, "name_"+ ResourceManager::getSingleton().languageSuffix() + " name_en name",
+ this, &OpenGate::Entity::setName, true );
+
readXMLNode< Uint16 >( hRoot, "object_id", this, &OpenGate::Entity::setID, true );
readXMLNode< Uint8 >( hRoot, "faction_id", this, &OpenGate::Entity::setFactionID, true );
-
+
readXMLNode< Uint8 >( hRoot, "class_id", this, &OpenGate::Entity::setClassID, false );
- readXMLNode< Uint8 >( hRoot, "techlevel", this, &OpenGate::Entity::setTechLevel, false );
- //readXMLNode< Uint8 >( hRoot, "required_rank", entity, &OpenGate::Entity::setRequieredRank, true );
-
+ readXMLNode< Uint8 >( hRoot, "techlevel required_rank", this, &OpenGate::Entity::setTechLevel, false );
+
readXMLNode< int >( hRoot, "size", this, &OpenGate::Entity::setSize, false );
readXMLNode< int >( hRoot, "mass", this, &OpenGate::Entity::setMass, false );
- if ( !readXMLNode< std::string >( hRoot, "description_" + ResourceManager::getSingleton().languageSuffix(), this,
- &OpenGate::Entity::setDescription, false ) ){
- readXMLNode< std::string >( hRoot, "description", this, &OpenGate::Entity::setDescription, false );
- }
+ readXMLNode< std::string >( hRoot, "description_" + ResourceManager::getSingleton().languageSuffix() +
+ " description_en description", this, &OpenGate::Entity::setDescription, false );
+
readXMLNodes< std::string >( hRoot, "production-center", this, &OpenGate::Entity::addProductionCenter );
readXMLNode< float >( hRoot, "baseyaw", this, &OpenGate::Entity::setBaseYaw, false );
readXMLNode< float >( hRoot, "basepitch", this, &OpenGate::Entity::setBasePitch, false );
readXMLNode< float >( hRoot, "baseroll", this, &OpenGate::Entity::setBaseRoll, false );
+
+ TiXmlElement * pElem;
-// Ogre::Real length = 0;
-// pElem = hRoot.ChildElement( "length", 0 ).Element();
-// if ( pElem ) length = toDouble( pElem->FirstChild()->Value() );
-//
-// Ogre::Real width = 0;
-// pElem = hRoot.ChildElement( "width", 0 ).Element();
-// if ( pElem ) width = toDouble( pElem->FirstChild()->Value() );
-//
-// Ogre::Real height = 0;
-// pElem = hRoot.ChildElement( "height", 0 ).Element();
-// if ( pElem ) height = toDouble( pElem->FirstChild()->Value() );
-// if ( length > 0 && width > 0 && height > 0 ) vessel->setBaseSize( width, height, length );
+ Ogre::Real length = 0;
+ pElem = hRoot.ChildElement( "size", 0 ).Element();
+ if ( pElem ) {
+ length = toDouble( pElem->FirstChild()->Value() );
+ this->setBaseSize( length );
+ }
+ pElem = hRoot.ChildElement( "length", 0 ).Element();
+ if ( pElem ) length = toDouble( pElem->FirstChild()->Value() );
+
+ Ogre::Real width = 0;
+ pElem = hRoot.ChildElement( "width", 0 ).Element();
+ if ( pElem ) width = toDouble( pElem->FirstChild()->Value() );
+
+ Ogre::Real height = 0;
+ pElem = hRoot.ChildElement( "height", 0 ).Element();
+ if ( pElem ) height = toDouble( pElem->FirstChild()->Value() );
+
+ if ( length > 0 && width > 0 && height > 0 ) this->setBaseSize( width, height, length );
return true;
}
Modified: trunk/src/Entity.h
===================================================================
--- trunk/src/Entity.h 2008-05-11 17:20:23 UTC (rev 892)
+++ trunk/src/Entity.h 2008-05-11 22:19:57 UTC (rev 893)
@@ -93,6 +93,7 @@
/*! If size is a scalar value, the length of the entity.*/
void setBaseSize( float size );
+
Ogre::Vector3 baseSize( ) const;
/*! Base sizes are necessary for resizing the ogremesh */
Modified: trunk/src/EntityManager.cpp
===================================================================
--- trunk/src/EntityManager.cpp 2008-05-11 17:20:23 UTC (rev 892)
+++ trunk/src/EntityManager.cpp 2008-05-11 22:19:57 UTC (rev 893)
@@ -46,8 +46,8 @@
}
EntityType EntityManager::categoryType( const std::string & category ){
- if ( category == "Commodity" || category == "Commoditys" ||
- category == "commodity" || category == "commoditys" ) return COMMODITY;
+ if ( category == "Commodity" || category == "Commodities" ||
+ category == "commodity" || category == "commodities" ) return COMMODITY;
else if ( category == "Power Plant" || category == "Power Plants" ||
category == "Powerplant" || category == "Powerplants" ||
category == "Power plant" || category == "Power plants" ||
@@ -71,9 +71,9 @@
category == "MODx" || category == "MODxs" ||
category == "modx" || category == "modxs" ) return MODX;
else if ( category == "Vessel" || category == "Vessels" ||
- category == "vessel" || category == "Vessels" ) return VESSEL;
+ category == "vessel" || category == "vessels" ) return VESSEL;
- LogManager::getSingleton().warn("Request entity rtti for " + category + " unknown" );
+ LogManager::getSingleton().warn("Requested entity rtti for " + category + " unknown" );
return ENTITY;
}
@@ -92,7 +92,7 @@
case VESSEL: return "Vessel";
}
- LogManager::getSingleton().warn("Request name for category " + toStr( type ) + " unknown" );
+ LogManager::getSingleton().warn("Requested name for category " + toStr( type ) + " unknown" );
return "unknown";
}
@@ -100,7 +100,7 @@
if ( templatesByName_.count( name ) ){
return templatesByName_[ name ];
} else {
- LogManager::getSingleton().warn("Request for entity: " + name + " unknown" );
+ LogManager::getSingleton().warn( "No entity named: " + name + " registered." );
return NULL;
}
}
@@ -109,11 +109,12 @@
if ( templatesByID_.count( ID ) ){
return templatesByID_[ ID ];
} else {
- LogManager::getSingleton().warn( ("Request for entity id: ") + toStr(ID) + " unknown" );
+ LogManager::getSingleton().warn( "No entity with ID: " + toStr( ID ) + " registered." );
return NULL;
}
}
+Commodity * EntityManager::commodity( const std::string & name ){ return entity_< Commodity >( name ); }
PowerPlant * EntityManager::powerPlant( const std::string & name ){ return entity_< PowerPlant >( name ); }
Engine * EntityManager::engine( const std::string & name ){ return entity_< Engine >( name ); }
Radar * EntityManager::radar( const std::string & name ){ return entity_< Radar >( name ); }
@@ -124,26 +125,40 @@
ModX * EntityManager::modx( const std::string & name ){ return entity_< ModX >( name ); }
Ecm * EntityManager::ecm( const std::string & name ){ return entity_< Ecm >( name ); }
Vessel * EntityManager::vessel( const std::string & name ){ return entity_< Vessel >( name ); }
+Vessel * EntityManager::vessel( Uint16 ID ){ return entity_< Vessel >( ID ); }
std::vector < Entity * > EntityManager::allByCategory( const std::string & category ){
- EntityType rtti = NONE;
- if ( category != "All" ) rtti = categoryType( category );
- std::vector < Entity * > items;
- for ( std::map < std::string, Entity * >::iterator it = templatesByName_.begin(); it != templatesByName_.end(); it ++ ){
- if ( ( category == "All" ) || ( it->second->entityType() == rtti ) ){
- items.push_back( it->second );
- }
- }
- return items;
- }
+ EntityType rtti = NONE;
+ if ( category != "All" ) rtti = categoryType( category );
+ std::vector < Entity * > items;
+ for ( std::map < std::string, Entity * >::iterator it = templatesByName_.begin(); it != templatesByName_.end(); it ++ ){
+ if ( ( category == "All" ) || ( it->second->entityType() == rtti ) ){
+ items.push_back( it->second );
+ }
+ }
+ return items;
+}
+std::set < Vessel * > EntityManager::vesselSet( ){
+
+ std::set < Vessel * > items;
+ for ( std::map < std::string, Entity * >::iterator it = templatesByName_.begin(); it != templatesByName_.end(); it ++ ){
+ if ( it->second->entityType() == VESSEL ){
+ items.insert( dynamic_cast< Vessel * >(it->second) );
+ }
+ }
+ return items;
+}
+
void EntityManager::load( const std::set < std::string > & resourcePaths, const std::string & resourceName ){
Ogre::FileSystemArchive * pArch = new Ogre::FileSystemArchive( (*resourcePaths.begin()) + "/" + resourceName, "FileSystem" );
Ogre::StringVectorPtr files = pArch->find( "*.xml", true, false);
for ( unsigned int i = 0; i < (*files).size(); i ++ ){
- log_->fout( std::string( "Found ressource: " ) + (*files)[ i ] );
- loadAndCreate( (*resourcePaths.begin()) + "/" + resourceName + "/" + (*files)[ i ] );
+ if ( (*files)[ i ].rfind( ".mesh.xml" ) == std::string::npos ){
+ log_->fout( std::string( "Found ressource: " ) + (*files)[ i ] );
+ loadAndCreate( (*resourcePaths.begin()) + "/" + resourceName + "/" + (*files)[ i ] );
+ }
}
delete pArch;
@@ -172,7 +187,12 @@
return NULL;
}
- if ( strcmp( "equipment", pElem->Value() ) != 0 && strcmp( "container", pElem->Value() ) != 0 ) {
+ if ( strcmp( "equipment", pElem->Value() ) != 0 &&
+ strcmp( "ship", pElem->Value() ) != 0 &&
+ strcmp( "entity", pElem->Value() ) != 0 &&
+ strcmp( "vessel", pElem->Value() ) != 0 &&
+ strcmp( "commodity", pElem->Value() ) != 0 &&
+ strcmp( "container", pElem->Value() ) != 0 ) {
log_->fatal( fileName + " is no entity description" );
return NULL;
}
@@ -195,6 +215,7 @@
case 6: entity = new Engine(); break;
case 7: entity = new Shield(); break;
case 8: entity = new Radar(); break;
+ case 9: entity = new Vessel(); break;
case 10: entity = new Gun(); break;
case 11: entity = new Missile(); break;
default:
@@ -529,165 +550,165 @@
// return entity;
// }
-template<> CommodityManager * Ogre::Singleton< CommodityManager >::ms_Singleton = 0;
+// template<> CommodityManager * Ogre::Singleton< CommodityManager >::ms_Singleton = 0;
+//
+// CommodityManager::CommodityManager(): EntityManager(){
+// }
+//
+// CommodityManager::~CommodityManager() {
+// }
+//
+// Commodity * CommodityManager::findByName( const std::string & commodityName ){
+// if ( templatesByName_.count( commodityName ) ){
+// return static_cast<Commodity *>(templatesByName_[ commodityName ]);
+// } else {
+// log_->fatal( std::string( "Unknown commodity with name :" ) + commodityName );
+// return NULL;
+// }
+// }
+//
+// std::vector < Entity * > CommodityManager::allCommodities(){
+// std::vector < Entity * > items;
+// for ( std::map < std::string, Entity * >::iterator it = templatesByName_.begin(); it != templatesByName_.end(); it ++ ){
+// items.push_back( it->second );
+// }
+// return items;
+// }
+//
+// Entity * CommodityManager::loadAndCreate( const std::string & fileName ){
+//
+// log_->fout( "Read commodity: " + fileName );
+//
+// TiXmlDocument doc( fileName );
+// bool loadOkay = doc.LoadFile();
+//
+// if ( !loadOkay ) {
+// log_->fatal( std::string( "Failed to load commodity file: " + fileName ) );
+// return NULL;
+// }
+//
+// TiXmlHandle docHandle( &doc );
+// TiXmlElement * pElem;
+// TiXmlHandle hRoot( 0 );
+//
+// pElem = docHandle.FirstChildElement().Element();
+// hRoot = TiXmlHandle( pElem );
+//
+// if ( !pElem ) {
+// log_->fatal( fileName + " cannot read first node." );
+// return NULL;
+// }
+//
+// if ( strcmp( "component", pElem->Value() ) != 0 && strcmp( "container", pElem->Value() ) != 0 ){
+// log_->fatal( fileName + " is no commodity description" );
+// return NULL;
+// }
+//
+// Commodity *entity;
+//
+// //** Mandatory elements;
+// pElem = hRoot.ChildElement( "category_id", 0 ).Element();
+// if ( !pElem ) { //** fallback
+// pElem = hRoot.ChildElement( "categorie_id", 0 ).Element();
+// }
+// if ( pElem ) {
+// if ( toInt( pElem->FirstChild()->Value() ) == 1 ){
+// entity = new Commodity;
+// } else {
+// log_->warn( fileName + " category_id is not 1, so I set them to 1." );
+// entity = new Commodity;
+// }
+// } else {
+// log_->fatal( fileName + " has no category_id (mandatory)." );
+// return NULL;
+// }
+//
+// pElem = hRoot.ChildElement( "name_" + ResourceManager::getSingleton().languageSuffix(), 0 ).Element();
+// if ( !pElem ){
+// //** Fallback to english
+// pElem = hRoot.ChildElement( "name_en", 0 ).Element();
+// }
+// if ( pElem ) {
+// entity->setName( pElem->FirstChild()->Value() );
+// } else {
+// log_->fatal( fileName + " has no name_en (mandatory)." );
+// return NULL;
+// }
+//
+// pElem = hRoot.ChildElement( "object_id", 0 ).Element();
+// if ( pElem ) {
+// entity->setID( toInt( pElem->FirstChild()->Value() ) );
+// } else {
+// log_->fatal( fileName + " has no object_id (mandatory)." );
+// return NULL;
+// }
+//
+//
+// //** Image name for the entity is derived from filename;
+// std::string basename( fileName.substr( fileName.rfind( "/" ) + 1 ) );
+// entity->setImageName( basename.substr( 0, basename.find( ".xml" ) ) );
+//
+// //** Generic data
+// pElem = hRoot.ChildElement( "class_id", 0 ).Element();
+// if ( pElem ) entity->setClassName( ResourceManager::getSingleton().className( toInt( pElem->FirstChild()->Value() ) ) );
+//
+// pElem = hRoot.ChildElement( "techlevel", 0 ).Element();
+// if ( pElem ) entity->setTechLevel( toInt( pElem->FirstChild()->Value() ) );
+//
+// pElem = hRoot.ChildElement( "size", 0 ).Element();
+// if ( pElem ) entity->setSize( toInt( pElem->FirstChild()->Value() ) );
+//
+// pElem = hRoot.ChildElement( "mass", 0 ).Element();
+// if ( pElem ) entity->setMass( toInt( pElem->FirstChild()->Value() ) );
+//
+// pElem = hRoot.ChildElement( "faction_id", 0 ).Element();
+// if ( pElem ) entity->setFactionID( toInt( pElem->FirstChild()->Value() ) );
+//
+// //** Additional Data
+// pElem = hRoot.ChildElement( "description_" + ResourceManager::getSingleton().languageSuffix(), 0 ).Element();
+// if ( pElem ) entity->setDescription( pElem->FirstChild()->Value() );
+//
+// //** Specific Data
+// pElem = hRoot.ChildElement( "id", 0 ).Element();
+// if ( pElem ) entity->setCommodityID( pElem->FirstChild()->Value() );
+// pElem = hRoot.ChildElement( "melting-point", 0 ).Element();
+// if ( pElem ) entity->setMeltingPoint( toInt( pElem->FirstChild()->Value() ) );
+// pElem = hRoot.ChildElement( "gravitic-sig", 0 ).Element();
+// if ( pElem ) entity->setGraviticSig( toFloat( pElem->FirstChild()->Value() ) );
+//
+// //** Production Data
+// std::set < std::string > productionCenters;
+// for ( pElem = hRoot.FirstChild( "production-center" ).Element(); pElem != 0; pElem = pElem->NextSiblingElement() ) {
+// productionCenters.insert( pElem->FirstChild()->Value() ); //!< \todo check return value!
+// }
+// // entity->setProductionCenters( productionCenters );
+// //! \todo Add required components
+//
+// if ( templatesByName_.count( entity->name() ) == 0 ){
+// templatesByName_[ entity->name() ] = entity;
+// templatesByID_[ entity->id() ] = entity;
+//
+// factions_.insert( entity->factionName() );
+// // log_->info( std::string( "Loaded Commodity: " ) + entity->factionName() + "/" + entity->name() );
+// } else {
+// log_->warn( std::string( "Equipment with name: " ) + entity->factionName() + "/" + entity->name() +
+// " allready loaded" );
+// }
+// return entity;
+// }
+//
+// CommodityManager & CommodityManager::getSingleton( ){
+// assert( ms_Singleton );
+// return ( *ms_Singleton );
+// }
+//
+// CommodityManager * CommodityManager::getSingletonPtr( ){
+// if ( ms_Singleton == NULL ){
+// LogManager::getSingleton().fatal( "CommodityManager not initialized." );
+// }
+// return ms_Singleton;
+// }
-CommodityManager::CommodityManager(): EntityManager(){
}
-CommodityManager::~CommodityManager() {
-}
-Commodity * CommodityManager::findByName( const std::string & commodityName ){
- if ( templatesByName_.count( commodityName ) ){
- return static_cast<Commodity *>(templatesByName_[ commodityName ]);
- } else {
- log_->fatal( std::string( "Unknown commodity with name :" ) + commodityName );
- return NULL;
- }
-}
-
-std::vector < Entity * > CommodityManager::allCommodities(){
- std::vector < Entity * > items;
- for ( std::map < std::string, Entity * >::iterator it = templatesByName_.begin(); it != templatesByName_.end(); it ++ ){
- items.push_back( it->second );
- }
- return items;
-}
-
-Entity * CommodityManager::loadAndCreate( const std::string & fileName ){
-
- log_->fout( "Read commodity: " + fileName );
-
- TiXmlDocument doc( fileName );
- bool loadOkay = doc.LoadFile();
-
- if ( !loadOkay ) {
- log_->fatal( std::string( "Failed to load commodity file: " + fileName ) );
- return NULL;
- }
-
- TiXmlHandle docHandle( &doc );
- TiXmlElement * pElem;
- TiXmlHandle hRoot( 0 );
-
- pElem = docHandle.FirstChildElement().Element();
- hRoot = TiXmlHandle( pElem );
-
- if ( !pElem ) {
- log_->fatal( fileName + " cannot read first node." );
- return NULL;
- }
-
- if ( strcmp( "component", pElem->Value() ) != 0 && strcmp( "container", pElem->Value() ) != 0 ){
- log_->fatal( fileName + " is no commodity description" );
- return NULL;
- }
-
- Commodity *entity;
-
- //** Mandatory elements;
- pElem = hRoot.ChildElement( "category_id", 0 ).Element();
- if ( !pElem ) { //** fallback
- pElem = hRoot.ChildElement( "categorie_id", 0 ).Element();
- }
- if ( pElem ) {
- if ( toInt( pElem->FirstChild()->Value() ) == 1 ){
- entity = new Commodity;
- } else {
- log_->warn( fileName + " category_id is not 1, so I set them to 1." );
- entity = new Commodity;
- }
- } else {
- log_->fatal( fileName + " has no category_id (mandatory)." );
- return NULL;
- }
-
- pElem = hRoot.ChildElement( "name_" + ResourceManager::getSingleton().languageSuffix(), 0 ).Element();
- if ( !pElem ){
- //** Fallback to english
- pElem = hRoot.ChildElement( "name_en", 0 ).Element();
- }
- if ( pElem ) {
- entity->setName( pElem->FirstChild()->Value() );
- } else {
- log_->fatal( fileName + " has no name_en (mandatory)." );
- return NULL;
- }
-
- pElem = hRoot.ChildElement( "object_id", 0 ).Element();
- if ( pElem ) {
- entity->setID( toInt( pElem->FirstChild()->Value() ) );
- } else {
- log_->fatal( fileName + " has no object_id (mandatory)." );
- return NULL;
- }
-
-
- //** Image name for the entity is derived from filename;
- std::string basename( fileName.substr( fileName.rfind( "/" ) + 1 ) );
- entity->setImageName( basename.substr( 0, basename.find( ".xml" ) ) );
-
- //** Generic data
- pElem = hRoot.ChildElement( "class_id", 0 ).Element();
- if ( pElem ) entity->setClassName( ResourceManager::getSingleton().className( toInt( pElem->FirstChild()->Value() ) ) );
-
- pElem = hRoot.ChildElement( "techlevel", 0 ).Element();
- if ( pElem ) entity->setTechLevel( toInt( pElem->FirstChild()->Value() ) );
-
- pElem = hRoot.ChildElement( "size", 0 ).Element();
- if ( pElem ) entity->setSize( toInt( pElem->FirstChild()->Value() ) );
-
- pElem = hRoot.ChildElement( "mass", 0 ).Element();
- if ( pElem ) entity->setMass( toInt( pElem->FirstChild()->Value() ) );
-
- pElem = hRoot.ChildElement( "faction_id", 0 ).Element();
- if ( pElem ) entity->setFactionID( toInt( pElem->FirstChild()->Value() ) );
-
- //** Additional Data
- pElem = hRoot.ChildElement( "description_" + ResourceManager::getSingleton().languageSuffix(), 0 ).Element();
- if ( pElem ) entity->setDescription( pElem->FirstChild()->Value() );
-
- //** Specific Data
- pElem = hRoot.ChildElement( "id", 0 ).Element();
- if ( pElem ) entity->setCommodityID( pElem->FirstChild()->Value() );
- pElem = hRoot.ChildElement( "melting-point", 0 ).Element();
- if ( pElem ) entity->setMeltingPoint( toInt( pElem->FirstChild()->Value() ) );
- pElem = hRoot.ChildElement( "gravitic-sig", 0 ).Element();
- if ( pElem ) entity->setGraviticSig( toFloat( pElem->FirstChild()->Value(...
[truncated message content] |
|
From: <spo...@us...> - 2008-05-14 21:33:25
|
Revision: 897
http://opengate.svn.sourceforge.net/opengate/?rev=897&view=rev
Author: spom_spom
Date: 2008-05-14 14:33:27 -0700 (Wed, 14 May 2008)
Log Message:
-----------
Added beacon as sector object
Modified Paths:
--------------
trunk/data/misc/beacon.mesh
trunk/data/misc/testsector.xml
trunk/src/AiCommands.h
trunk/src/AiManager.cpp
trunk/src/AiObject.cpp
trunk/src/AiObject.h
trunk/src/Entity.cpp
trunk/src/Entity.h
trunk/src/EntityManager.cpp
trunk/src/Equipment.h
trunk/src/Moveable.cpp
trunk/src/Moveable.h
trunk/src/OpcodeWrapper.cpp
trunk/src/OpcodeWrapper.h
trunk/src/Projectile.h
trunk/src/Sector.cpp
trunk/src/Sector.h
trunk/src/SectorObject.cpp
trunk/src/SectorObject.h
trunk/src/SectorObjectMissile.cpp
trunk/src/SectorObjectMoveable.cpp
trunk/src/SectorObjectMoveable.h
trunk/src/SectorObjectVessel.cpp
trunk/src/Station.cpp
trunk/src/Station.h
trunk/src/UnDockedState.cpp
trunk/src/Vessel.cpp
trunk/src/Vessel.h
trunk/src/common.h
trunk/src/metaserver.cpp
trunk/src/metaserver.h
trunk/src/networkProtocol.cpp
trunk/src/networkProtocol.h
Added Paths:
-----------
trunk/data/misc/beacon.material
trunk/data/misc/beacon_pad.mesh
Added: trunk/data/misc/beacon.material
===================================================================
--- trunk/data/misc/beacon.material (rev 0)
+++ trunk/data/misc/beacon.material 2008-05-14 21:33:27 UTC (rev 897)
@@ -0,0 +1,45 @@
+material beacon/pad_mount_0
+{
+ receive_shadows on
+ technique
+ {
+ pass
+ {
+ depth_check on
+ depth_write off
+ scene_blend add
+ ambient 1.000000 0.00000 0.00000 1.000000
+ diffuse 0.517647 0.018824 0.018824 1.000000
+ specular 1.000000 0.000000 0.000000 1.000000 12.500000
+ emissive 1.000000 0.000000 0.000000 1.000000
+ }
+ }
+}
+material beacon/pad_mount_1
+{
+ receive_shadows on
+ technique
+ {
+ pass
+ {
+ ambient 0.500000 0.500000 0.500000 1.000000
+ diffuse 0.517647 0.018824 0.018824 1.000000
+ specular 0.500000 0.500000 0.500000 1.000000 12.500000
+ emissive 0.000000 0.000000 0.000000 1.000000
+ }
+ }
+}
+material beacon/bg
+{
+ receive_shadows on
+ technique
+ {
+ pass
+ {
+ ambient 0.500000 0.500000 0.500000 1.000000
+ diffuse 0.439216 0.621176 0.533333 1.000000
+ specular 0.213726 0.382353 0.290196 1.000000 12.500000
+ emissive 0.000000 0.000000 0.000000 1.000000
+ }
+ }
+}
Modified: trunk/data/misc/beacon.mesh
===================================================================
(Binary files differ)
Added: trunk/data/misc/beacon_pad.mesh
===================================================================
(Binary files differ)
Property changes on: trunk/data/misc/beacon_pad.mesh
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: trunk/data/misc/testsector.xml
===================================================================
--- trunk/data/misc/testsector.xml 2008-05-12 16:19:10 UTC (rev 896)
+++ trunk/data/misc/testsector.xml 2008-05-14 21:33:27 UTC (rev 897)
@@ -26,14 +26,23 @@
<!-- <position>position of this object</position> -->
<!-- Optional -->
<!-- <direction>desired front direction</direction> -->
-<!-- </sectorobject> -->
+<!-- </station> -->
- <station>
+<!-- <beacon> -->
+<!-- <position>position of this object</position> -->
+<!-- <direction>desired front direction</direction> -->
+<!-- </beacon> -->
+
+ <station>
<name>Tauseti Wake</name>
<position>0, 0, -1480</position>
<direction>0.0, 0.0, 1.0 </direction>
</station>
- <sectorobject>
+ <beacon>
+ <position> -650, 0, 800</position>
+ <direction>0.0, 0.0, 1.0 </direction>
+ </beacon>
+ <sectorobject>
<name>astro with bump</name>
<mesh>asteroid01</mesh>
<position> -250, 0, 440</position>
@@ -48,13 +57,6 @@
<material>Asteroid</material>
</sectorobject>
<sectorobject>
- <name>beacon</name>
- <mesh>beacon</mesh>
- <position> -650, 0, 800</position>
- <scale>20, 20, 20</scale>
- <material>Sta/TS/Background</material>
- </sectorobject>
- <sectorobject>
<name>ring</name>
<mesh>ring</mesh>
<position> -650, 100, 800</position>
Modified: trunk/src/AiCommands.h
===================================================================
--- trunk/src/AiCommands.h 2008-05-12 16:19:10 UTC (rev 896)
+++ trunk/src/AiCommands.h 2008-05-14 21:33:27 UTC (rev 897)
@@ -79,7 +79,7 @@
return true;
}
- bool abort( ) { abort_ = true; }
+ void abort( ) { abort_ = true; }
virtual void start() { std::cout << "AiCommand start (virtual) " << std::endl; }
virtual bool update( ) { return false; }
Modified: trunk/src/AiManager.cpp
===================================================================
--- trunk/src/AiManager.cpp 2008-05-12 16:19:10 UTC (rev 896)
+++ trunk/src/AiManager.cpp 2008-05-14 21:33:27 UTC (rev 897)
@@ -95,7 +95,8 @@
std::copy( argv.begin(), argv.end(), std::ostream_iterator< std::string >( std::cout, " " ) );
std::cout << std::endl;
- AiObject * ai = spawnAi( );
+ //AiObject * ai =
+ spawnAi( );
}
AiObject * AiManager::spawnAi( ){
Modified: trunk/src/AiObject.cpp
===================================================================
--- trunk/src/AiObject.cpp 2008-05-12 16:19:10 UTC (rev 896)
+++ trunk/src/AiObject.cpp 2008-05-14 21:33:27 UTC (rev 897)
@@ -241,7 +241,7 @@
double AiObject::speedAfterTime( double time, double thrustRate ) const {
//** v[ t ] := vmax * tanh( th / m / vmax * t ) ** P
- double d = vesselObject_->vessel()->dragFactor();
+ // double d = vesselObject_->vessel()->dragFactor();
double m = vesselObject_->mass();
double th = vesselObject_->maxThrust() * thrustRate;
double vmax = maxSpeed( thrustRate );
@@ -255,7 +255,7 @@
//** v[ t ] := vmax * tanh( th / m / vmax * t )
//** s[t]:=integrate(v[t], t)
//** s = vmax^2/a * log( cosh( a / vmax * t ) ) ** P
- double d = vesselObject_->vessel()->dragFactor();
+ // double d = vesselObject_->vessel()->dragFactor();
double m = vesselObject_->mass();
double th = vesselObject_->maxThrust() * thrustRate;
double vmax = maxSpeed( thrustRate );
@@ -269,7 +269,7 @@
double d = vesselObject_->vessel()->dragFactor();
double m = vesselObject_->mass();
double a = vesselObject_->brakingAcc();
- double th = m * a;
+ // double th = m * a;
//std::cout << " th: " << th << "; m: " << m << "; d: " << d << "; v: " << v << "; t: " << time << std::endl;
double t = ( m * atan( ( d * v ) / sqrt( a * d * m ) ) ) / sqrt( a * d * m ); //see physics.m
return t;
@@ -279,7 +279,7 @@
double d = vesselObject_->vessel()->dragFactor();
double m = vesselObject_->mass();
double a = vesselObject_->brakingAcc();
- double th = m * a;
+ // double th = m * a;
double t = brakingTime( v );
double s = ( m * std::log( 1.0 / std::cos( (std::sqrt( a * d * m ) * t ) / m) ) ) / d; //see physics.m
Modified: trunk/src/AiObject.h
===================================================================
--- trunk/src/AiObject.h 2008-05-12 16:19:10 UTC (rev 896)
+++ trunk/src/AiObject.h 2008-05-14 21:33:27 UTC (rev 897)
@@ -116,6 +116,9 @@
void copy_( const AiObject & ai );
+ //! unique id
+ uint id_;
+
//! the graphical representation
SectorObjectVessel * vesselObject_;
@@ -137,10 +140,7 @@
//! objects name
std::string name_;
-
- //! unique id
- uint id_;
-
+
//! reference counter for threadholder
uint refCounter_;
Modified: trunk/src/Entity.cpp
===================================================================
--- trunk/src/Entity.cpp 2008-05-12 16:19:10 UTC (rev 896)
+++ trunk/src/Entity.cpp 2008-05-14 21:33:27 UTC (rev 897)
@@ -124,7 +124,7 @@
return !fail;
}
-bool Entity::readPropertiesFromXML( TiXmlHandle & hRoot ){
+void Entity::readPropertiesFromXML( TiXmlHandle & hRoot ){
readXMLNode< std::string >( hRoot, "name_"+ ResourceManager::getSingleton().languageSuffix() + " name_en name",
this, &OpenGate::Entity::setName, true );
@@ -166,8 +166,7 @@
if ( pElem ) height = toDouble( pElem->FirstChild()->Value() );
if ( length > 0 && width > 0 && height > 0 ) this->setBaseSize( width, height, length );
-
- return true;
+
}
Modified: trunk/src/Entity.h
===================================================================
--- trunk/src/Entity.h 2008-05-12 16:19:10 UTC (rev 896)
+++ trunk/src/Entity.h 2008-05-14 21:33:27 UTC (rev 897)
@@ -70,7 +70,7 @@
virtual EntityType entityType() const { return rtti_; }
- virtual bool readPropertiesFromXML( TiXmlHandle & hRoot );
+ virtual void readPropertiesFromXML( TiXmlHandle & hRoot );
inline std::string factionName( ) const { return factionName_; }
Modified: trunk/src/EntityManager.cpp
===================================================================
--- trunk/src/EntityManager.cpp 2008-05-12 16:19:10 UTC (rev 896)
+++ trunk/src/EntityManager.cpp 2008-05-14 21:33:27 UTC (rev 897)
@@ -79,6 +79,8 @@
std::string EntityManager::categoryName( EntityType type ){
switch( type ){
+ case NONE: return "None";
+ case ENTITY: return "Entity";
case COMMODITY: return "Commodity";
case POWERPLANT: return "Powerplant";
case CAPACITOR: return "Capacitor";
Modified: trunk/src/Equipment.h
===================================================================
--- trunk/src/Equipment.h 2008-05-12 16:19:10 UTC (rev 896)
+++ trunk/src/Equipment.h 2008-05-14 21:33:27 UTC (rev 897)
@@ -47,7 +47,7 @@
meltingPoint_ = 0;
graviticSig_ = 0.0;
}
- virtual bool readPropertiesFromXML( TiXmlHandle & hRoot ){
+ virtual void readPropertiesFromXML( TiXmlHandle & hRoot ){
Entity::readPropertiesFromXML( hRoot );
readXMLNode< int >( hRoot, "melting-point", this, &OpenGate::Commodity::setMeltingPoint, false );
readXMLNode< double >( hRoot, "gravitic-sig", this, &OpenGate::Commodity::setGraviticSig, false );
@@ -84,7 +84,7 @@
class Equipment : public Entity{
public:
- virtual bool readPropertiesFromXML( TiXmlHandle & hRoot ){
+ virtual void readPropertiesFromXML( TiXmlHandle & hRoot ){
Entity::readPropertiesFromXML( hRoot );
readXMLNode< double >( hRoot, "efficency", this, &OpenGate::Equipment::setEfficiency, false );
readXMLNode< std::string >( hRoot, "Manufacturer", this, &OpenGate::Equipment::setManufacturer, false );
@@ -138,7 +138,7 @@
rtti_ = POWERPLANT;
powerOutput_ = 0;
}
- virtual bool readPropertiesFromXML( TiXmlHandle & hRoot ){
+ virtual void readPropertiesFromXML( TiXmlHandle & hRoot ){
Equipment::readPropertiesFromXML( hRoot );
readXMLNode< Uint32 >( hRoot, "power_output", this, &OpenGate::PowerPlant::setPowerOutput, false );
}
@@ -170,7 +170,7 @@
maxThrust_ = 0;
}
- virtual bool readPropertiesFromXML( TiXmlHandle & hRoot ){
+ virtual void readPropertiesFromXML( TiXmlHandle & hRoot ){
Equipment::readPropertiesFromXML( hRoot );
readXMLNode< Uint32 >( hRoot, "maximum_thrust", this, &OpenGate::Engine::setMaxThrust, false );
}
@@ -202,7 +202,7 @@
Radar() : Equipment(){
rtti_ = RADAR;
}
- virtual bool readPropertiesFromXML( TiXmlHandle & hRoot ){
+ virtual void readPropertiesFromXML( TiXmlHandle & hRoot ){
Equipment::readPropertiesFromXML( hRoot );
readXMLNode< Uint32 >( hRoot, "maximum_range", this, &OpenGate::Radar::setMaxRange, false );
}
@@ -229,7 +229,7 @@
rtti_ = ECM;
sensorLevel_ = 0;
}
- virtual bool readPropertiesFromXML( TiXmlHandle & hRoot ){
+ virtual void readPropertiesFromXML( TiXmlHandle & hRoot ){
Equipment::readPropertiesFromXML( hRoot );
readXMLNode< Uint8 >( hRoot, "sensorlevel", this, &OpenGate::Ecm::setSensorLevel, false );
}
@@ -255,7 +255,7 @@
Shield() : Equipment(){
rtti_ = SHIELD;
}
- virtual bool readPropertiesFromXML( TiXmlHandle & hRoot ){
+ virtual void readPropertiesFromXML( TiXmlHandle & hRoot ){
Equipment::readPropertiesFromXML( hRoot );
readXMLNode< Uint32 >( hRoot, "regeneration_rate", this, &OpenGate::Shield::setRegenerationRate, false );
readXMLNode< Uint32 >( hRoot, "maximum_deflection", this, &OpenGate::Shield::setMaxDeflection, false );
@@ -297,7 +297,7 @@
rtti_ = CAPACITOR;
capacity_ = 0;
}
- virtual bool readPropertiesFromXML( TiXmlHandle & hRoot ){
+ virtual void readPropertiesFromXML( TiXmlHandle & hRoot ){
Equipment::readPropertiesFromXML( hRoot );
readXMLNode< Uint32 >( hRoot, "capacity", this, &OpenGate::Capacitor::setCapacity, false );
}
@@ -320,7 +320,7 @@
rtti_ = GUN;
type_ = UNKNOWN;
}
- virtual bool readPropertiesFromXML( TiXmlHandle & hRoot ){
+ virtual void readPropertiesFromXML( TiXmlHandle & hRoot ){
Equipment::readPropertiesFromXML( hRoot );
readXMLNode< Uint32 >( hRoot, "damage", this, &OpenGate::Gun::setDamage, false );
readXMLNode< Uint32 >( hRoot, "velocity", this, &OpenGate::Gun::setSpeed, false );
Modified: trunk/src/Moveable.cpp
===================================================================
--- trunk/src/Moveable.cpp 2008-05-12 16:19:10 UTC (rev 896)
+++ trunk/src/Moveable.cpp 2008-05-14 21:33:27 UTC (rev 897)
@@ -29,17 +29,17 @@
yaw_ = 1.0;
pitch_ = 1.0;
roll_ = 1.0;
- armor_ = 1.0;
+ armor_ = 1;
dragFactor_ = 1.0;
}
-bool Moveable::readPropertiesFromXML( TiXmlHandle & hRoot ){
+void Moveable::readPropertiesFromXML( TiXmlHandle & hRoot ){
Entity::readPropertiesFromXML( hRoot );
readXMLNode< float >( hRoot, "yaw", this, &OpenGate::Moveable::setYaw, false );
readXMLNode< float >( hRoot, "pitch", this, &OpenGate::Moveable::setPitch, false );
readXMLNode< float >( hRoot, "roll", this, &OpenGate::Moveable::setRoll, false );
- readXMLNode< float >( hRoot, "armor", this, &OpenGate::Moveable::setArmor, false );
+ readXMLNode< Uint32 >( hRoot, "armor", this, &OpenGate::Moveable::setArmor, false );
readXMLNode< float >( hRoot, "dragfactor drag_factor", this, &OpenGate::Moveable::setDragFactor, false );
if ( !readXMLNode< std::string >( hRoot, "mesh", this, &OpenGate::Moveable::setMesh, false ) ){
Modified: trunk/src/Moveable.h
===================================================================
--- trunk/src/Moveable.h 2008-05-12 16:19:10 UTC (rev 896)
+++ trunk/src/Moveable.h 2008-05-14 21:33:27 UTC (rev 897)
@@ -32,7 +32,7 @@
Moveable();
virtual ~Moveable(){}
- virtual bool readPropertiesFromXML( TiXmlHandle & hRoot );
+ virtual void readPropertiesFromXML( TiXmlHandle & hRoot );
inline void setArmor( Uint32 armor ){ armor_ = armor * 1000; }
inline Uint32 armor( ) const { return armor_; }
Modified: trunk/src/OpcodeWrapper.cpp
===================================================================
--- trunk/src/OpcodeWrapper.cpp 2008-05-12 16:19:10 UTC (rev 896)
+++ trunk/src/OpcodeWrapper.cpp 2008-05-14 21:33:27 UTC (rev 897)
@@ -147,13 +147,13 @@
}
}
-void OpcodeCollisionDetection::dettach( SectorObject * obj ){
+void OpcodeCollisionDetection::detach( BaseObject * obj ){
if ( obj && active_ ){
destroyObject( obj );
}
}
-void OpcodeCollisionDetection::attach( SectorObject * obj ){
+void OpcodeCollisionDetection::attach( BaseObject * obj ){
if ( obj && active_ ){
createObject( obj );
}
Modified: trunk/src/OpcodeWrapper.h
===================================================================
--- trunk/src/OpcodeWrapper.h 2008-05-12 16:19:10 UTC (rev 896)
+++ trunk/src/OpcodeWrapper.h 2008-05-14 21:33:27 UTC (rev 897)
@@ -54,9 +54,9 @@
void destroyObject( BaseObject * obj );
- void dettach( SectorObject * obj );
+ void detach( BaseObject * obj );
- void attach( SectorObject * obj );
+ void attach( BaseObject * obj );
bool checkCollideRay( BaseObject * obj, const Ogre::Ray & ray, double rayLength );
Modified: trunk/src/Projectile.h
===================================================================
--- trunk/src/Projectile.h 2008-05-12 16:19:10 UTC (rev 896)
+++ trunk/src/Projectile.h 2008-05-14 21:33:27 UTC (rev 897)
@@ -60,22 +60,23 @@
protected:
- BaseObject * parent_;
- Uint16 shotCount_;
- Uint32 damage_;
- Gun * gun_;
-
+ BaseObject * parent_;
+ Uint16 shotCount_;
+ Gun * gun_;
+
+ Uint32 damage_;
+ Ogre::Real maxLifeTime_;
+ Ogre::Vector3 vel_;
+
// Ogre::BillboardChain * chain_;
Ogre::BillboardSet * bullet_;
Ogre::ManualObject * beam_;
Ogre::RibbonTrail * trail_;
Ogre::SceneNode * trailNode_;
- Ogre::Vector3 vel_;
Ogre::SceneNode * shape_;
- Ogre::Real maxLifeTime_;
Ogre::Real oldTime_;
Ogre::Real maxRange_;
bool ammoHit_;
Modified: trunk/src/Sector.cpp
===================================================================
--- trunk/src/Sector.cpp 2008-05-12 16:19:10 UTC (rev 896)
+++ trunk/src/Sector.cpp 2008-05-14 21:33:27 UTC (rev 897)
@@ -77,16 +77,17 @@
Sector::Sector( Ogre::SceneManager * sceneMgr, NetworkClient * network )
: sceneMgr_( sceneMgr ), network_( network ) {
- radar_ = true;
- planet_ = NULL;
- koordAxisNode_ = NULL;
- starsNode_ = NULL;
- avatar_ = NULL;
- station_ = NULL;
- childIDCounter_= 0;
- log_ = LogManager::getSingletonPtr();
+ radar_ = true;
+ planet_ = NULL;
+ koordAxisNode_ = NULL;
+ starsNode_ = NULL;
+ avatar_ = NULL;
+ station_ = NULL;
+ name_ = "unknown";
+ childIDCounter_ = 0;
+ log_ = LogManager::getSingletonPtr();
- avatarDeathSequenceTime_ = 0.0;
+ avatarDeathSequenceTime_ = 0.0;
//*** starfield test 1
// Ogre::ManualObject* myManualObject = sceneMgr_->createManualObject("manual1");
@@ -175,7 +176,6 @@
// delete (*it).second[ i ];
// }
}
-
}
void Sector::populate( const std::string & fileName ){
@@ -203,14 +203,9 @@
log_->fatal( fileName + " is no sector description" );
return;
}
+
+ readXMLNode< std::string >( hRoot, "name_en name", this, &OpenGate::Sector::setName, false );
- pElem = hRoot.ChildElement( "name_en", 0 ).Element();
- if ( pElem ){
- sectorname_ = pElem->FirstChild()->Value();
- } else {
- sectorname_ = "Testsector";
- }
-
pElem = hRoot.ChildElement( "skybox", 0 ).Element();
if ( pElem ){
sceneMgr_->setSkyBox( true, pElem->FirstChild()->Value(), 10000 );
@@ -272,12 +267,31 @@
}
}
- //** Load passive sector objects
- for ( pElem = hRoot.FirstChild( "sectorobject" ).Element(); pElem != 0;
- pElem = pElem->NextSiblingElement("sectorobject") ) {
- std::string name;
- pSubElem = pElem->FirstChildElement( "name" );
- if ( pSubElem ){
+ //** load beacon
+ pElem = hRoot.FirstChild( "beacon" ).Element();
+ if ( pElem ){
+ Ogre::Vector3 beaconPos( 0.0, 0.0, 0.0);
+ pSubElem = pElem->FirstChildElement( "position" );
+ if ( pSubElem ){
+ beaconPos = Ogre::Vector3( &toVector3( pSubElem->FirstChild()->Value(), ',' )[ 0 ] );
+ } else {
+ log_->warn( "missing pos for beacon" );
+ }
+ SectorObject * obj = createBeacon( beaconPos );
+ Ogre::Vector3 beaconDir( 0.0, 0.0, 0.0);
+ pSubElem = pElem->FirstChildElement( "direction" );
+ if ( pSubElem ){
+ beaconDir = Ogre::Vector3( &toVector3( pSubElem->FirstChild()->Value(), ',' )[ 0 ] );
+ obj->mainNode()->setDirection( beaconDir );
+ }
+ }
+
+ //** Load passive sector objects
+ for ( pElem = hRoot.FirstChild( "sectorobject" ).Element(); pElem != 0;
+ pElem = pElem->NextSiblingElement("sectorobject") ) {
+ std::string name;
+ pSubElem = pElem->FirstChildElement( "name" );
+ if ( pSubElem ){
name = pSubElem->FirstChild()->Value();
} else {
log_->warn( "missing name for sectorobject " );
@@ -291,9 +305,9 @@
Ogre::MeshPtr pMesh = Ogre::MeshManager::getSingleton().load( mesh,
Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
- Ogre::HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY,
- Ogre::HardwareBuffer::HBU_STATIC_WRITE_ONLY,
- true, true);
+ Ogre::HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY,
+ Ogre::HardwareBuffer::HBU_STATIC_WRITE_ONLY,
+ true, true);
unsigned short src, dest;
if ( !pMesh->suggestTangentVectorBuildParams( Ogre::VES_TANGENT, src, dest) ) {
pMesh->buildTangentVectors( Ogre::VES_TANGENT, src, dest);
@@ -498,6 +512,14 @@
return obj;
}
+SectorObject * Sector::createBeacon( const Ogre::Vector3 & pos ){
+ SectorObject * obj = new BeaconObject( this );
+ obj->mainNode()->setPosition( pos );
+ obj->scale( Ogre::Vector3( 20.0, 20.0, 20.0 ) );
+ sectorObjects_.insert( obj );
+ return obj;
+}
+
SectorObjectMoveable * Sector::createMoveable( const Ogre::String & name,
Uint32 userID, Uint8 childID, Moveable & moveable ){
SectorObjectMoveable * obj = new SectorObjectMoveable( name, this, userID, childID,
@@ -705,15 +727,27 @@
koordAxisNode_ = sceneMgr_->getRootSceneNode()->createChildSceneNode( "axisnode" );
koordAxisMO_ = sceneMgr_->createManualObject( koordAxisNode_->getName()+ "/manualObject" );
Ogre::Real length = 20;
- koordAxisMO_->begin( "BaseWhiteNoLighting", Ogre::RenderOperation::OT_LINE_LIST);
- unsigned point_index = 0;
+
+ koordAxisMO_->begin( "singleColor", Ogre::RenderOperation::OT_LINE_LIST);
+ koordAxisMO_->getSection( 0 )->setCustomParameter( 0, Ogre::Vector4( 1.0, 0.0, 0.0, 1.0 ) );
koordAxisMO_->position( 0.0, 0.0, 0.0 );
koordAxisMO_->position( 1.0, 0.0, 0.0 );
koordAxisMO_->position( 0.0, 0.0, 0.0 );
+ koordAxisMO_->end();
+
+ koordAxisMO_->begin( "singleColor", Ogre::RenderOperation::OT_LINE_LIST);
+ koordAxisMO_->getSection( 1 )->setCustomParameter( 0, Ogre::Vector4( 0.0, 1.0, 0.0, 1.0 ) );
koordAxisMO_->position( 0.0, 1.0, 0.0 );
koordAxisMO_->position( 0.0, 0.0, 0.0 );
+ koordAxisMO_->end();
+
+ koordAxisMO_->begin( "singleColor", Ogre::RenderOperation::OT_LINE_LIST);
+ koordAxisMO_->getSection( 2 )->setCustomParameter( 0, Ogre::Vector4( 0.0, 0.0, 1.0, 1.0 ) );
koordAxisMO_->position( 0.0, 0.0, 1.0 );
koordAxisMO_->position( 0.0, 0.0, 0.0 );
+ koordAxisMO_->end();
+
+ koordAxisMO_->begin( "BaseWhiteNoLighting", Ogre::RenderOperation::OT_LINE_LIST);
koordAxisMO_->position( -1.0, 0.0, 0.0 );
koordAxisMO_->position( 0.0, 0.0, 0.0 );
koordAxisMO_->position( 0.0, -1.0, 0.0 );
@@ -771,11 +805,6 @@
void Sector::sendAllVesselMovements( ){
if ( avatar_ ) sendVesselMovement( avatar_ );
-
-// for ( std::map< int, SectorObjectMoveableAi * >::iterator it = localAiObjects_.begin(); it != localAiObjects_.end(); it ++ ){
-// sendVesselMovement( it->second );
-// }
-
}
void Sector::sendAllVesselInfos( ){
@@ -798,6 +827,7 @@
obj->velocity().ptr(),
obj->mainNode()->getOrientation().ptr(),
obj->thrustRate(),
+ obj->thrust(),
obj->scaledYaw(),
obj->scaledPitch(),
obj->scaledRoll(),
@@ -807,6 +837,62 @@
}
}
+void Sector::receiveVesselMovement( const std::vector < MessageBodyShipMovement * > & movements ){
+
+ std::map < long, const MessageBodyShipMovement * > singleMsg;
+
+ //** we sort the movement messaged
+ for ( size_t i = 0; i < movements.size(); i ++ ){
+// LogManager::getSingleton().debug( std::string( "Movement: " ) +
+// movableObjects_[ createGlobalID( movements[ i ]->senderID(), movements[ i ]->childID() )]->name() + " " + toStr( movements[ i ]->senderID() ) + " " + toStr( (int)movements[ i ]->childID() ) +
+// " " + toStr( movements[ i ]->position() ) );
+
+ if ( movements[ i ]->senderID() != network_->userID() ){
+ //** apply only foreign movements, and take just the actual movement
+ singleMsg[ createGlobalID( movements[ i ]->senderID(), movements[ i ]->childID() ) ] = movements[ i ];
+ }
+ }
+
+ std::map< long, SectorObjectMoveable * >::iterator it;
+
+ for ( std::map < long, const MessageBodyShipMovement * >::iterator i = singleMsg.begin(); i != singleMsg.end(); i++ ){
+ if ( ( it = movableObjects_.find( i->first ) ) != movableObjects_.end() ){
+ it->second->setFlightProperties( (*i->second) );
+ } else {
+ log_->fatal( "Requested non existant object for shipmovement: " +
+ toStr( network_->userName( i->second->senderID() ) ) +
+ " child: " + toStr( (int)i->second->childID() ) +
+ " this should not happen." );
+ }
+ }
+ for ( size_t i = 0; i < movements.size(); i ++ ){
+ delete movements[ i ];
+ }
+
+}
+
+void Sector::sendVesselStatus( SectorObjectVessel * obj ){
+ if ( obj ){
+ MessageBodyShipStatus msg( obj->childID(), obj->shield(), obj->armor(), 0, 0, 0 );
+ network_->send( msg );
+ }
+}
+
+void Sector::receiveVesselStatus( const MessageBodyShipStatus & msg ){
+ if ( msg.senderID() != network_->userID() ){
+
+ std::map< long, SectorObjectMoveable * >::iterator it;
+
+ if ( ( it = movableObjects_.find( createGlobalID( msg.senderID(), msg.childID() ) ) ) != movableObjects_.end() ){
+ // log_->debug( "ReceiveVesselStatus for " + it->second->name( ) );
+ it->second->setStatus( msg );
+ } else {
+ log_->fatal( "Requested non existant object for shipstatus: " +
+ network_->userName( msg.senderID() ) + " this should not happen." );
+ }
+ }
+}
+
void Sector::sendVesselRegister( SectorObjectVessel * obj ){
if ( obj ) {
log_->info( std::string( "Send register " ) + obj->name() + " id:" + toStr( obj->vessel()->id() ) );
@@ -826,12 +912,11 @@
*ResourceManager::getSingleton().entityManager->vessel( msg.vesselID() ) );
obj->mainNode()->setPosition( toOgreVec( msg.position() ) );
obj->setMass( msg.mass() );
-
- log_->info( "FIXTHIS: void Sector::receiveVesselRegister( " );
-// obj->setMaxShield( msg.maxShield() );
-// obj->setMaxThrust( msg.maxThrust() );
+ obj->setMaxShield( msg.maxShield() );
+ obj->setMaxThrust( msg.maxThrust() );
+ obj->setMaxSpeed( std::sqrt( msg.maxThrust() / obj->moveable()->dragFactor() ) );
+ std::cout << msg << std::endl;
-
} else {
log_->info( "Create ai object " + msg.name()+ " " + toStr( msg.senderID() ) + " " +
toStr( (int)msg.childID() ) + " " + toStr( msg.vesselID() ) );
@@ -895,62 +980,6 @@
}
}
-void Sector::receiveVesselMovement( const std::vector < MessageBodyShipMovement * > & movements ){
-
- std::map < long, const MessageBodyShipMovement * > singleMsg;
-
- //** we sort the movement messaged
- for ( size_t i = 0; i < movements.size(); i ++ ){
-// LogManager::getSingleton().debug( std::string( "Movement: " ) +
-// movableObjects_[ createGlobalID( movements[ i ]->senderID(), movements[ i ]->childID() )]->name() + " " + toStr( movements[ i ]->senderID() ) + " " + toStr( (int)movements[ i ]->childID() ) +
-// " " + toStr( movements[ i ]->position() ) );
-
- if ( movements[ i ]->senderID() != network_->userID() ){
- //** apply only foreign movements, and take just the actual movement
- singleMsg[ createGlobalID( movements[ i ]->senderID(), movements[ i ]->childID() ) ] = movements[ i ];
- }
- }
-
- std::map< long, SectorObjectMoveable * >::iterator it;
-
- for ( std::map < long, const MessageBodyShipMovement * >::iterator i = singleMsg.begin(); i != singleMsg.end(); i++ ){
- if ( ( it = movableObjects_.find( i->first ) ) != movableObjects_.end() ){
- it->second->setFlightProperties( (*i->second) );
- } else {
- log_->fatal( "Requested non existant object for shipmovement: " +
- toStr( network_->userName( i->second->senderID() ) ) +
- " child: " + toStr( (int)i->second->childID() ) +
- " this should not happen." );
- }
- }
- for ( size_t i = 0; i < movements.size(); i ++ ){
- delete movements[ i ];
- }
-
-}
-
-void Sector::sendVesselStatus( SectorObjectVessel * obj ){
- if ( obj ){
- MessageBodyShipStatus msg( obj->childID(), obj->shield(), obj->armor(), 0, 0, 0 );
- network_->send( msg );
- }
-}
-
-void Sector::receiveVesselStatus( const MessageBodyShipStatus & msg ){
- if ( msg.senderID() != network_->userID() ){
-
- std::map< long, SectorObjectMoveable * >::iterator it;
-
- if ( ( it = movableObjects_.find( createGlobalID( msg.senderID(), msg.childID() ) ) ) != movableObjects_.end() ){
- // log_->debug( "ReceiveVesselStatus for " + it->second->name( ) );
- it->second->setStatus( msg );
- } else {
- log_->fatal( "Requested non existant object for shipstatus: " +
- network_->userName( msg.senderID() ) + " this should not happen." );
- }
- }
-}
-
void Sector::sendVesselAmmoHit( const Projectile & projectile, BaseObject * victim ){
if ( projectile.parent().userID() == network_->userID() ){
Modified: trunk/src/Sector.h
===================================================================
--- trunk/src/Sector.h 2008-05-12 16:19:10 UTC (rev 896)
+++ trunk/src/Sector.h 2008-05-14 21:33:27 UTC (rev 897)
@@ -56,6 +56,12 @@
void setListe...
[truncated message content] |
|
From: <spo...@us...> - 2008-05-18 19:34:01
|
Revision: 900
http://opengate.svn.sourceforge.net/opengate/?rev=900&view=rev
Author: spom_spom
Date: 2008-05-18 12:30:59 -0700 (Sun, 18 May 2008)
Log Message:
-----------
Add opengate python bindings for the opengate editor
Modified Paths:
--------------
templates/stations/tauseti_wake_2.blend
trunk/ToDo
trunk/configure.ac
trunk/src/AiObject.h
trunk/src/BaseDialog.cpp
trunk/src/BaseDialog.h
trunk/src/BaseObject.cpp
trunk/src/BaseObject.h
trunk/src/ConfigDialog.h
trunk/src/Console.cpp
trunk/src/Console.h
trunk/src/DockedState.cpp
trunk/src/DockedState.h
trunk/src/Entity.cpp
trunk/src/Entity.h
trunk/src/EntityManager.cpp
trunk/src/EntityManager.h
trunk/src/Equipment.cpp
trunk/src/Equipment.h
trunk/src/GameStateManager.cpp
trunk/src/GameStateManager.h
trunk/src/InputManager.h
trunk/src/KeyMap.cpp
trunk/src/KeyMap.h
trunk/src/Makefile.am
trunk/src/MarketDialog.h
trunk/src/Moveable.cpp
trunk/src/OpcodeWrapper.h
trunk/src/OpenALSoundManager.h
trunk/src/ResourceManager.cpp
trunk/src/ResourceManager.h
trunk/src/Sector.cpp
trunk/src/SectorObject.h
trunk/src/SectorObjectMissile.cpp
trunk/src/SectorObjectMoveable.cpp
trunk/src/ShipConfigDialog.cpp
trunk/src/ShipConfigDialog.h
trunk/src/UnDockedState.cpp
trunk/src/Vessel.h
trunk/src/commonWithOgre.cpp
trunk/src/commonWithOgre.h
Added Paths:
-----------
templates/missiles/
templates/missiles/firefly.blend
Removed Paths:
-------------
trunk/data/menus/
Added: templates/missiles/firefly.blend
===================================================================
(Binary files differ)
Property changes on: templates/missiles/firefly.blend
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: templates/stations/tauseti_wake_2.blend
===================================================================
(Binary files differ)
Modified: trunk/ToDo
===================================================================
--- trunk/ToDo 2008-05-18 19:29:16 UTC (rev 899)
+++ trunk/ToDo 2008-05-18 19:30:59 UTC (rev 900)
@@ -210,3 +210,10 @@
-Guns: Dazzler
-Missiles: Firefly, Dragonfly, Mosquito, Bee, Hummel, Hornet
+
+
+Possible Refaktor: (Hier steht Kram den man vielleicht mal aufr\xE4umen kann oder sollte, das ist entweder: alter schief gewachsener code, unsicherheiten,
+als ich das machte konnte ichs nicht besser, einfach nur Mist, etc... )
+
+ /*! Returns the set of known resource paths, maybee this this can be saver by using ogre resource Manager directly instead of holding our own set. */
+ std::set < std::string > & ResourceManager::resourcePaths();
Modified: trunk/configure.ac
===================================================================
--- trunk/configure.ac 2008-05-18 19:29:16 UTC (rev 899)
+++ trunk/configure.ac 2008-05-18 19:30:59 UTC (rev 900)
@@ -26,6 +26,8 @@
AC_TYPE_SIGNAL
AC_TYPE_SIZE_T
+AC_SUBST([CPPFLAGS], ["${CPPFLAGS} -Wall -fPIC"])
+
# Check for header files
AC_CHECK_HEADERS([float.h stddef.h sys/timeb.h])
Modified: trunk/src/AiObject.h
===================================================================
--- trunk/src/AiObject.h 2008-05-18 19:29:16 UTC (rev 899)
+++ trunk/src/AiObject.h 2008-05-18 19:30:59 UTC (rev 900)
@@ -83,9 +83,10 @@
/*! Idle and look every second for new orders */
//bool cmdIdle( );
/*! Wait and do nothing */
- bool cmdWait( double time );
+ bool cmdWait( double time ){return true;}
+
/*! Accelerate a given time with a given thrustRate */
- bool cmdAccelerate( double time, double thrustRate );
+ bool cmdAccelerate( double time, double thrustRate ){ return true; }
/*! Calculate maximum speed from a given thrustRate [0..1]*/
double maxSpeed( double thrustRate = 1.0 ) const;
Modified: trunk/src/BaseDialog.cpp
===================================================================
--- trunk/src/BaseDialog.cpp 2008-05-18 19:29:16 UTC (rev 899)
+++ trunk/src/BaseDialog.cpp 2008-05-18 19:30:59 UTC (rev 900)
@@ -24,6 +24,8 @@
#include <OgreRenderWindow.h>
#include <CEGUIWindowManager.h>
+#include <CEGUIWindow.h>
+#include <CEGUIImageset.h>
namespace OpenGate{
Modified: trunk/src/BaseDialog.h
===================================================================
--- trunk/src/BaseDialog.h 2008-05-18 19:29:16 UTC (rev 899)
+++ trunk/src/BaseDialog.h 2008-05-18 19:30:59 UTC (rev 900)
@@ -21,7 +21,7 @@
#ifndef _OPENGATE_BASEDIALOG__H
#define _OPENGATE_BASEDIALOG__H
-#include "GameState.h"
+//#include "GameState.h"
#include <string>
@@ -32,6 +32,8 @@
namespace OpenGate{
+class ResourceManager;
+
void renameClonedWindows( const CEGUI::Window * parent, const CEGUI::String & namePrefix );
void fitWindowToImage( const std::string & name, CEGUI::Window * win );
float windowHeight( const CEGUI::Window * child );
Modified: trunk/src/BaseObject.cpp
===================================================================
--- trunk/src/BaseObject.cpp 2008-05-18 19:29:16 UTC (rev 899)
+++ trunk/src/BaseObject.cpp 2008-05-18 19:30:59 UTC (rev 900)
@@ -63,6 +63,10 @@
}
}
+void BaseObject::setVisible( bool visible ) {
+ mainNode_->setVisible( visible );
+}
+
void BaseObject::destroy(){
destroyRequest_ = true;
}
Modified: trunk/src/BaseObject.h
===================================================================
--- trunk/src/BaseObject.h 2008-05-18 19:29:16 UTC (rev 899)
+++ trunk/src/BaseObject.h 2008-05-18 19:30:59 UTC (rev 900)
@@ -21,16 +21,17 @@
#ifndef _OPENGATE_BASEOBJECT__H
#define _OPENGATE_BASEOBJECT__H
-//#include <OgrePrerequisites.h>
-
#include "common.h"
-#include <OgreSceneNode.h>
+#include <OgrePrerequisites.h>
+#include <OgreVector3.h>
+//#include <OgreSceneNode.h>
+//#include <OgreEntity.h>
namespace OgreOpcode{
class CollisionObject;
}
-
+
namespace OpenGate{
#define PROJECTILE_RTTI 100001
@@ -73,7 +74,7 @@
inline Ogre::SceneNode * mainNode() { return mainNode_; }
- inline Ogre::SceneNode mainNode() const { return *mainNode_; }
+ inline Ogre::SceneNode * mainNode() const { return mainNode_; }
virtual bool update( Ogre::Real elapsedTime ) = 0;
@@ -86,8 +87,6 @@
bool selectable() const { return selectable_ ;}
void setSelectable( bool selectable ) { selectable_ = selectable; }
-
- Ogre::Vector3 position() const;
/*! Mark the object for destruction
To keep destruction thread safe, we just notify and let the update cycle do the job */
@@ -95,7 +94,7 @@
bool isSetDestroyRequest() const { return destroyRequest_; }
- virtual void setVisible( bool visible ) { mainNode_->setVisible( visible ); }
+ virtual void setVisible( bool visible );
virtual void setActive( bool active );
Modified: trunk/src/ConfigDialog.h
===================================================================
--- trunk/src/ConfigDialog.h 2008-05-18 19:29:16 UTC (rev 899)
+++ trunk/src/ConfigDialog.h 2008-05-18 19:30:59 UTC (rev 900)
@@ -25,6 +25,7 @@
namespace CEGUI{
class Listbox;
+ class EventArgs;
}
namespace OpenGate{
Modified: trunk/src/Console.cpp
===================================================================
--- trunk/src/Console.cpp 2008-05-18 19:29:16 UTC (rev 899)
+++ trunk/src/Console.cpp 2008-05-18 19:30:59 UTC (rev 900)
@@ -18,9 +18,14 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
+#include "Console.h"
+
#include "common.h"
+
#include "ResourceManager.h"
-#include "Console.h"
+// #include "GameState.h"
+#include "GameStateManager.h"
+
#include "LogManager.h"
#include "networkClient.h"
#include "KeyMap.h"
Modified: trunk/src/Console.h
===================================================================
--- trunk/src/Console.h 2008-05-18 19:29:16 UTC (rev 899)
+++ trunk/src/Console.h 2008-05-18 19:30:59 UTC (rev 900)
@@ -18,24 +18,34 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
-#ifndef CONSOLE__H
-#define CONSOLE__H
+#ifndef _OPENGATE_CONSOLE__H
+#define _OPENGATE_CONSOLE__H
-#include <OgrePrerequisites.h>
+#include "InputManager.h"
+
+// #include <OgrePrerequisites.h>
+#include <OgreFrameListener.h>
+
#include <list>
-#include <vector>
-#include "GameState.h"
-#include "GameStateManager.h"
+#include <vector>
+namespace CEGUI{
+ class EventArgs;
+ class Window;
+ class Editbox;
+ class Listbox;
+}
+
namespace OpenGate{
-
+
+class GameStateManager;
+class ResourceManager;
+
class Console : public Ogre::FrameListener, public OIS::KeyListener {
public:
Console();
~Console();
-
- void setVisible( bool visible );
void start( );
void stop( );
@@ -50,9 +60,8 @@
virtual bool keyPressed( const OIS::KeyEvent & e );
virtual bool keyReleased( const OIS::KeyEvent & e );
-
- void addCommand( const std::string & command,
- void (GameStateManager::*ptr) ( const std::vector< std::string > & ), const std::string & help );
+ void addCommand( const std::string & command, void (GameStateManager::*ptr) ( const std::vector< std::string > & ), const std::string & help );
+
void removeCommand( const std::string & command );
virtual void write( const std::string & name, const std::string & message, bool maskDebug = false ){
Modified: trunk/src/DockedState.cpp
===================================================================
--- trunk/src/DockedState.cpp 2008-05-18 19:29:16 UTC (rev 899)
+++ trunk/src/DockedState.cpp 2008-05-18 19:30:59 UTC (rev 900)
@@ -20,9 +20,12 @@
#include "DockedState.h"
#include "Console.h"
+#include "GameStateManager.h"
#include "Avatar.h"
#include "Vessel.h"
#include "OpenALSoundManager.h"
+#include "ShipConfigDialog.h"
+#include "MarketDialog.h"
#include <OgreRoot.h>
#include <OgreRenderWindow.h>
Modified: trunk/src/DockedState.h
===================================================================
--- trunk/src/DockedState.h 2008-05-18 19:29:16 UTC (rev 899)
+++ trunk/src/DockedState.h 2008-05-18 19:30:59 UTC (rev 900)
@@ -21,17 +21,19 @@
#ifndef _OPENGATE_DOCKEDSTATELISTENER__H
#define _OPENGATE_DOCKEDSTATELISTENER__H
-#include <OgrePrerequisites.h>
+// #include <OgrePrerequisites.h>
#include "LogManager.h"
#include "GameState.h"
-#include "ShipConfigDialog.h"
-#include "MarketDialog.h"
+// #include "ShipConfigDialog.h"
+// #include "MarketDialog.h"
namespace OpenGate{
class OpenALSoundSource;
-
+class ShipConfigDialog;
+class MarketDialog;
+
/*!
* \brief This class defines the gamestate the gamestate when the user is docked
*
Modified: trunk/src/Entity.cpp
===================================================================
--- trunk/src/Entity.cpp 2008-05-18 19:29:16 UTC (rev 899)
+++ trunk/src/Entity.cpp 2008-05-18 19:30:59 UTC (rev 900)
@@ -20,18 +20,22 @@
#include "Entity.h"
+#include "common.h"
+#include <string>
+
+#include "ResourceManager.h"
+#include "LogManager.h"
+
#include <OgreException.h>
#include <OgreCEGUITexture.h>
#include <CEGUIImageset.h>
#include <CEGUIExceptions.h>
#include <CEGUIBase.h>
-#include "ResourceManager.h"
-
namespace OpenGate{
Entity::Entity()
- : name_( "unknown" ), className_( "unknown" ),
+ : name_( "unknown" ), category_( "unknown Entity" ),
description_("Please fill in description"), imageFileName_("unknown"), ceguiImageName_( "unknownEntityImageset") {
//** just an idea
// addProperty< float >( "baseYaw", this, setBaseYaw, baseYaw, mandatory, default, description )
@@ -55,8 +59,8 @@
}
void Entity::setFactionID( int id ){
- factionID_ = id;
- setFactionName_( ResourceManager::getSingleton().factionName( factionID_ ) );
+ factionID_ = id;
+ setFactionName_( ResourceManager::getSingleton().factionName( factionID_ ) );
}
void Entity::setBaseSize( float length, float width, float height ){
@@ -131,7 +135,8 @@
readXMLNode< Uint16 >( hRoot, "object_id", this, &OpenGate::Entity::setID, true );
readXMLNode< Uint8 >( hRoot, "faction_id", this, &OpenGate::Entity::setFactionID, true );
- readXMLNode< Uint8 >( hRoot, "class_id", this, &OpenGate::Entity::setClassID, false );
+ // what is that for
+ //readXMLNode< Uint8 >( hRoot, "class_id", this, &OpenGate::Entity::setClassID, false );
readXMLNode< Uint8 >( hRoot, "techlevel required_rank", this, &OpenGate::Entity::setTechLevel, false );
readXMLNode< int >( hRoot, "size", this, &OpenGate::Entity::setSize, false );
Modified: trunk/src/Entity.h
===================================================================
--- trunk/src/Entity.h 2008-05-18 19:29:16 UTC (rev 899)
+++ trunk/src/Entity.h 2008-05-18 19:30:59 UTC (rev 900)
@@ -24,16 +24,22 @@
#include <set>
#include <string>
-#include "LogManager.h"
-#include "ResourceManager.h"
+#include "common.h"
#include <OgreVector3.h>
+// namespace Ogre{
+// class Vector3;
+// class Real;
+// }
+
namespace OpenGate{
enum EntityType{NONE,ENTITY,VESSEL,COMMODITY,POWERPLANT,ENGINE,RADAR,ECM,CAPACITOR,SHIELD,GUN,MISSILE,MODX};
-
+enum GunType{UNKNOWN,LASER,MININGLASER,BULLET};
+
class Commodity;
+class ResourceManager;
// class Property {
// public:
@@ -79,12 +85,10 @@
inline void setName( const std::string & name ) { name_ = name; }
inline std::string name( ) const { return name_; }
-
- inline void setClassID( Uint8 id ) { className_ = ResourceManager::getSingleton().className( id ); }
-
- inline void setClassName( const std::string & name ) { className_ = name; }
- inline std::string className( ) const { return className_; }
+ inline void setCategoryName( const std::string & category ) { category_ = category; }
+ inline std::string categoryName( ) const { return category_; }
+
inline void setID( int id ){ id_ = id; }
inline int id( ) const { return id_; }
@@ -141,7 +145,7 @@
void loadImages_( );
std::string name_;
- std::string className_;
+ std::string category_;
/*! A rather long description of this component */
std::string description_;
Modified: trunk/src/EntityManager.cpp
===================================================================
--- trunk/src/EntityManager.cpp 2008-05-18 19:29:16 UTC (rev 899)
+++ trunk/src/EntityManager.cpp 2008-05-18 19:30:59 UTC (rev 900)
@@ -19,6 +19,7 @@
***************************************************************************/
#include "EntityManager.h"
+#include "LogManager.h"
#include "ResourceManager.h"
#include "tinyxml/tinyxml.h"
#include "Vessel.h"
@@ -228,7 +229,9 @@
log_->fatal( fileName + " has no category_id (mandatory)." );
return NULL;
}
- //** Image name for the entity is derived from filename;
+ entity->setCategoryName( categoryName( entity->entityType() ) );
+
+ //** Image name for the entity is derived from filename;
std::string basename( fileName.substr( fileName.rfind( "/" ) + 1 ) );
entity->setImageName( basename.substr( 0, basename.find( ".xml" ) ) );
@@ -236,6 +239,7 @@
entity->readPropertiesFromXML( hRoot );
} catch ( std::invalid_argument e ){
log_->warn( e.what() );
+ delete entity;
return NULL;
}
@@ -247,7 +251,7 @@
log_->warn( std::string( "Equipment with name: " ) + entity->factionName() + "/" + entity->name() +
" already loaded" );
}
-
+ categories_.insert( entity->categoryName() );
return entity;
}
Modified: trunk/src/EntityManager.h
===================================================================
--- trunk/src/EntityManager.h 2008-05-18 19:29:16 UTC (rev 899)
+++ trunk/src/EntityManager.h 2008-05-18 19:30:59 UTC (rev 900)
@@ -21,11 +21,12 @@
#ifndef _OPENGATE_ENTITYMANAGER_H
#define _OPENGATE_ENTITYMANAGER_H
-#include "LogManager.h"
#include "Entity.h"
namespace OpenGate {
+class LogManager;
+
class PowerPlant;
class Engine;
class Radar;
@@ -68,7 +69,9 @@
void load( const std::set < std::string > & resourcePaths, const std::string & resourceName );
inline std::set < std::string > factionNames( ) const { return factions_; }
-
+
+ inline std::set < std::string > categories( ) const { return categories_; }
+
EntityType categoryType( const std::string & category );
std::string categoryName( EntityType type );
@@ -105,8 +108,8 @@
if ( item->entityType() == tmp.entityType() ) {
return dynamic_cast< EntityType * >(item);
} else {
- LogManager::getSingleton().warn( "Requested " + categoryName( tmp.entityType() ) + ": " + name +
- " is a " + categoryName( item->entityType() ) );
+// LogManager::getSingleton().warn( "Requested " + categoryName( tmp.entityType() ) + ": " + name +
+// " is a " + categoryName( item->entityType() ) );
}
return NULL;
}
@@ -120,8 +123,8 @@
if ( item->entityType() == tmp.entityType() ) {
return dynamic_cast< EntityType * >(item);
} else {
- LogManager::getSingleton().warn( "Requested " + categoryName( tmp.entityType() ) + ": " + toStr( ID ) +
- " is a " + categoryName( item->entityType() ) );
+// LogManager::getSingleton().warn( "Requested " + categoryName( tmp.entityType() ) + ": " + toStr( ID ) +
+// " is a " + categoryName( item->entityType() ) );
}
return NULL;
}
@@ -132,6 +135,7 @@
std::map < std::string, Entity * > templatesByName_;
std::map < Uint16, Entity * > templatesByID_;
std::set < std::string > factions_;
+ std::set < std::string > categories_;
};
} // namespace OpenGate
Modified: trunk/src/Equipment.cpp
===================================================================
--- trunk/src/Equipment.cpp 2008-05-18 19:29:16 UTC (rev 899)
+++ trunk/src/Equipment.cpp 2008-05-18 19:30:59 UTC (rev 900)
@@ -22,7 +22,62 @@
#include "common.h"
namespace OpenGate{
+
+void Commodity::readPropertiesFromXML( TiXmlHandle & hRoot ){
+ Entity::readPropertiesFromXML( hRoot );
+ readXMLNode< int >( hRoot, "melting-point", this, &OpenGate::Commodity::setMeltingPoint, false );
+ readXMLNode< double >( hRoot, "gravitic-sig", this, &OpenGate::Commodity::setGraviticSig, false );
+}
+void Equipment::readPropertiesFromXML( TiXmlHandle & hRoot ){
+ Entity::readPropertiesFromXML( hRoot );
+ readXMLNode< double >( hRoot, "efficency", this, &OpenGate::Equipment::setEfficiency, false );
+ readXMLNode< std::string >( hRoot, "Manufacturer", this, &OpenGate::Equipment::setManufacturer, false );
+ readXMLNode< Uint32 >( hRoot, "power_input", this, &OpenGate::Equipment::setPowerConsumption, false );
+}
+
+void PowerPlant::readPropertiesFromXML( TiXmlHandle & hRoot ){
+ Equipment::readPropertiesFromXML( hRoot );
+ readXMLNode< Uint32 >( hRoot, "power_output", this, &OpenGate::PowerPlant::setPowerOutput, false );
+ }
+
+void Engine::readPropertiesFromXML( TiXmlHandle & hRoot ){
+ Equipment::readPropertiesFromXML( hRoot );
+ readXMLNode< Uint32 >( hRoot, "maximum_thrust", this, &OpenGate::Engine::setMaxThrust, false );
+ }
+
+void Radar::readPropertiesFromXML( TiXmlHandle & hRoot ){
+ Equipment::readPropertiesFromXML( hRoot );
+ readXMLNode< Uint32 >( hRoot, "maximum_range", this, &OpenGate::Radar::setMaxRange, false );
+ }
+
+void Ecm::readPropertiesFromXML( TiXmlHandle & hRoot ){
+ Equipment::readPropertiesFromXML( hRoot );
+ readXMLNode< Uint8 >( hRoot, "sensorlevel", this, &OpenGate::Ecm::setSensorLevel, false );
+ }
+
+void Shield::readPropertiesFromXML( TiXmlHandle & hRoot ){
+ Equipment::readPropertiesFromXML( hRoot );
+ readXMLNode< Uint32 >( hRoot, "regeneration_rate", this, &OpenGate::Shield::setRegenerationRate, false );
+ readXMLNode< Uint32 >( hRoot, "maximum_deflection", this, &OpenGate::Shield::setMaxDeflection, false );
+ }
+
+void Capacitor::readPropertiesFromXML( TiXmlHandle & hRoot ){
+ Equipment::readPropertiesFromXML( hRoot );
+ readXMLNode< Uint32 >( hRoot, "capacity", this, &OpenGate::Capacitor::setCapacity, false );
+}
+
+void Gun::readPropertiesFromXML( TiXmlHandle & hRoot ){
+ Equipment::readPropertiesFromXML( hRoot );
+ readXMLNode< Uint32 >( hRoot, "damage", this, &OpenGate::Gun::setDamage, false );
+ readXMLNode< Uint32 >( hRoot, "velocity", this, &OpenGate::Gun::setSpeed, false );
+ readXMLNode< std::string >( hRoot, "type", this, &OpenGate::Gun::setType, false );
+ readXMLNode< double >( hRoot, "life_time", this, &OpenGate::Gun::setLifeTime, false );
+ readXMLNode< double >( hRoot, "fire_delay", this, &OpenGate::Gun::setFireDelay, false );
+ readXMLNode< Uint32 >( hRoot, "power_per_shot", this, &OpenGate::Gun::setEnergy, false );
+}
+
+
} // namespace OpenGate
Modified: trunk/src/Equipment.h
===================================================================
--- trunk/src/Equipment.h 2008-05-18 19:29:16 UTC (rev 899)
+++ trunk/src/Equipment.h 2008-05-18 19:30:59 UTC (rev 900)
@@ -24,9 +24,10 @@
#include <set>
#include <string>
-#include "LogManager.h"
#include "Entity.h"
+#include "common.h"
+
#include <OgreVector3.h>
namespace OpenGate{
@@ -47,11 +48,8 @@
meltingPoint_ = 0;
graviticSig_ = 0.0;
}
- virtual void readPropertiesFromXML( TiXmlHandle & hRoot ){
- Entity::readPropertiesFromXML( hRoot );
- readXMLNode< int >( hRoot, "melting-point", this, &OpenGate::Commodity::setMeltingPoint, false );
- readXMLNode< double >( hRoot, "gravitic-sig", this, &OpenGate::Commodity::setGraviticSig, false );
- }
+ virtual void readPropertiesFromXML( TiXmlHandle & hRoot );
+
inline void setMeltingPoint( int meltingPoint ){ meltingPoint_ = meltingPoint; }
inline int meltingPoint( ) const { return meltingPoint_; }
@@ -84,13 +82,8 @@
class Equipment : public Entity{
public:
- virtual void readPropertiesFromXML( TiXmlHandle & hRoot ){
- Entity::readPropertiesFromXML( hRoot );
- readXMLNode< double >( hRoot, "efficency", this, &OpenGate::Equipment::setEfficiency, false );
- readXMLNode< std::string >( hRoot, "Manufacturer", this, &OpenGate::Equipment::setManufacturer, false );
- readXMLNode< Uint32 >( hRoot, "power_input", this, &OpenGate::Equipment::setPowerConsumption, false );
- }
-
+ virtual void readPropertiesFromXML( TiXmlHandle & hRoot );
+
inline void setManufacturer( const std::string & manufacturer ) { manufacturer_ = manufacturer; }
inline std::string manufacturer( ) const { return manufacturer_; }
@@ -134,15 +127,12 @@
*/
class PowerPlant : public Equipment {
public:
- PowerPlant() : Equipment(){
- rtti_ = POWERPLANT;
- powerOutput_ = 0;
- }
- virtual void readPropertiesFromXML( TiXmlHandle & hRoot ){
- Equipment::readPropertiesFromXML( hRoot );
- readXMLNode< Uint32 >( hRoot, "power_output", this, &OpenGate::PowerPlant::setPowerOutput, false );
- }
-
+ PowerPlant() : Equipment(){
+ rtti_ = POWERPLANT;
+ powerOutput_ = 0;
+ }
+ virtual void readPropertiesFromXML( TiXmlHandle & hRoot );
+
inline void setPowerOutput( Uint32 power ) {
powerOutput_ = power;
//** if input power is < 100kW, then input is scaled in kW
@@ -165,16 +155,13 @@
class Engine : public Equipment {
public:
- Engine() : Equipment() {
- rtti_ = ENGINE;
- maxThrust_ = 0;
- }
+ Engine() : Equipment() {
+ rtti_ = ENGINE;
+ maxThrust_ = 0;
+ }
- virtual void readPropertiesFromXML( TiXmlHandle & hRoot ){
- Equipment::readPropertiesFromXML( hRoot );
- readXMLNode< Uint32 >( hRoot, "maximum_thrust", this, &OpenGate::Engine::setMaxThrust, false );
- }
-
+ virtual void readPropertiesFromXML( TiXmlHandle & hRoot );
+
inline void setMaxThrust( Uint32 maxThrust ) {
maxThrust_ = maxThrust;
//** if input thrust is < 100kN, then input is scaled in kN
@@ -202,10 +189,7 @@
Radar() : Equipment(){
rtti_ = RADAR;
}
- virtual void readPropertiesFromXML( TiXmlHandle & hRoot ){
- Equipment::readPropertiesFromXML( hRoot );
- readXMLNode< Uint32 >( hRoot, "maximum_range", this, &OpenGate::Radar::setMaxRange, false );
- }
+ virtual void readPropertiesFromXML( TiXmlHandle & hRoot );
inline void setMaxRange( Uint32 range ){ range_ = range; }
inline Uint32 maxRange() const{ return range_; }
@@ -229,10 +213,7 @@
rtti_ = ECM;
sensorLevel_ = 0;
}
- virtual void readPropertiesFromXML( TiXmlHandle & hRoot ){
- Equipment::readPropertiesFromXML( hRoot );
- readXMLNode< Uint8 >( hRoot, "sensorlevel", this, &OpenGate::Ecm::setSensorLevel, false );
- }
+ virtual void readPropertiesFromXML( TiXmlHandle & hRoot );
inline void setSensorLevel( short sensorLevel ) { sensorLevel_ = sensorLevel; }
inline Uint8 sensorLevel( ) { return sensorLevel_; }
@@ -255,11 +236,7 @@
Shield() : Equipment(){
rtti_ = SHIELD;
}
- virtual void readPropertiesFromXML( TiXmlHandle & hRoot ){
- Equipment::readPropertiesFromXML( hRoot );
- readXMLNode< Uint32 >( hRoot, "regeneration_rate", this, &OpenGate::Shield::setRegenerationRate, false );
- readXMLNode< Uint32 >( hRoot, "maximum_deflection", this, &OpenGate::Shield::setMaxDeflection, false );
- }
+ virtual void readPropertiesFromXML( TiXmlHandle & hRoot );
inline void setMaxDeflection( Uint32 deflection ){
setMaximumDeflection_ = deflection;
@@ -297,10 +274,7 @@
rtti_ = CAPACITOR;
capacity_ = 0;
}
- virtual void readPropertiesFromXML( TiXmlHandle & hRoot ){
- Equipment::readPropertiesFromXML( hRoot );
- readXMLNode< Uint32 >( hRoot, "capacity", this, &OpenGate::Capacitor::setCapacity, false );
- }
+ virtual void readPropertiesFromXML( TiXmlHandle & hRoot );
inline void setCapacity( Uint32 capacity ) {
capacity_ = capacity;
@@ -316,20 +290,13 @@
class Gun : public Equipment{
public:
- Gun(): Equipment(){
- rtti_ = GUN;
- type_ = UNKNOWN;
- }
- virtual void readPropertiesFromXML( TiXmlHandle & hRoot ){
- Equipment::readPropertiesFromXML( hRoot );
- readXMLNode< Uint32 >( hRoot, "damage", this, &OpenGate::Gun::setDamage, false );
- readXMLNode< Uint32 >( hRoot, "velocity", this, &OpenGate::Gun::setSpeed, false );
- readXMLNode< std::string >( hRoot, "type", this, &OpenGate::Gun::setType, false );
- readXMLNode< double >( hRoot, "life_time", this, &OpenGate::Gun::setLifeTime, false );
- readXMLNode< double >( hRoot, "fire_delay", this, &OpenGate::Gun::setFireDelay, false );
- readXMLNode< Uint32 >( hRoot, "power_per_shot", this, &OpenGate::Gun::setEnergy, false );
+ Gun(): Equipment(){
+ rtti_ = GUN;
+ type_ = UNKNOWN;
}
+ virtual void readPropertiesFromXML( TiXmlHandle & hRoot );
+
void setType( const std::string & type ) {
if ( type == "laser" ){
type_ = LASER;
Modified: trunk/src/GameStateManager.cpp
===================================================================
--- trunk/src/GameStateManager.cpp 2008-05-18 19:29:16 UTC (rev 899)
+++ trunk/src/GameStateManager.cpp 2008-05-18 19:30:59 UTC (rev 900)
@@ -61,54 +61,6 @@
//** without any gamestate, shutdown immediately;
shutdownRequest_ = initialiseBootstrap( dialog );
-
- //** start for test purposes;
-// const Ogre::RenderSystemCapabilities * caps = Ogre::Root::getSingleton().getRenderSystem()->getCapabilities();
-// if ( !caps->hasCapability( Ogre::RSC_VERTEX_PROGRAM ) ) {
-// OGRE_EXCEPT(Ogre::Exception::ERR_NOT_IMPLEMENTED, "Your card does not support vertex programs.",
-// "GameStateManager::GameStateManager");
-// }
-// if ( !( caps->hasCapability( Ogre::RSC_FRAGMENT_PROGRAM ) || caps->hasCapability( Ogre::RSC_DOT3 ) ) ) {
-// OGRE_EXCEPT(Ogre::Exception::ERR_NOT_IMPLEMENTED, "Your card does not support dot3 blending or fragment programs.",
-// "GameStateManager::GameStateManager" );
-// }
-
-// Ogre::SceneManager* sceneMgr = devices_.ogreRoot->createSceneManager(Ogre::ST_GENERIC);
-// Ogre::Camera* camera = sceneMgr->createCamera("SimpleCamera");
-// resources_.ogreRoot->addFrameListener(&frameListener);
-// camera->setPosition( Ogre::Vector3( 0, 0, 200 ) );
-// camera->lookAt( Ogre::Vector3( 0, 0, -300 ) );
-// camera->setNearClipDistance( 1 );
-// sceneMgr->setAmbientLight( Ogre::ColourValue(0.1, 0.1, 0.1) );
-// Ogre::SceneNode * mainNode = static_cast< Ogre::SceneNode * >( sceneMgr->getRootSceneNode()->createChild("test") );
-
-// Ogre::SceneNode * light = sceneMgr->getRootSceneNode()->createChildSceneNode("baseLight");
-// Ogre::Light * l = sceneMgr->createLight("Light" );
-// l->setDiffuseColour( Ogre::ColourValue(1, 1, 1) );
-// l->setSpecularColour( Ogre::ColourValue(1, 1, 1) );
-// l->setVisible( true );
-// light->setPosition( 0, 0, 500);
-// light->attachObject( l );
-
-// Ogre::MeshPtr pMesh = Ogre::MeshManager::getSingleton().load( "ogrehead.mesh",
-// Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
-// Ogre::HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY,
-// Ogre::HardwareBuffer::HBU_STATIC_WRITE_ONLY,
-// true, true);
-// unsigned short src, dest;
-// if ( !pMesh->suggestTangentVectorBuildParams( Ogre::VES_TANGENT, src, dest) ) {
-// pMesh->buildTangentVectors( Ogre::VES_TANGENT, src, dest);
-// }
-
-// Ogre::Entity * shape = sceneMgr->createEntity( "ogrehead", "ogrehead.mesh" );
-// shape->setMaterialName("Examples/BumpMapping/MultiLight");
-
-// mainNode->attachObject( shape );
-// devices_.ogreRoot->startRendering();
-// while( 1 ){
-// resources_.o...
[truncated message content] |
|
From: <spo...@us...> - 2008-06-15 12:14:11
|
Revision: 910
http://opengate.svn.sourceforge.net/opengate/?rev=910&view=rev
Author: spom_spom
Date: 2008-06-15 05:14:18 -0700 (Sun, 15 Jun 2008)
Log Message:
-----------
change xml-format for sector description, it can be saved by ogeditor and loaded by the client
Modified Paths:
--------------
branches/ogEditor/generate_code.py
branches/ogEditor/ogEditor.py
branches/ogEditor/ogtest.py
branches/ogEditor/python_opengate.h
trunk/plugins.cfg
trunk/src/Sector.cpp
trunk/src/Sector.h
trunk/src/SectorObject.h
trunk/src/SectorObjectMoveable.cpp
trunk/src/Station.cpp
trunk/src/common.h
trunk/src/commonWithOgre.h
Added Paths:
-----------
branches/ogEditor/src/OpenGateSpecs.py
trunk/data/misc/test.sector
Modified: branches/ogEditor/generate_code.py
===================================================================
--- branches/ogEditor/generate_code.py 2008-06-11 21:08:31 UTC (rev 909)
+++ branches/ogEditor/generate_code.py 2008-06-15 12:14:18 UTC (rev 910)
@@ -135,10 +135,13 @@
#mb.class_( '::std::set < ::std::string >' ).alias = 'stringSet';
excludeClass( mb, [ 'deletePtr'
- ,'GameStateListener'
+ ,'AiManager'
+ ,'GameStateListener'
,'GameStateManager'
,'Message'
,'MessageBodyBase'
+ ,'MessageBodyShipAmmoHit'
+ ,'MessageBodyShipDeRegister'
,'OpenALSoundSource'
] )
Modified: branches/ogEditor/ogEditor.py
===================================================================
--- branches/ogEditor/ogEditor.py 2008-06-11 21:08:31 UTC (rev 909)
+++ branches/ogEditor/ogEditor.py 2008-06-15 12:14:18 UTC (rev 910)
@@ -14,18 +14,12 @@
import wx.lib.customtreectrl as CT
-from ObjectInspectorPanels import *
-from ResourceTreePane import *
+from ObjectInspectorPanels import *
+from ResourceTreePane import *
-from OgreWindowWx import *
+from OgreWindowWx import *
+from SectorXMLWriter import *
-try:
- import opengate as og
- haveOpenGatePlugin = True
-except:
- haveOpenGatePlugin = False
- pass
-
ID_MB_FILE_EXIT = wx.NewId()
ID_MB_VIEW_SCENETREE = wx.NewId()
ID_MB_VIEW_OBJECT = wx.NewId()
@@ -45,69 +39,10 @@
activeResource = None;
def __init__(self):
Pass
-
-class Opengate:
- resourceManager_ = None
-
- def __init__( self, OgreWindow ):
- self.resourceManager_ = og.ResourceManager()
- self.resourceManager_.logManager = og.LogManager()
- self.resourceManager_.entityManager = og.EntityManager( )
- self.resourceManager_.ogreRoot = OgreWindow.ogreRoot
- self.resourceManager_.renderWindow = OgreWindow.renderWindow
+from OpenGateSpecs import *
- OgreWindow.AddResources( "opengate-resources.cfg" )
- ogre.ResourceGroupManager.getSingleton().initialiseResourceGroup( "Opengate" )
-
- for res in OgreWindow.resourceLocations:
- self.resourceManager_.addResourceLocation( res[0], res[1] )
-
- def initOpenGateResources_( self ):
- self.resourceManager_.loadGlobalIDs( "ids.xml" )
- entityManager = self.resourceManager_.entityManager
- entityManager.load( self.resourceManager_.resourceLocations( "Opengate" ), "commodities" );
- entityManager.load( self.resourceManager_.resourceLocations( "Opengate" ), "engines" );
- entityManager.load( self.resourceManager_.resourceLocations( "Opengate" ), "capacitors" );
- entityManager.load( self.resourceManager_.resourceLocations( "Opengate" ), "radars" );
- entityManager.load( self.resourceManager_.resourceLocations( "Opengate" ), "shields" );
- entityManager.load( self.resourceManager_.resourceLocations( "Opengate" ), "ecms" );
- entityManager.load( self.resourceManager_.resourceLocations( "Opengate" ), "power_plants" );
- entityManager.load( self.resourceManager_.resourceLocations( "Opengate" ), "guns" );
- entityManager.load( self.resourceManager_.resourceLocations( "Opengate" ), "missiles" );
- entityManager.load( self.resourceManager_.resourceLocations( "Opengate" ), "ships" );
- entityManager.load( self.resourceManager_.resourceLocations( "Opengate" ), "stations" );
-
- def getName( self ):
- return "Opengate"
-
- def fillProperties( self, objectInspectorPanel ):
- objectInspectorPanel.typeStaticText.SetLabel( "Opengate" )
- shaderSchemes = ( "Default", "vpOnly", "vpfp" )
- vp = self.resourceManager_.renderWindow.getViewport( 0 )
- self.interpolModeChosser = objectInspectorPanel.propertyGrid.appendRowItemChoice( "shader scheme",
- value = "Default",
- itemList = shaderSchemes,
- cback = vp.setMaterialScheme )
-
- def AddToResourcesTree( self, tree, node):
-
- if self.resourceManager_:
- ogResManNode = tree.AppendItem( node, "OpenGate resource manager" )
-
- if self.resourceManager_.entityManager:
- ogEntityManagerNode = tree.AppendItem( ogResManNode, "Entity manager" )
- categories = self.resourceManager_.entityManager.categories();
-
- for category in categories:
- categoryNode = tree.AppendItem( ogEntityManagerNode, category )
-
-
- def AddToSceneGraph( self, tree, node ):
- opengateNode = tree.AppendItem( node, "Opengate" )
- tree.SetPyData( opengateNode, self )
-
class DropData(wx.CustomDataObject):
def __init__(self):
wx.CustomDataObject.__init__(self, wx.CustomDataFormat("MyDropData"))
@@ -230,8 +165,8 @@
ws = WorkSpace
self.allPanes = []
self.allPanes.append( OGEditorPane( ID_MB_VIEW_SCENETREE, NAME_SCENETREE, "\tF1", None, True ) )
- self.allPanes.append( OGEditorPane( ID_MB_VIEW_OBJECT, NAME_OBJECT , "\tF2", None, False ) )
- self.allPanes.append( OGEditorPane( ID_MB_VIEW_RESOURCE, NAME_RESOURCE , "\tF3", None, True ) )
+ self.allPanes.append( OGEditorPane( ID_MB_VIEW_OBJECT, NAME_OBJECT , "\tF2", None, True ) )
+ self.allPanes.append( OGEditorPane( ID_MB_VIEW_RESOURCE, NAME_RESOURCE , "\tF3", None, False ) )
self.allPanes.append( OGEditorPane( ID_MB_VIEW_MATERIAL, NAME_MATERIAL , "\tF4", None, False ) )
self.allPanes.append( OGEditorPane( ID_MB_VIEW_PYCRUST, NAME_PYCRUST , "\tF9", None, False ) )
@@ -379,9 +314,9 @@
self.resourceTree = ResourceTreePane( self, -1, wx.Point( 0, 0 ), wx.Size( 160, 250 ),
wx.TR_DEFAULT_STYLE | wx.NO_BORDER );
self.Bind( wx.EVT_TREE_SEL_CHANGED, self.doSelectTreeObject, self.resourceTree )
- self.resourceTree.Bind( wx.EVT_TREE_BEGIN_DRAG, self.OnBeginDrag )
- self.resourceTree.Bind( wx.EVT_TREE_BEGIN_RDRAG, self.OnBeginRDrag )
- self.resourceTree.Bind( wx.EVT_TREE_END_DRAG, self.OnEndDrag )
+ self.resourceTree.Bind( wx.EVT_TREE_BEGIN_DRAG, self.OnBeginDrag )
+ self.resourceTree.Bind( wx.EVT_TREE_BEGIN_RDRAG, self.OnBeginRDrag )
+ self.resourceTree.Bind( wx.EVT_TREE_END_DRAG, self.OnEndDrag )
return self.resourceTree
def setDefaultProperties_( self ):
Modified: branches/ogEditor/ogtest.py
===================================================================
--- branches/ogEditor/ogtest.py 2008-06-11 21:08:31 UTC (rev 909)
+++ branches/ogEditor/ogtest.py 2008-06-15 12:14:18 UTC (rev 910)
@@ -33,18 +33,21 @@
global ogResourceManager
- self.ogreRenderWindow = OgreWindow( self, ID = -1, ogResourceMan = ogResourceManager )
+ self.ogreRenderWindow = OgreWindow( self, ID = -1 )
+ self.ogreRenderWindow.AddResources( "opengate-resources.cfg" )
+ ogre.ResourceGroupManager.getSingleton().initialiseResourceGroup( "Opengate" )
- mops = og.Mops();
- print mops.name()
- print mops.getVec()
-
ogLog = og.LogManager();
ogResourceManager.logManager = ogLog
+
+
+ for res in self.ogreRenderWindow.resourceLocations:
+ ogResourceManager.addResourceLocation( res[0], res[1] )
+
ogResourceManager.loadGlobalIDs( "ids.xml" );
entityManager = og.EntityManager( )
ogResourceManager.entityManager = entityManager
- entityManager.load( ogResourceManager.resourceLocations( "General" ), "commodities" );
+ entityManager.load( ogResourceManager.resourceLocations( "Opengate" ), "commodities" );
self.SetMenuBar( self.mb )
self.Bind( wx.EVT_MENU, self.doExit, id = wx.ID_EXIT )
Modified: branches/ogEditor/python_opengate.h
===================================================================
--- branches/ogEditor/python_opengate.h 2008-06-11 21:08:31 UTC (rev 909)
+++ branches/ogEditor/python_opengate.h 2008-06-15 12:14:18 UTC (rev 910)
@@ -47,21 +47,6 @@
// #include "networkClient.h"
//#include "networkProtocol.h"
-namespace OpenGate{
- class Mops{
- public:
- Mops(){}
- std::string name(){ return "Mops";}
- Ogre::Vector3 getVec(){ return pos_;}
- void * voidPtr(){ return NULL; }
- void vec( const Ogre::Vector3 & pos ){
- std::cout << pos << std::endl;
- }
- private:
- Ogre::Vector3 pos_;
- };
-}
-
//First we create a magic namespace to hold all our aliases
namespace pyplusplus { namespace aliases {
#include "python_opengate_aliases.h"
Added: branches/ogEditor/src/OpenGateSpecs.py
===================================================================
--- branches/ogEditor/src/OpenGateSpecs.py (rev 0)
+++ branches/ogEditor/src/OpenGateSpecs.py 2008-06-15 12:14:18 UTC (rev 910)
@@ -0,0 +1,222 @@
+import sys
+from OgreWindowWx import *
+
+try:
+ import opengate as og
+ haveOpenGatePlugin = True
+except:
+ haveOpenGatePlugin = False
+ pass
+
+class Opengate:
+ resourceManager_ = None
+ sceneTree_ = None
+
+ def __init__( self, OgreWindow ):
+
+ self.resourceManager_ = og.ResourceManager()
+ self.resourceManager_.logManager = og.LogManager()
+ self.resourceManager_.entityManager = og.EntityManager( )
+ self.resourceManager_.ogreRoot = OgreWindow.ogreRoot
+ self.resourceManager_.renderWindow = OgreWindow.renderWindow
+
+ OgreWindow.AddResources( "opengate-resources.cfg" )
+ ogre.ResourceGroupManager.getSingleton().initialiseResourceGroup( "Opengate" )
+
+ for res in OgreWindow.resourceLocations:
+ self.resourceManager_.addResourceLocation( res[0], res[1] )
+
+ def initOpenGateResources_( self ):
+ self.resourceManager_.loadGlobalIDs( "ids.xml" )
+ entityManager = self.resourceManager_.entityManager
+ entityManager.load( self.resourceManager_.resourceLocations( "Opengate" ), "commodities" );
+ entityManager.load( self.resourceManager_.resourceLocations( "Opengate" ), "engines" );
+ entityManager.load( self.resourceManager_.resourceLocations( "Opengate" ), "capacitors" );
+ entityManager.load( self.resourceManager_.resourceLocations( "Opengate" ), "radars" );
+ entityManager.load( self.resourceManager_.resourceLocations( "Opengate" ), "shields" );
+ entityManager.load( self.resourceManager_.resourceLocations( "Opengate" ), "ecms" );
+ entityManager.load( self.resourceManager_.resourceLocations( "Opengate" ), "power_plants" );
+ entityManager.load( self.resourceManager_.resourceLocations( "Opengate" ), "guns" );
+ entityManager.load( self.resourceManager_.resourceLocations( "Opengate" ), "missiles" );
+ entityManager.load( self.resourceManager_.resourceLocations( "Opengate" ), "ships" );
+ entityManager.load( self.resourceManager_.resourceLocations( "Opengate" ), "stations" );
+
+ def getName( self ):
+ return "Opengate"
+
+ def fillProperties( self, objectInspectorPanel ):
+ objectInspectorPanel.typeStaticText.SetLabel( "Opengate" )
+ shaderSchemes = ( "Default", "vpOnly", "vpfp" )
+ vp = self.resourceManager_.renderWindow.getViewport( 0 )
+ self.interpolModeChosser = objectInspectorPanel.propertyGrid.appendRowItemChoice( "shader scheme",
+ value = "Default",
+ itemList = shaderSchemes,
+ cback = vp.setMaterialScheme )
+ objectInspectorPanel.propertyGrid.appendRowItemFileSelect("Load sector", cback = self.LoadSectorScene,
+ toolTip = "Load sector", wildcard = "*.sector")
+ objectInspectorPanel.propertyGrid.appendRowItemFileSelect("Save sector", cback = self.SaveSectorScene,
+ toolTip = "Save scene", wildcard = "*.sector")
+
+ def AddToResourcesTree( self, tree, node):
+ self.sceneTree_ = tree;
+ if self.resourceManager_:
+ ogResManNode = tree.AppendItem( node, "OpenGate resource manager" )
+
+ if self.resourceManager_.entityManager:
+ ogEntityManagerNode = tree.AppendItem( ogResManNode, "Entity manager" )
+ categories = self.resourceManager_.entityManager.categories();
+
+ for category in categories:
+ categoryNode = tree.AppendItem( ogEntityManagerNode, category )
+
+
+ def AddToSceneGraph( self, tree, node ):
+ opengateNode = tree.AppendItem( node, "Opengate" )
+ tree.SetPyData( opengateNode, self )
+
+ def SaveSectorScene( self, name ):
+ out = open( name, 'w')
+ #out = sys.stdout
+ sectorWriter = SectorXMLWriter( out, 'utf-8')
+ sectorWriter.writeEnvironment( self.sector.sceneManager() )
+ #sectorWriter.writeStation("test-station")
+ #sectorWriter.writeNode("test")
+
+ for obj in self.sector.sectorObjects():
+ sectorWriter.writeObject( obj )
+
+ sectorWriter.close()
+ print "save sector", name
+
+ def LoadSectorScene( self, name ):
+ print "load sector", name
+
+from xml.sax import saxexts, saxlib, saxutils
+from xml.sax.saxutils import XMLGenerator
+from xml.sax.xmlreader import AttributesImpl
+from xml.sax.xmlreader import AttributesNSImpl
+import string
+
+class SectorXMLWriter():
+ def __init__( self, output, encoding):
+
+ self.logger_ = XMLGenerator( output, encoding )
+ self.logger_.startDocument()
+ attrs = AttributesImpl({
+ u'name': 'testsector'
+ })
+ self.logger_.startElement( u'sector',attrs)
+ self.logger_.characters("\n")
+
+ def writeEnvironment( self, sceneManager ):
+ attrs = AttributesImpl({ u'skybox': "OpenGate/SimpleSkyBox3" })
+ self.logger_.startElement( u'environment', attrs)
+ self.logger_.characters("\n")
+ self.writeColour( u'ambient', sceneManager.getAmbientLight() )
+ self.logger_.endElement( u'environment' )
+ self.logger_.characters("\n")
+
+ def writeObject( self, obj ):
+ if type( obj ) == og.StationObject:
+ self.writeStation( obj )
+ elif type( obj ) == og.BeaconObject:
+ self.writeBeacon( obj )
+ else:
+ self.writeSectorObject( obj )
+
+ def writeStation( self, obj ):
+ attrs = AttributesImpl({ u'name': obj.name() })
+ self.logger_.startElement( u'station', attrs)
+ self.logger_.characters("\n")
+ self.writeVec3( u'position', obj.mainNode().getWorldPosition() )
+ #self.writeVec3( u'direction', obj.mainNode().getDirection() )
+ #self.writeVec3( u'scale', obj.mainNode().getScale() )
+ #self.writeEntity( u'mesh.mesh' )
+ self.logger_.endElement( u'station' )
+ self.logger_.characters("\n")
+
+ def writeBeacon( self, obj ):
+ attrs = AttributesImpl({})
+ self.logger_.startElement( u'beacon', attrs)
+ self.logger_.characters("\n")
+ self.writeVec3( u'position', obj.mainNode().getWorldPosition() )
+ #self.writeVec3( u'direction', obj.mainNode().getDirection() )
+ #self.writeVec3( u'scale', obj.mainNode().getScale() )
+ self.logger_.endElement( u'beacon')
+ self.logger_.characters("\n")
+
+ def writeSectorObject( self, obj ):
+ attrs = AttributesImpl({u'name': obj.name() })
+ self.logger_.startElement( u'sectorobject', attrs)
+ self.logger_.characters("\n")
+ self.writeVec3( u'position', obj.mainNode().getWorldPosition() )
+ #self.writeVec3( u'direction', obj.mainNode().getDirection() )
+ self.writeVec3( u'scale', obj.scaleNode().getScale() )
+ self.writeEntity( obj.entity() )
+ self.logger_.endElement( u'sectorobject')
+ self.logger_.characters("\n")
+
+ def writeNode( self, name ):
+
+ attrs = AttributesImpl({
+ u'name': name })
+
+ self.logger_.startElement( u'node', attrs)
+ self.logger_.characters("\n")
+ self.writeVec3( u'position', [0,0,0] )
+ self.writeVec3( u'scale', [1.0, 1.1, 1.0] )
+ self.writeQuat( u'rotation', [0.0, 0.0, 0.0, 1.0] )
+ #self.writeEntity( u'mesh.mesh' )
+ #self.logger_.characters("msg")
+ self.logger_.endElement( u'node' )
+ self.logger_.characters("\n")
+
+ def writeVec3( self, name, vec):
+ attrs = AttributesImpl({
+ u'x': "%g"%vec[0],
+ u'y': "%g"%vec[1],
+ u'z': "%g"%vec[2]
+ })
+ self._writeElement( name, attrs )
+
+ def writeQuat( self, name, quat):
+ attrs = AttributesImpl({
+ u'x': "%g"%quat[0],
+ u'y': "%g"%quat[1],
+ u'z': "%g"%quat[2],
+ u'w': "%g"%quat[3]
+ })
+ self._writeElement( name, attrs )
+
+ def writeColour( self, name, quat):
+ attrs = AttributesImpl({
+ u'r': "%g"%quat[0],
+ u'g': "%g"%quat[1],
+ u'b': "%g"%quat[2],
+ u'a': "%g"%quat[3]
+ })
+ self._writeElement( name, attrs )
+
+ def writeEntity( self, entity):
+ nSubEnt= entity.getNumSubEntities()
+ atts = {
+ u'meshFile': entity.getMesh().getName(),
+ u'numSubEntities': "%d"%nSubEnt
+ }
+
+ for i in range(0,nSubEnt):
+ atts[u'material-%d'%i] = entity.getSubEntity( i ).getMaterialName()
+
+ attrs = AttributesImpl( atts )
+
+ self._writeElement( "entity", attrs )
+
+ def _writeElement( self, name, attrs ):
+ self.logger_.startElement( name, attrs)
+ self.logger_.endElement( name)
+ self.logger_.characters("\n")
+
+ def close( self ):
+ self.logger_.endElement( u'sector')
+ self.logger_.characters("\n")
+ self.logger_.endDocument()
\ No newline at end of file
Added: trunk/data/misc/test.sector
===================================================================
--- trunk/data/misc/test.sector (rev 0)
+++ trunk/data/misc/test.sector 2008-06-15 12:14:18 UTC (rev 910)
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<sector name="testsector">
+<environment skybox="OpenGate/SimpleSkyBox3">
+<ambient a="1" r="0.1" b="0.1" g="0.1"></ambient>
+</environment>
+<station name="Tauseti Wake">
+<position y="0" x="0" z="-1480"></position>
+</station>
+<sectorobject name="ring">
+<position y="100" x="-650" z="800"></position>
+<scale y="35" x="35" z="35"></scale>
+<entity meshFile="ring.mesh" material-0="ring/main" numSubEntities="1"></entity>
+</sectorobject>
+<beacon>
+<position y="0" x="-650" z="800"></position>
+</beacon>
+<sectorobject name="astro with bump">
+<position y="0" x="-250" z="440"></position>
+<scale y="20" x="20" z="20"></scale>
+<entity meshFile="asteroid01.mesh" material-0="Asteroid/BumpMapping" numSubEntities="1"></entity>
+</sectorobject>
+<sectorobject name="astro without bump">
+<position y="0" x="-250" z="500"></position>
+<scale y="20" x="20" z="20"></scale>
+<entity meshFile="asteroid01.mesh" material-0="Asteroid" numSubEntities="1"></entity>
+</sectorobject>
+</sector>
Modified: trunk/plugins.cfg
===================================================================
--- trunk/plugins.cfg 2008-06-11 21:08:31 UTC (rev 909)
+++ trunk/plugins.cfg 2008-06-15 12:14:18 UTC (rev 910)
@@ -6,5 +6,5 @@
# Define D3D rendering implementation plugin
Plugin=RenderSystem_GL.so
Plugin=Plugin_ParticleFX.so
-#Plugin=Plugin_CgProgramManager.so
+Plugin=Plugin_CgProgramManager.so
Modified: trunk/src/Sector.cpp
===================================================================
--- trunk/src/Sector.cpp 2008-06-11 21:08:31 UTC (rev 909)
+++ trunk/src/Sector.cpp 2008-06-15 12:14:18 UTC (rev 910)
@@ -42,6 +42,7 @@
#include <OgreOverlayManager.h>
#include <OgreOverlayContainer.h>
#include <OgreSceneNode.h>
+#include <OgreSubEntity.h>
#include <OgreEntity.h>
#include <OgreRoot.h>
#include <OgreRenderSystemCapabilities.h>
@@ -125,12 +126,12 @@
//*** end starfield test 2;
- Ogre::Light * mainLight = sceneMgr_->createLight("MainLight" );
- mainLight->setDiffuseColour( 0.1, 0.1, 0.1 );
- mainLight->setSpecularColour( 0.4, 0.4, 0.4 );
- mainLight->setPosition(-50000, 0, -40000 );
+// Ogre::Light * mainLight = sceneMgr_->createLight("MainLight" );
+// mainLight->setDiffuseColour( 0.1, 0.1, 0.1 );
+// mainLight->setSpecularColour( 0.4, 0.4, 0.4 );
+// mainLight->setPosition(-50000, 0, -40000 );
- sceneMgr_->setAmbientLight( Ogre::ColourValue( 0.1, 0.1, 0.1 ) );
+ // sceneMgr_->setAmbientLight( Ogre::ColourValue( 0.1, 0.1, 0.1 ) );
if ( 1 ) {
// planet_ = new Planet( "planet", sceneMgr_, Ogre::Vector3( 20000.0, 10000.0, 40000 ), 15000.0f, 32 );
@@ -139,7 +140,7 @@
}
- populate( "testsector.xml" );
+ populate( "test.sector" );
createKoordAxis( );
}
@@ -181,41 +182,110 @@
}
void Sector::populate( const std::string & fileName ){
- TiXmlDocument doc( ResourceManager::getSingleton().findFullFileName( fileName ) );
- bool loadOkay = doc.LoadFile();
+ TiXmlDocument doc( ResourceManager::getSingleton().findFullFileName( fileName ) );
+ bool loadOkay = doc.LoadFile();
- if ( !loadOkay ) {
- log_->fatal( std::string( "Failed to load sector file: " + fileName ) );
- return;
- }
+ if ( !loadOkay ) {
+ log_->fatal( std::string( "Failed to load sector file: " + fileName ) );
+ return;
+ }
- TiXmlHandle docHandle( &doc );
- TiXmlElement *pElem, *pSubElem;
- TiXmlHandle hRoot( 0 );
+ TiXmlHandle docHandle( &doc );
+ TiXmlElement *pElem, *pSubElem;
+ TiXmlHandle hRoot( 0 );
- pElem = docHandle.FirstChildElement().Element();
- hRoot = TiXmlHandle( pElem );
+ pElem = docHandle.FirstChildElement().Element();
+ hRoot = TiXmlHandle( pElem );
- if ( !pElem ) {
- log_->fatal( fileName + " cannot read first node." );
- return;
- }
+ if ( !pElem ) {
+ log_->fatal( fileName + " cannot read first node." );
+ return;
+ }
- if ( strcmp( "sector", pElem->Value() ) != 0 ) {
- log_->fatal( fileName + " is no sector description" );
+ if ( strcmp( "sector", pElem->Value() ) != 0 ) {
+ log_->fatal( fileName + " is no sector description" );
+ return;
+ }
+ readXMLAttribute< std::string >( pElem, "name_en name", this, &OpenGate::Sector::setName, false );
+
+ pElem = hRoot.ChildElement( "environment", 0 ).Element();
+ if ( pElem ){
+ readXMLAttribute< std::string >( pElem, "skybox", this, &OpenGate::Sector::setSkyBox, false );
+ readXMLColourElement( pElem, "ambient", sceneMgr_, &Ogre::SceneManager::setAmbientLight, false );
+ }
+
+ pElem = hRoot.ChildElement( "station", 0 ).Element();
+ if ( pElem ){
+ std::string name; readXMLAttribute < std::string >( pElem, "name", name );
+ Ogre::Vector3 pos( readXMLVec3Element( pElem, "position" ) );
+ SectorObject *obj = createStation( name, pos );
+ }
+
+ pElem = hRoot.ChildElement( "beacon", 0 ).Element();
+ if ( pElem ){
+ Ogre::Vector3 pos( readXMLVec3Element( pElem, "position" ) );
+ Ogre::Vector3 dir( readXMLVec3Element( pElem, "direction" ) );
+ SectorObject * obj = createBeacon( pos );
+ obj->mainNode()->setDirection( dir );
+ }
+
+ for ( pElem = hRoot.FirstChild( "sectorobject" ).Element(); pElem != 0; pElem = pElem->NextSiblingElement("sectorobject") ) {
+ std::string name; readXMLAttribute < std::string >( pElem, "name", name );
+ Ogre::Vector3 pos( readXMLVec3Element( pElem, "position" ) );
+ Ogre::Vector3 scale( readXMLVec3Element( pElem, "scale" ) );
+
+ TiXmlElement * pElemChild = pElem->FirstChildElement( "entity" );
+
+ if ( pElemChild ){
+ std::string mesh; readXMLAttribute < std::string >( pElemChild, "meshFile", mesh );
+ SectorObject * obj = createStaticObject( mesh, name, pos );
+ if ( scale != Ogre::Vector3::ZERO ){
+ obj->scale( scale );
+ }
+ int nSubEnt = 0; readXMLAttribute < int >( pElemChild, "numSubEntities", nSubEnt );
+
+ for ( int i = 0; i < nSubEnt; i ++ ){
+ std::string matName; readXMLAttribute < std::string >( pElemChild, "material-"+toStr( i ), matName );
+ obj->entity()->getSubEntity( i )->setMaterialName( matName );
+ }
+
+ } else{
+ std::cerr << "no entity found for sectorobject: " << name << std::endl;
+ }
+ }
+
return;
- }
- readXMLNode< std::string >( hRoot, "name_en name", this, &OpenGate::Sector::setName, false );
- pElem = hRoot.ChildElement( "skybox", 0 ).Element();
- if ( pElem ){
- sceneMgr_->setSkyBox( true, pElem->FirstChild()->Value(), 10000 );
- } else{
- sceneMgr_->setSkyBox( true, "OpenGate/SimpleSkyBox1" );
- }
-
-// pElem = hRoot.ChildElement( "vesselschool", 0 ).Element();
+// for ( pElem = hRoot.FirstChild( "station" ).Element(); pElem != 0; pElem = pElem->NextSiblingElement("station") ) {
+// std::string name;
+// pSubElem = pElem->FirstChildElement( "name" );
+// if ( pSubElem ){
+// name = pSubElem->FirstChild()->Value();
+// } else {
+// log_->warn( "missing name for station " );
+// continue;
+// }
+// Ogre::Vector3 pos( 0.0, 0.0, 0.0);
+// pSubElem = pElem->FirstChildElement( "position" );
+// if ( pSubElem ){
+// pos = Ogre::Vector3( &toVector3( pSubElem->FirstChild()->Value(), ',' )[ 0 ] );
+// } else {
+// log_->warn( "missing pos for station " + name );
+// continue;
+// }
+// SectorObject *obj = createStation( name, pos );
+//
+// Ogre::Vector3 targetDirection( 0.0, 0.0, 0.0);
+// pSubElem = pElem->FirstChildElement( "direction" );
+// if ( pSubElem ){
+// targetDirection = Ogre::Vector3( &toVector3( pSubElem->FirstChild()->Value(), ',' )[0]);
+// Ogre::Quaternion rot = ( obj->mainNode()->getOrientation().zAxis()* -1.0).getRotationTo( targetDirection );
+// obj->mainNode()->rotate( rot );
+// }
+// }
+
+ // pElem = hRoot.ChildElement( "vesselschool", 0 ).Element();
// if ( pElem ){
// std::string schoolclass( pElem->FirstChild()->Value() );
//
@@ -241,34 +311,8 @@
// }
//** Load stations
- for ( pElem = hRoot.FirstChild( "station" ).Element(); pElem != 0; pElem = pElem->NextSiblingElement("station") ) {
- std::string name;
- pSubElem = pElem->FirstChildElement( "name" );
- if ( pSubElem ){
- name = pSubElem->FirstChild()->Value();
- } else {
- log_->warn( "missing name for station " );
- continue;
- }
- Ogre::Vector3 pos( 0.0, 0.0, 0.0);
- pSubElem = pElem->FirstChildElement( "position" );
- if ( pSubElem ){
- pos = Ogre::Vector3( &toVector3( pSubElem->FirstChild()->Value(), ',' )[ 0 ] );
- } else {
- log_->warn( "missing pos for station " + name );
- continue;
- }
- SectorObject *obj = createStation( name, pos );
-
- Ogre::Vector3 targetDirection( 0.0, 0.0, 0.0);
- pSubElem = pElem->FirstChildElement( "direction" );
- if ( pSubElem ){
- targetDirection = Ogre::Vector3( &toVector3( pSubElem->FirstChild()->Value(), ',' )[0]);
- Ogre::Quaternion rot = ( obj->mainNode()->getOrientation().zAxis()* -1.0).getRotationTo( targetDirection );
- obj->mainNode()->rotate( rot );
- }
- }
+
//** load beacon
pElem = hRoot.FirstChild( "beacon" ).Element();
if ( pElem ){
@@ -374,6 +418,10 @@
}
}
+void Sector::setSkyBox( const std::string & name ){
+ sceneMgr_->setSkyBox( true, name, 10000 );
+}
+
void Sector::update( Ogre::Real elapsedTime ){
if ( ResourceManager::getSingleton().collisionManager )
ResourceManager::getSingleton().collisionManager->update( elapsedTime );
Modified: trunk/src/Sector.h
===================================================================
--- trunk/src/Sector.h 2008-06-11 21:08:31 UTC (rev 909)
+++ trunk/src/Sector.h 2008-06-15 12:14:18 UTC (rev 910)
@@ -53,8 +53,10 @@
void populate( const std::string & fileName );
+ void setSkyBox( const std::string & name );
+
void setListener( UnDockedState * listener ){ listener_ = listener; }
-
+
Un...
[truncated message content] |