You can subscribe to this list here.
2006 |
Jan
|
Feb
|
Mar
(11) |
Apr
(47) |
May
(14) |
Jun
|
Jul
(73) |
Aug
(4) |
Sep
(2) |
Oct
(60) |
Nov
(48) |
Dec
(66) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2007 |
Jan
|
Feb
(1) |
Mar
(27) |
Apr
(82) |
May
(89) |
Jun
(91) |
Jul
(44) |
Aug
(53) |
Sep
(113) |
Oct
(20) |
Nov
(37) |
Dec
(10) |
2008 |
Jan
|
Feb
(2) |
Mar
|
Apr
(2) |
May
(21) |
Jun
(3) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(1) |
2009 |
Jan
(76) |
Feb
(89) |
Mar
(52) |
Apr
(11) |
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
(1) |
Oct
|
Nov
|
Dec
(27) |
2010 |
Jan
(11) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2011 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(1) |
Aug
(9) |
Sep
|
Oct
|
Nov
|
Dec
(14) |
2012 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(1) |
Aug
(2) |
Sep
(11) |
Oct
(3) |
Nov
|
Dec
|
2013 |
Jan
(4) |
Feb
|
Mar
(2) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <spo...@us...> - 2008-05-18 19:50:16
|
Revision: 899 http://opengate.svn.sourceforge.net/opengate/?rev=899&view=rev Author: spom_spom Date: 2008-05-18 12:29:16 -0700 (Sun, 18 May 2008) Log Message: ----------- Add opengate python bindings for the opengate editor Modified Paths: -------------- branches/ogEditor/ogEditor.py branches/ogEditor/plugins.cfg branches/ogEditor/resources.cfg Added Paths: ----------- branches/ogEditor/Makefile branches/ogEditor/build.sh branches/ogEditor/environment.py branches/ogEditor/generate_code.py branches/ogEditor/generated/ branches/ogEditor/hand_made_wrappers.py branches/ogEditor/ogtest.py branches/ogEditor/python_ogre_masterlist.h branches/ogEditor/python_opengate.h branches/ogEditor/python_opengate_aliases.h branches/ogEditor/python_opengate_sizeof.h branches/ogEditor/src/ branches/ogEditor/src/ObjectInspectorPanels.py branches/ogEditor/src/OgreWindowWx.py branches/ogEditor/src/PropertyGrid.py branches/ogEditor/src/PythonOgreConfig.py branches/ogEditor/src/ResourceTreePane.py Removed Paths: ------------- branches/ogEditor/ObjectInspectorPanels.py branches/ogEditor/OgreWindowWx.py branches/ogEditor/PropertyGrid.py branches/ogEditor/PythonOgreConfig.py branches/ogEditor/ResourceTreePane.py Added: branches/ogEditor/Makefile =================================================================== --- branches/ogEditor/Makefile (rev 0) +++ branches/ogEditor/Makefile 2008-05-18 19:29:16 UTC (rev 899) @@ -0,0 +1,34 @@ +BOOSTINC=-I /usr/include/boost +PYTHONINC=-I /usr/include/python2.5 +OGREINC=`pkg-config --cflags OGRE gtk+-2.0 ogreopcode` +OPENGATEINC=-I $(HOME)/local/opengate/trunk/src + +BOOSTLIB=-L /usr/lib64 -lboost_python +EXTLIB=/usr/lib64/libCEGUIOgreRenderer.so -L/var/tmp/portage/media-libs/devil-1.6.7-r2/work/DevIL-1.6.7/src-IL/src -L/usr/lib64 /usr/lib64/libCEGUIBase.so /usr/lib64/libpcre.so -lbz2 -lxerces-c /usr/lib64/libalut.so /usr/lib64/libopenal.so /usr/lib64/libvorbisfile.so /usr/lib64/libvorbis.so -lm /usr/lib64/libogg.so /usr/lib64/libOIS.so -L/usr/X11R6/lib /usr/lib64/libopcode.so /usr/lib64/libogreopcode.so /usr/lib64/libOgreMain.so /usr/lib64/libzzip.so /usr/lib64/libgtk-x11-2.0.so /usr/lib64/libgdk-x11-2.0.so /usr/lib64/libatk-1.0.so /usr/lib64/libgdk_pixbuf-2.0.so /usr/lib64/libpangocairo-1.0.so /usr/lib64/libpangoft2-1.0.so /usr/lib64/libpango-1.0.so /usr/lib64/libcairo.so /usr/lib64/libfontconfig.so /usr/lib64/libfreetype.so /usr/lib64/libexpat.so /usr/lib64/libXrender.so /usr/lib64/libgobject-2.0.so /usr/lib64/libgmodule-2.0.so /usr/lib64/libglib-2.0.so /usr/lib64/libX11.so /usr/lib64/libXau.so /usr/lib64/libXdmcp.so -lXaw /usr/lib64/libILU.so /usr/lib64/libIL.so -lCg /usr/lib64/libpng12.so /usr/lib64/libtiff.so /usr/lib64/libjpeg.so -lpthread -lz -ldl -lboost_thread -lboost_regex + +OGREGEN=-I /home/carsten/local/python-ogre/python-ogre/generated/ogre_1.4/ +TARGET=opengate +COPT=-Os -fPIC + +#CONTAINERSUITE= -I ./indexing_suite_v2 + +CPPCFILES = $(wildcard generated/*.cpp) +OBJECTS = $(patsubst %.cpp,%.o,$(CPPCFILES)) +OPENGATEOBJ=$(wildcard $(HOME)/local/opengate/trunk/src/opengateclient*.o) + +default: $(TARGET) + +.cpp.o: + g++ $(COPT) $(DEFINES) -c -o $(patsubst %.cpp,%.o, $<) -I ./ $(CONTAINERSUITE) $(BOOSTINC) $(OPENGATEINC) $(PYTHONINC) $(OGREGEN) $(OGREINC) $< + +$(TARGET): $(OBJECTS) + g++ -o generated/$(TARGET).so -Wl,-rpath=\/../../lib `pkg-config --libs OGRE` --strip-all -lstdc++ --shared \ + $(OBJECTS) \ + $(BOOSTLIB) \ + $(OPENGATEOBJ) \ + $(EXTLIB) + strip -g -S -d --strip-debug -s generated/$(TARGET).so +clean: + rm -rf generated/* + rm -f *.so + rm -f *.cache Deleted: branches/ogEditor/ObjectInspectorPanels.py =================================================================== --- branches/ogEditor/ObjectInspectorPanels.py 2008-05-14 21:50:43 UTC (rev 898) +++ branches/ogEditor/ObjectInspectorPanels.py 2008-05-18 19:29:16 UTC (rev 899) @@ -1,214 +0,0 @@ -#!/usr/bin/env python -# -*- coding: ansi_x3.4-1968 -*- -# generated by wxGlade 0.6.2 on Mon Jan 7 21:02:32 2008 - -import wx -import sys - -import PythonOgreConfig -import ogre.renderer.OGRE as ogre - -from PropertyGrid import * - -class PropertyCollapsibleOgreFogPane( PropertyPaneItem ): - def __init__( self, parent, name, object = None ): - PropertyPaneItem.__init__(self, parent, name) - - self.object = object - self.colour = [255, 255, 255, 255] - self.mode = 0 - self.expDensity = 0.01 - self.linearStart = 0.0 - self.linearEnd = 1.0 -# self.fogmodes = {"FOG_NONE" :"No fog. Duh.", -# "FOG_EXP": "Fog density increases exponentially from the camera (fog = 1/e^(distance * density)).", -# "FOG_EXP2": "Fog density increases at the square of FOG_EXP, i.e. even quicker (fog = 1/e^(distance * density)^2)." -# "FOG_LINEAR": "Fog density increases linearly between the start and end distances."} -# - modes = ((ogre.FOG_NONE, "FOG_NONE"), - (ogre.FOG_EXP, "FOG_EXP"), - (ogre.FOG_EXP2, "FOG_EXP2"), - (ogre.FOG_LINEAR,"FOG_LINEAR")) - - self.m = self.appendRowItemChoice( "Mode", itemMap=modes, cback = self.setMode ) - self.c = self.appendRowItemColourSelect( "Colour", cback = self.setRGBA ) - self.min = self.appendRowItemSlider( "linearStart", 0, 1, format = SLIDER_FLOAT, cback = self.setLinMin ) - self.max = self.appendRowItemSlider( "linearEnd", 0, 1, format = SLIDER_FLOAT, cback = self.setLinMax ) - self.exp = self.appendRowItemSlider( "expDensity", 0.0001, 0.01, format = SLIDER_LOG10, cback = self.setExpDens ) - - if object != None: - mode = object.getFogMode() - #self.mode = ogre.mode - col = object.getFogColour() - print col - self.colour = map( lambda x: x * 255.0, [col[0],col[1], col[2], col[3]] ) - self.linearStart = object.getFogStart() - self.linearEnd = object.getFogEnd() - self.expDensity= object.getFogDensity() - - self.applyValues( False ) - - def setMode( self, value ): - self.mode = value - self.applyValues( ) - def setRGBA( self, value ): - self.colour[ 0:3 ] = value - self.applyValues( ) - def setLinMin( self, value ): - self.linearStart = value - self.applyValues( ) - def setLinMax( self, value ): - self.linearEnd = value - self.applyValues( ) - def setExpDens( self, value ): - self.expDensity = value - self.applyValues( ) - - def applyValues(self, update = True): - self.m.setValue( self.mode ) - self.c.setValue( self.colour ) - self.min.setValue( self.linearStart ) - self.max.setValue( self.linearEnd ) - self.exp.setValue( self.expDensity ) - - if update == True: - if self.object != None: - col = map( lambda x: x / 255.0, self.colour ) - self.object.setFog(self.mode, col, self.expDensity, self.linearStart, self.linearEnd ) - -class ObjectInspectorPanel(wx.Panel): - def __init__(self, *args, **kwds): - kwds["style"] = wx.TAB_TRAVERSAL - wx.Panel.__init__(self, *args, **kwds) - self.typeStaticText = wx.StaticText(self, -1, "Type") - self.propertyGrid = PropertyMainGrid( self, -1, style=wx.SIMPLE_BORDER ) - - self.__set_properties() - self.__do_layout() - - il = wx.ImageList(16, 16) - self.ColourIconID = il.Add( wx.ArtProvider_GetBitmap( wx.ART_GO_DOWN, wx.ART_TOOLBAR, ( 16, 16 ) ) ) - #self.propertyList.AssignImageList( il, wx.IMAGE_LIST_SMALL ) - - def __set_properties(self): - self.SetBackgroundColour(wx.Colour(255, 255, 255)) - self.SetFont(wx.Font(8, wx.DEFAULT, wx.NORMAL, wx.NORMAL, 0, "")) - self.typeStaticText.SetFont(wx.Font(8, wx.DEFAULT, wx.NORMAL, wx.NORMAL, 0, "")) - - def __do_layout(self): - sizer_1 = wx.BoxSizer(wx.HORIZONTAL) - content = wx.BoxSizer(wx.VERTICAL) - sizer_1.Add((5, 20), 0, 0, 0) - content.Add((20, 5), 0, 0, 0) - content.Add(self.typeStaticText, 0, 0, 0) - content.Add((20, 3), 0, 0, 0) - content.Add(self.propertyGrid, 1, wx.EXPAND, 0) - content.Add((20, 5), 0, 0, 0) - sizer_1.Add(content, 1, wx.EXPAND, 0) - sizer_1.Add((5, 20), 0, 0, 0) - self.SetSizer(sizer_1) - sizer_1.Fit(self) - - def showData( self, data ): - self.propertyGrid.clean() - if type( data ) == None: - self.showNone() - if type( data ) == ogre.SceneNode: - self.showSceneNode( data ) - elif issubclass( type( data ), ogre.SceneManager): - self.showSceneManager( data ) - elif issubclass( type( data ), ogre.Resource ): - self.showResource( data ) - elif issubclass( type( data ), ogre.MovableObject ): - self.showMovableObject( data ) - elif issubclass( type( data ), ogre.ResourceManager ): - self.showResourceManager( data ) - else: - self.showUnknown( data ) - self.propertyGrid.sizer.Layout() - - def showNone( self ): - self.typeStaticText.SetLabel( "None" ) - - def showUnknown( self, data ): - self.typeStaticText.SetLabel( "Unknown" ) - self.showName( data ); - - def showSceneManager( self, data ): - self.typeStaticText.SetLabel( "SceneManager" ) - self.showName( data ); - - self.propertyGrid.appendRowItemName( "Type name", data.getTypeName() ) - self.propertyGrid.appendPaneColourSelect( "Ambient color", - cfront = data.getAmbientLight, - cback = data.setAmbientLight ) - - print data - fog = PropertyCollapsibleOgreFogPane( self.propertyGrid, "Fog", object = data ) - self.propertyGrid.appendPane( fog ) - -# self.propertyTree.createTextBoolRow( "SkyPlane", data.isSkyPlaneEnabled() ) -# self.propertyTree.createTextBoolRow( "SkyBox", data.isSkyBoxEnabled() ) -# self.propertyTree.createTextBoolRow( "SkyDone", data.isSkyDomeEnabled() ) -# -# fogmodes = {"FOG_NONE":"No fog. Duh.", -# "FOG_EXP": "Fog density increases exponentially from the camera (fog = 1/e^(distance * density)).", -# "FOG_EXP2": "Fog density increases at the square of FOG_EXP, i.e. even quicker (fog = 1/e^(distance * density)^2)." -# "FOG_LINEAR": "Fog density increases linearly between the start and end distances."} -# -# pane = self.propertyTree.createPane( "Fog" ) - - #pane.AppendSelectFromDictRow( "Mode", fogmodes ) - #self.propertyTree.createColourPane( "fog color" ) - - -# getFogColour (void) const -# virtual Real getFogStart (void) const -# virtual Real getFogEnd (void) const -# virtual Real getFogDensity (void) const -# getRenderQueue -# showBoundingBoxes (bool bShow) -# getShowBoundingBoxes () -# getCameraIterator -# getAnimationIterator -# getShadowTechnique -# many props - - def showSceneNode( self, data ): - self.typeStaticText.SetLabel( "SceneNode" ) - self.showName( data ); - - def showResource( self, data ): - self.typeStaticText.SetLabel( "Resource: " + data.getCreator().getResourceType() ) - self.showName( data ); - self.appendRowItemName( "Group", data.getGroup() ) - self.appendRowItemName( "Origin", data.getOrigin() ) - -# params = data.getParameters() -# if len( params ) > 0: -# pane = self.propertyTree.createPane( "Parameters" ) -# -# for i in params: -# self.propertyTree.createTextRow( i.name, data.getParameter( i.name ), pane ) -# -# if type( data ) == ogre.Texture: -# print "Texture" - - def showMovableObject( self, data ): - self.typeStaticText.SetLabel( "Movable object: " + data.getMovableType() ) - self.showName( data ); - - def showResourceManager( self, data ): - self.typeStaticText.SetLabel( "Resourcemanager: " + data.getResourceType() ) - self.propertyGrid.appendRowItemName( "Memory budget", "%.3g Mb" - % (data.getMemoryBudget()/ 1024.0 /1024.0 ) ) - self.propertyGrid.appendRowItemName( "Memory usage", "%.3g Mb" - % (data.getMemoryUsage()/ 1024.0 /1024.0 ) ) - - def showName( self, data ): - self.propertyGrid.appendRowItemName( "Name", data.getName() ) - - -# end of class ObjectInspectorPanel - - Deleted: branches/ogEditor/OgreWindowWx.py =================================================================== --- branches/ogEditor/OgreWindowWx.py 2008-05-14 21:50:43 UTC (rev 898) +++ branches/ogEditor/OgreWindowWx.py 2008-05-18 19:29:16 UTC (rev 899) @@ -1,262 +0,0 @@ -import wx -import ogre.renderer.OGRE as ogre -import wxogre_util as wxHandle -import os -import os.path - -try : - import psyco #use psyco if available (JIT compiler) - psyco.full() -except ImportError: - pass - -def getPluginPath(): - """Return the absolute path to a valid plugins.cfg file.""" -# import sys - - paths = [ os.path.join( os.getcwd(), 'plugins.cfg'), - os.path.join( os.path.dirname( os.path.abspath( __file__ ) ), 'plugins.cfg'), - '/etc/OGRE/plugins.cfg' ] - - for path in paths: - if os.path.exists(path): - return path - - sys.stderr.write("\n" - "** Warning: Unable to locate a suitable plugins.cfg file.\n" - "** Warning: Please check your ogre installation and copy a\n" - "** Warning: working plugins.cfg file to the current directory.\n\n") - raise ogre.Exception(0, "can't locate the 'plugins.cfg' file", "") - -class Struct: - "simple dummy class to regroup scene entities in a single parameter" - pass - -class OgreWindow( wx.PyWindow ): - """wx.Frame subclass to embed an Ogre window in wxPython - It is somewhat inspired from SampleFramework.py""" - - #all animation states included in this dictionary will be automatically updated at each render - animStates = {} #the values have to be (AnimationState, SpeedFactor) tuples - - #namespace for holding a reference to the entities you create. You can comment it out - #if you don't like the idea - sceneEntities = Struct() - - def __init__( self, parent, ID, size = wx.Size( 800, 600 ), renderSystem = "OpenGL", **kwargs ): - self.parent = parent - wx.PyWindow.__init__( self, parent, ID, size = size, **kwargs ) - #Event bindings - self.Bind( wx.EVT_CLOSE, self._OnCloseWindow) - self.Bind( wx.EVT_SIZE, self._OnSize) - self.Bind( wx.EVT_TIMER, self.UpdateRender) #Bind the timer events to Ogre rendering - self.Bind( wx.EVT_ERASE_BACKGROUND, self._OnEraseBackground) - - #Timer creation - self.timer = wx.Timer() - self.timer.SetOwner( self ) #Sets the timer to notify self: binding the timer event is not enough - - #Ogre Initialisation - self._OgreInit( size, renderSystem ) - self.SceneInitialisation() - self.UpdateRender() - self.SetFocus() #Gives KeyboardFocus - - def _OgreInit(self,size,renderSystem): - #Root creation - root = ogre.Root( getPluginPath(), "ogre.cfg" ) - self.ogreRoot = root - - # setup resources - config = ogre.ConfigFile() - config.load( 'resources.cfg' ) - - section_iter = config.getSectionIterator() - while section_iter.hasMoreElements(): - section_name = section_iter.peekNextKey() - settings = section_iter.getNext() - for key, path in settings: - ogre.ResourceGroupManager.getSingleton().addResourceLocation( path, key, section_name, False) - - if os.path.exists( "ogre.cfg" ): - root.restoreConfig() - else: - carryOn = root.showConfigDialog() - if not carryOn: - sys.exit('Quit from Config Dialog') - - #The following section tries to avoid showing the configuration dilaog. -# rsList = root.getAvailableRenderers() #Gets the available RenderSystems -# rs = None -# CouldNotFindRequestedRenderer = False -# for i in rsList: -# print i - -# if renderSystem in i.name: #Tries to locate the requested render system -# rs=i -# if rs is not None : -# root.renderSystem=rs -# rs.setConfigOption("Full Screen","No") -# try : -# rs.setConfigOption("Video Mode","800 x 600 @ 16-bit colour") -# except : -# CouldNotFindRequestedRenderer=True -# else : -# CouldNotFindRequestedRenderer=True -# -# if CouldNotFindRequestedRenderer: #Calls Ogre's default Config dialog if failed -# carryOn = root.showConfigDialog() -# if not carryOn: -# sys.exit('Quit from Config Dialog') - -# carryOn = root.showConfigDialog() -# if not carryOn: -# sys.exit('Quit from Config Dialog') - -#get the topmost window and make it visible, otherwise we cant get a valid windowhandle - - lastValid = self.parent - parent = lastValid - while parent != None: - lastValid = parent - parent = lastValid.GetParent() - lastValid.Show( True ) - - root.initialise(False) - renderParameters = ogre.NameValuePairList() - handle = wxHandle.get_window_handle_str( self ) - if handle == "No window found": - print handle - renderParameters = ogre.NameValuePairList(); - else: - renderParameters['externalWindowHandle'] = handle - print handle, lastValid.GetHandle(), self.parent.GetHandle() - - renderWindow = root.createRenderWindow('wxPython render window', size[ 0 ], size[ 1 ], False, renderParameters) - renderWindow.active = True - self.renderWindow = renderWindow - ogre.ResourceGroupManager.getSingleton().initialiseAllResourceGroups() - - def _OnSize(self, event): - if getattr(self, 'ogreRoot', None): - self.UpdateRender() - self.renderWindow.windowMovedOrResized() - event.Skip() - - def _OnEraseBackground(self, event): - pass # Do nothing, to avoid flashing on MSW. - - def _OnCloseWindow(self, event): - self.Destroy() - - def AcceptsFocus(self): - return True - - def StartRendering(self,interval=33): - "Activates the timer. A rendering will be triggered at each interval (default :33ms)" - self.timer.Start(interval) - - def OnFrameStarted(self,event): - "SubClass and fill in this declaration if you want something done before each rendering" - pass - - def OnFrameEnded(self,event): - "SubClass and fill in this declaration if you want something done after each rendering" - pass - - def UpdateRender(self,event=None): - """Method that can be called manually or by a wx.Timer - If the method is called by timer, the animation states contained in - the self.animStates variable get updated before rendering the frame""" - - #Enables the user to define actions to be undertaken before the frame is started - self.OnFrameStarted(event) - - if hasattr(event ,"GetInterval"): #Timer Events have a GetInterval method that returns the time interval between events - for anim,speed in self.animStates.itervalues(): - anim.addTime(speed*event.GetInterval()/1000.0) #updates the animations - - self.ogreRoot.renderOneFrame()#Asks Ogre to render a frame - - #Enables the user to define actions to be undertaken after the frame has been drawn - self.OnFrameEnded(event) - - def SceneInitialisation(self): - """This method can be replaced completely to suit your needs or you can - subclass only the helper methods such as self._CreateCamera""" - self._ChooseSceneManager() - self._CreateCamera() - self._CreateViewport() - self._PopulateScene() - self._MouseAndKeysBindings() - - #You will want to subclass the following methods to suit your needs - - def _ChooseSceneManager(self): - "choose SceneManager" - self.sceneManager = self.ogreRoot.createSceneManager(ogre.ST_GENERIC,"ExampleSMInstance") - - def _CreateCamera(self): - "create a Camera" - camera = self.sceneManager.createCamera('Camera') - camera.lookAt(ogre.Vector3(0, 0, 0)) - camera.nearClipDistance = 1 - camera.setAutoAspectRatio( True ) - - self.sceneEntities.camera = camera - - # create the camera nodes & attach camera - cameraNode = self.sceneManager.getRootSceneNode().createChildSceneNode( camera.getName() + "/Node", - ogre.Vector3( 0, 0, 250 ) ) - pitchNode = cameraNode.createChildSceneNode( cameraNode.getName() + "/PitchNode" ) - pitchNode.attachObject( camera ) - - self.sceneEntities.cameraNode = cameraNode - self.sceneEntities.cameraPitchNode = pitchNode - - def _CreateViewport(self): - "create a Viewport" - renderWindow=self.renderWindow - viewport = renderWindow.addViewport( self.sceneEntities.camera, 0, 0.0, 0.0, 1.0, 1.0) - viewport.backgroundColour = ogre.ColourValue(0, 0, 0) - - def _PopulateScene(self): - "Implement this method to put entities in your scene" - pass - - def _MouseAndKeysBindings(self): - "Some Additional mouse and keys bindings" - d=10.0 #displacement for key strokes - self.ControlKeyDict={ wx.WXK_LEFT :ogre.Vector3( -d, 0.0, 0.0), - wx.WXK_RIGHT :ogre.Vector3( d, 0.0, 0.0), - wx.WXK_UP :ogre.Vector3( 0.0, 0.0, -d), - wx.WXK_DOWN :ogre.Vector3( 0.0, 0.0, d), - wx.WXK_PAGEUP :ogre.Vector3( 0.0, d, 0.0), - wx.WXK_PAGEDOWN :ogre.Vector3( 0.0, -d, 0.0)} - self.Bind( wx.EVT_KEY_DOWN, self._DefaultKeyDownManager ) - self.Bind( wx.EVT_MOUSE_EVENTS, self._DefaultMouseEventManager) - ##self.Bind(wx.EVT_ENTER_WINDOW,lambda evt : self.SetFocus()) - - def _DefaultKeyDownManager( self, event ): - "If you want to implement a similar callback function, do not forget the event.Skip() at the end" - validMove = self.ControlKeyDict.get( event.m_keyCode, False ) - if validMove: - self.sceneEntities.cameraNode.translate( validMove, self.sceneEntities.cameraNode.TS_LOCAL ) - event.Skip() - - def _DefaultMouseEventManager( self, event ): - "If you want to implement a similar callback function, do not forget the event.Skip() at the end" - self.SetFocus() #Gives Keyboard focus to the window - - if event.RightDown(): #Precedes dragging - self.StartDragX, self.StartDragY = event.GetPosition() #saves position of initial click - - if event.Dragging() and event.RightIsDown(): #Dragging with RMB - x,y = event.GetPosition() - dx = x-self.StartDragX - dy = y-self.StartDragY - self.StartDragX, self.StartDragY = x, y - - self.sceneEntities.cameraNode.yaw( ogre.Degree( dx / 3.0 ) ) - self.sceneEntities.cameraPitchNode.pitch( ogre.Degree( dy / 3.0 ) ) - event.Skip() Deleted: branches/ogEditor/PropertyGrid.py =================================================================== --- branches/ogEditor/PropertyGrid.py 2008-05-14 21:50:43 UTC (rev 898) +++ branches/ogEditor/PropertyGrid.py 2008-05-18 19:29:16 UTC (rev 899) @@ -1,435 +0,0 @@ -#!/usr/bin/env python - -import wx -import wx.combo -import wx.lib.colourselect as csel - -SLIDER_INT=0 -SLIDER_FLOAT=1 -SLIDER_LOG10=2 - -class NullLog: - def write(*args): - pass - -class SimpleLog: - def write(*args): - print args - - -class ListCtrlComboPopup( wx.ListCtrl, wx.combo.ComboPopup ): - def __init__( self, log = None, cback = None ): - if log: - self.log = log - else: - self.log = NullLog() - - self.cback = cback - - # Since we are using multiple inheritance, and don't know yet - # which window is to be the parent, we'll do 2-phase create of - # the ListCtrl instead, and call its Create method later in - # our Create method. (See Create below.) - self.PostCreate(wx.PreListCtrl()) - - # Also init the ComboPopup base class. - wx.combo.ComboPopup.__init__(self) - - def AddItem(self, txt): - self.InsertStringItem(self.GetItemCount(), txt) - - def OnMotion(self, evt): - item, flags = self.HitTest(evt.GetPosition()) - if item >= 0: - self.Select(item) - self.curitem = item - - def OnLeftDown(self, evt): - self.value = self.curitem - self.Dismiss() - - # The following methods are those that are overridable from the - # ComboPopup base class. Most of them are not required, but all - # are shown here for demonstration purposes. - - - # This is called immediately after construction finishes. You can - # use self.GetCombo if needed to get to the ComboCtrl instance. - def Init(self): - self.log.write("ListCtrlComboPopup.Init") - self.value = -1 - self.curitem = -1 - - # Create the popup child control. Return true for success. - def Create(self, parent): - self.log.write("ListCtrlComboPopup.Create") - wx.ListCtrl.Create(self, parent, - style=wx.LC_LIST|wx.LC_SINGLE_SEL|wx.SIMPLE_BORDER) - self.Bind(wx.EVT_MOTION, self.OnMotion) - self.Bind(wx.EVT_LEFT_DOWN, self.OnLeftDown) - return True - - # Return the widget that is to be used for the popup - def GetControl(self): - return self - - # Called just prior to displaying the popup, you can use it to - # 'select' the current item. - def SetStringValue(self, val): - self.log.write("ListCtrlComboPopup.SetStringValue") - idx = self.FindItem(-1, val) - if idx != wx.NOT_FOUND: - self.Select(idx) - - # Return a string representation of the current item. - def GetStringValue(self): - self.log.write("ListCtrlComboPopup.GetStringValue") - if self.value >= 0: - return self.GetItemText(self.value) - return "" - - # Called immediately after the popup is shown - def OnPopup(self): - self.log.write("ListCtrlComboPopup.OnPopup") - wx.combo.ComboPopup.OnPopup(self) - - # Called when popup is dismissed - def OnDismiss(self): - self.log.write("ListCtrlComboPopup.OnDismiss") - if self.cback != None: - self.cback( self.value ) - wx.combo.ComboPopup.OnDismiss(self) - - # This is called to custom paint in the combo control itself - # (ie. not the popup). Default implementation draws value as - # string. - def PaintComboControl(self, dc, rect): - self.log.write("ListCtrlComboPopup.PaintComboControl") - wx.combo.ComboPopup.PaintComboControl(self, dc, rect) - - # Receives key events from the parent ComboCtrl. Events not - # handled should be skipped, as usual. - def OnComboKeyEvent(self, event): - self.log.write("ListCtrlComboPopup.OnComboKeyEvent") - wx.combo.ComboPopup.OnComboKeyEvent(self, event) - - # Implement if you need to support special action when user - # double-clicks on the parent wxComboCtrl. - def OnComboDoubleClick(self): - self.log.write("ListCtrlComboPopup.OnComboDoubleClick") - wx.combo.ComboPopup.OnComboDoubleClick(self) - - # Return final size of popup. Called on every popup, just prior to OnPopup. - # minWidth = preferred minimum width for window - # prefHeight = preferred height. Only applies if > 0, - # maxHeight = max height for window, as limited by screen size - # and should only be rounded down, if necessary. - def GetAdjustedSize(self, minWidth, prefHeight, maxHeight): - self.log.write("ListCtrlComboPopup.GetAdjustedSize: %d, %d, %d" % (minWidth, prefHeight, maxHeight)) - return wx.combo.ComboPopup.GetAdjustedSize(self, minWidth, prefHeight, maxHeight) - - # Return true if you want delay the call to Create until the popup - # is shown for the first time. It is more efficient, but note that - # it is often more convenient to have the control created - # immediately. - # Default returns false. - def LazyCreate(self): - self.log.write("ListCtrlComboPopup.LazyCreate") - return wx.combo.ComboPopup.LazyCreate(self) - - -class PropertyRowItem( ): - def __init__( self, parent, name ): - self.sizer = wx.BoxSizer( wx.HORIZONTAL ) - - labelTextCtrl = wx.TextCtrl( parent, -1, name, - style = wx.NO_BORDER | wx.ALIGN_LEFT ) - self.rowHeight = labelTextCtrl.GetSize()[ 1 ] - labelTextCtrl.SetEditable( False ) - self.sizer.Add( labelTextCtrl, 0, wx.EXPAND | wx.ALIGN_RIGHT ) - -class PropertyRowItemName( PropertyRowItem ): - def __init__( self, parent, name, value = "" ): - PropertyRowItem.__init__( self, parent, name ) - self.valueTextCtrl = wx.TextCtrl( parent, -1, value, - size = wx.Size( 30, self.rowHeight ), - style = wx.NO_BORDER | wx.ALIGN_LEFT | wx.EXPAND) - self.sizer.AddSpacer( 1 ) - self.sizer.Add( self.valueTextCtrl, 1, wx.EXPAND | wx.ALIGN_LEFT ) - -class PropertyRowItemSlider( PropertyRowItem ): - def __init__( self, parent, name, start = 0, end = 100, format = SLIDER_INT, cback = None ): - PropertyRowItem.__init__( self, parent, name ) - self.format = format - self.cback = cback - self.value = 0 - self.start = start - self.end = end - self.sliderValue = 0 - - if self.format == SLIDER_INT: - self.sliderStart = start - self.sliderEnd = end - else: - self.sliderStart = 0 - self.sliderEnd = 100 - - self.scale = float( self.end - self.start )/( self.sliderEnd - self.sliderStart ) - - self.valueTextCtrl = wx.TextCtrl( parent, -1, "", - size = wx.Size( 30, self.rowHeight ), - style = wx.NO_BORDER | wx.ALIGN_LEFT | wx.EXPAND) - - self.slider = wx.Slider( parent, -1, self.sliderValue, self.sliderStart, self.sliderEnd, - size = wx.Size( 100, self.rowHeight ), - style = wx.NO_BORDER | wx.NO_3D ) - - self.sizer.AddSpacer( 1 ) - self.sizer.Add( self.valueTextCtrl, 0, wx.EXPAND | wx.ALIGN_LEFT ) - self.sizer.Add( self.slider, 1, wx.EXPAND | wx.ALIGN_LEFT ) - self.slider.Bind(wx.EVT_SLIDER, self.OnSlide ) - - def OnSlide(self, event): - val = event.GetEventObject().GetValue() - self.value = self.start + self.scale * val; - self.applyValue() - - def setValue(self, value): - self.value = value - self.applyValue( False ) - - def applyValue( self, update = True ): - if self.format == SLIDER_INT: - self.valueTextCtrl.SetValue( "%d" % self.value ) - else: - self.valueTextCtrl.SetValue( "%.1g" % self.value ) - - self.slider.SetValue( (self.value -self.start)/ self.scale ) - - if update == True: - if self.cback != None: - self.cback( self.value ) - -class PropertyRowItemChoice( PropertyRowItem ): - def __init__( self, parent, name, itemList = None, itemMap = None, cback = None): - PropertyRowItem.__init__( self, parent, name ) - - self.cback = cback - self.value = "None" - - if itemList != None: - self.ITEMDICT = False - self.itemList = itemList - elif itemMap != None: - self.ITEMDICT = True - self.itemList = itemMap - - self.choice = wx.combo.ComboCtrl( parent, -1, - size = wx.Size( 100, self.rowHeight ), - style = wx.NO_BORDER | wx.NO_3D | wx.CB_READONLY ) - - #self.choice.SetFont(wx.Font(8, wx.DEFAULT, wx.NORMAL, wx.NORMAL, 0, "")) - - self.popup = ListCtrlComboPopup( cback = self.choiceChanged ) - self.popup.SetFont(wx.Font(8, wx.DEFAULT, wx.NORMAL, wx.NORMAL, 0, "")) - - self.choice.SetPopupControl( self.popup ) - - - if self.ITEMDICT == False: - for i in self.itemList: - self.popup.AddItem( i ) - else: - for i in self.itemList: - self.popup.AddItem( i[ 1 ] ) - - self.sizer.AddSpacer( 1 ) - self.sizer.Add( self.choice, 1, wx.EXPAND | wx.ALIGN_LEFT ) - - def choiceChanged(self, idx): - if self.ITEMDICT == False: - self.value = self.itemList[ idx ] - else: - self.value = self.itemList[idx][ 0 ] - - self.applyValue() - - def setValue(self, value): - self.value = value - self.applyValue( False ) - - def applyValue( self, update = True ): - #print self.value - #item = self.value in self.itemList - # for val in self.itemList: -# if self.ITEMDICT == False: -# if self.value == val: -# item = val -# else: -# if self.value == val[0]: -# item = val -# print item - - if update == True: - if self.cback != None: - self.cback( self.value ) - -class PropertyRowItemColourSelect( PropertyRowItemName ): - def __init__( self, parent, name, cback = None ): - PropertyRowItemName.__init__( self, parent, name ) - self.cback = cback - self.value = wx.Colour(0,0,0) - - self.colourButton = csel.ColourSelect( parent, -1, "", - colour = self.value, - size = wx.Size( self.rowHeight,self.rowHeight ), - style = wx.NO_BORDER ) - - self.sizer.AddSpacer( 1 ) - self.sizer.Add( self.colourButton, 0, wx.EXPAND ) - self.colourButton.Bind( csel.EVT_COLOURSELECT, self.OnColour ) - - def OnColour(self, event): - self.value = event.GetValue() - self.applyValue() - - def setValue(self, value): - self.value = value - self.applyValue( False ) - - def applyValue( self, update = True ): - self.valueTextCtrl.SetValue( "%d,%d,%d" % (self.value[0],self.value[1],self.value[2]) ) - self.colourButton.SetColour( self.value ) - if update == True: - if self.cback != None: - self.cback( self.value ) - - -class PropertyGrid( ): - def __init__(self): - self.sizer = wx.BoxSizer( wx.VERTICAL ) - self.SetSizer( self.sizer ) - self.widthCol0 = 70 - self.widthCol2 = 24 - self.xOffset = 17 - - def appendRow(self, row ): - self.sizer.AddSpacer(1) - self.sizer.Add( row.sizer, 0, wx.EXPAND ) - - def appendRowItemName(self, name, value = "" ): - item = PropertyRowItemName( self.pane, name, value ) - self.appendRow( item ) - return item - - def appendRowItemChoice(self, name, itemList = None, itemMap = None, cback = None ): - item = PropertyRowItemChoice( self.pane, name, itemList, itemMap, cback ) - self.appendRow( item ) - return item - - def appendRowItemSlider(self, name, start = 0, end = 100, format = SLIDER_INT, cback = None ): - item = PropertyRowItemSlider( self.pane, name, start, end, format, cback ) - self.appendRow( item ) - return item - - def appendRowItemColourSelect( self, name, cback = None ): - item = PropertyRowItemColourSelect( self.pane, name, cback ) - self.appendRow( item ) - return item - - def appendPane(self, pane ): - self.sizer.AddSpacer(1) - self.sizer.Add( pane, 0, wx.EXPAND ) - - def appendPaneColourSelect( self, name, cfront = None, cback = None ): - pane = PropertyPaneItemColour( self.pane, name, cfront, cback ) - self.appendPane( pane ) - return pane - - -class PropertyPaneItem( wx.CollapsiblePane, PropertyGrid ): - def __init__(self, parent, name): - - wx.CollapsiblePane.__init__( self, parent, -1, name, - style = wx.CP_DEFAULT_STYLE - | wx.CP_NO_TLW_RESIZE ) - PropertyGrid.__init__(self) - - - self.SetFont(wx.Font(8, wx.DEFAULT, wx.NORMAL, wx.NORMAL, 0, "")) - self.Bind(wx.EVT_COLLAPSIBLEPANE_CHANGED, self.OnPaneChanged ) - - self.pane = self.GetPane() - self.pane.SetFont( wx.Font( 8, wx.DEFAULT, wx.NORMAL, wx.NORMAL, 0, "" ) ) - self.sizer = wx.BoxSizer( wx.VERTICAL ) - self.pane.SetSizer( self.sizer ) - - def OnPaneChanged(self, event = None): - if event: - if ( event.Collapsed ): - event.GetEventObject().GetPane().Hide() - else: - event.GetEventObject().GetPane().Show() - parent = self.GetParent().Layout() - - -class PropertyPaneItemColour( PropertyPaneItem ): - def __init__( self, parent, name, cfront = None, cback = None ): - PropertyPaneItem.__init__(self, parent, name) - self.cback = cback - self.cfront = cfront - self.value = [0, 0, 0, 0] - self.scale = 255.0 - - self.c = self.appendRowItemColourSelect( "Colour", cback = self.setRGB ) - self.r = self.appendRowItemSlider( "red", 0, 255, cback = self.setRed ) - self.g = self.appendRowItemSlider( "green", 0, 255, cback = self.setGreen ) - self.b = self.appendRowItemSlider( "blue", 0, 255, cback = self.setBlue ) - self.a = self.appendRowItemSlider( "alpha", 0, 255, cback = self.setAlpha ) - - if self.cfront != None: - colour = self.cfront() - self.value = map(lambda x: x * self.scale, [colour[0], colour[1], colour[2], colour[3]] ) - self.applyValue( False ) - - def setRGB(self, value): - self.value[0:3] = value - self.applyValue() - def setRed(self, value): - self.value[0] = value - self.applyValue() - def setGreen(self, value): - self.value[1] = value - self.applyValue() - def setBlue(self, value): - self.value[2] = value - self.applyValue() - def setAlpha(self, value): - self.value[3] = value - self.applyValue() - - def applyValue(self, update = True ): - self.r.setValue( self.value[ 0 ] ) - self.g.setValue( self.value[ 1 ] ) - self.b.setValue( self.value[ 2 ] ) - self.a.setValue( self.value[ 3 ] ) - self.c.setValue( self.value ) - if update == True: - if self.cback != None: - self.cback( map(lambda x: x / self.scale, self.value) ) - - -class PropertyMainGrid( wx.Panel, PropertyGrid ): - def __init__(self, *argc, **argv): - argv["style"] = wx.TAB_TRAVERSAL - wx.Panel.__init__(self, *argc, **argv) - PropertyGrid.__init__(self) - self.SetFont(wx.Font(8, wx.DEFAULT, wx.NORMAL, wx.NORMAL, 0, "")) - #self.SetBackgroundColour( wx.Colour(200, 200, 200) ) - - self.pane = self - - def clean( self ): - self.sizer.Clear( True ) - self.sizer.Layout() - Deleted: branches/ogEditor/PythonOgreConfig.py =================================================================== --- branches/ogEditor/PythonOgreConfig.py 2008-05-14 21:50:43 UTC (rev 898) +++ branches/ogEditor/PythonOgreConfig.py 2008-05-18 19:29:16 UTC (rev 899) @@ -1,43 +0,0 @@ -#!/usr/bin/env python -# a single config file that is imported 'first' by the Python-Ogre demos -# this is primarly used to manage Linux demos when we have binaries in non standard (safe) locations - -import os,sys - -######################################################################### -### Override this setting if you are using non standard locations - -libpath = "/home/carsten/local/python-ogre.work/root/usr/lib" -libpathpyton = "/home/carsten/local/python-ogre.work/root/usr/lib64/" - -######################################################################### - -if os.name == 'nt': - libpath="" - libpathpyton="" - pythonpath = "" -else: - if libpathpyton == "" : # we need to find this ourselves - localpath = os.path.abspath(os.path.dirname(__file__) ) # assume that this module is in the ./demos directory - libpathpyton = os.path.abspath(os.path.join(localpath,'../lib')) # so in the binary release the lib is one path back up - if not os.path.exists ( libpathpyton ): #we must be running from the development environment - libpathpyton = os.path.abspath(os.path.join(localpath,'../../root/usr/lib')) - if not os.path.exists ( libpathpyton ): - ## should die here - print "**Problem finding libraries" - libpathpyton=localpath - - ## path to the Python-Ogre modules - pythonpath = os.path.abspath(os.path.join(libpathpyton, 'python2.5/site-packages') ) - ## and insert it into the system path - sys.path.insert(0,pythonpath) - - ## now we need to set the library path so the shared libraries can be found - try: - ldpath = os.environ['LD_LIBRARY_PATH'] - except: - ldpath="" - newldpath = libpath + ":" + ldpath - os.environ['LD_LIBRARY_PATH'] = newldpath - os.putenv('LD_LIBRARY_PATH', newldpath) - print "export LD_LIBRARY_PATH=%s" % os.environ['LD_LIBRARY_PATH'] Deleted: branches/ogEditor/ResourceTreePane.py =================================================================== --- branches/ogEditor/ResourceTreePane.py 2008-05-14 21:50:43 UTC (rev 898) +++ branches/ogEditor/ResourceTreePane.py 2008-05-18 19:29:16 UTC (rev 899) @@ -1,68 +0,0 @@ -import wx -import wx.lib.customtreectrl as CT -import ogre.renderer.OGRE as ogre - -class MyCustomTree( CT.CustomTreeCtrl ): - def __init__(self, parent, id=wx.ID_ANY, pos=wx.DefaultPosition, size=wx.DefaultSize, - style=wx.TR_DEFAULT_STYLE, ctstyle=0, validator=wx.DefaultValidator, - name="MyCustomTreeCtrl"): - CT.CustomTreeCtrl.__init__(self, parent, id, pos, size, style, ctstyle, validator, name) - - def OnInternalIdle(self): - wx.PyScrolledWindow.OnInternalIdle( self ) - CT.CustomTreeCtrl.OnInternalIdle( self ) - - -class ResourceTreePane( MyCustomTree ): - def __init__(self, parent, id=wx.ID_ANY, pos=wx.DefaultPosition, size=wx.DefaultSize, - style=wx.TR_DEFAULT_STYLE, ctstyle=0, validator=wx.DefaultValidator, - name="MyCustomTreeCtrl"): - CT.CustomTreeCtrl.__init__(self, parent, id, pos, size, style, ctstyle, validator, name) - - CT.CustomTreeCtrl.SetConnectionPen( self, wx.Pen( wx.Colour(100,100,100), 1, wx.SOLID) ) - CT.CustomTreeCtrl.SetFont( self, wx.Font( 8, wx.FONTFAMILY_DEFAULT, wx.TR_DEFAULT_STYLE, wx.FONTWEIGHT_NORMAL ) ) - - def OnInternalIdle(self): - wx.PyScrolledWindow.OnInternalIdle( self ) - CT.CustomTreeCtrl.OnInternalIdle( self ) - - def addItem( self, node, name, data ): - newNode = self.AppendItem( node, name ) - self.SetPyData( newNode, data ) - return newNode - - def buildResourceTree( self ): - root = self.AddRoot( "Ogre resources" ) - resManNode = self.AppendItem( root, "Resource manager" ) - - resManIter = ogre.ResourceGroupManager.getSingleton().getResourceManagerIterator() - while resManIter.hasMoreElements(): - resManNodeIter = self.addItem( resManNode, resManIter.peekNextKey(), resManIter.peekNextValue() ) - resIter = resManIter.peekNextValue().getResourceIterator() - while resIter.hasMoreElements(): - self.addItem( resManNodeIter, resIter.peekNextValue().getName(), resIter.peekNextValue() ) - resIter.getNext() - - resManIter.getNext() - - resGroupManNode = self.addItem( root, "Resource groups", ogre.ResourceGroupManager.getSingleton() ) - - resGroups = ogre.ResourceGroupManager.getSingleton().getResourceGroups( ) - for resGroupName in resGroups: - resGroupNode = self.addItem( resGroupManNode, resGroupName, None ) - - resLocNode = self.addItem( resGroupNode, "Resource locations", None ) - - resLocationList = ogre.ResourceGroupManager.getSingleton().getResourceDeclarationList( resGroupName ) - for resLocation in resLocationList: - print resLocation.resourceName - self.addItem( resLocNode, resLocation.resourceName, None ) - - resNameNode = self.addItem( resGroupNode, "Resources", None ) - resNameList = ogre.ResourceGroupManager.getSingleton().listResourceNames( resGroupName ) - for res in resNameList: - self.addItem( resNameNode, res, None ); - - # this fails ??? - #fileInfoList = ogre.ResourceGroupManager.getSingleton().findResourceFileInfo( "General", "*.png") - #fileNameList = ogre.ResourceGroupManager.getSingleton().listResourceFileInfo( resGroupName ) Added: branches/ogEditor/build.sh =================================================================== --- branches/ogEditor/build.sh (rev 0) +++ branches/ogEditor/build.sh 2008-05-18 19:29:16 UTC (rev 899) @@ -0,0 +1,21 @@ +#!/bin/bash + +if [ $OSTYPE = "msys" ]; then + echo "build for mingw" + python generate_code.py vector + bjam toolset=gcc +else + echo "build for linux gcc" + mkdir -p generated + MAKEOPTS=-j5 + make clean + sh build.wxogre_util.sh +# cp ./indexing_suite_v2/src/indexing/* generated/ + + if [ $# -lt 1 ]; then + python generate_code.py + make $MAKEOPTS + cp generated/opengate.so packages_2.5/opengate/OpenGate.so + + fi +fi Added: branches/ogEditor/environment.py =================================================================== --- branches/ogEditor/environment.py (rev 0) +++ branches/ogEditor/environment.py 2008-05-18 19:29:16 UTC (rev 899) @@ -0,0 +1,49 @@ +#! /usr/bin/python +# Copyright 2004 Roman Yakovenko. +# Distributed under the Boost Software License, Version 1.0. (See +# accompanying file LICENSE_1_0.txt or copy at +# http://www.boost.org/LICENSE_1_0.txt) + +import sys + +class settings: + module_name = 'OpenGate' + #opengate_path = '../../trunc/src/' + opengate_path = '/home/carsten/local/opengate/trunk/src/' + opengate_cache_file ='python_opengate.cache' + ogre_include_path = '' + ogreopcode_include_path = '' + boost_path = '' + boost_libs_path = '' + gccxml_path = '' + pygccxml_path = '' + pyplusplus_path = '' + python_libs_path = '' + python_include_path = '' + working_dir = '' + unittests_dir = '' + generated_files_dir = './generated' + opengate_defines = '' + def setup_environment(): + print settings.pygccxml_path + sys.path.append( settings.pygccxml_path ) + sys.path.append( settings.pyplusplus_path ) + setup_environment = staticmethod(setup_environment) + +if sys.platform == 'linux2': + settings.python_include_path = '/usr/include/python2.5' + settings.ogre_include_path = '/usr/include/OGRE' + settings.ogreopcode_include_path = '/usr/include/ogreopcode' + settings.gccxml_path = '/usr/bin' + settings.pygccxml_path = '/usr/lib64/python2.5/site-packages' + settings.pyplusplus_path = '/usr/lib64/python2.5/site-packages' + +elif sys.platform == 'win32': + settings.pygccxml_path = 'c:/python25/Lib/site-packages/' + settings.python_libs_path = 'c:/python25/libs' + settings.gccxml_path = 'c:/Programme/GCCXMLcomplete/bin' + settings.opengate_defines ='MINGW' +else: + raise RuntimeError( 'There is no configuration for "%s" platform.' % sys.platform ) + +settings.setup_environment() Added: branches/ogEditor/generate_code.py =================================================================== --- branches/ogEditor/generate_code.py (rev 0) +++ branches/ogEditor/generate_code.py 2008-05-18 19:29:16 UTC (rev 899) @@ -0,0 +1,221 @@ +#! /usr/bin/python + +import os +import sys +import string +from environment import settings + +import hand_made_wrappers + +from pygccxml import parser +from pygccxml import declarations +from pygccxml.declarations import access_type_matcher_t +from pyplusplus import code_creators +from pyplusplus import module_builder +from pyplusplus.module_builder import call_policies + +import common_utils.ogre_properties as ogre_properties + +MAIN_NAMESPACE = 'OpenGate' + +def set_call_policies( mb ): +# + # Set the default policy to deal with pointer/reference return types to reference_existing object^M + # as this is the Ogre Default.^M + mem_funs = mb.calldefs () + mem_funs.create_with_signature = True #Generated code will not compile on^M + #MSVC 7.1 if function has throw modifier.^M + for mem_fun in mem_funs: + if mem_fun.call_policies: + continue + if declarations.is_pointer (mem_fun.return_type) or declarations.is_reference (mem_fun.return_type): + mem_fun.call_policies = call_policies.return_value_policy( call_policies.reference_existing_object ) + + +class decl_starts_with (object): + def __init__ (self, prefix): + self.prefix = prefix + def __call__ (self, decl): + return self.prefix in decl.name + +def excludeFreeFunctionsByReturn( mb, functs): + for funct in functs: + fun = mb.global_ns.free_functions( return_type=funct, allow_empty=True ) + print "exclude", funct, len( fun ) + for f in fun: + f.exclude() + +def excludeFreeFunctionsByName( mb, functs): + for funct in functs: + fun = mb.global_ns.free_functions( name=funct, allow_empty=True ) + print "exclude", funct, len( fun ) + for f in fun: + f.exclude() + +def excludeFreeOperatorsByReturn( mb, functs): + for funct in functs: + fun = mb.global_ns.free_operators( return_type=funct, allow_empty=True ) + print "exclude", funct, len( fun ) + for f in fun: + f.exclude() + +def excludeClass( mb, functs): + for funct in functs: + fun = mb.global_ns.class_( funct ) + print "exclude", fun + fun.exclude() + +def excludeMemberByReturn( mb, functs): + for funct in functs: + fun = mb.global_ns.member_functions( return_type=funct, allow_empty=True ) + print "exclude", funct, len( fun ) + for f in fun: + f.exclude() + +def excludeMemberOperators( mb, functs): + for funct in functs: + fun = mb.global_ns.member_operators( symbol=funct, allow_empty=True ) + print "exclude", funct, len( fun ) + for f in fun: + f.exclude() + +def setMemberFunctionCallPolicieByReturn(mb, MemberRetRef, callPolicie ): + for ref in MemberRetRef: + memFuns = mb.global_ns.member_functions( return_type=ref, allow_empty=True ) + print ref, len(memFuns) + + for memFun in memFuns: + if memFun.call_policies: + continue + else: + memFun.call_policies = \ + call_policies.return_value_policy( callPolicie ) + +def generate( defined_symbols ): + xml_cached_fc = parser.create_cached_source_fc( os.path.join( r"python_opengate.h" ), + settings.opengate_cache_file ) + + print xml_cached_fc + + mb = module_builder.module_builder_t( [xml_cached_fc], + gccxml_path = settings.gccxml_path, + working_directory = settings.opengate_path, + include_paths = [settings.opengate_path, settings.python_include_path, + settings.ogreopcode_include_path, settings.ogre_include_path], + define_symbols = defined_symbols, + indexing_suite_version = 2 ) + + ## This module depends on Ogre + mb.register_module_dependency ( '/home/carsten/local/python-ogre/python-ogre/generated/ogre_1.4/' ) + + global_ns = mb.global_ns + global_ns.exclude() + + main_ns = global_ns.namespace( MAIN_NAMESPACE ) + main_ns.include() + + global_ns.namespace( 'Ogre' ).class_('Vector3').include(already_exposed=True) + + hand_made_wrappers.apply( mb ) + + mb.BOOST_PYTHON_MAX_ARITY = 25 + mb.classes().always_expose_using_scope = True + + set_call_policies( mb.global_ns.namespace ('OpenGate') ) + set_call_policies( mb.global_ns.namespace ('Ogre') ) + + for cls in main_ns.classes(): + print cls + cls.add_properties( recognizer=ogre_properties.ogre_property_recognizer_t() ) + + + mb.calldefs( access_type_matcher_t( 'protected' ) ).exclude() + mb.calldefs( access_type_matcher_t( 'private' ) ).exclude() + + #mb.class_( '::std::set < ::std::string >' ).alias = 'stringSet'; + + excludeClass( mb, [ 'deletePtr' + ,'GameStateListener' + ,'GameStateManager' + ,'Message' + ,'MessageBodyBase' + ,'OpenALSoundSource' + ] ) + + # mb.class_( 'Vector<double>' ).alias = 'RVector' + + + #call_policies.return_value_policy( call_policies.reference_existing_object ) + #call_policies.return_value_policy( call_policies.copy_non_const_reference ) + #call_policies.return_value_policy( call_policies.copy_const_reference ) + + #excludeFreeFunctionsByName( mb, ['strReplaceBlankWithUnderscore' + #'toStr', 'toInt', 'toFloat', 'toDouble', + #'getRowSubstrings', 'getNonEmptyRow', 'getSubstrings' ] ) + + #excludeFreeFunctionsByReturn( mb, [ 'float *', 'float &' ] ) + + #excludeFreeOperatorsByReturn( mb, [ '::std::ostream &', '::std::istream &' ] ) + + #excludeMemberOperators( mb, ['++', '--', '*'] ) + + +## setMemberFunctionCallPolicie( mb, [''], call_policies.copy_non_const_reference ) + + ##setMemberFunctionCallPolicieByReturn( mb, ['::Ogre::Vector3' ], + ##call_policies.return_pointee_value ) + + #setMemberFunctionCallPolicieByReturn( mb, ['::std::string *', 'float *', 'double *'], + #call_policies.return_pointee_value ) + + #setMemberFunctionCallPolicieByReturn( mb, ['::std::string &', 'double &' ], + #call_policies.return_by_value ) + + + # exclude all that does not match any predefined callpolicie + excludeRest = True + + if excludeRest: + mem_funs = mb.calldefs () + + for mem_fun in mem_funs: + if mem_fun.call_policies: + continue + if not mem_fun.call_policies and \ + (declarations.is_reference( mem_fun.return_type ) or declarations.is_pointer (mem_fun.return_type) ): + #print mem_fun + mem_fun.exclude() + #mem_fun.call_policies = \ + #call_policies.return_value_policy( call_policies.reference_existing_object ) + #mem_fun.call_policies = \ + # call_policies.return_value_policy( call_policies.return_pointee_value ) + #mem_fun.call_policies = \ + # call_policies.return_value_policy( call_policies.return_opaque_pointer ) + #mem_fun.call_policies = \ + # call_policies.return_value_policy(call_policies.copy_non_const_reference) + + # mb.print_declarations( main_ns ) +#I can print declarations to see what is going on +#mb.print_declarations() + +#Now it is the time to give a name to our module + mb.build_code_creator( settings.module_name ) + +#It is common requirement in software world - each file should have license + #mb.code_creator.license = '//Boost Software License( http://boost.org/more/license_info.html )' + +#I don't want absolute includes within code + mb.code_creator.user_defined_directories.append( os.path.abspath('.') ) + + #And finally we can write code to the disk + mb.split_module( settings.generated_files_dir ) + #mb.write_module( os.path.join( settings.generated_files_dir, settings.module_name + '.cpp') ) + +if __name__ == '__main__': + + defined_symbols = ['OPENGATE'] + + generate( defined_symbols ) + print 'done' + + Added: branches/ogEditor/hand_made_wrappers.py =================================================================== --- branches/ogEditor/hand_made_wrappers.py (rev 0) +++ branches/ogEditor/hand_made_wrappers.py 2008-05-18 19:29:16 UTC (rev 899) @@ -0,0 +1,20 @@ +#! /usr/bin/python + +import os +import environment + +WRAPPER_DEFINITION_General = \ +""" +""" + +WRAPPER_REGISTRATION_General = [ + """ + """] + +def apply_reg ( class_, code ): + for c in code: + class_.add_registration_code ( c ) + +def apply( mb ): + mb.add_declaration_code( WRAPPER_DEFINITION_General ) + apply_reg( mb, WRAPPER_REGISTRATION_General ) \ No newline at end of file Modified: branches/ogEditor/ogEditor.py =================================================================== --- branches/ogEditor/ogEditor.py 2008-05-14 21:50:43 UTC (rev 898) +++ branches/ogEditor/ogEditor.py 2008-05-18 19:29:16 UTC (rev 899) @@ -1,23 +1,32 @@ #!/usr/bin/env python -# -*- coding: ansi_x3.4-1968 -*- - import wxversion wxversion.ensureMinimal('2.8') +import sys import wx + +sys.path.append( './packages_2.5/' ) +sys.path.append( '../' ) +sys.path.append( './src/' ) + import wx.aui import wx.py as py import wx.lib.customtreectrl as CT -from OgreWindowWx import * + from ObjectInspectorPanels import * from ResourceTreePane import * +from OgreWindowWx import * + +import opengate as og + class OGView3D( OgreWindow ): def _PopulateScene(self): #automatic called by parent init # self.headE... [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_.ogreRoot->renderOneFrame( ); -// } - //** end just for test purposes } GameStateManager::~GameStateManager( ){ @@ -158,181 +110,6 @@ // if ( resources_.ogreRoot ) delete resources_.ogreRoot; } -void GameStateManager::switchConfigDialog( ){ - if ( configDialog_->isVisible() ) { - configDialog_->hide(); - } else{ - configDialog_->show(); - } -} - -void GameStateManager::manageGameState( const std::string & stateName, GameState * state ){ - StateInfo newStateInfo; - newStateInfo.name = stateName; - newStateInfo.state = state; - newStateInfo.state->init( ); - states_.push_back( newStateInfo ); -} - -void GameStateManager::start( GameState * state ){ - if ( state ){ - shutdownRequest_ = false; - changeGameState( state ); - } - - while ( !shutdownRequest_ ){ - if ( resources_.inputManager ) resources_.inputManager->capture(); - - captureNetwork(); - - Ogre::WindowEventUtilities::messagePump(); - -#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32 - { - MSG msg; - while ( PeekMessage( & msg, NULL, 0, 0, PM_REMOVE ) ) { - if ( msg.message == WM_QUIT ){ - shutdown(); - } else { - // TranslateMessage(&msg); - // DispatchMessage(&msg); - } - } - } -#endif - resources_.ogreRoot->renderOneFrame( ); - } -} - -bool GameStateManager::captureNetwork(){ - //** start capture network; - std::vector < std::vector < char > > msgs; - std::vector < MessageBodyShipMovement * > movements; - resources_.network->pull( msgs ); - - Sector * sector = NULL; - if ( stateStack_.back()->name() == "UnDockedState" ){ - sector = dynamic_cast < UnDockedState * >(stateStack_.back())->sector(); - } - - if ( msgs.size() > 0 ) { - // LogManager::getSingleton().debug( std::string( "Pullcount: " ) + toStr( msgs.size() ) ); - for ( size_t i = 0; i < msgs.size(); i ++ ){ - - // LogManager::getSingleton().debug( std::string( "Pull: " ) + toStr( (int)msgs[ i ][ 0 ] ) ); - // if ( msgs[ i ][ 0 ] == PROTO_SHIPMOVEMENT ) { - // MessageBodyShipMovement m( &msgs[ i ][ 0 ] ); - // std::cout << m << std::endl; - // } - - switch ( msgs[ i ][ 0 ] ){ - case PROTO_CHAT:{ - resources_.network->ping(); - MessageBodyChat msg( &msgs[ i ][ 0 ] ); - log_->chat( resources_.network->userName( msg.senderID() ), msg.message() ); - } break; - case PROTO_SHIP_REGISTER: - if ( sector ) sector->receiveVesselRegister( &msgs[ i ][ 0 ] ); break; - case PROTO_SHIP_DEREGISTER: - if ( sector ) sector->receiveVesselDeRegister( &msgs[ i ][ 0 ] ); break; - case PROTO_SHIP_DIED: - if ( sector ) sector->receiveVesselDied( &msgs[ i ][ 0 ] ); break; - case PROTO_SHIP_STATUS: - if ( sector ) sector->receiveVesselStatus( &msgs[ i ][ 0 ] ); break; - case PROTO_SHIP_MOVEMENT:{ - //** we handle that in sum, so we can ignore dups because of packet loss - MessageBodyShipMovement *msg = new MessageBodyShipMovement( &msgs[ i ][ 0 ] ); - movements.push_back( msg ); - } break; - case PROTO_SHIP_PROJECTILEFIRED: - if ( sector ) sector->receiveProjectile( &msgs[ i ][ 0 ] ); break; - case PROTO_SHIP_AMMOHIT: - if ( sector ) sector->receiveVesselAmmoHit( &msgs[ i ][ 0 ] ); break; - default: - std::cerr << "PROTO type unknown: " << msgs[ i ][ 0 ] << " " << msgs[ i ].size() << std::endl; - break; - } - } - if ( movements.size() > 0 && sector ) sector->receiveVesselMovement( movements ); - } - return true; -} - -GameState * GameStateManager::findByName( const std::string & stateName ) { - for ( std::vector< StateInfo >::iterator itr = states_.begin(); itr != states_.end(); itr++ ) { - if ( itr->name == stateName ) - return itr->state; - } - log_->fatal( std::string( "Cannot find gamestate: " ) + stateName ); - log_->fatal( "Available states: " ); - for ( std::vector< StateInfo >::iterator itr = states_.begin(); itr != states_.end(); itr++ ) { - log_->fatal( std::string( "\t" ) + itr->name ) ; - } - return NULL; -} - -void GameStateManager::changeGameState( GameState * state ){ - // cleanup the current game state - if ( !stateStack_.empty() ) { - cleanup_( stateStack_.back() ); - if ( stateStack_.back()->rootWindow() ) stateStack_.back()->rootWindow()->removeChildWindow( configDialog_->rootWindow() ); - stateStack_.back()->exit(); - stateStack_.pop_back(); - } - - // store and init the new state - stateStack_.push_back( state ); - stateStack_.back()->enter(); - if ( stateStack_.back()->rootWindow() ) stateStack_.back()->rootWindow()->addChildWindow( configDialog_->rootWindow() ); - init_( state ); -} - -bool GameStateManager::pushGameState( GameState * state ){ - // pause current game state - if ( !stateStack_.empty() ) { - if ( !stateStack_.back()->pause() ){ - return false; - } - cleanup_( stateStack_.back() ); - } - - // store and init the new state - stateStack_.push_back( state ); - init_( state ); - stateStack_.back()->enter(); - - return true; -} - -void GameStateManager::popGameState( ) { - // cleanup the current game state - if ( !stateStack_.empty() ) { - cleanup_( stateStack_.back() ); - stateStack_.back()->exit(); - stateStack_.pop_back(); - } - - // resume previous game state or quit if there isn't one - if ( !stateStack_.empty() ) { - init_( stateStack_.back() ); - stateStack_.back()->resume(); - } else { - shutdown(); - } -} - -void GameStateManager::shutdown( ){ - shutdownRequest_ = true; -} - -void GameStateManager::init_( GameState * state ) { - resources_.ogreRoot->addFrameListener( state ); -} - -void GameStateManager::cleanup_( GameState * state ){ - resources_.ogreRoot->removeFrameListener( state ); -} - bool GameStateManager::initialiseBootstrap( bool dialog ){ resources_.ogreRoot = new Ogre::Root; resources_.gameStateRoot = this; @@ -366,7 +143,7 @@ typeName = i->first; archName = i->second; Ogre::ResourceGroupManager::getSingleton().addResourceLocation( archName, typeName, secName ); - resources_.resourcePaths().insert( archName ); + resources_.addResourceLocation( archName, secName ); } } } @@ -492,16 +269,16 @@ bool GameStateManager::initialiseEntityManager(){ resources_.entityManager = new EntityManager( ); - resources_.entityManager->load( resources_.resourcePaths(), "commodities" ); - resources_.entityManager->load( resources_.resourcePaths(), "engines" ); - resources_.entityManager->load( resources_.resourcePaths(), "capacitors" ); - resources_.entityManager->load( resources_.resourcePaths(), "radars" ); - resources_.entityManager->load( resources_.resourcePaths(), "shields" ); - //resources_.entityManager->load( resources_.resourcePaths(), "ecms" ); - resources_.entityManager->load( resources_.resourcePaths(), "power_plants" ); - resources_.entityManager->load( resources_.resourcePaths(), "guns" ); - resources_.entityManager->load( resources_.resourcePaths(), "missiles" ); - resources_.entityManager->load( resources_.resourcePaths(), "ships" ); + resources_.entityManager->load( resources_.resourceLocations( "General" ), "commodities" ); + resources_.entityManager->load( resources_.resourceLocations( "General" ), "engines" ); + resources_.entityManager->load( resources_.resourceLocations( "General" ), "capacitors" ); + resources_.entityManager->load( resources_.resourceLocations( "General" ), "radars" ); + resources_.entityManager->load( resources_.resourceLocations( "General" ), "shields" ); + resources_.entityManager->load( resources_.resourceLocations( "General" ), "ecms" ); + resources_.entityManager->load( resources_.resourceLocations( "General" ), "power_plants" ); + resources_.entityManager->load( resources_.resourceLocations( "General" ), "guns" ); + resources_.entityManager->load( resources_.resourceLocations( "General" ), "missiles" ); + resources_.entityManager->load( resources_.resourceLocations( "General" ), "ships" ); return true; } @@ -570,12 +347,19 @@ typeName = i->first; archName = i->second; Ogre::ResourceGroupManager::getSingleton().addResourceLocation( archName, typeName, secName ); - resources_.resourcePaths().insert( archName ); + resources_.addResourceLocation( archName, secName ); } } } Ogre::ResourceGroupManager::getSingleton().initialiseResourceGroup( "General" ); + std::cout << "Ogre::ResourceGroupManager::getSingleton().initialiseResourceGroup( General ); " << std::endl; + Ogre::ResourceGroupManager::ResourceDeclarationList li = Ogre::ResourceGroupManager::getSingleton().getResourceDeclarationList( "General" ); + std::cout << li.size() << std::endl; + for ( std::list<Ogre::ResourceGroupManager::ResourceDeclaration>::iterator it = li.begin(); it != li.end(); it ++ ){ + std::cout << (*it).resourceName << std::endl; + } + return true; } @@ -606,6 +390,181 @@ return true; } +void GameStateManager::switchConfigDialog( ){ + if ( configDialog_->isVisible() ) { + configDialog_->hide(); + } else{ + configDialog_->show(); + } +} + +void GameStateManager::manageGameState( const std::string & stateName, GameState * state ){ + StateInfo newStateInfo; + newStateInfo.name = stateName; + newStateInfo.state = state; + newStateInfo.state->init( ); + states_.push_back( newStateInfo ); +} + +void GameStateManager::start( GameState * state ){ + if ( state ){ + shutdownRequest_ = false; + changeGameState( state ); + } + + while ( !shutdownRequest_ ){ + if ( resources_.inputManager ) resources_.inputManager->capture(); + + captureNetwork(); + + Ogre::WindowEventUtilities::messagePump(); + +#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32 + { + MSG msg; + while ( PeekMessage( & msg, NULL, 0, 0, PM_REMOVE ) ) { + if ( msg.message == WM_QUIT ){ + shutdown(); + } else { + // TranslateMessage(&msg); + // DispatchMessage(&msg); + } + } + } +#endif + resources_.ogreRoot->renderOneFrame( ); + } +} + +bool GameStateManager::captureNetwork(){ + //** start capture network; + std::vector < std::vector < char > > msgs; + std::vector < MessageBodyShipMovement * > movements; + resources_.network->pull( msgs ); + + Sector * sector = NULL; + if ( stateStack_.back()->name() == "UnDockedState" ){ + sector = dynamic_cast < UnDockedState * >(stateStack_.back())->sector(); + } + + if ( msgs.size() > 0 ) { + // LogManager::getSingleton().debug( std::string( "Pullcount: " ) + toStr( msgs.size() ) ); + for ( size_t i = 0; i < msgs.size(); i ++ ){ + + // LogManager::getSingleton().debug( std::string( "Pull: " ) + toStr( (int)msgs[ i ][ 0 ] ) ); + // if ( msgs[ i ][ 0 ] == PROTO_SHIPMOVEMENT ) { + // MessageBodyShipMovement m( &msgs[ i ][ 0 ] ); + // std::cout << m << std::endl; + // } + + switch ( msgs[ i ][ 0 ] ){ + case PROTO_CHAT:{ + resources_.network->ping(); + MessageBodyChat msg( &msgs[ i ][ 0 ] ); + log_->chat( resources_.network->userName( msg.senderID() ), msg.message() ); + } break; + case PROTO_SHIP_REGISTER: + if ( sector ) sector->receiveVesselRegister( &msgs[ i ][ 0 ] ); break; + case PROTO_SHIP_DEREGISTER: + if ( sector ) sector->receiveVesselDeRegister( &msgs[ i ][ 0 ] ); break; + case PROTO_SHIP_DIED: + if ( sector ) sector->receiveVesselDied( &msgs[ i ][ 0 ] ); break; + case PROTO_SHIP_STATUS: + if ( sector ) sector->receiveVesselStatus( &msgs[ i ][ 0 ] ); break; + case PROTO_SHIP_MOVEMENT:{ + //** we handle that in sum, so we can ignore dups because of packet loss + MessageBodyShipMovement *msg = new MessageBodyShipMovement( &msgs[ i ][ 0 ] ); + movements.push_back( msg ); + } break; + case PROTO_SHIP_PROJECTILEFIRED: + if ( sector ) sector->receiveProjectile( &msgs[ i ][ 0 ] ); break; + case PROTO_SHIP_AMMOHIT: + if ( sector ) sector->receiveVesselAmmoHit( &msgs[ i ][ 0 ] ); break; + default: + std::cerr << "PROTO type unknown: " << msgs[ i ][ 0 ] << " " << msgs[ i ].size() << std::endl; + break; + } + } + if ( movements.size() > 0 && sector ) sector->receiveVesselMovement( movements ); + } + return true; +} + +GameState * GameStateManager::findByName( const std::string & stateName ) { + for ( std::vector< StateInfo >::iterator itr = states_.begin(); itr != states_.end(); itr++ ) { + if ( itr->name == stateName ) + return itr->state; + } + log_->fatal( std::string( "Cannot find gamestate: " ) + stateName ); + log_->fatal( "Available states: " ); + for ( std::vector< StateInfo >::iterator itr = states_.begin(); itr != states_.end(); itr++ ) { + log_->fatal( std::string( "\t" ) + itr->name ) ; + } + return NULL; +} + +void GameStateManager::changeGameState( GameState * state ){ + // cleanup the current game state + if ( !stateStack_.empty() ) { + cleanup_( stateStack_.back() ); + if ( stateStack_.back()->rootWindow() ) stateStack_.back()->rootWindow()->removeChildWindow( configDialog_->rootWindow() ); + stateStack_.back()->exit(); + stateStack_.pop_back(); + } + + // store and init the new state + stateStack_.push_back( state ); + stateStack_.back()->enter(); + if ( stateStack_.back()->rootWindow() ) stateStack_.back()->rootWindow()->addChildWindow( configDialog_->rootWindow() ); + init_( state ); +} + +bool GameStateManager::pushGameState( GameState * state ){ + // pause current game state + if ( !stateStack_.empty() ) { + if ( !stateStack_.back()->pause() ){ + return false; + } + cleanup_( stateStack_.back() ); + } + + // store and init the new state + stateStack_.push_back( state ); + init_( state ); + stateStack_.back()->enter(); + + return true; +} + +void GameStateManager::popGameState( ) { + // cleanup the current game state + if ( !stateStack_.empty() ) { + cleanup_( stateStack_.back() ); + stateStack_.back()->exit(); + stateStack_.pop_back(); + } + + // resume previous game state or quit if there isn't one + if ( !stateStack_.empty() ) { + init_( stateStack_.back() ); + stateStack_.back()->resume(); + } else { + shutdown(); + } +} + +void GameStateManager::shutdown( ){ + shutdownRequest_ = true; +} + +void GameStateManager::init_( GameState * state ) { + resources_.ogreRoot->addFrameListener( state ); +} + +void GameStateManager::cleanup_( GameState * state ){ + resources_.ogreRoot->removeFrameListener( state ); +} + void GameStateManager::CMD_shutdown( const std::vector < std::string > & argv ){ shutdown(); } Modified: trunk/src/GameStateManager.h =================================================================== --- trunk/src/GameStateManager.h 2008-05-18 19:29:16 UTC (rev 899) +++ trunk/src/GameStateManager.h 2008-05-18 19:30:59 UTC (rev 900) @@ -57,10 +57,15 @@ /*! Destructor that cleans up the states before the instance dies. */ ~GameStateManager(); + /*! Init ogre root and call initialiseOgreEngine_. */ + bool initialiseBootstrap( bool dialog ); + + /*! Init ogre bootstrap resoucees for the init state. */ + bool initialiseBootstrapResources( ); + + /*! Init the callback list for loading the game resouces. */ void initLoadingVector(); - bool initialiseBootstrap( bool dialog ); - bool initialiseBootstrapResources( ); bool initialiseAllResources(); bool checkRenderSystemCapabilities( ); bool initialiseOgreResources( ); @@ -131,6 +136,7 @@ /*! This removes event handling from a previous state. */ void cleanup_( GameState * state ); + /*! Read ogre ogre.cfg and configure the engine e.g. screen resoulution. If there is no ogre.cfg it will create. */ bool initialiseOgreEngine_( bool dialog ); LogManager * log_; Modified: trunk/src/InputManager.h =================================================================== --- trunk/src/InputManager.h 2008-05-18 19:29:16 UTC (rev 899) +++ trunk/src/InputManager.h 2008-05-18 19:30:59 UTC (rev 900) @@ -49,6 +49,7 @@ * * \author Carsten <spo...@us...> */ + class InputManager : public Ogre::Singleton< InputManager >, public OIS::KeyListener, public OIS::MouseListener, Modified: trunk/src/KeyMap.cpp =================================================================== --- trunk/src/KeyMap.cpp 2008-05-18 19:29:16 UTC (rev 899) +++ trunk/src/KeyMap.cpp 2008-05-18 19:30:59 UTC (rev 900) @@ -18,9 +18,9 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ -#include "UnDockedState.h" #include "KeyMap.h" #include "InputManager.h" +#include "UnDockedState.h" #include "Console.h" namespace OpenGate{ Modified: trunk/src/KeyMap.h =================================================================== --- trunk/src/KeyMap.h 2008-05-18 19:29:16 UTC (rev 899) +++ trunk/src/KeyMap.h 2008-05-18 19:30:59 UTC (rev 900) @@ -22,18 +22,17 @@ #define _OPENGATE_KEYMAP__H #include <map> -// #include "InputManager.h" - #include "UnDockedState.h" +//#include "InputManager.h" +namespace OIS{ + class KeyEvent; +} + namespace OpenGate{ class UnDockedState; class Console; -// namespace OIS{ -// class KeyEvent; -// } - template < class Object, typename returnT, typename Args > class memberBind { public: typedef returnT( Object::*F )( Args ); Modified: trunk/src/Makefile.am =================================================================== --- trunk/src/Makefile.am 2008-05-18 19:29:16 UTC (rev 899) +++ trunk/src/Makefile.am 2008-05-18 19:30:59 UTC (rev 900) @@ -104,9 +104,9 @@ $(ogreopcode_LIBS) opengateclient_CXXFLAGS = \ - $(OGRE_CFLAGS) \ - $(CEGUI_CFLAGS) \ - $(ogreopcode_CFLAGS) + $(OGRE_CFLAGS) \ + $(CEGUI_CFLAGS) \ + $(ogreopcode_CFLAGS) opengateserver_SOURCES = \ opengateserver.cpp \ @@ -126,8 +126,8 @@ opengateserver_LDFLAGS = \ $(ogreopcode_LIBS) -opengateserver_CXXFLAGS = \ - $(ogreopcode_CFLAGS) +# opengateserver_CXXFLAGS = \ +# $(ogreopcode_CFLAGS) # testaimanager_SOURCES = \ # testaimanager.cpp \ Modified: trunk/src/MarketDialog.h =================================================================== --- trunk/src/MarketDialog.h 2008-05-18 19:29:16 UTC (rev 899) +++ trunk/src/MarketDialog.h 2008-05-18 19:30:59 UTC (rev 900) @@ -21,10 +21,16 @@ #ifndef _OPENGATE_MARKETDIALOG__H #define _OPENGATE_MARKETDIALOG__H -#include <vector> #include "BaseDialog.h" #include "EntityManager.h" +namespace CEGUI{ + class Listbox; + class EventArgs; +} + +#include <vector> + namespace OpenGate{ /*! Modified: trunk/src/Moveable.cpp =================================================================== --- trunk/src/Moveable.cpp 2008-05-18 19:29:16 UTC (rev 899) +++ trunk/src/Moveable.cpp 2008-05-18 19:30:59 UTC (rev 900) @@ -20,6 +20,7 @@ #include "Moveable.h" #include "common.h" +#include "LogManager.h" #include <OgreMeshManager.h> Modified: trunk/src/OpcodeWrapper.h =================================================================== --- trunk/src/OpcodeWrapper.h 2008-05-18 19:29:16 UTC (rev 899) +++ trunk/src/OpcodeWrapper.h 2008-05-18 19:30:59 UTC (rev 900) @@ -23,6 +23,7 @@ #include <OgreSingleton.h> #include <OgrePrerequisites.h> +// #include <OgreOpcode.h> namespace OgreOpcode{ class CollisionContext; Modified: trunk/src/OpenALSoundManager.h =================================================================== --- trunk/src/OpenALSoundManager.h 2008-05-18 19:29:16 UTC (rev 899) +++ trunk/src/OpenALSoundManager.h 2008-05-18 19:30:59 UTC (rev 900) @@ -31,9 +31,6 @@ #include <ogg/ogg.h> #include <vorbis/codec.h> -//#include <vorbis/vorbisenc.h> -//#endif - #include <vorbis/vorbisfile.h> namespace OpenGate { Modified: trunk/src/ResourceManager.cpp =================================================================== --- trunk/src/ResourceManager.cpp 2008-05-18 19:29:16 UTC (rev 899) +++ trunk/src/ResourceManager.cpp 2008-05-18 19:30:59 UTC (rev 900) @@ -62,6 +62,20 @@ delete keymap_; } +void ResourceManager::addResourceLocation( const std::string & path, const std::string & group ){ + resourceLocations_[ group ].insert( path ); +} + +std::set < std::string > & ResourceManager::resourceLocations( const std::string & group ) { + if ( resourceLocations_.count( group ) == 0 ){ + throw std::length_error( "ResourceManager::resourceLocations( group ) no group: " + group ); + } + if ( resourceLocations_[ group ].empty() ){ + throw std::length_error( "ResourceManager::resourceLocations( group ) will return an empty set for group " + group ); + } + return resourceLocations_[ group ]; +} + std::string ResourceManager::factionName( int id ) { if ( factionIDs_.count( id ) ){ return factionIDs_[ id ]; @@ -120,11 +134,11 @@ std::string ResourceManager::findFullFileName( const std::string & fileName ){ - Ogre::FileSystemArchive pArch = Ogre::FileSystemArchive( (*resourcePaths_.begin()), "FileSystem" ); + Ogre::FileSystemArchive pArch = Ogre::FileSystemArchive( (*resourceLocations_["General"].begin()), "FileSystem" ); Ogre::StringVectorPtr file = pArch.find( fileName, true, false); if ( (*file).size() > 0 ){ - return (*resourcePaths_.begin() ) + "/" + (*file)[ 0 ] ; + return (*resourceLocations_["General"].begin() ) + "/" + (*file)[ 0 ] ; } // for ( unsigned int i = 0; i < (*file).size(); i ++ ){ @@ -135,13 +149,13 @@ void ResourceManager::load( const std::string & resourceName ){ - Ogre::FileSystemArchive * pArch = new Ogre::FileSystemArchive( (*resourcePaths_.begin()) + "/" + resourceName, "FileSystem" ); + Ogre::FileSystemArchive * pArch = new Ogre::FileSystemArchive( (*resourceLocations_["General"].begin()) + "/" + resourceName, "FileSystem" ); Ogre::StringVectorPtr files = pArch->find( "*.xml", true, false); for ( unsigned int i = 0; i < (*files).size(); i ++ ){ if ( (*files)[ i ].rfind( ".mesh.xml" ) == std::string::npos ){ log_->fout( std::string( "Found ressource: " ) + (*files)[ i ] ); - loadAndCreate( (*resourcePaths_.begin()) + "/" + resourceName + "/" + (*files)[ i ] ); + loadAndCreate( (*resourceLocations_["General"].begin()) + "/" + resourceName + "/" + (*files)[ i ] ); } } Modified: trunk/src/ResourceManager.h =================================================================== --- trunk/src/ResourceManager.h 2008-05-18 19:29:16 UTC (rev 899) +++ trunk/src/ResourceManager.h 2008-05-18 19:30:59 UTC (rev 900) @@ -30,8 +30,6 @@ namespace OpenGate{ -enum GunType{UNKNOWN,LASER,MININGLASER,BULLET}; - /*! * \brief This is a global storage for all and everything; * @@ -89,8 +87,12 @@ /*! Find file in resources and returns full name */ std::string findFullFileName( const std::string & fileName ); - std::set < std::string > & resourcePaths() { return resourcePaths_; } - + /*! Return the set of known resource paths, maybee this this can be saver by using ogre resource Manager directly instead of holding our own set. Maybee deprecated.*/ + std::set < std::string > & resourceLocations( const std::string & group ); + + /*! Add path to the opengate resources. Usually set by ogre resource initialisation. Maybee deprecated. */ + void addResourceLocation( const std::string & path, const std::string & group ); + void setMappingCapability( bool mapping ) { mapping_ = mapping; } bool mappingCapability() const { return mapping_; } @@ -112,7 +114,7 @@ std::string languageSuffix_; std::map< int, std::string > factionIDs_; - std::set< std::string > resourcePaths_; + std::map< std::string, std::set< std::string > > resourceLocations_; std::map< std::string, Entity * > stations_; Modified: trunk/src/Sector.cpp =================================================================== --- trunk/src/Sector.cpp 2008-05-18 19:29:16 UTC (rev 899) +++ trunk/src/Sector.cpp 2008-05-18 19:30:59 UTC (rev 900) @@ -1018,7 +1018,7 @@ void Sector::sendProjectile( const Projectile & projectile ){ MessageBodyShipProjectileFired msg( projectile.parent().childID(), projectile.shotCount(), - projectile.mainNode().getWorldPosition().ptr(), + Ogre::Vector3( projectile.mainNode()->getWorldPosition() ).ptr(), projectile.velocity().ptr(), projectile.gun()->id(), projectile.damage(), projectile.lifeTime() ); network_->send( msg ); Modified: trunk/src/SectorObject.h =================================================================== --- trunk/src/SectorObject.h 2008-05-18 19:29:16 UTC (rev 899) +++ trunk/src/SectorObject.h 2008-05-18 19:30:59 UTC (rev 900) @@ -60,7 +60,7 @@ virtual bool update( Ogre::Real elapsedTime ){ return true; } void setShape( const Ogre::String & meshname ); - void setShape( Ogre::MeshPtr & mesh ); + virtual Ogre::Entity * entity(){ return entity_; } void scale( const Ogre::Vector3 & scale ); Modified: trunk/src/SectorObjectMissile.cpp =================================================================== --- trunk/src/SectorObjectMissile.cpp 2008-05-18 19:29:16 UTC (rev 899) +++ trunk/src/SectorObjectMissile.cpp 2008-05-18 19:30:59 UTC (rev 900) @@ -21,6 +21,7 @@ #include "SectorObjectMissile.h" #include "OpcodeWrapper.h" #include "Vessel.h" +#include "ResourceManager.h" #include <OgreParticleSystem.h> #include <OgreParticleEmitter.h> Modified: trunk/src/SectorObjectMoveable.cpp =================================================================== --- trunk/src/SectorObjectMoveable.cpp 2008-05-18 19:29:16 UTC (rev 899) +++ trunk/src/SectorObjectMoveable.cpp 2008-05-18 19:30:59 UTC (rev 900) @@ -113,7 +113,7 @@ armor_ = maxArmor_; thrust_ = 0; maxThrust_ = 0; - thrustRate_ = 0; + thrustRate_ = 0.0; shieldGlowActive_ = false; shieldGlowTime_ = 0.0; @@ -344,8 +344,9 @@ if ( breakStatus != breakPressed_ ) statusChanged_ = true; if ( breakStatus == true ){ - thrust_ = 0; updateThruster(); - thrustRate_ = 0; + thrust_ = 0; + thrustRate_ = 0.0; + updateThruster(); } breakPressed_ = breakStatus; } @@ -394,7 +395,7 @@ int nEmits = thrusterParticles_->getNumEmitters( ); // Ogre::Real thrustRate = 0.0; // if ( maxThrust() > 0 ) thrustRate = (float)thrust_ / maxThrust_ * 100.0; - // std::cout << "SectorObjectMoveable::updateThruster()" << name_ << " " << thrustRate_ << " " << nEmits << std::endl; + std::cout << "SectorObjectMoveable::updateThruster()" << name_ << " " << thrustRate_ << " " << nEmits << std::endl; for ( int i = 0; i < nEmits; i ++ ){ Ogre::ParticleEmitter * pEmit; Modified: trunk/src/ShipConfigDialog.cpp =================================================================== --- trunk/src/ShipConfigDialog.cpp 2008-05-18 19:29:16 UTC (rev 899) +++ trunk/src/ShipConfigDialog.cpp 2008-05-18 19:30:59 UTC (rev 900) @@ -38,6 +38,8 @@ #include <OgreCEGUITexture.h> #include <CEGUIWindow.h> +#include <CEGUIWindowManager.h> +#include <CEGUIImageset.h> #include <CEGUI/elements/CEGUIPushButton.h> Modified: trunk/src/ShipConfigDialog.h =================================================================== --- trunk/src/ShipConfigDialog.h 2008-05-18 19:29:16 UTC (rev 899) +++ trunk/src/ShipConfigDialog.h 2008-05-18 19:30:59 UTC (rev 900) @@ -24,9 +24,16 @@ #include "BaseDialog.h" #include "Entity.h" -#include <OgrePrerequisites.h> +// #include <OgrePrerequisites.h> #include <OgreRenderTargetListener.h> +namespace CEGUI{ + class Listbox; + class PushButton; + class EventArgs; + class OgreCEGUITexture; +} + namespace OpenGate{ class Entity; Modified: trunk/src/UnDockedState.cpp =================================================================== --- trunk/src/UnDockedState.cpp 2008-05-18 19:29:16 UTC (rev 899) +++ trunk/src/UnDockedState.cpp 2008-05-18 19:30:59 UTC (rev 900) @@ -23,6 +23,7 @@ #include "AiManager.h" #include "AiObject.h" #include "Avatar.h" +#include "GameStateManager.h" #include "Sector.h" #include "networkProtocol.h" #include "networkClient.h" Modified: trunk/src/Vessel.h =================================================================== --- trunk/src/Vessel.h 2008-05-18 19:29:16 UTC (rev 899) +++ trunk/src/Vessel.h 2008-05-18 19:30:59 UTC (rev 900) @@ -22,7 +22,6 @@ #define _OPENGATE_VESSEL__H #include "Moveable.h" -#include <OgreMesh.h> #include <map> #include <vector> Modified: trunk/src/commonWithOgre.cpp =================================================================== --- trunk/src/commonWithOgre.cpp 2008-05-18 19:29:16 UTC (rev 899) +++ trunk/src/commonWithOgre.cpp 2008-05-18 19:30:59 UTC (rev 900) @@ -24,6 +24,8 @@ #include <OgreVector3.h> #include <OgreMovableObject.h> +namespace OpenGate{ + void dumpSceneNodes( std::stringstream & ss, Ogre::Node * n, int level ) { for ( int i = 0; i < level; i++ ) { ss << " "; @@ -52,3 +54,5 @@ dumpSceneNodes( ss, n, 0 ); return ss.str(); } + +} // namespace OpenGate Modified: trunk/src/commonWithOgre.h =================================================================== --- trunk/src/commonWithOgre.h 2008-05-18 19:29:16 UTC (rev 899) +++ trunk/src/commonWithOgre.h 2008-05-18 19:30:59 UTC (rev 900) @@ -52,7 +52,7 @@ /*! For debugging purposes dump scene node tree to a string */ void dumpSceneNodes( std::stringstream & ss, Ogre::Node * n, int level ); -// /*! For debugging purposes dump scene node tr... [truncated message content] |
From: <spo...@us...> - 2008-05-14 21:50:36
|
Revision: 898 http://opengate.svn.sourceforge.net/opengate/?rev=898&view=rev Author: spom_spom Date: 2008-05-14 14:50:43 -0700 (Wed, 14 May 2008) Log Message: ----------- update beacon_2.blend Modified Paths: -------------- templates/misc/beacon_2.blend Modified: templates/misc/beacon_2.blend =================================================================== (Binary files differ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
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 setListener( UnDockedState * listener ){ listener_ = listener; } UnDockedState * listener( ){ return listener_; } + + /*! Set the name of this sector */ + void setName( const std::string & name ) { name_ = name; } + + /*! Return the name of this sector. Set during population from xml-file */ + std::string name() const { return name_; } void update( Ogre::Real elapsedTime ); @@ -65,6 +71,8 @@ const Ogre::Vector3 & pos, const Ogre::Vector3 & targetSize, Ogre::Degree yaw ); SectorObject * createStation( const Ogre::String & stationName, Ogre::Vector3 & pos ); + + SectorObject * createBeacon( const Ogre::Vector3 & pos ); SectorObjectMoveable * createMoveable( const Ogre::String & name, Uint32 userId, Uint8 childId, Moveable & moveable ); @@ -119,38 +127,38 @@ StationObject * station() { return station_; } protected: - + //** do not destruct objects manualy, let them send false during update loop void destruct_( SectorObject * obj ); - Ogre::SceneManager * sceneMgr_; - NetworkClient * network_; - LogManager * log_; + Ogre::SceneManager * sceneMgr_; + NetworkClient * network_; + LogManager * log_; - UnDockedState * listener_; + UnDockedState * listener_; - std::string sectorname_; + std::string name_; - SectorObjectAvatar * avatar_; - Planet * planet_; + SectorObjectAvatar * avatar_; + Planet * planet_; - Ogre::SceneNode * starsNode_; - Ogre::SceneNode * koordAxisNode_; - Ogre::ManualObject * koordAxisMO_; - - std::set< SectorObject * > sectorObjects_; + Ogre::SceneNode * starsNode_; + Ogre::SceneNode * koordAxisNode_; + Ogre::ManualObject * koordAxisMO_; - std::map< long, SectorObjectMoveable * > movableObjects_; - std::map< long, SectorObjectMissile * > localAiObjects_; + std::set< SectorObject * > sectorObjects_; - float avatarDeathSequenceTime_; + std::map< long, SectorObjectMoveable * > movableObjects_; + std::map< long, SectorObjectMissile * > localAiObjects_; - bool radar_ ; + float avatarDeathSequenceTime_; - StationObject * station_; - - std::map< std::string, std::deque< SectorObject * > > objectHeap_; - uint childIDCounter_; + bool radar_ ; + + StationObject * station_; + + std::map< std::string, std::deque< SectorObject * > > objectHeap_; + uint childIDCounter_; }; } // namespace OpenGate Modified: trunk/src/SectorObject.cpp =================================================================== --- trunk/src/SectorObject.cpp 2008-05-12 16:19:10 UTC (rev 896) +++ trunk/src/SectorObject.cpp 2008-05-14 21:33:27 UTC (rev 897) @@ -31,7 +31,7 @@ namespace OpenGate{ SectorObject::SectorObject( const Ogre::String & name, Sector * sector, Uint32 userID, Uint8 childID ) - : BaseObject( name, sector, userID, childID ), target_( NULL ) { __D( name ) + : BaseObject( name, sector, userID, childID ), target_( NULL ), entity_( NULL ) { __D( name ) isOnRadar_ = false; mainNodeEntityScale_ = mainNode_->createChildSceneNode( name_ + "_baseScale" ); @@ -65,8 +65,10 @@ ResourceManager::getSingleton().collisionManager->destroyObject( this ); - mainNodeEntityRot_->detachObject( entity_ ); - sceneMgr_->destroyEntity( entity_ ); + if ( entity_ ){ + mainNodeEntityRot_->detachObject( entity_ ); + sceneMgr_->destroyEntity( entity_ ); + } mainNodeEntityScale_->removeAndDestroyChild( mainNodeEntityRot_->getName() ); mainNode_->removeAndDestroyChild( mainNodeEntityScale_->getName() ); @@ -78,12 +80,23 @@ if ( target_ ){ std::cerr << WHERE_AM_I << "*************** this should not happen" << " " << target_->name() << std::endl; } else { - target_ == NULL; + target_ = NULL; } } void SectorObject::setShape( const Ogre::String & meshname ){ - entity_ = sceneMgr_->createEntity( name_ + "_shape", meshname ); + try { + entity_ = sceneMgr_->createEntity( name_ + "_shape", meshname ); + } catch( Ogre::Exception & e ){ + LogManager::getSingleton().warn( e.what() ); + entity_ = NULL; + return ; + } catch( ... ){ + LogManager::getSingleton().warn( "Unknown exception" ); + entity_ = NULL; + return ; + } + mainNodeEntityRot_->attachObject( entity_ ); ResourceManager::getSingleton().collisionManager->createObject( this ); } Modified: trunk/src/SectorObject.h =================================================================== --- trunk/src/SectorObject.h 2008-05-12 16:19:10 UTC (rev 896) +++ trunk/src/SectorObject.h 2008-05-14 21:33:27 UTC (rev 897) @@ -51,7 +51,12 @@ virtual void collide( BaseObject * object ){ // std::cout << "SectorObject " << name_ << " collide with " << object->rtti() << " " << object->name()<< std::endl; } - + + /*! Return pointer to the active sector.*/ + Sector * sector() { return sector_; } + + Ogre::SceneNode * rotnode() { return mainNodeEntityRot_;} + virtual bool update( Ogre::Real elapsedTime ){ return true; } void setShape( const Ogre::String & meshname ); @@ -97,19 +102,21 @@ virtual void inititialize_(); - Ogre::SceneNode * mainNodeEntityScale_; // Main character node for base size - Ogre::SceneNode * mainNodeEntityRot_; // Main character node for base rotation - Ogre::Entity * entity_; + SectorObject * target_; + Ogre::Entity * entity_; + + Ogre::SceneNode * mainNodeEntityScale_; // Main character node for base size + Ogre::SceneNode * mainNodeEntityRot_; // Main character node for base rotation + + Ogre::OverlayElement * dotA_; + Ogre::OverlayElement * dotB_; - Ogre::OverlayElement * dotA_; - Ogre::OverlayElement * dotB_; - bool isOnRadar_; Ogre::Vector3 baseSize_; Ogre::Vector3 baseScale_; std::set < SectorObject * > observers_; // better listener / e.g. radar - SectorObject * target_; + }; Modified: trunk/src/SectorObjectMissile.cpp =================================================================== --- trunk/src/SectorObjectMissile.cpp 2008-05-12 16:19:10 UTC (rev 896) +++ trunk/src/SectorObjectMissile.cpp 2008-05-14 21:33:27 UTC (rev 897) @@ -110,7 +110,7 @@ Ogre::Real scaledYaw = yawTo.valueDegrees() / ( elapsedTime * rotFric * moveable_->yaw() ); Ogre::Real scaledPitch = pitchTo.valueDegrees() / ( elapsedTime * rotFric * moveable_->pitch() ); - Ogre::Real scaledRoll = rollTo.valueDegrees() / ( elapsedTime * rotFric * moveable_->yaw() ); + // Ogre::Real scaledRoll = rollTo.valueDegrees() / ( elapsedTime * rotFric * moveable_->yaw() ); yaw_ = max( -1.0f, scaledYaw ); yaw_ = min( yaw_, 1.0f ); pitch_ = max( -1.0f, scaledPitch ); pitch_ = min( pitch_, 1.0f ); @@ -149,7 +149,7 @@ thrustTrail_->setMaterialName( "BeamGreen" ); thrustTrail_->setTrailLength( 1000 ); thrustTrail_->setColourChange( 0, Ogre::ColourValue( 0.0, 0.0, 0.0, 0.3 ) ); - thrustTrail_->setWidthChange( 0, 0.5 ); + thrustTrail_->setWidthChange( 0, 0.3 ); thrustTrail_->setMaxChainElements( 100 ); thrustTrail_->setInitialWidth( 0, 1.0 ); thrustTrail_->addNode( mainNode_ ); Modified: trunk/src/SectorObjectMoveable.cpp =================================================================== --- trunk/src/SectorObjectMoveable.cpp 2008-05-12 16:19:10 UTC (rev 896) +++ trunk/src/SectorObjectMoveable.cpp 2008-05-14 21:33:27 UTC (rev 897) @@ -97,7 +97,7 @@ void SectorObjectMoveable::inititialize_(){ - if ( moveable_ ) maxArmor_ = moveable_->armor(); else maxArmor_ = 1.0; + if ( moveable_ ) maxArmor_ = moveable_->armor(); else maxArmor_ = 1; if ( moveable_ ) maxSpeed_ = moveable_->maxSpeed(); else maxSpeed_ = 0.0; mass_ = 1; @@ -130,7 +130,7 @@ netSequence_ = 0; lifeTime_ = 0.0; lastLifeTime_ = 0.0; - forceMovement_ = false; + forceMovement_ = true; statusChanged_ = false; selectable_ = true; @@ -150,7 +150,7 @@ } if ( destroyRequest_ || destroyWithExplosion_ ){ - ResourceManager::getSingleton().collisionManager->dettach( this ); + ResourceManager::getSingleton().collisionManager->detach( this ); this->unsubscribeToObservers(); @@ -220,7 +220,7 @@ if ( speed > maxSpeed() ){ vel_ *= maxSpeed() / speed; - } else if ( speed < 0.1 ){ + } else if ( speed < 0.01 ){ vel_ *= 0.0; } @@ -231,9 +231,6 @@ Ogre::Ray rayNoNextPos( mainNode_->getWorldPosition(), vel_.normalisedCopy() ); ResourceManager::getSingleton().collisionManager->checkCollideRay( this, rayNoNextPos, (vel_ * elapsedTime).length() ); } - - - // //** snap quaternion // Ogre::Quaternion rnd( mainNode_->getOrientation() ); @@ -246,15 +243,20 @@ void SectorObjectMoveable::setFlightProperties( const MessageBodyShipMovement & msg ){ setThrustRate( msg.thrustRate() ); + thrust_ = msg.thrust(); + + updateThruster(); + + std::cout << name_ << " " << msg << std::endl; if ( forceMovement_ ){ - mainNode_->setPosition( toOgreVec( msg.position() ) ); - mainNode_->setOrientation( toOgreQuat( msg.orientation() ) ); - vel_ = toOgreVec( msg.velocity() ); - setScaledYaw( msg.yaw() ); - setScaledPitch( msg.pitch() ); - setScaledRoll( msg.roll() ); - forceMovement_ = false; - } else { + mainNode_->setPosition( toOgreVec( msg.position() ) ); + mainNode_->setOrientation( toOgreQuat( msg.orientation() ) ); + vel_ = toOgreVec( msg.velocity() ); + setScaledYaw( msg.yaw() ); + setScaledPitch( msg.pitch() ); + setScaledRoll( msg.roll() ); + forceMovement_ = false; + } else { // if ( ( fabs( msg.yaw() ) -1.0f ) < 1e-4 ) { // setScaledYaw( msg.yaw() ); @@ -272,36 +274,36 @@ // setScaledRoll( 0.0 ); // } - setScaledYaw( msg.yaw() ); - setScaledRoll( msg.roll() ); - setScaledPitch( msg.pitch() ); + setScaledYaw( msg.yaw() ); + setScaledRoll( msg.roll() ); + setScaledPitch( msg.pitch() ); - vel_ = toOgreVec( msg.velocity() ); + vel_ = toOgreVec( msg.velocity() ); - Ogre::Vector3 srcP( mainNode_->getPosition( ) ); - Ogre::Quaternion srcQ( mainNode_->getOrientation( ) ); - Ogre::Vector3 destP( toOgreVec( msg.position( ) ) ); + Ogre::Vector3 srcP( mainNode_->getPosition( ) ); + Ogre::Quaternion srcQ( mainNode_->getOrientation( ) ); + Ogre::Vector3 destP( toOgreVec( msg.position( ) ) ); - //** try Slerp - Ogre::Quaternion diff = Ogre::Quaternion::nlerp( 1, srcQ, toOgreQuat( msg.orientation() ) ); - interpolateRot_ = diff * srcQ.Inverse(); + //** try Slerp + Ogre::Quaternion diff = Ogre::Quaternion::nlerp( 1, srcQ, toOgreQuat( msg.orientation() ) ); + interpolateRot_ = diff * srcQ.Inverse(); // if ( msg.childID() > 0 ){ - if ( !1 ){ + if ( !1 ){ - std::cout << std::endl; - std::cout << msg.sequenceNr() << "LastFrameCount: " << lastFrameCount_ - << " life: " << lifeTime_ << " last: " << lastLifeTime_ - << " diff: "<< lifeTime_ - lastLifeTime_ << std::endl; + std::cout << std::endl; + std::cout << msg.sequenceNr() << "LastFrameCount: " << lastFrameCount_ + << " life: " << lifeTime_ << " last: " << lastLifeTime_ + << " diff: "<< lifeTime_ - lastLifeTime_ << std::endl; // std::cout << "Ist: " << mainNode_->getOrientation( ) // << " " << mainNode_->getOrientation( ).getYaw().valueDegrees() << std::endl; // std::cout << "Soll: " << msg.orientation() << " " << msg.orientation().getYaw().valueDegrees() << std::endl; - std::cout << "Diff: send: " << msg.yaw() << " " << msg.pitch() << " " << msg.roll() << std::endl; + std::cout << "Diff: send: " << msg.yaw() << " " << msg.pitch() << " " << msg.roll() << std::endl; - std::cout << "Diff: Pos: " << (srcP-destP).length() + std::cout << "Diff: Pos: " << (srcP-destP).length() << " Y:" << interpolateRot_.getYaw().valueDegrees() << " P:" << interpolateRot_.getPitch().valueDegrees() << " R:" << interpolateRot_.getRoll().valueDegrees() << std::endl; Modified: trunk/src/SectorObjectMoveable.h =================================================================== --- trunk/src/SectorObjectMoveable.h 2008-05-12 16:19:10 UTC (rev 896) +++ trunk/src/SectorObjectMoveable.h 2008-05-14 21:33:27 UTC (rev 897) @@ -100,6 +100,8 @@ /*! Return the maximum thrust */ inline Uint32 maxThrust() const { return maxThrust_; } + inline Uint32 thrust() const { return thrust_; } + /*! Update visual feedback for thrusters */ void updateThruster(); @@ -113,6 +115,9 @@ inline Ogre::Real speed() const { return vel_.length(); } /*! Returns the maximum speed depend on vessel and mounted engine */ + inline void setMaxSpeed( Ogre::Real speed ) { maxSpeed_ = speed; } + + /*! Returns the maximum speed depend on vessel and mounted engine */ inline Ogre::Real maxSpeed() const { return maxSpeed_; } /*! Returns the relative speed */ Modified: trunk/src/SectorObjectVessel.cpp =================================================================== --- trunk/src/SectorObjectVessel.cpp 2008-05-12 16:19:10 UTC (rev 896) +++ trunk/src/SectorObjectVessel.cpp 2008-05-14 21:33:27 UTC (rev 897) @@ -101,12 +101,12 @@ if ( this->vessel()->engine() ){ maxThrust_ = this->vessel()->engine()->maxThrust(); } else { - maxThrust_ = 0.0; + maxThrust_ = 0; } if ( this->vessel()->shield() ) { maxShield_ = this->vessel()->shield()->maxDeflection(); } else { - maxShield_ = 0.0; + maxShield_ = 0; } controler_ = NULL; Modified: trunk/src/Station.cpp =================================================================== --- trunk/src/Station.cpp 2008-05-12 16:19:10 UTC (rev 896) +++ trunk/src/Station.cpp 2008-05-14 21:33:27 UTC (rev 897) @@ -76,12 +76,12 @@ ibuf->unlock(); } -StationPad::StationPad( const std::string & name, StationObject * station, Ogre::SubEntity * padSubEntity, bool docking ) - : BaseObject( name, station->sector() ), station_( station ), docking_( docking ){ +Pad::Pad( const std::string & name, SectorObject * parent, Ogre::SubEntity * padSubEntity ) + : BaseObject( name, parent->sector() ), parent_( parent ){ //** hier gibt es eine mainNode die nicht genutzt wird. C. //** mach das sauber!! ersetzt getPosition, getDirection, padNode - padNode_ = station_->rotnode()->createChildSceneNode( station_->name() + "/" + name_ ); + padNode_ = parent_->rotnode()->createChildSceneNode( parent_->name() + "/" + name_ ); padManualObject_ = sceneMgr_->createManualObject( padNode_->getName() + "/ManualObject" ); std::vector < Ogre::Vector3 > verts; @@ -122,24 +122,33 @@ padEntity_ = sceneMgr_->createEntity( padMesh_->getName() + "/Entity", padMesh_->getName() ); padNode_->attachObject( padEntity_ ); padNode_->translate( direction_.normalisedCopy() * 0.1 ); - if ( docking_ ){ - ResourceManager::getSingleton().collisionManager->createObject( this ); - } } - -StationPad::~StationPad( ){ - ResourceManager::getSingleton().collisionManager->destroyObject( this ); + +Pad::~Pad( ){ padNode_->detachObject( padEntity_ ); sceneMgr_->destroyEntity( padEntity_ ); Ogre::MeshManager::getSingleton().remove( padMesh_->getName() ); sceneMgr_->destroyManualObject( padManualObject_ ); - station_->rotnode()->removeAndDestroyChild( padNode_->getName() ); + parent_->rotnode()->removeAndDestroyChild( padNode_->getName() ); } +StationPad::StationPad( const std::string & name, StationObject * station, Ogre::SubEntity * padSubEntity, + bool docking ) + : Pad( name, station, padSubEntity), docking_( docking ){ + + if ( docking_ ){ + ResourceManager::getSingleton().collisionManager->createObject( this ); + } +} + +StationPad::~StationPad( ){ + ResourceManager::getSingleton().collisionManager->destroyObject( this ); +} + void StationPad::collide( BaseObject * object ){ - if ( docking_ ) { if ( object->rtti() == AVATAR_RTTI ){ + std::cout << "StationPad::collide() docking request for " << object->name() << std::endl; sector_->listener()->changeToDockedState(); } else if ( object->rtti() == SECTOROBJECTVESSEL_RTTI ){ std::cout << "StationPad::collide() docking request for " << object->name() << std::endl; @@ -190,7 +199,7 @@ dockPad_ = new StationPad( name_ + "DockPad", this, entity()->getSubEntity( i ), true ); } if ( entity()->getSubEntity( i )->getMaterialName() == "Station/LaunchPad.001" ){ - launchPad_ = new StationPad( name_ + "LaunchPad", this, entity()->getSubEntity( i ) ); + launchPad_ = new StationPad( name_ + "LaunchPad", this, entity()->getSubEntity( i ), false ); } } @@ -346,4 +355,98 @@ ringNode_->attachObject( ringEntity_ ); } +BeaconPad::BeaconPad( const std::string & name, BeaconObject * beacon, Ogre::SubEntity * padSubEntity ) + : Pad( name, beacon, padSubEntity){ + + ResourceManager::getSingleton().collisionManager->createObject( this ); +} + +BeaconPad::~BeaconPad( ){ + ResourceManager::getSingleton().collisionManager->destroyObject( this ); +} + +void BeaconPad::collide( BaseObject * object ){ + if ( object->rtti() == AVATAR_RTTI ){ + std::cout << "BeaconPad::collide() bcu for " << object->name() << std::endl; + } else if ( object->rtti() == SECTOROBJECTVESSEL_RTTI ){ + std::cout << "BeaconPad::collide() bcu for " << object->name() << std::endl; + } +} + +void BeaconPad::changeEntity( const std::string & meshname ){ + ResourceManager::getSingleton().collisionManager->detach( this ); + padNode_->detachObject( padEntity_ ); + sceneMgr_->destroyEntity( padEntity_ ); + padEntity_ = sceneMgr_->createEntity( name_ + "/Entity", meshname ); + padNode_->attachObject( padEntity_ ); + padNode_->translate( position_ ); + ResourceManager::getSingleton().collisionManager->attach( this ); +} + + +BeaconObject::BeaconObject( Sector * sector ) + : SectorObject ( sector->name() + "/Beacon ", sector ), entryPad_( NULL ), exitPad_( NULL ) { + + Ogre::MeshPtr pMesh = Ogre::MeshManager::getSingleton().load( "beacon.mesh", + Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, + Ogre::HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY, + Ogre::HardwareBuffer::HBU_STATIC_WRITE_ONLY, + true, true); + + unsigned short src = 0, dest = 0; + if ( !pMesh->suggestTangentVectorBuildParams( Ogre::VES_TANGENT, src, dest) ) { + pMesh->buildTangentVectors( Ogre::VES_TANGENT, src, dest); + } + setShape( "beacon.mesh" ); + //entity_->setMaterialName( "Sta/TS/Background" ); + + for ( uint i = 0; i < entity()->getNumSubEntities(); i ++ ){ + std::cout << entity()->getSubEntity( i )->getMaterialName() << " Techniques: " + << entity()->getSubEntity( i )->getMaterial()->getNumTechniques() << " used: " + << entity()->getSubEntity( i )->getTechnique()->getName() << std::endl; + + if ( entity()->getSubEntity( i )->getMaterialName() == "beacon/bg" ){ + entity()->getSubEntity( i )->setMaterialName( "Sta/TS/Background" ); + } + + if ( entity()->getSubEntity( i )->getMaterialName() == "beacon/pad_mount_0" ){ + entity()->getSubEntity( i )->setMaterialName( "singleColor" ); + entity()->getSubEntity( i )->setCustomParameter( 0, Ogre::Vector4( 0.5, 0.5, 0.5, 1.0 ) ); + entryPad_ = new BeaconPad( "EntryPad", this, entity()->getSubEntity( i ) ); + entryPad_->changeEntity( "beacon_pad.mesh" ); + entryPad_->entity()->setMaterialName( "singleColor" ); + entryPad_->entity()->getSubEntity( 0 )->setCustomParameter( 0, Ogre::Vector4( 0.8, 0.0, 0.0, 0.2 ) ); + } + if ( entity()->getSubEntity( i )->getMaterialName() == "beacon/pad_mount_1" ){ + entity()->getSubEntity( i )->setMaterialName( "singleColor" ); + entity()->getSubEntity( i )->setCustomParameter( 0, Ogre::Vector4( 0.5, 0.5, 0.5, 1.0 ) ); + exitPad_ = new BeaconPad( "ExitPad", this, entity()->getSubEntity( i ) ); + exitPad_->changeEntity( "beacon_pad.mesh" ); + exitPad_->entity()->setMaterialName( "singleColor" ); + exitPad_->entity()->getSubEntity( 0 )->setCustomParameter( 0, Ogre::Vector4( 0.8, 0.0, 0.0, 0.2 ) ); + } + } + + +// std::vector < Ogre::Vector3 > verts; +// std::vector < Triangle > tris; +// readSubEntity( entity_, verts, tris ); + + + +} + +BeaconObject::~BeaconObject( ){ + if ( entryPad_ ) delete entryPad_; + if ( exitPad_ ) delete exitPad_; +} + +Ogre::Vector3 BeaconObject::entrancePosition() const { + return Ogre::Vector3::ZERO; +} + +Ogre::Vector3 BeaconObject::exitPosition() const { + return Ogre::Vector3::ZERO; +} + } // namespace OpenGate Modified: trunk/src/Station.h =================================================================== --- trunk/src/Station.h 2008-05-12 16:19:10 UTC (rev 896) +++ trunk/src/Station.h 2008-05-14 21:33:27 UTC (rev 897) @@ -31,8 +31,11 @@ namespace OpenGate{ class Station; +class Pad; class StationPad; +class BeaconPad; class StationObject; +class BeaconObject; struct Triangle{ int a, b, c; @@ -52,14 +55,12 @@ protected: }; -/*! A station pad is a plain area where vessel dock or launch */ -class StationPad : public BaseObject{ +class Pad : public BaseObject { public: /*! Constructor, with a name, */ - StationPad( const std::string & name, StationObject * station, Ogre::SubEntity * padSubEntity, - bool docking = false ); + Pad( const std::string & name, SectorObject * parent, Ogre::SubEntity * padSubEntity ); /*! Destructor */ - virtual ~StationPad( ); + virtual ~Pad( ); /*! Return runtime type information */ virtual long rtti() const { return STATIONPAD_RTTI; } @@ -67,7 +68,7 @@ virtual std::string collisionClass() const { return "DockPad"; } /*! What happen on collision */ - void collide( BaseObject * object ); + virtual void collide( BaseObject * object ){} /*! Update the pad in each frame */ virtual bool update( Ogre::Real elapsedTime ){ return true; } @@ -80,16 +81,13 @@ /*! Radius of the pad */ Ogre::Real radius() const { return radius_; } - - bool isDocking( ) const { return docking_; } Ogre::SceneNode * padNode(){ return padNode_; } virtual Ogre::Entity * entity( ) { return padEntity_; } protected: - StationObject * station_; - bool docking_; + SectorObject * parent_; Ogre::SceneNode * padNode_; Ogre::ManualObject * padManualObject_; Ogre::MeshPtr padMesh_; @@ -99,6 +97,22 @@ Ogre::Vector3 direction_; Ogre::Real radius_; }; + +/*! A station pad is a plain area where vessel dock or launch */ +class StationPad : public Pad { +public: + /*! Constructor, with a name, */ + StationPad( const std::string & name, StationObject * station, Ogre::SubEntity * padSubEntity, + bool docking = false ); + /*! Destructor */ + virtual ~StationPad( ); + + /*! What to do on collision */ + void collide( BaseObject * object ); + +protected: + bool docking_; +}; //** derive from dockable so sector can handle set of dockables class StationObject : public SectorObject{ @@ -142,11 +156,6 @@ /*! Docking rings end position respectively outer position of the dockingtube*/ Ogre::Vector3 dockingRingEnd( ) const ; - /*! Return pointer to the active sector.*/ - Sector * sector() { return sector_; } - - Ogre::SceneNode * rotnode() { return mainNodeEntityRot_;} - protected: Station * station_; Ogre::SceneNode * ringNode_; @@ -159,9 +168,43 @@ StationPad * dockPad_; StationPad * launchPad_; //StationDockPad * dockPad_; +}; + +/*! A station pad is a plain area where vessel dock or launch */ +class BeaconPad : public Pad{ +public: + /*! Constructor, with a name, */ + BeaconPad( const std::string & name, BeaconObject * station, Ogre::SubEntity * padSubEntity ); + + /*! Destructor */ + virtual ~BeaconPad( ); + + /*! What happen on collision */ + void collide( BaseObject * object ); + + void changeEntity( const std::string & meshname ); + +protected: }; +class BeaconObject : public SectorObject { +public: + BeaconObject( Sector * sector ); + + virtual ~BeaconObject( ); + + /*! Return entrance position in world coordinates */ + Ogre::Vector3 entrancePosition() const; + + /*! Return exit position in world coordinates */ + Ogre::Vector3 exitPosition() const; + +protected: + BeaconPad * entryPad_; + BeaconPad * exitPad_; +}; + } // namespace OpenGate #endif //_OPENGATE_STATION__H Modified: trunk/src/UnDockedState.cpp =================================================================== --- trunk/src/UnDockedState.cpp 2008-05-12 16:19:10 UTC (rev 896) +++ trunk/src/UnDockedState.cpp 2008-05-14 21:33:27 UTC (rev 897) @@ -771,7 +771,7 @@ } void UnDockedState::setTarget( SectorObject * target ) { - SectorObject * oldTarget = target_; + // SectorObject * oldTarget = target_; target_ = target; if ( target_ != NULL ){ Modified: trunk/src/Vessel.cpp =================================================================== --- trunk/src/Vessel.cpp 2008-05-12 16:19:10 UTC (rev 896) +++ trunk/src/Vessel.cpp 2008-05-14 21:33:27 UTC (rev 897) @@ -25,28 +25,29 @@ #include <OgreMeshManager.h> namespace OpenGate{ - + Vessel::Vessel( ) : Moveable() { - rtti_ = VESSEL; - fixEquipment_ = false; + rtti_ = VESSEL; + fixEquipment_ = false; - amountModX_ = 0; + amountModX_ = 0; amountMissiles_ = 0; - - shieldSize_ = 0; - radarSize_ = 0; - engineSize_ = 0; - capacitorSize_ = 0; + + shieldSize_ = 0; + radarSize_ = 0; + engineSize_ = 0; + capacitorSize_ = 0; powerPlantSize_ = 0; - cargoSize_ = 0; - ecmSize_ = 0; - missileSize_ = 0; - powerPlant_ = NULL; - engine_ = NULL; - radar_ = NULL; - ecm_ = NULL; - shield_ = NULL; - capacitor_ = NULL; + cargoSize_ = 0; + ecmSize_ = 0; + missileSize_ = 0; + + powerPlant_ = NULL; + engine_ = NULL; + radar_ = NULL; + ecm_ = NULL; + shield_ = NULL; + capacitor_ = NULL; } std::vector < Ogre::Vector3 > findMountPoints( TiXmlHandle * hRoot, const std::string & key ){ @@ -60,7 +61,7 @@ return mountPoints; } -bool Vessel::readPropertiesFromXML( TiXmlHandle & hRoot ){ +void Vessel::readPropertiesFromXML( TiXmlHandle & hRoot ){ Moveable::readPropertiesFromXML( hRoot ); readXMLNode< int >( hRoot, "modx", this, &OpenGate::Vessel::setAmountModX, false ); @@ -262,7 +263,7 @@ } Ogre::Real Vessel::maxSpeed() const { - if ( engine_ ) return sqrt( engine_->maxThrust() / dragFactor() ); + if ( engine_ ) return std::sqrt( engine_->maxThrust() / dragFactor() ); return 0.0; } @@ -273,7 +274,7 @@ lifetime_ = 1; } -bool Missile::readPropertiesFromXML( TiXmlHandle & hRoot ){ +void Missile::readPropertiesFromXML( TiXmlHandle & hRoot ){ Moveable::readPropertiesFromXML( hRoot ); readXMLNode< int >( hRoot, "damage", this, &OpenGate::Missile::setDamage, false ); Modified: trunk/src/Vessel.h =================================================================== --- trunk/src/Vessel.h 2008-05-12 16:19:10 UTC (rev 896) +++ trunk/src/Vessel.h 2008-05-14 21:33:27 UTC (rev 897) @@ -67,94 +67,93 @@ /*! Desctructor */ virtual ~Vessel(){} - bool readPropertiesFromXML( TiXmlHandle & hRoot ); + virtual void readPropertiesFromXML( TiXmlHandle & hRoot ); inline void setFixEquipment( bool fix ) { fixEquipment_ = fix; } - inline bool fixEquipment( ) const { return fixEquipment_ ; } + inline bool fixEquipment( ) const { return fixEquipment_ ; } - inline void setPowerPlantSize( int size ){ powerPlantSize_ = size; } - inline int powerPlantSize( ) const { return powerPlantSize_; } - bool setPowerPlant( PowerPlant * item ); - inline PowerPlant * powerPlant( ){ return powerPlant_; } + inline void setPowerPlantSize( int size ){ powerPlantSize_ = size; } + inline int powerPlantSize( ) const { return powerPlantSize_; } + bool setPowerPlant( PowerPlant * item ); + inline PowerPlant * powerPlant( ){ return powerPlant_; } - inline void setEngineSize( int size ){ engineSize_ = size; } - inline int engineSize( ) const { return engineSize_; } - bool setEngine( Engine * item ); - inline Engine * engine( ){ return engine_; } + inline void setEngineSize( int size ){ engineSize_ = size; } + inline int engineSize( ) const { return engineSize_; } + bool setEngine( Engine * item ); + inline Engine * engine( ){ return engine_; } - inline void setRadarSize( int size ){ radarSize_ = size; } - inline int radarSize( ) const { return radarSize_; } - bool setRadar( Radar * item ); - inline Radar * radar( ){ return radar_; } + inline void setRadarSize( int size ){ radarSize_ = size; } + inline int radarSize( ) const { return radarSize_; } + bool setRadar( Radar * item ); + inline Radar * radar( ){ return radar_; } - inline void setEcmSize( int size ){ ecmSize_ = size; } - inline int ecmSize( ) const { return ecmSize_; } - bool setEcm( Ecm *... [truncated message content] |
From: <spo...@us...> - 2008-05-12 16:19:09
|
Revision: 896 http://opengate.svn.sourceforge.net/opengate/?rev=896&view=rev Author: spom_spom Date: 2008-05-12 09:19:10 -0700 (Mon, 12 May 2008) Log Message: ----------- Just another fix Modified Paths: -------------- trunk/src/OpcodeWrapper.cpp trunk/src/SectorObjectMissile.cpp trunk/src/SectorObjectMoveable.cpp Modified: trunk/src/OpcodeWrapper.cpp =================================================================== --- trunk/src/OpcodeWrapper.cpp 2008-05-12 13:50:09 UTC (rev 895) +++ trunk/src/OpcodeWrapper.cpp 2008-05-12 16:19:10 UTC (rev 896) @@ -108,7 +108,9 @@ void OpcodeCollisionDetection::createObject( BaseObject * obj ){ if ( obj && active_ ){ - if ( !obj->collisionObject() ){ + OgreOpcode::CollisionObject * collObj = obj->collisionObject(); + + if ( !collObj ){ OgreOpcode::EntityCollisionShape * collShape = collisionManager_->createEntityCollisionShape( obj->name() + "/CollShape" ); if ( obj->entity() ){ @@ -117,12 +119,13 @@ std::cout << "OpcodeCollisionDetection::createObject( BaseObject * obj ), no entity defined for obj: " << obj->name(); } - OgreOpcode::CollisionObject * collObj = collideInSectorContext_->createObject( obj->name() + "/CollObj" ); - collObj->setContext( collideInSectorContext_ ); + collObj = collideInSectorContext_->createObject( obj->name() + "/CollObj" ); collObj->setCollClass( collisionManager_->queryCollClass( obj->collisionClass() ) ); collObj->setShape( collShape ); + + collObj->setClientData( obj ); collideInSectorContext_->addObject( collObj ); - collObj->setClientData( obj ); + obj->setCollisionObject( collObj ); } } @@ -131,14 +134,14 @@ void OpcodeCollisionDetection::destroyObject( BaseObject * obj ){ if ( obj && active_ ){ - if ( obj->collisionObject() ){ - - OgreOpcode::CollisionObject * collObj = obj->collisionObject(); + OgreOpcode::CollisionObject * collObj = obj->collisionObject(); + if ( collObj ){ OgreOpcode::ICollisionShape * shape = collObj->getShape(); collideInSectorContext_->destroyObject( collObj ); - + collisionManager_->detachShape( shape ); collisionManager_->destroyShape( shape ); + obj->setCollisionObject( NULL ); } } @@ -164,9 +167,11 @@ uint nColl = collideInSectorContext_->rayCheck( ray, rayLength, OgreOpcode::COLLTYPE_EXACT, OgreOpcode::COLLTYPE_ALWAYS_EXACT, rayPickReport ); - std::cout << "OpcodeCollisionDetection::checkCollideRay()" << " " << rayLength << " " << nColl <<std::endl; + // std::cout << "OpcodeCollisionDetection::checkCollideRay()" << " " << rayLength << " " << nColl <<std::endl; for ( uint i = 0; i < nColl; i ++ ){ +/* std::cout << "OpcodeCollisionDetection::checkCollideRay()" << " " << rayLength << " " << nColl <<std::endl;*/ + OgreOpcode::CollisionObject* col1 = rayPickReport[ i ]->this_object; OgreOpcode::CollisionObject* col2 = rayPickReport[ i ]->other_object; Modified: trunk/src/SectorObjectMissile.cpp =================================================================== --- trunk/src/SectorObjectMissile.cpp 2008-05-12 13:50:09 UTC (rev 895) +++ trunk/src/SectorObjectMissile.cpp 2008-05-12 16:19:10 UTC (rev 896) @@ -148,7 +148,8 @@ thrustTrail_ = sceneMgr_->createRibbonTrail( name_ + "_RibbonTrail"); thrustTrail_->setMaterialName( "BeamGreen" ); thrustTrail_->setTrailLength( 1000 ); - thrustTrail_->setWidthChange( 0, 2.0 ); + thrustTrail_->setColourChange( 0, Ogre::ColourValue( 0.0, 0.0, 0.0, 0.3 ) ); + thrustTrail_->setWidthChange( 0, 0.5 ); thrustTrail_->setMaxChainElements( 100 ); thrustTrail_->setInitialWidth( 0, 1.0 ); thrustTrail_->addNode( mainNode_ ); Modified: trunk/src/SectorObjectMoveable.cpp =================================================================== --- trunk/src/SectorObjectMoveable.cpp 2008-05-12 13:50:09 UTC (rev 895) +++ trunk/src/SectorObjectMoveable.cpp 2008-05-12 16:19:10 UTC (rev 896) @@ -183,40 +183,53 @@ //** friction = drag * v^2; Ogre::Real v = speed(); - Ogre::Real friction = ethernalDensity_ * moveable_->dragFactor() * v * v; + double friction = ethernalDensity_ * moveable_->dragFactor() * v * v; - Ogre::Vector3 trustDir( mainNode_->getWorldOrientation().zAxis().normalisedCopy() ); - Ogre::Vector3 flightDir( vel_ ); flightDir.normalise(); - + Ogre::Vector3 thrustDir( mainNode_->getWorldOrientation().zAxis().normalisedCopy() ); + Ogre::Vector3 flightDir( vel_.normalisedCopy() ); + + thrustDir.x = round( thrustDir.x, 7 ); thrustDir.y = round( thrustDir.y, 7 ); thrustDir.z = round( thrustDir.z, 7 ); + flightDir.x = round( flightDir.x, 7 ); flightDir.y = round( flightDir.y, 7 ); flightDir.z = round( flightDir.z, 7 ); + + //** thrust = mass * a; if ( mass_ > 0 ){ - acc_ = ( - trustDir * thrust_ - flightDir * friction ) / mass_; + acc_ = ( - thrustDir * (double)thrust_ - flightDir * friction ) / mass_; } else { LogManager::getSingleton().fatal( name_ + " mass: " + toStr( mass_ ) ); } - if ( breakPressed_ == true ) { - if ( speed() > 0 ) { - acc_ -= flightDir * brakingAcc(); - } - } // if ( thrust_ > 0 ){ +// std::cout << name_ << " " << thrustDir << " " << flightDir << " " << thrustDir + flightDir << std::endl; // std::cout << name_ << " " << acc_.normalisedCopy() << " " << vel_.normalisedCopy() << std::endl; // std::cout << name_ << " " << acc_ << " " << vel_ << std::endl; // std::cout << yaw_ << " " << pitch_ << " " << roll_ << std::endl; // std::cout << thrust_ << " " << moveable_->dragFactor() << " " << breakPressed_ // << " " << friction << " " << v << " " << mass_ << std::endl; // } - //** v = a * t; - vel_ += acc_ * elapsedTime; - mainNode_->translate( ( vel_ + interpolateVel_ ) * elapsedTime ); + if ( breakPressed_ == true ) { + if ( speed() > 0 ) { + acc_ -= flightDir * brakingAcc(); + } + } + + //** v = a * t; + vel_ += acc_ * elapsedTime; + double speed = vel_.length(); + + if ( speed > maxSpeed() ){ + vel_ *= maxSpeed() / speed; + } else if ( speed < 0.1 ){ + vel_ *= 0.0; + } + + mainNode_->translate( ( vel_ + interpolateVel_ ) * elapsedTime ); + //** because of the discrete jumps between to frames we have to check for collisions via ray; if ( collObj_ ){ - //Ogre::Ray rayNoNextPos( mainNode_->getPosition(), vel_.normalisedCopy() ); - - //** bitte bitte check, ob das vor oder nach dem Move soll bzw, ob die richtung stimmt - //OpcodeCollisionDetection::getSingleton().checkCollideRay( this, rayNoNextPos, (vel_ * elapsedTime).length() ); + Ogre::Ray rayNoNextPos( mainNode_->getWorldPosition(), vel_.normalisedCopy() ); + ResourceManager::getSingleton().collisionManager->checkCollideRay( this, rayNoNextPos, (vel_ * elapsedTime).length() ); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <spo...@us...> - 2008-05-12 13:50:50
|
Revision: 895 http://opengate.svn.sourceforge.net/opengate/?rev=895&view=rev Author: spom_spom Date: 2008-05-12 06:50:09 -0700 (Mon, 12 May 2008) Log Message: ----------- Add firefly.xml Added Paths: ----------- trunk/data/missiles/firefly.xml Added: trunk/data/missiles/firefly.xml =================================================================== --- trunk/data/missiles/firefly.xml (rev 0) +++ trunk/data/missiles/firefly.xml 2008-05-12 13:50:09 UTC (rev 895) @@ -0,0 +1,31 @@ +<?xml version="1.0"?> + +<container> + <object_id>10001</object_id> + <name_de>firefly</name_de> + <name_en>firefly</name_en> + <mesh>firefly</mesh> + <category_id>11</category_id> + <faction_id>3</faction_id> + <description_en>Defense anti missile missile</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>10</mass> + <thrust>350000</thrust> + <damage>1000</damage> + <yaw>150</yaw> + <pitch>150</pitch> + <roll>150</roll> + <armor>10</armor> + <lifetime>20</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> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <spo...@us...> - 2008-05-12 13:08:07
|
Revision: 894 http://opengate.svn.sourceforge.net/opengate/?rev=894&view=rev Author: spom_spom Date: 2008-05-12 06:08:10 -0700 (Mon, 12 May 2008) Log Message: ----------- Cleaning opcodewrapper and remove a related bug Modified Paths: -------------- trunk/src/AiCommands.cpp trunk/src/AiCommands.h trunk/src/BaseObject.cpp trunk/src/BaseObject.h trunk/src/OpcodeWrapper.cpp trunk/src/OpcodeWrapper.h trunk/src/Sector.cpp trunk/src/SectorObject.cpp trunk/src/SectorObject.h trunk/src/SectorObjectMissile.cpp trunk/src/SectorObjectMoveable.cpp trunk/src/SectorObjectVessel.cpp trunk/src/Station.cpp trunk/src/Station.h Modified: trunk/src/AiCommands.cpp =================================================================== --- trunk/src/AiCommands.cpp 2008-05-11 22:19:57 UTC (rev 893) +++ trunk/src/AiCommands.cpp 2008-05-12 13:08:10 UTC (rev 894) @@ -31,7 +31,7 @@ namespace OpenGate{ void AiCommandStop::start(){ - std::cout << "AiCommandStop start" << std::endl; + std::cout << "AiCommandStop start" << std::endl; if ( ai_->vesselObject( ) ) ai_->vesselObject( )->setThrustRate( 0.0 ); if ( turnaround_ ){ addCommand( new AiCommandPitch( ai_, 180.0 ) ); @@ -40,9 +40,9 @@ addCommand( new AiCommandStop( ai_ ) ); } else { 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; +// 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(); } } @@ -56,10 +56,10 @@ std::cout << "AiCommandStop stop" << std::endl; if ( ai_->vesselObject( ) ) { ai_->vesselObject( )->setBreakPressed( false ); - std::cout << "braking time real: " << runtime_ << std::endl; - std::cout << "braking way real: " - << ( ai_->vesselObject( )->mainNode()->getWorldPosition()- startPos_ ).length() - << std::endl; +// std::cout << "braking time real: " << runtime_ << std::endl; +// std::cout << "braking way real: " +// << ( ai_->vesselObject( )->mainNode()->getWorldPosition()- startPos_ ).length() +// << std::endl; } } @@ -95,14 +95,14 @@ std::cout << "AiCommandLookAt::start()" << std::endl; if ( ai_->vesselObject() ){ if ( isPosition_ ) { - std::cout << "ai pos: " << ai_->vesselObject()->mainNode()->getWorldPosition() << std::endl; - std::cout << "target: " << targetDir_ << std::endl; +// std::cout << "ai pos: " << ai_->vesselObject()->mainNode()->getWorldPosition() << std::endl; +// std::cout << "target: " << targetDir_ << std::endl; targetDir_ = targetDir_ - ai_->vesselObject()->mainNode()->getWorldPosition(); } targetDir_.normalise(); - std::cout << "ai dir: " << ai_->vesselObject()->mainNode()->getWorldOrientation() - * Ogre::Vector3::NEGATIVE_UNIT_Z << std::endl; - std::cout << "target: " << targetDir_ << std::endl; +// std::cout << "ai dir: " << ai_->vesselObject()->mainNode()->getWorldOrientation() +// * Ogre::Vector3::NEGATIVE_UNIT_Z << std::endl; +// std::cout << "target: " << targetDir_ << std::endl; } } bool AiCommandLookAt::update( ){ @@ -199,8 +199,8 @@ 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; +// std::cout << "curr: " << ai_->vesselObject()->mainNode()->getWorldOrientation() +// * Ogre::Vector3::NEGATIVE_UNIT_Z << std::endl; } } @@ -247,10 +247,10 @@ std::cout << "AiCommandTimedAccelerate stop" << std::endl; if ( ai_->vesselObject( ) ){ ai_->vesselObject( )->setThrustRate( 0.0 ); - std::cout << " reclined way(real): " - << (ai_->vesselObject( )->mainNode()->getWorldPosition()- initPos_).length() << std::endl; - std::cout << " reclined way(ana): " - << ai_->wayAfterTime( runtime_, rate_ ) << std::endl; +// std::cout << " reclined way(real): " +// << (ai_->vesselObject( )->mainNode()->getWorldPosition()- initPos_).length() << std::endl; +// std::cout << " reclined way(ana): " +// << ai_->wayAfterTime( runtime_, rate_ ) << std::endl; } } @@ -285,10 +285,10 @@ void AiCommandAccelerate::stop(){ std::cout << "AiCommandAccelerate::stop" << std::endl; if ( ai_->vesselObject( ) ) ai_->vesselObject( )->setThrustRate( 0.0 ); - std::cout << " reclined way(real): " - << (ai_->vesselObject( )->mainNode()->getWorldPosition()- initPos_).length() << std::endl; - std::cout << " reclined way(ana): " - << ai_->wayAfterTime( runtime_, thrustRate_ ) << std::endl; +// std::cout << " reclined way(real): " +// << (ai_->vesselObject( )->mainNode()->getWorldPosition()- initPos_).length() << std::endl; +// std::cout << " reclined way(ana): " +// << ai_->wayAfterTime( runtime_, thrustRate_ ) << std::endl; } @@ -297,9 +297,9 @@ 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; +// 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 ) ); @@ -318,7 +318,7 @@ } if ( ai_->vesselObject( )->speed() < 0.05 ){ - std::cout << "dist: " << dist << std::endl; +// std::cout << "dist: " << dist << std::endl; if ( dist < 10.0 ) { // 10m snapping return false; } else { @@ -339,12 +339,12 @@ std::cout << "AiCommandApproach::stop():" << std::endl; 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_->vesselObject( )->mainNode()->getWorldOrientation().zAxis() - << std::endl; +// 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_->vesselObject( )->mainNode()->getWorldOrientation().zAxis() +// << std::endl; } } Modified: trunk/src/AiCommands.h =================================================================== --- trunk/src/AiCommands.h 2008-05-11 22:19:57 UTC (rev 893) +++ trunk/src/AiCommands.h 2008-05-12 13:08:10 UTC (rev 894) @@ -81,9 +81,9 @@ bool abort( ) { abort_ = true; } - virtual void start() { std::cout << "AiCommand start" << std::endl; } + virtual void start() { std::cout << "AiCommand start (virtual) " << std::endl; } virtual bool update( ) { return false; } - virtual void stop() { std::cout << "AiCommand stop" << std::endl; } + virtual void stop() { std::cout << "AiCommand stop (virtual)" << std::endl; } void addCommand( AiCommand * cmd ) { cmdQueue_.push_back( cmd ); } Modified: trunk/src/BaseObject.cpp =================================================================== --- trunk/src/BaseObject.cpp 2008-05-11 22:19:57 UTC (rev 893) +++ trunk/src/BaseObject.cpp 2008-05-12 13:08:10 UTC (rev 894) @@ -63,4 +63,8 @@ } } +void BaseObject::destroy(){ + destroyRequest_ = true; +} + } // namespace OpenGate Modified: trunk/src/BaseObject.h =================================================================== --- trunk/src/BaseObject.h 2008-05-11 22:19:57 UTC (rev 893) +++ trunk/src/BaseObject.h 2008-05-12 13:08:10 UTC (rev 894) @@ -91,7 +91,7 @@ /*! Mark the object for destruction To keep destruction thread safe, we just notify and let the update cycle do the job */ - void destroy() { destroyRequest_ = true; } + void destroy(); bool isSetDestroyRequest() const { return destroyRequest_; } @@ -101,6 +101,14 @@ inline virtual bool isActive() const { return active_; } + OgreOpcode::CollisionObject * collisionObject( ){ return collObj_; } + + void setCollisionObject( OgreOpcode::CollisionObject * obj ){ collObj_ = obj; } + + virtual std::string collisionClass() const { return "SectorObject"; } + + virtual Ogre::Entity * entity(){ return NULL; } + protected: virtual void deactivate_(){ } Modified: trunk/src/OpcodeWrapper.cpp =================================================================== --- trunk/src/OpcodeWrapper.cpp 2008-05-11 22:19:57 UTC (rev 893) +++ trunk/src/OpcodeWrapper.cpp 2008-05-12 13:08:10 UTC (rev 894) @@ -71,10 +71,6 @@ void OpcodeCollisionDetection::free( ){ - std::vector< OgreOpcode::CollisionObject * > activeObjects( collideInSectorContext_->getAttachedObjects() ); - - std::cout << "OpcodeCollisionDetection::free( ) " << activeObjects.size() << std::endl; - if ( collisionManager_ ) delete collisionManager_; collisionManager_ = NULL; } @@ -87,91 +83,79 @@ int nCollids = report.getNumCollisions(); if ( nCollids > 0 ){ - // std::cout << "Collisions: " << nCollids << std::endl; +// std::cout << "OpcodeCollisionDetection::update() " << nCollids << std::endl; OgreOpcode::CollisionPair **collisionReport; report.getAllCollisions( collisionReport ); - for ( int i = 0; i < nCollids; i ++ ){ - OgreOpcode::CollisionObject* col1 = collisionReport[ i ]->this_object; - OgreOpcode::CollisionObject* col2 = collisionReport[ i ]->other_object; - - static_cast< BaseObject * >( col1->getClientData() )->collide( static_cast< BaseObject * >( + for ( int i = 0; i < nCollids; i ++ ){ + OgreOpcode::CollisionObject* col1 = collisionReport[ i ]->this_object; + OgreOpcode::CollisionObject* col2 = collisionReport[ i ]->other_object; + +// std::cout << i << ": "<< col1->getName() << "<->" << col2->getName() << std::endl; + + static_cast< BaseObject * >( col1->getClientData() )->collide( static_cast< BaseObject * >( col2->getClientData() ) ); - static_cast< BaseObject * >( col2->getClientData() )->collide( static_cast< BaseObject * >( + static_cast< BaseObject * >( col2->getClientData() )->collide( static_cast< BaseObject * >( col1->getClientData() ) ); - } - -// std::cout << "CollisionContext attached objects: " + Ogre::StringConverter::toString(collideInSectorContext_->getAttachedObjectCount()) << std::endl; -// std::cout << "CollisionContext owned objects: " + Ogre::StringConverter::toString(collideInSectorContext_->getOwnedObjectCount()) << std::endl; -// std::cout << "CollisionManager shapes: " + Ogre::StringConverter::toString(collisionManager_->getShapeCount())<< std::endl; - + } } // if ncols } return true; } -OgreOpcode::CollisionObject * OpcodeCollisionDetection::createObject( Ogre::Entity * entity, BaseObject * obj, - const std::string & collClass ){ - OgreOpcode::CollisionObject * collObj = NULL; +void OpcodeCollisionDetection::createObject( BaseObject * obj ){ - if ( active_ ){ - OgreOpcode::EntityCollisionShape * collShape = collisionManager_->createEntityCollisionShape( obj->name() + "/CollShape" ); - collShape->load( entity ); + if ( obj && active_ ){ + if ( !obj->collisionObject() ){ + + OgreOpcode::EntityCollisionShape * collShape = collisionManager_->createEntityCollisionShape( obj->name() + "/CollShape" ); + if ( obj->entity() ){ + collShape->load( obj->entity() ); + } else { + std::cout << "OpcodeCollisionDetection::createObject( BaseObject * obj ), no entity defined for obj: " << obj->name(); + } - collObj = collideInSectorContext_->createObject( obj->name() + "/CollObj" ); - collObj->setCollClass( collisionManager_->queryCollClass( collClass ) ); - collObj->setShape( collShape ); - collideInSectorContext_->addObject( collObj ); - attachedSet_.insert( collObj ); - collObj->setClientData( obj ); + OgreOpcode::CollisionObject * collObj = collideInSectorContext_->createObject( obj->name() + "/CollObj" ); + collObj->setContext( collideInSectorContext_ ); + collObj->setCollClass( collisionManager_->queryCollClass( obj->collisionClass() ) ); + collObj->setShape( collShape ); + collideInSectorContext_->addObject( collObj ); + collObj->setClientData( obj ); + obj->setCollisionObject( collObj ); + } } - return collObj; } -OgreOpcode::CollisionObject * OpcodeCollisionDetection::createObject( SectorObject * obj ){ - return createObject( obj->entity(), obj, "SectorObject" ); +void OpcodeCollisionDetection::destroyObject( BaseObject * obj ){ + + if ( obj && active_ ){ + if ( obj->collisionObject() ){ + + OgreOpcode::CollisionObject * collObj = obj->collisionObject(); + OgreOpcode::ICollisionShape * shape = collObj->getShape(); + collideInSectorContext_->destroyObject( collObj ); + + collisionManager_->detachShape( shape ); + collisionManager_->destroyShape( shape ); + obj->setCollisionObject( NULL ); + } + } } -void OpcodeCollisionDetection::dettach( OgreOpcode::CollisionObject * obj ){ +void OpcodeCollisionDetection::dettach( SectorObject * obj ){ if ( obj && active_ ){ - - if ( attachedSet_.find( obj ) != attachedSet_.end() ){ - // std::cout << "dettach"<< std::endl; - collideInSectorContext_->removeObject( obj ); - attachedSet_.erase( obj ); - } + destroyObject( obj ); } } -void OpcodeCollisionDetection::attach( OgreOpcode::CollisionObject * obj ){ +void OpcodeCollisionDetection::attach( SectorObject * obj ){ if ( obj && active_ ){ - - if ( attachedSet_.find( obj ) == attachedSet_.end() ){ - - collideInSectorContext_->addObject( obj ); - attachedSet_.insert( obj ); - } + createObject( obj ); } } -void OpcodeCollisionDetection::destroyObject( OgreOpcode::CollisionObject * obj ){ - - if ( active_ ){ - OgreOpcode::ICollisionShape * shape = obj->getShape(); - if ( obj && attachedSet_.find( obj ) == attachedSet_.end() ){ - attach( obj ); - } - collideInSectorContext_->destroyObject( obj ); - attachedSet_.erase( obj ); - - collisionManager_->detachShape( shape ); - collisionManager_->destroyShape( shape ); - obj = NULL; - } -} - bool OpcodeCollisionDetection::checkCollideRay( BaseObject * obj, const Ogre::Ray & ray, double rayLength){ if ( active_ ){ if ( !obj->isSetDestroyRequest() ){ @@ -180,7 +164,7 @@ uint nColl = collideInSectorContext_->rayCheck( ray, rayLength, OgreOpcode::COLLTYPE_EXACT, OgreOpcode::COLLTYPE_ALWAYS_EXACT, rayPickReport ); - // std::cout << "checkCollideRay: " << " " << rayLength << " " << nColl <<std::endl; + std::cout << "OpcodeCollisionDetection::checkCollideRay()" << " " << rayLength << " " << nColl <<std::endl; for ( uint i = 0; i < nColl; i ++ ){ OgreOpcode::CollisionObject* col1 = rayPickReport[ i ]->this_object; @@ -208,22 +192,22 @@ return false; } -void OpcodeCollisionDetection::changeCollClass( OgreOpcode::CollisionObject * collObj, const std::string & collClass ){ - if ( collObj ) collObj->setCollClass( collisionManager_->queryCollClass( collClass ) ); +void OpcodeCollisionDetection::info( ){ + std::cout << "OpcodeCollisionDetection::info( )" << std::endl; + + std::vector< OgreOpcode::CollisionObject * > activeObjects( collideInSectorContext_->getAttachedObjects() ); + std::cout << "CollisionContext attached objects: " + Ogre::StringConverter::toString(collideInSectorContext_->getAttachedObjectCount()) << std::endl; + for ( uint i = 0; i < activeObjects.size(); i ++ ){ + std::cout << i << ": " << activeObjects[ i ]->getName() << std::endl; + } + + std::vector< OgreOpcode::CollisionObject * > ownedObjects( collideInSectorContext_->getOwnedObjects() ); + std::cout << "CollisionContext owned objects: " + Ogre::StringConverter::toString(collideInSectorContext_->getOwnedObjectCount()) << std::endl; + for ( uint i = 0; i < ownedObjects.size(); i ++ ){ + std::cout << i << ": " << ownedObjects[ i ]->getName() << std::endl; + } + std::cout << "CollisionManager shapes: " + Ogre::StringConverter::toString(collisionManager_->getShapeCount())<< std::endl; + } -// OpcodeCollisionDetection & OpcodeCollisionDetection::getSingleton( ){ -// assert( ms_Singleton ); -// return ( *ms_Singleton ); -// } -// -// OpcodeCollisionDetection * OpcodeCollisionDetection::getSingletonPtr( ){ -// if ( ms_Singleton == NULL ){ -// std::cerr << "OpcodeCollisionDetection not initialized." << std::endl; -// return NULL; -// } -// return ms_Singleton; -// } - - } // namespace OpenGate{ Modified: trunk/src/OpcodeWrapper.h =================================================================== --- trunk/src/OpcodeWrapper.h 2008-05-11 22:19:57 UTC (rev 893) +++ trunk/src/OpcodeWrapper.h 2008-05-12 13:08:10 UTC (rev 894) @@ -50,27 +50,22 @@ bool update( Ogre::Real elapsedTime ); - OgreOpcode::CollisionObject * createObject( Ogre::Entity * entity, BaseObject * obj, const std::string & collClass ); - - OgreOpcode::CollisionObject * createObject( SectorObject * obj ); + void createObject( BaseObject * obj ); - void destroyObject( OgreOpcode::CollisionObject * obj ); + void destroyObject( BaseObject * obj ); - void dettach( OgreOpcode::CollisionObject * obj ); + void dettach( SectorObject * obj ); - void attach( OgreOpcode::CollisionObject * obj ); + void attach( SectorObject * obj ); bool checkCollideRay( BaseObject * obj, const Ogre::Ray & ray, double rayLength ); - - void changeCollClass( OgreOpcode::CollisionObject * collObj, const std::string & collClass ); + void info( ); + protected: OgreOpcode::CollisionContext * collideInSectorContext_; OgreOpcode::CollisionManager * collisionManager_; bool active_; - - //** das brauchen zum einfachen dettach/attach, OgreOpcode gibt uns diese Infos nicht. - std::set < OgreOpcode::CollisionObject * > attachedSet_; }; Modified: trunk/src/Sector.cpp =================================================================== --- trunk/src/Sector.cpp 2008-05-11 22:19:57 UTC (rev 893) +++ trunk/src/Sector.cpp 2008-05-12 13:08:10 UTC (rev 894) @@ -588,7 +588,7 @@ void Sector::destruct_( SectorObject * obj ){ if ( obj ){ - log_->debug( "Sector::destruct_ object: " + obj->name() + " " + toStr( obj->rtti() ) ); +// log_->debug( "Sector::destruct_ object: " + obj->name() + " " + toStr( obj->rtti() ) ); sectorObjects_.erase( obj ); if ( listener_->target() == obj ) selectNextTarget( ); Modified: trunk/src/SectorObject.cpp =================================================================== --- trunk/src/SectorObject.cpp 2008-05-11 22:19:57 UTC (rev 893) +++ trunk/src/SectorObject.cpp 2008-05-12 13:08:10 UTC (rev 894) @@ -63,9 +63,8 @@ Ogre::OverlayManager::getSingleton().destroyOverlayElement( "Radar/Map/DotA_" + name_ ); Ogre::OverlayManager::getSingleton().destroyOverlayElement( "Radar/Map/DotB_" + name_ ); - if ( collObj_ ) ResourceManager::getSingleton().collisionManager->destroyObject( collObj_ ); - collObj_ = NULL; - + ResourceManager::getSingleton().collisionManager->destroyObject( this ); + mainNodeEntityRot_->detachObject( entity_ ); sceneMgr_->destroyEntity( entity_ ); @@ -86,7 +85,7 @@ void SectorObject::setShape( const Ogre::String & meshname ){ entity_ = sceneMgr_->createEntity( name_ + "_shape", meshname ); mainNodeEntityRot_->attachObject( entity_ ); - collObj_ = ResourceManager::getSingleton().collisionManager->createObject( this ); + ResourceManager::getSingleton().collisionManager->createObject( this ); } void SectorObject::setBaseRot( const Ogre::Real & yaw, const Ogre::Real & pitch, const Ogre::Real & roll ){ Modified: trunk/src/SectorObject.h =================================================================== --- trunk/src/SectorObject.h 2008-05-11 22:19:57 UTC (rev 893) +++ trunk/src/SectorObject.h 2008-05-12 13:08:10 UTC (rev 894) @@ -56,7 +56,7 @@ void setShape( const Ogre::String & meshname ); void setShape( Ogre::MeshPtr & mesh ); - Ogre::Entity * entity(){ return entity_; } + virtual Ogre::Entity * entity(){ return entity_; } void scale( const Ogre::Vector3 & scale ); Modified: trunk/src/SectorObjectMissile.cpp =================================================================== --- trunk/src/SectorObjectMissile.cpp 2008-05-11 22:19:57 UTC (rev 893) +++ trunk/src/SectorObjectMissile.cpp 2008-05-12 13:08:10 UTC (rev 894) @@ -62,7 +62,7 @@ } bool SectorObjectMissile::update( Ogre::Real elapsedTime ){ - if ( launched_ ) { + if ( launched_ && !destroyRequest_) { if ( target_ != NULL && elapsedTime > 1e-4 ) { Ogre::Vector3 currDir = mainNode_->getWorldOrientation() * Ogre::Vector3::NEGATIVE_UNIT_Z; @@ -119,7 +119,7 @@ missileLifetime_ -= elapsedTime; } - if ( missileLifetime_ < 0 ) explode(); + if ( missileLifetime_ < 0 && ! destroyRequest_ ) explode(); return SectorObjectMoveable::update( elapsedTime ); } @@ -127,7 +127,7 @@ void SectorObjectMissile::collide( BaseObject * object ){ if ( ( this->missile()->lifetime() - missileLifetime_ ) > 0.1 ){ - std::cout << "SectorObjectMissile::collide: " << name_ << "<->" << object->name() << std::endl; + std::cout << "SectorObjectMissile::collide: " << name_ << "<->" << object->name() << " " << missileLifetime_<< std::endl; this->setVelocity( Ogre::Vector3::ZERO ); this->explode(); this->setVisible( false ); @@ -140,7 +140,6 @@ thrustTrail_->removeNode( mainNode_ ); thrustTrailNode_->setVisible( false ); } - launched_ = false; } void SectorObjectMissile::launch( ){ @@ -161,7 +160,7 @@ } SectorObjectMoveable::inititialize_(); inititialize_(); - ResourceManager::getSingleton().collisionManager->attach( collObj_ ); + ResourceManager::getSingleton().collisionManager->attach( this ); setThrustRate( 1.0 ); updateThruster(); launched_ = true; Modified: trunk/src/SectorObjectMoveable.cpp =================================================================== --- trunk/src/SectorObjectMoveable.cpp 2008-05-11 22:19:57 UTC (rev 893) +++ trunk/src/SectorObjectMoveable.cpp 2008-05-12 13:08:10 UTC (rev 894) @@ -118,7 +118,7 @@ shieldGlowActive_ = false; shieldGlowTime_ = 0.0; - vel_ = Ogre::Vector3( 0.0, 0.0, 0.0 ); + vel_ = Ogre::Vector3( 0.0, 0.0, 0.0 ); interpolateRot_ = Ogre::Quaternion( 1.0, 0.0, 0.0, 0.0 ); interpolateVel_ = Ogre::Vector3( 0.0, 0.0, 0.0 ); @@ -150,7 +150,7 @@ } if ( destroyRequest_ || destroyWithExplosion_ ){ - ResourceManager::getSingleton().collisionManager->dettach( collObj_ ); + ResourceManager::getSingleton().collisionManager->dettach( this ); this->unsubscribeToObservers(); Modified: trunk/src/SectorObjectVessel.cpp =================================================================== --- trunk/src/SectorObjectVessel.cpp 2008-05-11 22:19:57 UTC (rev 893) +++ trunk/src/SectorObjectVessel.cpp 2008-05-12 13:08:10 UTC (rev 894) @@ -129,11 +129,10 @@ setThrustRate( 0.0 ); updateThruster(); - ResourceManager::getSingleton().collisionManager->attach( collObj_ ); + ResourceManager::getSingleton().collisionManager->attach( this ); setVisible( true ); } - bool SectorObjectVessel::update( Ogre::Real elapsedTime ){ if ( armor_ <= 0 ) { explode(); Modified: trunk/src/Station.cpp =================================================================== --- trunk/src/Station.cpp 2008-05-11 22:19:57 UTC (rev 893) +++ trunk/src/Station.cpp 2008-05-12 13:08:10 UTC (rev 894) @@ -121,14 +121,14 @@ padMesh_ = padManualObject_->convertToMesh( padManualObject_->getName() + "/Mesh" ); padEntity_ = sceneMgr_->createEntity( padMesh_->getName() + "/Entity", padMesh_->getName() ); padNode_->attachObject( padEntity_ ); - - if ( docking_ ){ collObj_ = ResourceManager::getSingleton().collisionManager->createObject( padEntity_, this, "DockPad" ); + padNode_->translate( direction_.normalisedCopy() * 0.1 ); + if ( docking_ ){ + ResourceManager::getSingleton().collisionManager->createObject( this ); } } StationPad::~StationPad( ){ - if ( collObj_ ) ResourceManager::getSingleton().collisionManager->destroyObject( collObj_ ); - collObj_ = NULL; + ResourceManager::getSingleton().collisionManager->destroyObject( this ); padNode_->detachObject( padEntity_ ); sceneMgr_->destroyEntity( padEntity_ ); Ogre::MeshManager::getSingleton().remove( padMesh_->getName() ); @@ -142,8 +142,9 @@ if ( object->rtti() == AVATAR_RTTI ){ sector_->listener()->changeToDockedState(); } else if ( object->rtti() == SECTOROBJECTVESSEL_RTTI ){ - std::cout << "docking request for " << object->name() << std::endl; - dynamic_cast< SectorObjectVessel * >( object )->controler()->kill(); + std::cout << "StationPad::collide() docking request for " << object->name() << std::endl; + //dynamic_cast< SectorObjectVessel * >( object )->controler()->kill(); +// ResourceManager::getSingleton().collisionManager->dettachObject( padEntity_, this, "DockPad" ); object->destroy( ); } } @@ -168,11 +169,10 @@ unsigned short src = 0, dest = 0; if ( !pMesh->suggestTangentVectorBuildParams( Ogre::VES_TANGENT, src, dest) ) { - pMesh->buildTangentVectors( Ogre::VES_TANGENT, src, dest); + pMesh->buildTangentVectors( Ogre::VES_TANGENT, src, dest); } setShape( station_->meshName() ); - ResourceManager::getSingleton().collisionManager->changeCollClass( collObj_, "Station" ); for ( uint i = 0; i < entity()->getNumSubEntities(); i ++ ){ std::cout << entity()->getSubEntity( i )->getMaterialName() << " Techniques: " @@ -193,17 +193,14 @@ launchPad_ = new StationPad( name_ + "LaunchPad", this, entity()->getSubEntity( i ) ); } } - std::cout << " Station base size " << station_->baseSize() << std::endl; setBaseRot( station_->baseYaw(), station_->basePitch(), station_->baseRoll() ); - std::cout << " Station base size " << station_->baseSize() << std::endl; setBaseSize( station_->baseSize() ); - if ( dockPad_ ){ - createRings( dockPad_->position(), dockPad_->radius(), - dockPad_->direction() ); - ringNode_->setVisible( false ); - } + if ( dockPad_ ){ + createRings( dockPad_->position(), dockPad_->radius(), dockPad_->direction() ); + ringNode_->setVisible( false ); + } } StationObject::~StationObject( ) { Modified: trunk/src/Station.h =================================================================== --- trunk/src/Station.h 2008-05-11 22:19:57 UTC (rev 893) +++ trunk/src/Station.h 2008-05-12 13:08:10 UTC (rev 894) @@ -64,6 +64,8 @@ /*! Return runtime type information */ virtual long rtti() const { return STATIONPAD_RTTI; } + virtual std::string collisionClass() const { return "DockPad"; } + /*! What happen on collision */ void collide( BaseObject * object ); @@ -83,6 +85,8 @@ Ogre::SceneNode * padNode(){ return padNode_; } + virtual Ogre::Entity * entity( ) { return padEntity_; } + protected: StationObject * station_; bool docking_; @@ -104,7 +108,9 @@ virtual ~StationObject( ); virtual long rtti() const { return STATION_RTTI; } - + + virtual std::string collisionClass() const { return "Station"; } + void collide( BaseObject * object ); void createRings( const Ogre::Vector3 & position, Ogre::Real rMin, const Ogre::Vector3 & direction = Ogre::Vector3::ZERO ); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
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() ) ); - - //** 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; -} - -} - - Modified: trunk/src/EntityManager.h =================================================================== --- trunk/src/EntityManager.h 2008-05-11 17:20:23 UTC (rev 892) +++ trunk/src/EntityManager.h 2008-05-11 22:19:57 UTC (rev 893) @@ -79,6 +79,7 @@ std::vector < Entity * > allByCategory( const std::string & category ); + Commodity * commodity( const std::string & name ); PowerPlant * powerPlant( const std::string & name ); Engine * engine( const std::string & name ); Radar * radar( const std::string & name ); @@ -89,64 +90,50 @@ ModX * modx( const std::string & name ); Ecm * ecm( const std::string & name ); Vessel * vessel( const std::string & name ); - + Vessel * vessel( Uint16 ID ); + + std::set < Vessel * > vesselSet(); + protected: template < class EntityType > EntityType * entity_( const std::string & name ){ - Entity * item = entity( name ); - if ( !item ) { - LogManager::getSingleton().warn( "No entity named: " + name + " registered." ); - return NULL; - } + Entity * item = entity( name ); + if ( !item ) { + return NULL; + } EntityType tmp; //**very ugly - if ( item->entityType() == tmp.entityType() ) { - return dynamic_cast< EntityType * >(item); - } else { - LogManager::getSingleton().warn( "Requested " + categoryName( tmp.entityType() ) + ": " + name + - " is a " + categoryName( item->entityType() ) ); - } - return NULL; - } + if ( item->entityType() == tmp.entityType() ) { + return dynamic_cast< EntityType * >(item); + } else { + LogManager::getSingleton().warn( "Requested " + categoryName( tmp.entityType() ) + ": " + name + + " is a " + categoryName( item->entityType() ) ); + } + return NULL; + } + template < class EntityType > EntityType * entity_( Uint16 ID ){ + Entity * item = entity( ID ); + if ( !item ) { + return NULL; + } + EntityType tmp; //**very ugly + 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() ) ); + } + return NULL; + } + LogManager * log_; ResourceManager * resources_; - - std::map < std::string, Entity * > templatesByName_; + std::map < std::string, Entity * > templatesByName_; std::map < Uint16, Entity * > templatesByID_; - std::set < std::string > factions_; }; -/*! - * \brief This class is able to load equipment (reactors, engines, guns, etc.) - * from XML files. - * \author Christoph Brill <eg...@us...> - */ -class CommodityManager : public Ogre::Singleton< CommodityManager >, public EntityManager{ -public: - - /*! Get the single instance of the EquipmentManager */ - static CommodityManager & getSingleton( ); - - /*! Get the pointer to single instance of the EquipmentManager */ - static CommodityManager * getSingletonPtr( ); - - /*! Constructor */ - CommodityManager(); - - /*! Destructor that free's all loaded vessels */ - virtual ~CommodityManager(); - - virtual Entity * loadAndCreate( const std::string & filename ); - - /*! This returns a commodity by it's given name \remarks The commodity needs to be loaded before \param commodityName The name of a commodity */ - Commodity * findByName( const std::string & commodityName ); - - std::vector < Entity * > allCommodities(); - -}; - } // namespace OpenGate #endif //_OPENGATE_ENTITYMANAGER_H Modified: trunk/src/GameStateManager.cpp =================================================================== --- trunk/src/GameStateManager.cpp 2008-05-11 17:20:23 UTC (rev 892) +++ trunk/src/GameStateManager.cpp 2008-05-11 22:19:57 UTC (rev 893) @@ -38,7 +38,7 @@ #include "Sector.h" #include "InputManager.h" #include "AiManager.h" -#include "VesselManager.h" +#include "Vessel.h" #include "OpenALSoundManager.h" #include "OpcodeWrapper.h" #include "UnDockedState.h" @@ -56,7 +56,6 @@ GameStateManager::GameStateManager( NetworkClient & nw, bool dialog ) { resources_.network = & nw; log_ = NULL; - vesselManager_ = NULL; configDialog_ = NULL; log_ = LogManager::getSingletonPtr(); @@ -136,21 +135,11 @@ delete resources_.console; resources_.console = NULL; } - if ( commodityManager_ ){ - log_->info( "Shutdown commoditymanager." ); - delete commodityManager_; - commodityManager_ = NULL; - } if ( resources_.entityManager ){ log_->info( "Shutdown entitymanager." ); delete resources_.entityManager; resources_.entityManager = NULL; } - if ( vesselManager_ ){ - log_->info( "Shutdown vesselmanager." ); - delete vesselManager_; - vesselManager_ = NULL; - } if ( resources_.soundManager ) { log_->info( "Shutdown soundmanager." ); delete resources_.soundManager; @@ -409,15 +398,9 @@ std::string >( &GameStateManager::initialiseSoundManager, "initialise sound manager" ) ); loadResourcesVector_.push_back( std::pair< bool (GameStateManager::*)( ), - std::string >( &GameStateManager::initialiseVesselManager, - "initialise vessel manager" ) ); + std::string >( &GameStateManager::initialiseEntityManager, + "initialise entity manager" ) ); loadResourcesVector_.push_back( std::pair< bool (GameStateManager::*)( ), - std::string >( &GameStateManager::initialiseCommodityManager, - "initialise commodity manager" ) ); - loadResourcesVector_.push_back( std::pair< bool (GameStateManager::*)( ), - std::string >( &GameStateManager::initialiseEquipmentManager, - "initialise equipment manager" ) ); - loadResourcesVector_.push_back( std::pair< bool (GameStateManager::*)( ), std::string >( &GameStateManager::initialiseAiManager, "initialise ai manager" ) ); loadResourcesVector_.push_back( std::pair< bool (GameStateManager::*)( ), @@ -501,33 +484,30 @@ return true; } -bool GameStateManager::initialiseVesselManager(){ - vesselManager_ = new VesselManager( ); - vesselManager_->load( resources_.resourcePaths(), "ships" ); - return true; -} +// bool GameStateManager::initialiseVesselManager(){ +// vesselManager_ = new VesselManager( ); +// vesselManager_->load( resources_.resourcePaths(), "ships" ); +// return true; +// } -bool GameStateManager::initialiseCommodityManager(){ - commodityManager_ = new CommodityManager( ); - commodityManager_->load( resources_.resourcePaths(), "commodities" ); - return true; -} - -bool GameStateManager::initialiseEquipmentManager(){ +bool GameStateManager::initialiseEntityManager(){ resources_.entityManager = new EntityManager( ); + resources_.entityManager->load( resources_.resourcePaths(), "commodities" ); resources_.entityManager->load( resources_.resourcePaths(), "engines" ); resources_.entityManager->load( resources_.resourcePaths(), "capacitors" ); resources_.entityManager->load( resources_.resourcePaths(), "radars" ); resources_.entityManager->load( resources_.resourcePaths(), "shields" ); + //resources_.entityManager->load( resources_.resourcePaths(), "ecms" ); resources_.entityManager->load( resources_.resourcePaths(), "power_plants" ); resources_.entityManager->load( resources_.resourcePaths(), "guns" ); resources_.entityManager->load( resources_.resourcePaths(), "missiles" ); + resources_.entityManager->load( resources_.resourcePaths(), "ships" ); return true; } bool GameStateManager::createAvatar(){ resources_.avatar = new Avatar( resources_.network->userName(), resources_.network->userID() ); - resources_.avatar->setVessel( *VesselManager::getSingleton().vessel( "apteryx" ) ); + resources_.avatar->setVessel( *resources_.entityManager->vessel( "apteryx" ) ); resources_.avatar->vessel( )->setPowerPlant( resources_.entityManager->powerPlant( "Spud" ) ); resources_.avatar->vessel( )->setEngine( resources_.entityManager->engine( "T-E-15" ) ); resources_.avatar->vessel( )->setRadar( resources_.entityManager->radar( "Outlook" ) ); @@ -653,7 +633,7 @@ bool showHelp = false; if ( aiName != "help" ){ if ( stateStack_.back()->name() == "UnDockedState" ){ - if ( VesselManager::getSingleton().vessel( aiName ) ){ + if ( resources_.entityManager->vessel( aiName ) ){ //dynamic_cast< UnDockedState * >( stateStack_.back() )->spawnAI( aiName ); } else { showHelp = true; @@ -666,9 +646,9 @@ } if ( showHelp ){ - std::set< Vessel * > vessel( VesselManager::getSingleton().factionVessels( "All" ) ); + std::vector< Entity * > vessel( resources_.entityManager->allByCategory( "Vessel" ) ); std::string vesselNames("Vessels available: "); - for ( std::set< Vessel * >::iterator it = vessel.begin(); it!= vessel.end(); it ++ ){ + for ( std::vector< Entity * >::iterator it = vessel.begin(); it!= vessel.end(); it ++ ){ vesselNames += (*it)->name() + " "; } LogManager::getSingleton().info( vesselNames ); Modified: trunk/src/GameStateManager.h =================================================================== --- trunk/src/GameStateManager.h 2008-05-11 17:20:23 UTC (rev 892) +++ trunk/src/GameStateManager.h 2008-05-11 22:19:57 UTC (rev 893) @@ -33,8 +33,6 @@ class InputManager; class VesselManager; class ConfigDialog; -class EquipmentManager; -class CommodityManager; /*! * \brief The class defines the gamestate manager. @@ -74,9 +72,7 @@ //** load id, rank matrix etc. bool initialiseMiscResources(); bool initialiseSoundManager(); - bool initialiseVesselManager(); - bool initialiseCommodityManager(); - bool initialiseEquipmentManager(); + bool initialiseEntityManager(); bool initialiseAiManager(); bool initialiseCollisionManager(); bool createAvatar(); @@ -138,9 +134,7 @@ bool initialiseOgreEngine_( bool dialog ); LogManager * log_; - VesselManager * vesselManager_; - EquipmentManager * equipmentManager_; - CommodityManager * commodityManager_; +// VesselManager * vesselManager_; std::vector< GameState * > stateStack_; std::vector< StateInfo > states_; Modified: trunk/src/Makefile.am =================================================================== --- trunk/src/Makefile.am 2008-05-11 17:20:23 UTC (rev 892) +++ trunk/src/Makefile.am 2008-05-11 22:19:57 UTC (rev 893) @@ -91,8 +91,6 @@ UnDockedState.h \ Vessel.h \ Vessel.cpp \ - VesselManager.h \ - VesselManager.cpp \ metaserver.h \ metaserver.cpp Modified: trunk/src/MarketDialog.cpp =================================================================== --- trunk/src/MarketDialog.cpp 2008-05-11 17:20:23 UTC (rev 892) +++ trunk/src/MarketDialog.cpp 2008-05-11 22:19:57 UTC (rev 893) @@ -178,12 +178,8 @@ std::vector < Entity * > items; - if ( selectedCategory_ == "Commodities" ){ - items = CommodityManager::getSingleton().allCommodities(); - } else { - items = ResourceManager::getSingleton().entityManager->allByCategory( selectedCategory_ ); - } - + items = ResourceManager::getSingleton().entityManager->allByCategory( selectedCategory_ ); + switch ( sortBy_ ){ case Alphanumeric: if ( sortAscending_ ) sort( items.begin(), items.end(), &OpenGate::lesserName ); Modified: trunk/src/Moveable.cpp =================================================================== --- trunk/src/Moveable.cpp 2008-05-11 17:20:23 UTC (rev 892) +++ trunk/src/Moveable.cpp 2008-05-11 22:19:57 UTC (rev 893) @@ -40,14 +40,11 @@ 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 ); - - if ( !readXMLNode< float >( hRoot, "dragfactor", this, &OpenGate::Moveable::setDragFactor, false ) ) { - readXMLNode< float >( hRoot, "drag_factor", this, &OpenGate::Moveable::setDragFactor, false ); - } - + readXMLNode< float >( hRoot, "dragfactor drag_factor", this, &OpenGate::Moveable::setDragFactor, false ); + if ( !readXMLNode< std::string >( hRoot, "mesh", this, &OpenGate::Moveable::setMesh, false ) ){ - try{ - setMesh( name_, false ); + try { + setMesh( name_, true ); } catch( Ogre::Exception & e ){ LogManager::getSingleton().warn( e.what() ); } @@ -59,8 +56,8 @@ if ( genPath ){ fileName = std::string("ships") + PATHSEPARATOR + strCopyToLowerCase( factionName_ ) + PATHSEPARATOR - + strCopyToLowerCase( name_ ) + PATHSEPARATOR - + meshName; + + strReplaceBlankWithUnderscore( strCopyToLowerCase( name_ ) ) + PATHSEPARATOR + + strReplaceBlankWithUnderscore( strCopyToLowerCase( meshName ) ); } else { fileName = meshName; } Modified: trunk/src/OpcodeWrapper.cpp =================================================================== --- trunk/src/OpcodeWrapper.cpp 2008-05-11 17:20:23 UTC (rev 892) +++ trunk/src/OpcodeWrapper.cpp 2008-05-11 22:19:57 UTC (rev 893) @@ -69,7 +69,12 @@ } } -void OpcodeCollisionDetection::free( ){ +void OpcodeCollisionDetection::free( ){ + + std::vector< OgreOpcode::CollisionObject * > activeObjects( collideInSectorContext_->getAttachedObjects() ); + + std::cout << "OpcodeCollisionDetection::free( ) " << activeObjects.size() << std::endl; + if ( collisionManager_ ) delete collisionManager_; collisionManager_ = NULL; } @@ -155,10 +160,12 @@ if ( active_ ){ OgreOpcode::ICollisionShape * shape = obj->getShape(); - if ( obj && attachedSet_.find( obj ) != attachedSet_.end() ){ - collideInSectorContext_->destroyObject( obj ); - attachedSet_.erase( obj ); + if ( obj && attachedSet_.find( obj ) == attachedSet_.end() ){ + attach( obj ); } + collideInSectorContext_->destroyObject( obj ); + attachedSet_.erase( obj ); + collisionManager_->detachShape( shape ); collisionManager_->destroyShape( shape ); obj = NULL; Modified: trunk/src/OpcodeWrapper.h =================================================================== --- trunk/src/OpcodeWrapper.h 2008-05-11 17:20:23 UTC (rev 892) +++ trunk/src/OpcodeWrapper.h 2008-05-11 22:19:57 UTC (rev 893) @@ -63,11 +63,7 @@ bool checkCollideRay( BaseObject * obj, const Ogre::Ray & ray, double rayLength ); void changeCollClass( OgreOpcode::CollisionObject * collObj, const std::string & collClass ); - -// static OpcodeCollisionDetection & getSingleton( ); -// -// static OpcodeCollisionDetection * getSingletonPtr( ); - + protected: OgreOpcode::CollisionContext * collideInSectorContext_; OgreOpcode::CollisionManager * collisionManager_; Modified: trunk/src/Planet.cpp =================================================================== --- trunk/src/Planet.cpp 2008-05-11 17:20:23 UTC (rev 892) +++ trunk/src/Planet.cpp 2008-05-11 22:19:57 UTC (rev 893) @@ -199,3 +199,40 @@ } // namespace OpenGate +// if ( !1 ) { +// planetNode_ = sceneMgr_->getRootSceneNode()->createChildSceneNode( "PlanetNode" ); +// +// Ogre::ManualObject * planet = sceneMgr_->createManualObject( "Planet" ); +// // planet->setUseIdentityProjection( true ); +// // planet->setUseIdentityView( true ); +// +// planet->begin( "OpenGate/RedPlanet", Ogre::RenderOperation::OT_TRIANGLE_LIST); +// planet->position( Ogre::Vector3( -1.0, -1.0, 200.0 ) ); +// planet->textureCoord( 0, 0 ); +// planet->position( Ogre::Vector3( 1.0, -1.0, 200.0 ) ); +// planet->textureCoord( 1, 0 ); +// planet->position( Ogre::Vector3( 1.0, 1.0, 200.0 ) ); +// planet->textureCoord( 1, 1 ); +// planet->position( Ogre::Vector3( -1.0, 1.0, 200.0 ) ); +// planet->textureCoord( 0, 1 ); +// planet->quad( 0, 1, 2, 3 ); +// planet->end(); +// Ogre::AxisAlignedBox aabInf; aabInf.setInfinite(); +// planet->setBoundingBox( aabInf ); +// planetNode_->attachObject( planet ); +// planetNode_->scale( 20000, 20000, 1 ); +// planetNode_->setPosition( Ogre::Vector3( 20000.0, 10000.0, 50000 ) ); +// } +// if ( planetNode_ ){ // updateLoop +// Ogre::Vector3 src = planetNode_->getWorldOrientation() * Ogre::Vector3::UNIT_Z; +// src.normalise(); +// +// Ogre::Vector3 target( avatar_->mainNode()->getPosition() - planetNode_->getWorldPosition() ); +// target.normalise(); +// +// Ogre::Quaternion rot = src.getRotationTo( target ); +// rot.normalise(); +// +// planetNode_->setPosition( Ogre::Vector3( 20000.0, 10000.0, 50000 ) + avatar_->mainNode()->getPosition() ); +// planetNode_->rotate( rot, Ogre::Node::TS_PARENT ); +// } Modified: trunk/src/ResourceManager.cpp =================================================================== --- trunk/src/ResourceManager.cpp 2008-05-11 17:20:23 UTC (rev 892) +++ trunk/src/ResourceManager.cpp 2008-05-11 22:19:57 UTC (rev 893) @@ -139,8 +139,10 @@ 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; Modified: trunk/src/Sector.cpp =================================================================== --- trunk/src/Sector.cpp 2008-05-11 17:20:23 UTC (rev 892) +++ trunk/src/Sector.cpp 2008-05-11 22:19:57 UTC (rev 893) @@ -27,8 +27,9 @@ #include "Projectile.h" #include "Station.h" #include "Planet.h" -#include "VesselManager.h" +#include "Vessel.h" #include "Equipment.h" +#include "EntityManager.h" #include "SectorObjectMoveable.h" #include "SectorObjectAvatar.h" #include "SectorObjectVessel.h" @@ -77,7 +78,6 @@ : sceneMgr_( sceneMgr ), network_( network ) { radar_ = true; - planetNode_ = NULL; planet_ = NULL; koordAxisNode_ = NULL; starsNode_ = NULL; @@ -137,67 +137,29 @@ planet_->lighting( true ); } - if ( !1 ) { - planetNode_ = sceneMgr_->getRootSceneNode()->createChildSceneNode( "PlanetNode" ); - - Ogre::ManualObject * planet = sceneMgr_->createManualObject( "Planet" ); - // planet->setUseIdentityProjection( true ); - // planet->setUseIdentityView( true ); - - planet->begin( "OpenGate/RedPlanet", Ogre::RenderOperation::OT_TRIANGLE_LIST); - planet->position( Ogre::Vector3( -1.0, -1.0, 200.0 ) ); - planet->textureCoord( 0, 0 ); - planet->position( Ogre::Vector3( 1.0, -1.0, 200.0 ) ); - planet->textureCoord( 1, 0 ); - planet->position( Ogre::Vector3( 1.0, 1.0, 200.0 ) ); - planet->textureCoord( 1, 1 ); - planet->position( Ogre::Vector3( -1.0, 1.0, 200.0 ) ); - planet->textureCoord( 0, 1 ); - planet->quad( 0, 1, 2, 3 ); - planet->end(); - Ogre::AxisAlignedBox aabInf; aabInf.setInfinite(); - planet->setBoundingBox( aabInf ); - planetNode_->attachObject( planet ); - planetNode_->scale( 20000, 20000, 1 ); - planetNode_->setPosition( Ogre::Vector3( 20000.0, 10000.0, 50000 ) ); - } - populate( "testsector.xml" ); createKoordAxis( ); } Sector::~Sector( ){ - for ( std::map< long, SectorObjectMoveable * >::iterator it = movableObjects_.begin(); it != movableObjects_.end();){ -// log_->info( "Destructing: " + it->second->name() ); - destruct_( (it++)->second ); - // log_->info( "done: " ); - } - - for ( std::set< SectorObject * >::iterator it = sectorObjects_.begin(); it != sectorObjects_.end(); ){ - // log_->info( "Destructing: " + (*it)->name() ); + for ( std::set< SectorObject * >::iterator it = sectorObjects_.begin(); it != sectorObjects_.end(); it ++){ + // log_->info( "Sector::~Sector( ) deleting sector object: " + (*it)->name() ); if ( radar_ && (*it)->isOnRadar() ){ - Ogre::Overlay * radar = Ogre::OverlayManager::getSingleton().getByName( "Radar" ); - Ogre::OverlayContainer * radarMap = radar->getChild( "Radar/Map" ); - radarMap->removeChild( (*it)->dotA()->getName() ); - radarMap->removeChild( (*it)->dotB()->getName() ); + Ogre::Overlay * radar = Ogre::OverlayManager::getSingleton().getByName( "Radar" ); + Ogre::OverlayContainer * radarMap = radar->getChild( "Radar/Map" ); + radarMap->removeChild( (*it)->dotA()->getName() ); + radarMap->removeChild( (*it)->dotB()->getName() ); } delete *it; - sectorObjects_.erase( (*it++) ); } sceneMgr_->destroyLight("MainLight" ); if ( planet_ ) { delete planet_; } - if ( planetNode_ ){ - sceneMgr_->destroyManualObject( "Planet" ); - sceneMgr_->getRootSceneNode()->removeAndDestroyChild( planetNode_->getName() ); - } - planetNode_ = NULL; - if ( koordAxisNode_ ) { koordAxisNode_->detachObject( koordAxisMO_ ); sceneMgr_->destroyManualObject( koordAxisMO_->getName() ); @@ -207,6 +169,11 @@ for ( std::map< std::string, std::deque< SectorObject * > >::iterator it = objectHeap_.begin(); it != objectHeap_.end(); it ++ ){ for_each( (*it).second.begin(), (*it).second.end(), deletePtr() ); +// std::cout << (*it).first << std::endl; +// for ( int i = 0; i < (*it).second.size(); i ++ ){ +// std::cout << (*it).second[ i ]->name() << std::endl; +// delete (*it).second[ i ]; +// } } } @@ -251,31 +218,31 @@ sceneMgr_->setSkyBox( true, "OpenGate/SimpleSkyBox1" ); } - pElem = hRoot.ChildElement( "vesselschool", 0 ).Element(); - if ( pElem ){ - std::string schoolclass( pElem->FirstChild()->Value() ); +// pElem = hRoot.ChildElement( "vesselschool", 0 ).Element(); +// if ( pElem ){ +// std::string schoolclass( pElem->FirstChild()->Value() ); +// +// if ( schoolclass == "all" ){ +// std::set < std::string > factions = VesselManager::getSingleton().factionNames(); +// int factionCounter = 0; +// for ( std::set < std::string >::iterator factIt = factions.begin(); factIt != factions.end(); factIt ++ ){ +// std::set < Vessel * > vessels( VesselManager::getSingleton().factionVessels( (*factIt) ) ); +// int vesselCounter = 0; +// for ( std::set < Vessel * >::iterator it = vessels.begin(); it != vessels.end(); it ++ ){ +// SectorObject * obj = createStaticObject( (*it)->meshPtr().get()->getName(), +// (*it)->factionName() + "/" + (*it)->name(), +// Ogre::Vector3( -1000.0, 50 * factionCounter, +// -100.0 + 100 * vesselCounter ) ); +// +// obj->setBaseRot( (*it)->baseYaw(), (*it)->basePitch(), (*it)->baseRoll() ); +// obj->setBaseSize( (*it)->baseSize() ); +// vesselCounter++; +// } +// factionCounter++; +// } +// } +// } - if ( schoolclass == "all" ){ - std::set < std::string > factions = VesselManager::getSingleton().factionNames(); - int factionCounter = 0; - for ( std::set < std::string >::iterator factIt = factions.begin(); factIt != factions.end(); factIt ++ ){ - std::set < Vessel * > vessels( VesselManager::getSingleton().factionVessels( (*factIt) ) ); - int vesselCounter = 0; - for ( std::set < Vessel * >::iterator it = vessels.begin(); it != vessels.end(); it ++ ){ - SectorObject * obj = createStaticObject( (*it)->meshPtr().get()->getName(), - (*it)->factionName() + "/" + (*it)->name(), - Ogre::Vector3( -1000.0, 50 * factionCounter, - -100.0 + 100 * vesselCounter ) ); - - obj->setBaseRot( (*it)->baseYaw(), (*it)->basePitch(), (*it)->baseRoll() ); - obj->setBaseSize( (*it)->baseSize() ); - vesselCounter++; - } - factionCounter++; - } - } - } - //** Load stations for ( pElem = hRoot.FirstChild( "station" ).Element(); pElem != 0; pElem = pElem->NextSiblingElement("station") ) { std::string name; @@ -399,19 +366,7 @@ if ( planet_ ){ planet_->update( elapsedTime ); } - if ( planetNode_ ){ - Ogre::Vector3 src = planetNode_->getWorldOrientation() * Ogre::Vector3::UNIT_Z; - src.normalise(); - - Ogre::Vector3 target( avatar_->mainNode()->getPosition() - planetNode_->getWorldPosition() ); - target.normalise(); - - Ogre::Quaternion rot = src.getRotationTo( target ); - rot.normalise(); - - planetNode_->setPosition( Ogre::Vector3( 20000.0, 10000.0, 50000 ) + avatar_->mainNode()->getPosition() ); - planetNode_->rotate( rot, Ogre::Node::TS_PARENT ); - } + if ( starsNode_ ) starsNode_->setPosition( avatar_->mainNode()->getPosition() ); if ( radar_ ){ @@ -556,16 +511,27 @@ SectorObjectVessel * Sector::createVessel( const Ogre::String & name, Uint32 userID, Uint8 childID, Vessel & vessel ){ - SectorObjectVessel * obj = new SectorObjectVessel( name + toStr( childIDCounter_++ ), - this, userID, childIDCounter_, new Vessel( vessel ) ); + SectorObjectVessel * obj; + if ( objectHeap_[ vessel.name() ].empty() ){ + childIDCounter_++; + obj = new SectorObjectVessel( name + "_" + toStr( childIDCounter_ ), + this, userID, childIDCounter_, new Vessel( vessel ) ); + log_->debug( "Sector::createVessel new " + obj->name() ); + } else { + obj = dynamic_cast< SectorObjectVessel * >( objectHeap_[ vessel.name() ].front() ); + objectHeap_[ vessel.name() ].pop_front(); + obj->reset(); + log_->debug( "Sector::createVessel reuse " + obj->name() ); + } + sectorObjects_.insert( obj ); if ( !movableObjects_.count( obj->globalID() ) ){ movableObjects_[ obj->globalID() ] = obj; } else { std::cout << "Sector::createVessel: globalID allready exist:" << name << std::endl; } -//** ist das notwendig ? localAiObjects_[ obj->globalID() ] = obj; + obj->setActive( true ); return obj; } @@ -576,14 +542,14 @@ //if ( objectHeap_.count( missile.name() ) == 0 ){ if ( objectHeap_[ missile.name() ].empty() ){ childIDCounter_++; - obj = new SectorObjectMissile( name + toStr( childIDCounter_ ), + obj = new SectorObjectMissile( name + "_" + toStr( childIDCounter_ ), this, userID, childIDCounter_, new Missile( missile ) ); - // log_->debug( "Sector::createMissile new " + obj->name() ); + //log_->debug( "Sector::createMissile new " + obj->name() ); } else { obj = dynamic_cast< SectorObjectMissile * >( objectHeap_[ missile.name() ].front() ); objectHeap_[ missile.name() ].pop_front(); obj->reset(); - // log_->debug( "Sector::createMissile reuse " + obj->name() ); + //log_->debug( "Sector::createMissile reuse " + obj->name() ); } sectorObjects_.insert( obj ); @@ -598,7 +564,7 @@ } void Sector::createAvatarObject( Avatar & avatar ){ - log_->info( std::string( "Create avatar: " ) + avatar.name() ); + log_->info( std::string( "Sector::createAvatarObject: " ) + avatar.name() ); avatar_ = new SectorObjectAvatar( avatar.name(), this, avatar.userID(), avatar.vessel() ); sectorObjects_.insert( avatar_ ); movableObjects_[ avatar_->userID() ] = avatar_; @@ -622,7 +588,7 @@ void Sector::destruct_( SectorObject * obj ){ if ( obj ){ - // log_->debug( "Sector::destruct_ object: " + obj->name() + " " + toStr( obj->rtti() ) ); + log_->debug( "Sector::destruct_ object: " + obj->name() + " " + toStr( obj->rtti() ) ); sectorObjects_.erase( obj ); if ( listener_->target() == obj ) selectNextTarget( ); @@ -642,7 +608,8 @@ // it->second->setTarget( NULL ); // } // } - + obj->setActive(... [truncated message content] |
From: <spo...@us...> - 2008-05-11 17:20:15
|
Revision: 892 http://opengate.svn.sourceforge.net/opengate/?rev=892&view=rev Author: spom_spom Date: 2008-05-11 10:20:23 -0700 (Sun, 11 May 2008) Log Message: ----------- Add 2nd blender file Added Paths: ----------- templates/misc/beacon_2.blend Added: templates/misc/beacon_2.blend =================================================================== (Binary files differ) Property changes on: templates/misc/beacon_2.blend ___________________________________________________________________ Name: svn:mime-type + application/octet-stream This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <spo...@us...> - 2008-05-11 12:02:39
|
Revision: 891 http://opengate.svn.sourceforge.net/opengate/?rev=891&view=rev Author: spom_spom Date: 2008-05-11 05:02:46 -0700 (Sun, 11 May 2008) Log Message: ----------- Forgot some files, add beacon and a ring mesh to populate the testsector a bit Added Paths: ----------- trunk/data/misc/beacon.mesh trunk/data/misc/ring.material trunk/data/misc/ring.mesh Added: trunk/data/misc/beacon.mesh =================================================================== (Binary files differ) Property changes on: trunk/data/misc/beacon.mesh ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/data/misc/ring.material =================================================================== --- trunk/data/misc/ring.material (rev 0) +++ trunk/data/misc/ring.material 2008-05-11 12:02:46 UTC (rev 891) @@ -0,0 +1,30 @@ +material ring/main +{ + receive_shadows on + technique + { + pass + { + ambient 0.500000 0.500000 0.500000 1.000000 + diffuse 0.640000 0.640000 0.640000 1.000000 + specular 0.500000 0.500000 0.500000 1.000000 12.500000 + emissive 0.000000 0.000000 0.000000 1.000000 + } + } +} +material ring/plane +{ + receive_shadows on + technique + { + pass + { + ambient 0.500000 0.500000 0.500000 0.228379 + diffuse 0.652549 0.009412 0.009412 0.228379 + specular 0.500000 0.500000 0.500000 0.228379 12.500000 + emissive 0.000000 0.000000 0.000000 0.228379 + scene_blend alpha_blend + depth_write off + } + } +} Added: trunk/data/misc/ring.mesh =================================================================== (Binary files differ) Property changes on: trunk/data/misc/ring.mesh ___________________________________________________________________ Name: svn:mime-type + application/octet-stream This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
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" ) return GUN; else if ( category == "Missile" || category == "Missiles" || @@ -63,84 +70,62 @@ else if ( category == "MODX" || category == "MODXs" || category == "MODx" || category == "MODxs" || category == "modx" || category == "modxs" ) return MODX; + else if ( category == "Vessel" || category == "Vessels" || + category == "vessel" || category == "Vessels" ) return VESSEL; LogManager::getSingleton().warn("Request entity rtti for " + category + " unknown" ); return ENTITY; } +std::string EntityManager::categoryName( EntityType type ){ + switch( type ){ + case COMMODITY: return "Commodity"; + case POWERPLANT: return "Powerplant"; + case CAPACITOR: return "Capacitor"; + case ENGINE: return "Engine"; + case SHIELD: return "Shield"; + case RADAR: return "Radar"; + case ECM: return "ECM"; + case GUN: return "GUN"; + case MISSILE: return "MISSILE"; + case MODX: return "MODx"; + case VESSEL: return "Vessel"; + } -Entity * EntityManager::entity( const std::string & name ){ - if ( templatesByName_.count( name ) ){ - return templatesByName_[ name ]; - } else { - LogManager::getSingleton().warn("Request for entity: " + name + " unknown" ); - return NULL; - } - } - - Entity * EntityManager::entity( Uint16 ID ){ - if ( templatesByID_.count( ID ) ){ - return templatesByID_[ ID ]; - } else { - LogManager::getSingleton().warn( ("Request for entity id: ") + toStr(ID) + " unknown" ); - return NULL; - } - } - -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 ] ); - } - - delete pArch; + LogManager::getSingleton().warn("Request name for category " + toStr( type ) + " unknown" ); + return "unknown"; } -template<> EquipmentManager * Ogre::Singleton< EquipmentManager >::ms_Singleton = 0; - -EquipmentManager::EquipmentManager(): EntityManager(){ - Entity * entity = new Missile(); - entity->setName( "firefly" ); - entity->setID( 10001 ); - dynamic_cast< Missile * >( entity )->setDamage( 10000000 ); - dynamic_cast< Missile * >( entity )->setThrust( 150000 ); - dynamic_cast< Missile * >( entity )->setYaw( 90 ); - dynamic_cast< Missile * >( entity )->setPitch( 90 ); - dynamic_cast< Missile * >( entity )->setRoll( 90 ); - dynamic_cast< Missile * >( entity )->setArmor( 1 ); - dynamic_cast< Missile * >( entity )->setMass( 150 ); - dynamic_cast< Missile * >( entity )->setLifeTime( 20 ); - dynamic_cast< Missile * >( entity )->setDragFactor( 1 ); - dynamic_cast< Missile * >( entity )->setBaseSize(0.2, 0.2, 1.0 ); - try{ - dynamic_cast< Missile * >(entity)->setMesh( "firefly.mesh", false ); - } catch( Ogre::Exception & e ){ - LogManager::getSingleton().warn( e.what() ); +Entity * EntityManager::entity( const std::string & name ) { + if ( templatesByName_.count( name ) ){ + return templatesByName_[ name ]; + } else { + LogManager::getSingleton().warn("Request for entity: " + name + " unknown" ); + return NULL; } - templatesByName_[ entity->name() ] = entity; - templatesByID_[ entity->id() ] = entity; } -EquipmentManager::~EquipmentManager() { +Entity * EntityManager::entity( Uint16 ID ){ + if ( templatesByID_.count( ID ) ){ + return templatesByID_[ ID ]; + } else { + LogManager::getSingleton().warn( ("Request for entity id: ") + toStr(ID) + " unknown" ); + return NULL; + } } + +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 ); } +Shield * EntityManager::shield( const std::string & name ){ return entity_< Shield >( name ); } +Capacitor * EntityManager::capacitor( const std::string & name ){ return entity_< Capacitor >( name ); } +Gun * EntityManager::gun( const std::string & name ){ return entity_< Gun >( name ); } +Missile * EntityManager::missile( const std::string & name ){ return entity_< Missile >( name ); } +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 ); } -EquipmentManager & EquipmentManager::getSingleton( ){ - assert( ms_Singleton ); - return ( *ms_Singleton ); -} - -EquipmentManager * EquipmentManager::getSingletonPtr( ){ - if ( ms_Singleton == NULL ){ - LogManager::getSingleton().fatal( "CommodityManager not initialized." ); - } - return ms_Singleton; -} - - std::vector < Entity * > EquipmentManager::allByCategory( const std::string & category ){ +std::vector < Entity * > EntityManager::allByCategory( const std::string & category ){ EntityType rtti = NONE; if ( category != "All" ) rtti = categoryType( category ); std::vector < Entity * > items; @@ -151,347 +136,398 @@ } return items; } - -PowerPlant * EquipmentManager::powerPlant( const std::string & name ){ - Entity * item = entity( name ); - if ( !item ) return NULL; - - if ( item->entityType() == POWERPLANT ) { - return dynamic_cast< PowerPlant * >(item); - } else { - LogManager::getSingleton().warn( name + " is no power plant." ); - } - return NULL; -} -Engine * EquipmentManager::engine( const std::string & name ){ - Entity * item = entity( name ); - if ( !item ) return NULL; - - if ( item->entityType() == ENGINE ) { - return dynamic_cast< Engine * >(item); - } else { - LogManager::getSingleton().warn( name + " is no engine." ); - } - return NULL; -} +void EntityManager::load( const std::set < std::string > & resourcePaths, const std::string & resourceName ){ + Ogre::FileSystemArchive * pArch = new Ogre::FileSystemArchive( (*resourcePaths.begin()) + "/" + resourceName, "FileSystem" ); -Radar * EquipmentManager::radar( const std::string & name ){ - Entity * item = entity( name ); - if ( !item ) return NULL; - - if ( item->entityType() == RADAR ) { - return dynamic_cast< Radar * >(item); - } else { - LogManager::getSingleton().warn( name + " is no radar." ); - } - return NULL; -} + 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 ] ); + } -Shield * EquipmentManager::shield( const std::string & name ){ - Entity * item = entity( name ); - if ( !item ) return NULL; - - if ( item->entityType() == SHIELD ) { - return dynamic_cast< Shield * >(item); - } else { - LogManager::getSingleton().warn( name + " is no shield." ); - } - return NULL; + delete pArch; } -Capacitor * EquipmentManager::capacitor( const std::string & name ){ - Entity * item = entity( name ); - if ( !item ) return NULL; - - if ( item->entityType() == CAPACITOR ) { - return dynamic_cast< Capacitor * >(item); - } else { - LogManager::getSingleton().warn( name + " is no capacitor." ); - } - return NULL; -} +Entity * EntityManager::loadAndCreate( const std::string & fileName ){ + log_->fout( "Read equipment: " + fileName ); -Gun * EquipmentManager::gun( const std::string & name ){ - Entity * item = entity( name ); - if ( !item ) return NULL; - - if ( item->entityType() == GUN ) { - return dynamic_cast< Gun * >(item); - } else { - LogManager::getSingleton().warn( name + " is no gun." ); - } - return NULL; -} - -Missile * EquipmentManager::missile( const std::string & name ){ - Entity * item = entity( name ); - if ( !item ) return NULL; - - if ( item->entityType() == MISSILE ) { - return dynamic_cast< Missile * >(item); - } else { - LogManager::getSingleton().warn( name + " is no missile." ); + TiXmlDocument doc( fileName ); + bool loadOkay = doc.LoadFile(); + + if ( !loadOkay ) { + log_->fatal( std::string( "Failed to load equipment file: " + fileName ) ); + return NULL; } - return NULL; -} - -Entity * EquipmentManager::loadAndCreate( const std::string & fileName ){ - log_->fout( "Read equipment: " + fileName ); + TiXmlHandle docHandle( &doc ); + TiXmlElement * pElem; + TiXmlHandle hRoot( 0 ); - TiXmlDocument doc( fileName ); - bool loadOkay = doc.LoadFile(); + pElem = docHandle.FirstChildElement().Element(); + hRoot = TiXmlHandle( pElem ); - if ( !loadOkay ) { - log_->fatal( std::string( "Failed to load equipment file: " + fileName ) ); - return NULL; - } + if ( !pElem ) { + log_->fatal( fileName + " cannot read first node." ); + return NULL; + } - TiXmlHandle docHandle( &doc ); - TiXmlElement *pElem; - TiXmlHandle hRoot( 0 ); + if ( strcmp( "equipment", pElem->Value() ) != 0 && strcmp( "container", pElem->Value() ) != 0 ) { + log_->fatal( fileName + " is no entity description" ); + return NULL; + } + + Entity * entity; - pElem = docHandle.FirstChildElement().Element(); - hRoot = TiXmlHandle( pElem ); - - if ( !pElem ) { - log_->fatal( fileName + " cannot read first node." ); - return NULL; - } - - if ( strcmp( "equipment", pElem->Value() ) != 0 && strcmp( "container", pElem->Value() ) != 0 ) { - log_->fatal( fileName + " is no equipment description" ); - return NULL; - } - -// Equipment * entity = 0; -// std::string equipmentType = pElem->Attribute("type"); - - -// if ( equipmentType == "Engine" ) entity = new Engine(); -// else if ( equipmentType == "ECM" ) entity = new Ecm(); -// else if ( equipmentType == "Capacitor" ) entity = new Capacitor(); -// else { -// log_->fatal( fileName + " has no type of equipment defined" ); -// return NULL; -// } - - - Entity * entity; - - //** Mandatory elements; - pElem = hRoot.ChildElement( "category_id", 0 ).Element(); - if ( !pElem ) { //** fallback - pElem = hRoot.ChildElement( "categorie_id", 0 ).Element(); - } - - if ( pElem ) { - int category = toInt( pElem->FirstChild()->Value() ); - - switch( category ){ - case 1: entity = new Commodity(); break; - case 2: entity = new PowerPlant(); break; - case 4: entity = new Capacitor(); break; - case 6: entity = new Engine(); break; - case 7: entity = new Shield(); break; - case 8: entity = new Radar(); break; - case 10: entity = new Gun(); break; - case 11: entity = new Missile(); break; - default: - log_->fatal( fileName + " category_id " + toStr( category ) + " unknown." ); - return NULL; + //** Mandatory elements; + pElem = hRoot.ChildElement( "category_id", 0 ).Element(); + if ( !pElem ) { //** fallback + pElem = hRoot.ChildElement( "categorie_id", 0 ).Element(); } - } else { - log_->fatal( fileName + " has no category_id (mandatory)." ); - return NULL; - } - //** Mandatory elements; - 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; - } - - - pElem = hRoot.ChildElement( "faction_id", 0 ).Element(); - if ( pElem ) { - entity->setFactionID( toInt( pElem->FirstChild()->Value() ) ); - } else { - log_->fatal( fileName + " has no faction_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 elements - 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( "required_rank", 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() ) ); - - double efficiency = 1.0; - pElem = hRoot.ChildElement( "efficiency", 0 ).Element(); - if ( pElem ) { - efficiency = toDouble( pElem->FirstChild()->Value() ); - if ( efficiency > 1 ) efficiency /= 100; - } - - Uint32 powerConsumption = 0; - pElem = hRoot.ChildElement( "power_input", 0 ).Element(); - if ( pElem ) powerConsumption = toInt( pElem->FirstChild()->Value() ); - - pElem = hRoot.ChildElement( "description_" + ResourceManager::getSingleton().languageSuffix(), 0 ).Element(); - if ( !pElem ){ //** fallback to english - pElem = hRoot.ChildElement( "description_en", 0 ).Element(); - } - if ( !pElem ){ //** fallback to english - pElem = hRoot.ChildElement( "description_en", 0 ).Element(); - } - if ( pElem ) { - std::cout << entity->description() << std::endl; - entity->setDescription( pElem->FirstChild()->Value() ); - } - - //** Specific elements; - switch ( entity->entityType() ){ - case POWERPLANT: - pElem = hRoot.ChildElement( "power_output", 0 ).Element(); - if ( pElem ) dynamic_cast< PowerPlant * >( entity )->setPowerOutput( toInt( pElem->FirstChild()->Value() ) ); - break; - case ENGINE: - dynamic_cast< Engine * >( entity )->setEfficiency( efficiency ); - pElem = hRoot.ChildElement( "maximum_thrust", 0 ).Element(); - if ( pElem ) dynamic_cast< Engine * >( entity )->setMaxThrust( toInt( pElem->FirstChild()->Value() ) ); - - break; - case RADAR: - dynamic_cast< Radar * >( entity )->setEfficiency( efficiency ); - dynamic_cast< Radar * >( entity )->setPowerConsumption( powerConsumption ); - - pElem = hRoot.ChildElement( "maximum_range", 0 ).Element(); - if ( pElem ) dynamic_cast< Radar * >( entity )->setMaxRange( toInt( pElem->FirstChild()->Value() ) ); - - break; - case ECM: - dynamic_cast< Ecm * >( entity )->setPowerConsumption( powerConsumption ); - - pElem = hRoot.ChildElement( "sensorlevel", 0 ).Element(); - if ( pElem ) dynamic_cast< Ecm * >( entity )->setSensorLevel( toInt( pElem->FirstChild()->Value() ) ); - - pElem = hRoot.ChildElement( "power", 0 ).Element(); - if ( pElem ) dynamic_cast< Ecm * >( entity )->setPowerConsumption( toInt( pElem->FirstChild()->Value() ) ); - break; - case CAPACITOR: - dynamic_cast< Capacitor * >( entity )->setEfficiency( efficiency ); - - pElem = hRoot.ChildElement( "capacity", 0 ).Element(); - if ( pElem ) dynamic_cast< Capacitor * >( entity )->setCapacity( toInt( pElem->FirstChild()->Value() ) ); - break; - case SHIELD: - dynamic_cast< Shield * >( entity )->setEfficiency( efficiency ); - - pElem = hRoot.ChildElement( "regeneration_rate", 0 ).Element(); - if ( pElem ) dynamic_cast< Shield * >( entity )->setRegenerationRate( toInt( pElem->FirstChild()->Value() ) ); - pElem = hRoot.ChildElement( "maximum_deflection", 0 ).Element(); - if ( pElem ) dynamic_cast< Shield * >( entity )->setMaxDeflection( toInt( pElem->FirstChild()->Value() ) ); - - break; - case GUN: - pElem = hRoot.ChildElement( "type", 0 ).Element(); if ( pElem ) { - if ( strcmp( pElem->FirstChild()->Value(), "laser" ) == 0 ){ - dynamic_cast< Gun * >( entity )->setType( LASER ); - } else if ( strcmp( pElem->FirstChild()->Value(), "mininglaser" ) == 0 ){ - dynamic_cast< Gun * >( entity )->setType( MININGLASER ); - } else if ( strcmp( pElem->FirstChild()->Value(), "bullet" ) == 0 ){ - dynamic_cast< Gun * >( entity )->setType( BULLET ); - } - } + int category = toInt( pElem->FirstChild()->Value() ); - pElem = hRoot.ChildElement( "velocity", 0 ).Element(); - if ( pElem ) dynamic_cast< Gun * >( entity )->setSpeed( toInt( pElem->FirstChild()->Value() ) ); - - pElem = hRoot.ChildElement( "life_time", 0 ).Element(); - if ( pElem ) dynamic_cast< Gun * >( entity )->setLifeTime( toDouble( pElem->FirstChild()->Value() ) ); - - pElem = hRoot.ChildElement( "fire_delay", 0 ).Element(); - if ( pElem ) dynamic_cast< Gun * >( entity )->setFireDelay( toDouble( pElem->FirstChild()->Value() ) ); - - 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(); - if ( pElem ) dynamic_cast< Gun * >( entity )->setDamage( toInt( pElem->FirstChild()->Value() ) ); - break; - case MISSILE: - break; - case MODX: - break; - default: - break; - } - - //** 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 ); - CommodityManager* commodityMgr = CommodityManager::getSingletonPtr(); - if ( !commodityMgr ) { - log_->fatal( "Cannot find the commodity manager, no production data available" ); - return NULL; - } - std::set < Commodity * > commodities; - for ( pElem = hRoot.FirstChild( "required-component" ).Element(); pElem != 0; pElem = pElem->NextSiblingElement() ) { - Commodity *commodity = commodityMgr->findByName ( pElem->FirstChild()->Value() ); //!< \todo check return value! - if ( commodity ) { - commodities.insert( commodity ); + switch( category ){ + case 1: entity = new Commodity(); break; + case 2: entity = new PowerPlant(); break; + case 4: entity = new Capacitor(); break; + case 6: entity = new Engine(); break; + case 7: entity = new Shield(); break; + case 8: entity = new Radar(); break; + case 10: entity = new Gun(); break; + case 11: entity = new Missile(); break; + default: + log_->fatal( fileName + " category_id " + toStr( category ) + " unknown." ); + return NULL; + } } else { - log_->warn( fileName + " has unsatisfied commodities." ); + log_->fatal( fileName + " has no category_id (mandatory)." ); + return NULL; } - } - entity->setRequieredComponents( commodities ); + //** 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" ) ) ); + + try{ + entity->readPropertiesFromXML( hRoot ); + } catch ( std::invalid_argument e ){ + log_->warn( e.what() ); + return NULL; + } + + if ( templatesByName_.count( entity->name() ) == 0 ){ + templatesByName_[ entity->name() ] = entity; + templatesByID_[ entity->id() ] = entity; + factions_.insert( entity->factionName() ); + } else { + log_->warn( std::string( "Equipment with name: " ) + entity->factionName() + "/" + entity->name() + + " already loaded" ); + } - if ( templatesByName_.count( entity->name() ) == 0 ){ - templatesByName_[ entity->name() ] = entity; - templatesByID_[ entity->id() ] = entity; - - factions_.insert( entity->factionName() ); - } else { - log_->warn( std::string( "Equipment with name: " ) + entity->factionName() + "/" + entity->name() + - " already loaded" ); - } - return entity; + return entity; } + +// template<> EquipmentManager * Ogre::Singleton< EquipmentManager >::ms_Singleton = 0; +// +// EquipmentManager::EquipmentManager(): EntityManager(){ +// Entity * entity = new Missile(); +// entity->setName( "firefly" ); +// entity->setID( 10001 ); +// dynamic_cast< Missile * >( entity )->setDamage( 10400 ); +// dynamic_cast< Missile * >( entity )->setThrust( 150000 ); +// // dynamic_cast< Missile * >( entity )->setYaw( 90 ); +// // dynamic_cast< Missile * >( entity )->setPitch( 90 ); +// // dynamic_cast< Missile * >( entity )->setRoll( 90 ); +// //dynamic_cast< Missile * >( entity )->setArmor( 1 ); +// //dynamic_cast< Missile * >( entity )->setMass( 150 ); +// dynamic_cast< Missile * >( entity )->setLifeTime( 20 ); +// // dynamic_cast< Missile * >( entity )->setDragFactor( 1 ); +// dynamic_cast< Missile * >( entity )->setBaseSize(0.2, 0.2, 1.0 ); +// try{ +// dynamic_cast< Missile * >(entity)->setMesh( "firefly.mesh", false ); +// +// +// } catch( Ogre::Exception & e ){ +// LogManager::getSingleton().warn( e.what() ); +// } +// templatesByName_[ entity->name() ] = entity; +// templatesByID_[ entity->id() ] = entity; +// } +// +// EquipmentManager::~EquipmentManager() { +// } +// +// EquipmentManager & EquipmentManager::getSingleton( ){ +// assert( ms_Singleton ); +// return ( *ms_Singleton ); +// } +// +// EquipmentManager * EquipmentManager::getSingletonPtr( ){ +// if ( ms_Singleton == NULL ){ +// LogManager::getSingleton().fatal( "CommodityManager not initialized." ); +// } +// return ms_Singleton; +// } +// +// +// +// Entity * EquipmentManager::loadAndCreate( const std::string & fileName ){ +// +// log_->fout( "Read equipment: " + fileName ); +// +// TiXmlDocument doc( fileName ); +// bool loadOkay = doc.LoadFile(); +// +// if ( !loadOkay ) { +// log_->fatal( std::string( "Failed to load equipment 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( "equipment", pElem->Value() ) != 0 && strcmp( "container", pElem->Value() ) != 0 ) { +// log_->fatal( fileName + " is no equipment description" ); +// return NULL; +// } +// +// // Equipment * entity = 0; +// // std::string equipmentType = pElem->Attribute("type"); +// +// +// // if ( equipmentType == "Engine" ) entity = new Engine(); +// // else if ( equipmentType == "ECM" ) entity = new Ecm(); +// // else if ( equipmentType == "Capacitor" ) entity = new Capacitor(); +// // else { +// // log_->fatal( fileName + " has no type of equipment defined" ); +// // return NULL; +// // } +// +// +// Entity * entity; +// +// //** Mandatory elements; +// pElem = hRoot.ChildElement( "category_id", 0 ).Element(); +// if ( !pElem ) { //** fallback +// pElem = hRoot.ChildElement( "categorie_id", 0 ).Element(); +// } +// +// if ( pElem ) { +// int category = toInt( pElem->FirstChild()->Value() ); +// +// switch( category ){ +// case 1: entity = new Commodity(); break; +// case 2: entity = new PowerPlant(); break; +// case 4: entity = new Capacitor(); break; +// case 6: entity = new Engine(); break; +// case 7: entity = new Shield(); break; +// case 8: entity = new Radar(); break; +// case 10: entity = new Gun(); break; +// case 11: entity = new Missile(); break; +// default: +// log_->fatal( fileName + " category_id " + toStr( category ) + " unknown." ); +// return NULL; +// } +// } else { +// log_->fatal( fileName + " has no category_id (mandatory)." ); +// return NULL; +// } +// +// //** Mandatory elements; +// 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; +// } +// +// +// pElem = hRoot.ChildElement( "faction_id", 0 ).Element(); +// if ( pElem ) { +// entity->setFactionID( toInt( pElem->FirstChild()->Value() ) ); +// } else { +// log_->fatal( fileName + " has no faction_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 elements +// 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( "required_rank", 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() ) ); +// +// double efficiency = 1.0; +// pElem = hRoot.ChildElement( "efficiency", 0 ).Element(); +// if ( pElem ) { +// efficiency = toDouble( pElem->FirstChild()->Value() ); +// if ( efficiency > 1 ) efficiency /= 100; +// } +// +// Uint32 powerConsumption = 0; +// pElem = hRoot.ChildElement( "power_input", 0 ).Element(); +// if ( pElem ) powerConsumption = toInt( pElem->FirstChild()->Value() ); +// +// pElem = hRoot.ChildElement( "description_" + ResourceManager::getSingleton().languageSuffix(), 0 ).Element(); +// if ( !pElem ){ //** fallback to english +// pElem = hRoot.ChildElement( "description_en", 0 ).Element(); +// } +// if ( !pElem ){ //** fallback to english +// pElem = hRoot.ChildElement( "description_en", 0 ).Element(); +// } +// if ( pElem ) { +// std::cout << entity->description() << std::endl; +// entity->setDescription( pElem->FirstChild()->Value() ); +// } +// +// //** Specific elements; +// switch ( entity->entityType() ){ +// case POWERPLANT: +// pElem = hRoot.ChildElement( "power_output", 0 ).Element(); +// if ( pElem ) dynamic_cast< PowerPlant * >( entity )->setPowerOutput( toInt( pElem->FirstChild()->Value() ) ); +// break; +// case ENGINE: +// dynamic_cast< Engine * >( entity )->setEfficiency( efficiency ); +// pElem = hRoot.ChildElement( "maximum_thrust", 0 ).Element(); +// if ( pElem ) dynamic_cast< Engine * >( entity )->setMaxThrust( toInt( pElem->FirstChild()->Value() ) ); +// +// break; +// case RADAR: +// dynamic_cast< Radar * >( entity )->setEfficiency( efficiency ); +// dynamic_cast< Radar * >( entity )->setPowerConsumption( powerConsumption ); +// +// pElem = hRoot.ChildElement( "maximum_range", 0 ).Element(); +// if ( pElem ) dynamic_cast< Radar * >( entity )->setMaxRange( toInt( pElem->FirstChild()->Value() ) ); +// +// break; +// case ECM: +// dynamic_cast< Ecm * >( entity )->setPowerConsumption( powerConsumption ); +// +// pElem = hRoot.ChildElement( "sensorlevel", 0 ).Element(); +// if ( pElem ) dynamic_cast< Ecm * >( entity )->setSensorLevel( toInt( pElem->FirstChild()->Value() ) ); +// +// pElem = hRoot.ChildElement( "power", 0 ).Element(); +// if ( pElem ) dynamic_cast< Ecm * >( entity )->setPowerConsumption( toInt( pElem->FirstChild()->Value() ) ); +// break; +// case CAPACITOR: +// dynamic_cast< Capacitor * >( entity )->setEfficiency( efficiency ); +// +// pElem = hRoot.ChildElement( "capacity", 0 ).Element(); +// if ( pElem ) dynamic_cast< Capacitor * >( entity )->setCapacity( toInt( pElem->FirstChild()->Value() ) ); +// break; +// case SHIELD: +// dynamic_cast< Shield * >( entity )->setEfficiency( efficiency ); +// +// pElem = hRoot.ChildElement( "regeneration_rate", 0 ).Element(); +// if ( pElem ) dynamic_cast< Shield * >( entity )->setRegenerationRate( toInt( pElem->FirstChild()->Value() ) ); +// pElem = hRoot.ChildElement( "maximum_deflection", 0 ).Element(); +// if ( pEl... [truncated message content] |
From: <spo...@us...> - 2008-05-04 15:50:26
|
Revision: 889 http://opengate.svn.sourceforge.net/opengate/?rev=889&view=rev Author: spom_spom Date: 2008-05-04 08:50:32 -0700 (Sun, 04 May 2008) Log Message: ----------- Add docking assistant. Shift-A toggle on/off Modified Paths: -------------- trunk/src/AiCommands.cpp trunk/src/AiManager.cpp trunk/src/AiManager.h trunk/src/AiObject.cpp trunk/src/AiObject.h trunk/src/BaseObject.h trunk/src/KeyMap.cpp trunk/src/OpenALSoundManager.cpp trunk/src/Projectile.cpp trunk/src/Sector.cpp trunk/src/SectorObject.h 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/UnDockedState.h Modified: trunk/src/AiCommands.cpp =================================================================== --- trunk/src/AiCommands.cpp 2008-05-04 12:13:52 UTC (rev 888) +++ trunk/src/AiCommands.cpp 2008-05-04 15:50:32 UTC (rev 889) @@ -64,7 +64,13 @@ } -void AiCommandSelfDestruct::stop(){ ai_->kill(); } +void AiCommandSelfDestruct::stop(){ + if ( ai_->vesselObject() ){ + ai_->vesselObject()->setControler( NULL ); + ai_->vesselObject()->destroy(); + } + ai_->kill(); +} void AiCommandYaw::start(){ Modified: trunk/src/AiManager.cpp =================================================================== --- trunk/src/AiManager.cpp 2008-05-04 12:13:52 UTC (rev 888) +++ trunk/src/AiManager.cpp 2008-05-04 15:50:32 UTC (rev 889) @@ -41,7 +41,7 @@ namespace OpenGate{ AiManager::AiManager( ResourceManager * resources ) : resources_( resources ){ - eraseAiObjectCB_ = new AiManagerCB( this, &AiManager::eraseAiObject ); + eraseAiObjectCB_ = new AiManagerCB( this, &AiManager::eraseAiObject_ ); aiID_ = 1; } @@ -143,14 +143,11 @@ // 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 ); - std::cout << "starting: " << ai->name() << std::endl; - - RunAiObject aio( ai, eraseAiObjectCB_ ); - aiThreads_.create_thread( aio ); return ai; } @@ -170,19 +167,28 @@ return ai; } -void AiManager::eraseAiObject( AiObject * ai ){ +void AiManager::startAiObject( AiObject * ai ){ + std::cout << "starting: " << ai->name() << std::endl; + RunAiObject aio( ai, eraseAiObjectCB_ ); + aiThreads_.create_thread( aio ); +} + +void AiManager::stopAiObject( AiObject * ai ){ + ai->kill(); +} + +void AiManager::eraseAiObject_( AiObject * ai ){ boost::mutex::scoped_lock lock( eraseMutex_ ); SectorObjectVessel *obj = ai->vesselObject( ); if ( obj ){ __D( obj->name() ) - obj->destroy(); + obj->setControler( NULL ); } aiObjects_.erase( ai ); + recycle_( ai ); } -void AiManager::recycle( AiObject * ai ){ - aiObjectHeap_.push_back( ai ); -} +void AiManager::recycle_( AiObject * ai ){ aiObjectHeap_.push_back( ai ); } } // namespace OpenGate{ Modified: trunk/src/AiManager.h =================================================================== --- trunk/src/AiManager.h 2008-05-04 12:13:52 UTC (rev 888) +++ trunk/src/AiManager.h 2008-05-04 15:50:32 UTC (rev 889) @@ -58,29 +58,38 @@ ~AiManager( ); - void cmd( const std::vector < std::string > & argv ); + 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 ); + /*! Create new ai and put it to the set of active ai. The instance is taken from heap if available else create new. + The object will start its work when startAiObject is called. + The object will destoyed automaticaly either there work is done or stopAiObject is called.*/ + 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 ); + /*! Create new thread for the ai and start running */ + void startAiObject( AiObject * ai ); + + /*! Send kill signal to aiObject. The object will erased automaticaly */ + void stopAiObject( AiObject * ai ); + + /*! Check for any active ai's. */ + inline bool hasActiveObjects() const { return ( aiObjects_.size() > 0 ); } - /*! 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_; } - /*!Send kill signal to all ai and join all threads. Mainly used for shutdown the manager.*/ - void killall(); + AiObject * spawnAi( ); - /*! ID of the last created ai */ - uint aiID() const { return aiID_; } - protected: + /*! The ai is dead and can be recycled. */ + void recycle_( AiObject * ai ); + + /*! 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 ); + + ResourceManager * resources_; std::set< AiObject * > aiObjects_; Modified: trunk/src/AiObject.cpp =================================================================== --- trunk/src/AiObject.cpp 2008-05-04 12:13:52 UTC (rev 888) +++ trunk/src/AiObject.cpp 2008-05-04 15:50:32 UTC (rev 889) @@ -37,13 +37,13 @@ namespace OpenGate{ AiObject::AiObject( uint id ) : id_( id ), vesselObject_( NULL ){ - livetime_ = new Ogre::Timer(); + lifeTimer_ = new Ogre::Timer(); reset(); } AiObject::~AiObject(){ for_each( cmdQueue_.begin(), cmdQueue_.end(), deletePtr() ); - delete livetime_; + delete lifeTimer_; } //** protected copy constructor @@ -62,7 +62,8 @@ } void AiObject::reset( ){ - livetime_->reset(); + vesselObject_ = NULL; + lifeTimer_->reset(); lasttime_ = 0; refCounter_ = 0; name_ = "unknown"; @@ -79,12 +80,18 @@ } } +void AiObject::kill() { + if ( vesselObject_ ) vesselObject_->setControler( NULL ); + vesselObject_ = NULL; + isAlive_ = false; +} + void AiObject::run(){ __D( name_ ) isAlive_ = true; - livetime_->reset(); + lifeTimer_->reset(); do { if ( activeCmd_ ){ - unsigned long tmpTime = livetime_->getMicroseconds(); + unsigned long tmpTime = lifeTimer_->getMicroseconds(); // std::cout << tmpTime << " " << lasttime_ << std::endl; if ( !activeCmd_->update( ( tmpTime - lasttime_ ) / 1e6 ) ) { delete activeCmd_; @@ -167,24 +174,22 @@ cmdQueue_.push_back( new AiCommandLookAt( this, Ogre::Vector3( 0.0, 0.0, 1.0 ) ) ); } -void AiObject::land( const StationObject & station ){ - cmdQueue_.push_back( new AiCommandWait( this, 2.0 ) ); - //Vector3(-0.563038, -77.3473, -1348.36) // dockpad - std::cout << "station docking pad: " << station.dockPadPosition( ) << std::endl; +void AiObject::land( StationObject * station ){ + if ( station ){ + cmdQueue_.push_back( new AiCommandWait( this, 1.0 ) ); +// std::cout << "station docking pad: " << station.dockPadPosition( ) << std::endl; +// std::cout << "station ring end:" << station.dockingRingEnd( ) << std::endl; +// std::cout << "station ring start:" << station.dockingRingStart( ) << std::endl; +// station->sector()->koordAxis()->setPosition( station.dockPadPosition( ) ); +// std::cout << "station launch pad: " << station.launchPadPosition( ) << std::endl; - std::cout << "station ring end:" << station.dockingRingEnd( ) << std::endl; - // Vector3(-66.7835, -78.9126, -433.894) - std::cout << "station ring start:" << station.dockingRingStart( ) << std::endl; - - const_cast< StationObject * > (&station)->sector()->koordAxis()->setPosition( station.dockPadPosition( ) ) ; - // Vector3(-261.482, -5.00386, -1384.19) - std::cout << "station launch pad: " << station.launchPadPosition( ) << std::endl; - //cmdQueue_.push_back( new AiCommandApproach( this, station.dockingRingStart( ), true ) ); - cmdQueue_.push_back( new AiCommandApproach( this, station.dockingRingStart( ), true ) ); - cmdQueue_.push_back( new AiCommandWait( this, 1.0 ) ); - cmdQueue_.push_back( new AiCommandApproach( this, station.dockPadPosition( ), true ) ); - + cmdQueue_.push_back( new AiCommandApproach( this, station->dockingRingStart( ), true ) ); + cmdQueue_.push_back( new AiCommandWait( this, 1.0 ) ); + cmdQueue_.push_back( new AiCommandApproach( this, station->dockPadPosition( ), true ) ); + } else { + std::cerr << "Station is not valid" << std::endl; + } cmdQueue_.push_back( new AiCommandWait( this, 5.0 ) ); cmdQueue_.push_back( new AiCommandSelfDestruct( this ) ); } Modified: trunk/src/AiObject.h =================================================================== --- trunk/src/AiObject.h 2008-05-04 12:13:52 UTC (rev 888) +++ trunk/src/AiObject.h 2008-05-04 15:50:32 UTC (rev 889) @@ -64,8 +64,8 @@ bool isAlive() const { return isAlive_; } - void kill() { isAlive_ = false; } - + void kill(); + void reset(); void setName ( const std::string & name ){ name_ = name; } @@ -78,10 +78,10 @@ void test( ); - void land( const StationObject & station ); + void land( StationObject * station ); /*! Idle and look every second for new orders */ - bool cmdIdle( ); + //bool cmdIdle( ); /*! Wait and do nothing */ bool cmdWait( double time ); /*! Accelerate a given time with a given thrustRate */ @@ -130,7 +130,7 @@ bool die_; //! holds objects livetime - Ogre::Timer * livetime_; + Ogre::Timer * lifeTimer_; //! time from last livecyle in microseconds unsigned long lasttime_; Modified: trunk/src/BaseObject.h =================================================================== --- trunk/src/BaseObject.h 2008-05-04 12:13:52 UTC (rev 888) +++ trunk/src/BaseObject.h 2008-05-04 15:50:32 UTC (rev 889) @@ -83,12 +83,14 @@ 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 */ + /*! Mark the object for destruction + To keep destruction thread safe, we just notify and let the update cycle do the job */ void destroy() { destroyRequest_ = true; } - + bool isSetDestroyRequest() const { return destroyRequest_; } - + + virtual void setVisible( bool visible ) { mainNode_->setVisible( visible ); } + protected: Ogre::String name_; Sector * sector_; Modified: trunk/src/KeyMap.cpp =================================================================== --- trunk/src/KeyMap.cpp 2008-05-04 12:13:52 UTC (rev 888) +++ trunk/src/KeyMap.cpp 2008-05-04 15:50:32 UTC (rev 889) @@ -63,6 +63,8 @@ unDockedActionMap_[ keycode( OIS::KC_4 ) ] = &UnDockedState::keyActionCameraUp; unDockedActionMap_[ keycode( OIS::KC_5 ) ] = &UnDockedState::keyActionCameraDown; unDockedActionMap_[ keycode( OIS::KC_6 ) ] = &UnDockedState::keyActionCameraToggle; + + unDockedActionMap_[ keycode( OIS::KC_A, KEY_SHIFT ) ] = &UnDockedState::keyActionDockAssist; /*! Actions for console. */ consoleActionMap_[ keycode( OIS::KC_SYSRQ ) ] = &Console::keyActionScreenshot; Modified: trunk/src/OpenALSoundManager.cpp =================================================================== --- trunk/src/OpenALSoundManager.cpp 2008-05-04 12:13:52 UTC (rev 888) +++ trunk/src/OpenALSoundManager.cpp 2008-05-04 15:50:32 UTC (rev 889) @@ -278,10 +278,10 @@ } bool OpenALOggStreamSource::release(){ - alSourceStop( source_ ); + stop(); empty_(); - //** alDeleteSources(1, & source_ ); + alDeleteSources(1, & source_ ); //** valgrind says:; // Invalid read of size 4 // ==10954== at 0x6129E42: (within /usr/lib64/libopenal.so.0.0.0) @@ -298,7 +298,7 @@ } void OpenALOggStreamSource::showInfos(){ - std::cout << "version " << vorbisInfo_->version << "\n" + std::cout << "version " << vorbisInfo_->version << "\n" << "channels " << vorbisInfo_->channels << "\n" << "rate (hz) " << vorbisInfo_->rate << "\n" << "bitrate upper " << vorbisInfo_->bitrate_upper << "\n" @@ -401,7 +401,7 @@ return true; } - OpenALListener::OpenALListener( OpenALSoundManager * soundMgr, bool dummy ) : soundMgr_( soundMgr ), dummy_( dummy ){ +OpenALListener::OpenALListener( OpenALSoundManager * soundMgr, bool dummy ) : soundMgr_( soundMgr ), dummy_( dummy ){ reset(); } Modified: trunk/src/Projectile.cpp =================================================================== --- trunk/src/Projectile.cpp 2008-05-04 12:13:52 UTC (rev 888) +++ trunk/src/Projectile.cpp 2008-05-04 15:50:32 UTC (rev 889) @@ -32,7 +32,7 @@ namespace OpenGate{ - Projectile::Projectile( BaseObject * parent, long shotCount, Gun & gun, const Ogre::Vector3 & pos, const Ogre::Vector3 & vel ) +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 ){ @@ -48,8 +48,9 @@ } Projectile::Projectile( BaseObject * parent, long shotCounter, const GunObject & gun, const Ogre::Vector3 & mountPoint ) - : BaseObject( parent->name() + "_" + toStr( shotCounter ), parent->sector() ), parent_( parent ), - shotCount_( shotCounter), gun_( gun.gun() ), 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; beam_ = NULL; @@ -60,6 +61,7 @@ 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() ) * @@ -67,6 +69,8 @@ Ogre::Vector3 pos( gun.sceneNode().getWorldPosition() - direction.zAxis() * relGunPos[ 2 ] ); +// std::cout << parent_->name() << std::endl; +// std::cout << pos << " " << relGunPos << std::endl; fire( pos, relGunPos ); } @@ -103,7 +107,7 @@ Ogre::Quaternion direction( parent_->mainNode()->getOrientation() ); mainNode_->setOrientation( direction ); mainNode_->setPosition( pos ); - mainNode_->_update( true, true ); + //mainNode_->_update( true, true ); lifeTime_ = 0.0; oldTime_ = 0.0; @@ -138,6 +142,7 @@ } if ( manuObject ){ +// std::cout << "createManualObject" << std::endl; beam_ = sceneMgr_->createManualObject( bulletName + "_ManualObj" ); Ogre::Real width = 0.25; beam_->begin( "BeamGreen", Ogre::RenderOperation::OT_TRIANGLE_LIST); @@ -150,13 +155,14 @@ beam_->end(); shape_->attachObject( beam_ ); } else { +// std::cout << "createRibbonTrail" << std::endl; trail_ = sceneMgr_->createRibbonTrail( bulletName + "_RibbonTrail"); trail_->setMaterialName( "BeamGreen" ); trail_->setTrailLength( maxRange_ ); trail_->setWidthChange( 0, 2.0 ); trail_->setMaxChainElements( 1000 ); trail_->setInitialWidth( 0, 1.0 ); - trail_->addNode( shape_ ); + trail_->addNode( mainNode_ ); trailNode_ = sceneMgr_->getRootSceneNode()->createChildSceneNode(); trailNode_->attachObject( trail_ ); } @@ -210,7 +216,7 @@ // trail_->setTrailLength( beamLength ); } } - } else { + } else { // if not ammoHit_ Ogre::Real beamLength = min( (vel_ * lifeTime_).length(), maxRange_ / 2.0f ); beamLength -= ( parent_->mainNode()->getWorldPosition() + ( vel_ * lifeTime_ ) - mainNode_->getWorldPosition() ).length(); Modified: trunk/src/Sector.cpp =================================================================== --- trunk/src/Sector.cpp 2008-05-04 12:13:52 UTC (rev 888) +++ trunk/src/Sector.cpp 2008-05-04 15:50:32 UTC (rev 889) @@ -166,10 +166,6 @@ populate( "testsector.xml" ); createKoordAxis( ); - SectorObject *obj = createStaticObject( "Firefly.mesh", "Firefly/static", Ogre::Vector3( 0.0, 0.0, 0.0 )); -obj->mainNode()->showBoundingBox( true ); - - std::cout << "Firefly: " << obj->mainNode()->_getWorldAABB() << std::endl; } Sector::~Sector( ){ Modified: trunk/src/SectorObject.h =================================================================== --- trunk/src/SectorObject.h 2008-05-04 12:13:52 UTC (rev 888) +++ trunk/src/SectorObject.h 2008-05-04 15:50:32 UTC (rev 889) @@ -54,25 +54,25 @@ virtual bool update( Ogre::Real elapsedTime ){ return true; } - void setShape( const Ogre::String & meshname ); - void setShape( Ogre::MeshPtr & mesh ); - Ogre::Entity * entity(){ return entity_; } + void setShape( const Ogre::String & meshname ); + void setShape( Ogre::MeshPtr & mesh ); + Ogre::Entity * entity(){ return entity_; } - void scale( const Ogre::Vector3 & scale ); + void scale( const Ogre::Vector3 & scale ); - void setBaseSize( const Ogre::Vector3 & targetSize ); - void setBaseRot( const Ogre::Real & yaw, const Ogre::Real & pitch = 0, const Ogre::Real & roll = 0 ); + void setBaseSize( const Ogre::Vector3 & targetSize ); + void setBaseRot( const Ogre::Real & yaw, const Ogre::Real & pitch = 0, const Ogre::Real & roll = 0 ); - Ogre::Vector3 baseSize( ) const { return baseSize_; } - Ogre::Real maxBaseSize( ) const { return max( max( baseSize_[0], baseSize_[1] ), baseSize_[2] ); } + Ogre::Vector3 baseSize( ) const { return baseSize_; } + Ogre::Real maxBaseSize( ) const { return max( max( baseSize_[0], baseSize_[1] ), baseSize_[2] ); } - bool isOnRadar() const { return isOnRadar_; } - void onRadar( bool onradar ) { isOnRadar_ = onradar; } + bool isOnRadar() const { return isOnRadar_; } + void onRadar( bool onradar ) { isOnRadar_ = onradar; } - virtual Ogre::Vector3 velocity() const { return Ogre::Vector3(0.0, 0.0, 0.0 ); } + virtual Ogre::Vector3 velocity() const { return Ogre::Vector3(0.0, 0.0, 0.0 ); } - Ogre::OverlayElement * dotA() { return dotA_; } - Ogre::OverlayElement * dotB() { return dotB_; } + Ogre::OverlayElement * dotA() { return dotA_; } + Ogre::OverlayElement * dotB() { return dotB_; } /*! Add an object to the set of observers e.g. selected as target, dot on radar. When this object dies the observers have to informed. */ @@ -90,10 +90,6 @@ /*! Return the current target. */ virtual SectorObject * target( ){ return target_; } - virtual void setVisible( bool visible ){ mainNode_->setVisible( false ); } - void show( ){ setVisible( true ); } - void hide( ){ setVisible( false ); } - protected: Ogre::SceneNode * mainNodeEntityScale_; // Main character node for base size Modified: trunk/src/SectorObjectMoveable.cpp =================================================================== --- trunk/src/SectorObjectMoveable.cpp 2008-05-04 12:13:52 UTC (rev 888) +++ trunk/src/SectorObjectMoveable.cpp 2008-05-04 15:50:32 UTC (rev 889) @@ -100,51 +100,50 @@ roll_ = 0.0; pitch_ = 0.0; - mass_ = 1; - armor_ = maxArmor_; - thrust_ = 0; - maxThrust_ = 0; + mass_ = 1; + armor_ = maxArmor_; + thrust_ = 0; + maxThrust_ = 0; + thrustRate_ = 0; - - shieldGlowActive_ = false; - shieldGlowTime_ = 0.0; + shieldGlowActive_ = false; + shieldGlowTime_ = 0.0; vel_ = Ogre::Vector3( 0.0, 0.0, 0.0 ); - interpolateRot_ = Ogre::Quaternion( 1.0, 0.0, 0.0, 0.0 ); - interpolateVel_ = Ogre::Vector3( 0.0, 0.0, 0.0 ); + interpolateRot_ = Ogre::Quaternion( 1.0, 0.0, 0.0, 0.0 ); + interpolateVel_ = Ogre::Vector3( 0.0, 0.0, 0.0 ); - explosion_ = NULL; + explosion_ = NULL; explodeSequenceTime_ = 5.0; - deathSequence_ = false; - breakPressed_ = false; + deathSequence_ = false; + breakPressed_ = false; - netSequence_ = 0; - lifeTime_ = 0.0; - lastLifeTime_ = 0.0; - forceMovement_ = false; - statusChanged_ = false; + netSequence_ = 0; + lifeTime_ = 0.0; + lastLifeTime_ = 0.0; + forceMovement_ = false; + statusChanged_ = false; - lastFrameCount_ = 0; - //** increase this value to add some fog-friction; - ethernalDensity_ = 1.0; - explosion_ = NULL; + lastFrameCount_ = 0; + + ethernalDensity_ = 1.0; } bool SectorObjectMoveable::update( Ogre::Real elapsedTime ){ - if ( elapsedTime < 0.001 ) return true; + if ( elapsedTime < 0.001 ) return true; - if ( destroyRequest_ ){ - std::cout << "SectorObjectMoveable::update( Ogre::Real elapsedTime ) destroy: " << name_ << " " << destroyRequest_ << std::endl; - - return false; - } + if ( destroyRequest_ ){ + std::cout << "SectorObjectMoveable::update( Ogre::Real elapsedTime ) destroy: " << name_ << " " + << destroyRequest_ << std::endl; + return false; + } - lifeTime_ += elapsedTime; - lastFrameCount_ ++; + lifeTime_ += elapsedTime; + lastFrameCount_ ++; - Ogre::Real rotFric = rotFriction(); + Ogre::Real rotFric = rotFriction(); if ( !isChild() ){ mainNode_->yaw( Ogre::Degree( yaw_ * ( moveable_->yaw() * rotFric ) * elapsedTime ) ); @@ -192,7 +191,7 @@ mainNode_->translate( ( vel_ + interpolateVel_ ) * elapsedTime ); //** because of the discrete jumps between to frames we have to check for collisions via ray; - if ( !destroyRequest_ && collObj_ ){ + if ( collObj_ ){ Ogre::Ray rayNoNextPos( mainNode_->getPosition(), vel_.normalisedCopy() ); //** bitte bitte check, ob das vor oder nach dem Move soll bzw, ob die richtung stimmt Modified: trunk/src/SectorObjectMoveable.h =================================================================== --- trunk/src/SectorObjectMoveable.h 2008-05-04 12:13:52 UTC (rev 888) +++ trunk/src/SectorObjectMoveable.h 2008-05-04 15:50:32 UTC (rev 889) @@ -163,35 +163,35 @@ Ogre::Entity * shieldEntity_; Ogre::SceneNode * shieldEntityNode_; - Ogre::Real yaw_; - Ogre::Real pitch_; - Ogre::Real roll_; + Ogre::Real yaw_; + Ogre::Real pitch_; + Ogre::Real roll_; - Ogre::Vector3 acc_; - Ogre::Vector3 vel_; + Ogre::Vector3 acc_; + Ogre::Vector3 vel_; - Uint32 mass_; + Uint32 mass_; - Uint32 thrust_; - Uint32 maxThrust_; - Ogre::Real thrustRate_; + Uint32 thrust_; + Uint32 maxThrust_; + Ogre::Real thrustRate_; - Uint32 armor_; - Uint32 maxArmor_; + Uint32 armor_; + Uint32 maxArmor_; - Ogre::Real maxSpeed_; + Ogre::Real maxSpeed_; - Uint32 shield_; - Uint32 maxShield_; - bool shieldGlowActive_; - Ogre::Real shieldGlowTime_; + Uint32 shield_; + Uint32 maxShield_; + bool shieldGlowActive_; + Ogre::Real shieldGlowTime_; - bool deathSequence_; - bool breakPressed_; + bool deathSequence_; + bool breakPressed_; - Ogre::Real ethernalDensity_; + Ogre::Real ethernalDensity_; - Ogre::Real explodeSequenceTime_; + Ogre::Real explodeSequenceTime_; Ogre::Quaternion interpolateRot_; Ogre::Vector3 interpolateVel_; Modified: trunk/src/SectorObjectVessel.cpp =================================================================== --- trunk/src/SectorObjectVessel.cpp 2008-05-04 12:13:52 UTC (rev 888) +++ trunk/src/SectorObjectVessel.cpp 2008-05-04 15:50:32 UTC (rev 889) @@ -75,7 +75,10 @@ } SectorObjectVessel::~SectorObjectVessel(){ __D( name_ ) - if ( controler_ ) ResourceManager::getSingleton().aiManager->recycle( controler_ ); + if ( controler_ ) { + ResourceManager::getSingleton().aiManager->stopAiObject( controler_ ); + controler_ = NULL; + } shieldEntityNode_->detachObject( shieldEntity_ ); mainNodeEntityRot_->removeAndDestroyChild( shieldEntityNode_->getName() ); @@ -118,9 +121,7 @@ flashfire_ = false; firePressed_ = false; lastShieldSend_ = 0; - maxCapacity_ = 0; - - thrustRate_ = 0; + maxCapacity_ = 0; } bool SectorObjectVessel::update( Ogre::Real elapsedTime ){ @@ -135,8 +136,10 @@ //** object died if ( armor_ <= 0 || deathSequence_ || !SectorObjectMoveable::update( elapsedTime ) ) { - //** we only can destroy this object when all projectiles are end of life - if ( !deathSequence( elapsedTime ) && projectiles_.empty() ) return false; + //** we only can destroy this object when all projectiles are end of life + if ( destroyRequest_ && projectiles_.empty() ) { + return false; + } else if ( !deathSequence( elapsedTime ) && projectiles_.empty() ) return false; return true; } @@ -241,8 +244,8 @@ void SectorObjectVessel::fireMissile( SectorObject * target ){ std::cout << "SectorObjectVessel::fireMissile()" << std::endl; - SectorObjectMissile *missile = sector_->createMissile( "Firefly", userID_, 0, - *EquipmentManager::getSingleton().missile( "Firefly" ) ); + SectorObjectMissile *missile = sector_->createMissile( "firefly", userID_, 0, + *EquipmentManager::getSingleton().missile( "firefly" ) ); missile->setTarget( target ); missile->mainNode()->setOrientation( mainNode_->getWorldOrientation() ); Modified: trunk/src/Station.cpp =================================================================== --- trunk/src/Station.cpp 2008-05-04 12:13:52 UTC (rev 888) +++ trunk/src/Station.cpp 2008-05-04 15:50:32 UTC (rev 889) @@ -144,6 +144,7 @@ } else if ( object->rtti() == SECTOROBJECTVESSEL_RTTI ){ std::cout << "docking request for " << object->name() << std::endl; dynamic_cast< SectorObjectVessel * >( object )->controler()->kill(); + object->destroy( ); } } Modified: trunk/src/Station.h =================================================================== --- trunk/src/Station.h 2008-05-04 12:13:52 UTC (rev 888) +++ trunk/src/Station.h 2008-05-04 15:50:32 UTC (rev 889) @@ -103,7 +103,7 @@ virtual ~StationObject( ); - virtual long getTypeID() const { return STATION_RTTI; } + virtual long rtti() const { return STATION_RTTI; } void collide( BaseObject * object ); Modified: trunk/src/UnDockedState.cpp =================================================================== --- trunk/src/UnDockedState.cpp 2008-05-04 12:13:52 UTC (rev 888) +++ trunk/src/UnDockedState.cpp 2008-05-04 15:50:32 UTC (rev 889) @@ -21,6 +21,7 @@ #include "UnDockedState.h" #include "AiManager.h" +#include "AiObject.h" #include "Avatar.h" #include "Sector.h" #include "networkProtocol.h" @@ -31,6 +32,7 @@ #include "KeyMap.h" #include "OpenALSoundManager.h" #include "SectorObjectAvatar.h" +#include "Station.h" #include <iostream> @@ -1201,10 +1203,38 @@ } bool UnDockedState::keyActionSelectPreviousTarget( bool pressed ){ - if ( pressed ) setTarget( sector_->prevTarget() ); - return true; + if ( pressed ) setTarget( sector_->prevTarget() ); + return true; } +bool UnDockedState::keyActionDockAssist( bool pressed ){ + if ( pressed ){ + if ( target_ ){ + if ( target_->rtti() == STATION_RTTI ){ + if ( !sector_->avatarObject()->controler() ){ + log_->info( "Docking started." ); + AiObject * ai = resources_->aiManager->createAiObject( "autodocker" ); + ai->setVesselObject( sector_->avatarObject() ); + ai->land( dynamic_cast< StationObject * >( target_ ) ); + resources_->aiManager->startAiObject( ai ); + } else { + log_->info( "Docking aborted." ); + sector_->avatarObject()->setThrustRate( 0.0 ); + sector_->avatarObject()->setScaledYaw( 0.0 ); + sector_->avatarObject()->setScaledPitch( 0.0 ); + sector_->avatarObject()->setScaledRoll( 0.0 ); + sector_->avatarObject()->controler()->kill(); + } + } else { + log_->info( "Selected target is not dockable: " + target_->name() ); + } + } else { + log_->info("No target selected." ); + } + } + return true; +} + bool UnDockedState::keyActionCameraNormal( bool pressed ){ if ( pressed ){ if ( cameraMode_ == 0 ) showHud(); Modified: trunk/src/UnDockedState.h =================================================================== --- trunk/src/UnDockedState.h 2008-05-04 12:13:52 UTC (rev 888) +++ trunk/src/UnDockedState.h 2008-05-04 15:50:32 UTC (rev 889) @@ -41,222 +41,225 @@ class UnDockedState : public GameState{ public: - DECLARE_GAMESTATE_CLASS( UnDockedState ); + DECLARE_GAMESTATE_CLASS( UnDockedState ); - void createContent( ); + void createContent( ); - void destroyContent( ); + void destroyContent( ); - void enter(); + void enter(); - void exit(); + void exit(); - void changeToDockedState(); + void changeToDockedState(); - bool switchConfigDialog( ); + bool switchConfigDialog( ); - virtual void setupEventHandlers(); + virtual void setupEventHandlers(); - virtual bool frameStarted( const Ogre::FrameEvent & evt ); - virtual bool frameEnded( const Ogre::FrameEvent & evt ); + virtual bool frameStarted( const Ogre::FrameEvent & evt ); + virtual bool frameEnded( const Ogre::FrameEvent & evt ); - virtual bool keyPressed( const OIS::KeyEvent & e ); - virtual bool keyReleased( const OIS::KeyEvent & e ); + virtual bool keyPressed( const OIS::KeyEvent & e ); + virtual bool keyReleased( const OIS::KeyEvent & e ); - virtual bool mouseMoved(const OIS::MouseEvent & e ); - virtual bool mousePressed(const OIS::MouseEvent & e, OIS::MouseButtonID id ); - virtual bool mouseReleased(const OIS::MouseEvent & e, OIS::MouseButtonID id ); + virtual bool mouseMoved(const OIS::MouseEvent & e ); + virtual bool mousePressed(const OIS::MouseEvent & e, OIS::MouseButtonID id ); + virtual bool mouseReleased(const OIS::MouseEvent & e, OIS::MouseButtonID id ); - virtual bool axisMoved( const OIS::JoyStickEvent & e, int axis ); - virtual bool buttonPressed( const OIS::JoyStickEvent & e, int axis ); - virtual bool buttonReleased( const OIS::JoyStickEvent & e, int axis ); + virtual bool axisMoved( const OIS::JoyStickEvent & e, int axis ); + virtual bool buttonPressed( const OIS::JoyStickEvent & e, int axis ); + virtual bool buttonReleased( const OIS::JoyStickEvent & e, int axis ); - virtual void avatarDeathSequence( bool on ); + virtual void avatarDeathSequence( bool on ); - bool renderSpaceDust(); + bool renderSpaceDust(); - void setTarget( SectorObject * target ); + void setTarget( SectorObject * target ); - bool maximiseConsole( ); - bool minimiseConsole( ); + bool maximiseConsole( ); + bool minimiseConsole( ); - SectorObject * target( ) { return target_; } + SectorObject * target( ) { return target_; } - Sector * sector( ) { return sector_; } + Sector * sector( ) { return sector_; } - void showHud(); - void hideHud(); + void showHud(); + void hideHud(); - bool keyActionDoNothing( bool pressed = true ) { return false; } - bool keyActionSwitchMinMaxConsole( bool pressed = true ); + bool keyActionDoNothing( bool pressed = true ) { return false; } + bool keyActionSwitchMinMaxConsole( bool pressed = true ); - bool keyActionAvatarIncreaseYaw( bool pressed = true ); - bool keyActionAvatarDecreaseYaw( bool pressed = true ); - bool keyActionAvatarIncreasePitch( bool pressed = true ); - bool keyActionAvatarDecreasePitch( bool pressed = true ); - bool keyActionAvatarIncreaseRoll( bool pressed = true ); - bool keyActionAvatarDecreaseRoll( bool pressed = true ); + bool keyActionAvatarIncreaseYaw( bool pressed = true ); + bool keyActionAvatarDecreaseYaw( bool pressed = true ); + bool keyActionAvatarIncreasePitch( bool pressed = true ); + bool keyActionAvatarDecreasePitch( bool pressed = true ); + bool keyActionAvatarIncreaseRoll( bool pressed = true ); + bool keyActionAvatarDecreaseRoll( bool pressed = true ); - bool keyActionSelectTextTarget( bool pressed = true ); - bool keyActionSelectPreviousTarget( bool pressed = true ); + /*! Start docking assistent. A dockable station must selected */ + bool keyActionDockAssist( bool pressed = true ); - bool keyActionCameraNormal( bool pressed = true ); - bool keyActionCameraLeft( bool pressed = true ); - bool keyActionCameraRight( bool pressed = true ); - bool keyActionCameraUp( bool pressed = true ); - bool keyActionCameraDown( bool pressed = true ); - bool keyActionCameraToggle( bool pressed = true ); + bool keyActionSelectTextTarget( bool pressed = true ); + bool keyActionSelectPreviousTarget( bool pressed = true ); - /*! center avatar stop yaw/pitch/roll */ - bool keyActionAvatarCenter( bool pressed = true ); + bool keyActionCameraNormal( bool pressed = true ); + bool keyActionCameraLeft( bool pressed = true ); + bool keyActionCameraRight( bool pressed = true ); + bool keyActionCameraUp( bool pressed = true ); + bool keyActionCameraDown( bool pressed = true ); + bool keyActionCameraToggle( bool pressed = true ); - /*! Avatar increase thrust by 10% */ - bool keyActionAvatarIncrementThrust( bool pressed = true ); + /*! center avatar stop yaw/pitch/roll */ + bool keyActionAvatarCenter( bool pressed = true ); - /*! Avatar decrease thrust by 10% */ - bool keyActionAvatarDecrementThrust( bool pressed = true ); + /*! Avatar increase thrust by 10% */ + bool keyActionAvatarIncrementThrust( bool pressed = true ); - bool keyActionAvatarBreakPressed( bool pressed = true ); - bool keyActionAvatarAfterburnerPressed( bool pressed = true ); + /*! Avatar decrease thrust by 10% */ + bool keyActionAvatarDecrementThrust( bool pressed = true ); - /*! Actions for development, will removed later. */ - bool keyActionTogglePolygonMode_DEV( bool pressed = true ); - bool keyActionToggleFiltering_DEV( bool pressed = true ); + bool keyActionAvatarBreakPressed( bool pressed = true ); + bool keyActionAvatarAfterburnerPressed( bool pressed = true ); - bool keyActionIncreaseAmbientLight_DEV( bool pressed = true ); - bool keyActionDecreaseAmbientLight_DEV( bool pressed = true ); + /*! Actions for development, will removed later. */ + bool keyActionTogglePolygonMode_DEV( bool pressed = true ); + bool keyActionToggleFiltering_DEV( bool pressed = true ); - bool keyActionIncreaseShaderScheme_DEV( bool pressed = true ); - bool keyActionDecreaseShaderScheme_DEV( bool pressed = true ); + bool keyActionIncreaseAmbientLight_DEV( bool pressed = true ); + bool keyActionDecreaseAmbientLight_DEV( bool pressed = true ); - bool keyActionAvatarSwitchDuelistPilot_DEV( bool pressed = true ); - bool keyActionAvatarSwitchDuelistTarget_DEV( bool pressed = true ); - bool keyActionAvatarChangeDockedState_DEV( bool pressed = true ); - bool keyActionAvatarSelfDestruct_DEV( bool pressed = true ); - bool keyActionSpawnAi_DEV( bool pressed = true ); - bool keyActionShowInfos_DEV( bool pressed = true ); -protected: - UnDockedState( ); - virtual ~UnDockedState( ){} + bool keyActionIncreaseShaderScheme_DEV( bool pressed = true ); + bool keyActionDecreaseShaderScheme_DEV( bool pressed = true ); - inline bool handleMaximiseConsole( const CEGUI::EventArgs & e ){ maximiseConsole(); return true; } - inline bool handleMinimiseConsole( const CEGUI::EventArgs & e ){ minimiseConsole(); return true; } - inline bool handleConfigBackButton( const CEGUI::EventArgs & e ){ return switchConfigDialog( ); } + bool keyActionAvatarSwitchDuelistPilot_DEV( bool pressed = true ); + bool keyActionAvatarSwitchDuelistTarget_DEV( bool pressed = true ); + bool keyActionAvatarChangeDockedState_DEV( bool pressed = true ); + bool keyActionAvatarSelfDestruct_DEV( bool pressed = true ); + bool keyActionSpawnAi_DEV( bool pressed = true ); + bool keyActionShowInfos_DEV( bool pressed = true ); - void setAmbientLight_(); - void setScheme_(); - void toggleNextCamera_( int mode = -1 ); - void updateCamera_( Ogre::Real elapsedTime ); - void updateHUD_( Ogre::Real elapsedTime ); +protected: + UnDockedState( ); + virtual ~UnDockedState( ){} - bool projectionPos_( Ogre::Camera * cam, const Ogre::Vector3 & pos, Ogre::Vector3 & screenPos ); - bool projectionPosAndSize_( Ogre::Camera * cam, const Ogre::Vector3 & pos, const Ogre::Real rad, - Ogre::Real & x, Ogre::Real & y, Ogre::Real & cx, Ogre::Real & cy ); + inline bool handleMaximiseConsole( const CEGUI::EventArgs & e ){ maximiseConsole(); return true; } + inline bool handleMinimiseConsole( const CEGUI::EventArgs & e ){ minimiseConsole(); return true; } + inline bool handleConfigBackButton( const CEGUI::EventArgs & e ){ return switchConfigDialog( ); } - Ogre::RenderWindow * window_; - Ogre::Root * root_; - Ogre::SceneManager * sceneMgr_; + void setAmbientLight_(); + void setScheme_(); + void toggleNextCamera_( int mode = -1 ); + void updateCamera_( Ogre::Real elapsedTime ); + void updateHUD_( Ogre::Real elapsedTime ); - Ogre::Camera * mainCamera_; - Ogre::Camera * secondCamera_; - Sector * sector_; - NetworkClient * network_; + bool projectionPos_( Ogre::Camera * cam, const Ogre::Vector3 & pos, Ogre::Vector3 & screenPos ); + bool projectionPosAndSize_( Ogre::Camera * cam, const Ogre::Vector3 & pos, const Ogre::Real rad, + Ogre::Real & x, Ogre::Real & y, Ogre::Real & cx, Ogre::Real & cy ); - Ogre::Vector2 flightCursorPos_; - CEGUI::Window * flightCursor_; - Ogre::Real flightCursorHalfWidth_; - Ogre::Real flightCursorHalfHeight_; + Ogre::RenderWindow * window_; + Ogre::Root * root_; + Ogre::SceneManager * sceneMgr_; - CEGUI::Window * targetCursor_; - Ogre::Real targetCursorHalfWidth_; - Ogre::Real targetCursorHalfHeight_; + Ogre::Camera * mainCamera_; + Ogre::Camera * secondCamera_; + Sector * sector_; + NetworkClient * network_; - CEGUI::Window * pilotFlightCursor_; - Ogre::Real pilotFlightCursorHalfWidth_; - Ogre::Real pilotFlightCursorHalfHeight_; + Ogre::Vector2 flightCursorPos_; + CEGUI::Window * flightCursor_; + Ogre::Real flightCursorHalfWidth_; + Ogre::Real flightCursorHalfHeight_; - CEGUI::Window * targetFlightCursor_; - Ogre::Real targetFlightCursorHalfWidth_; - Ogre::Real targetFlightCursorHalfHeight_; + CEGUI::Window * targetCursor_; + Ogre::Real targetCursorHalfWidth_; + Ogre::Real targetCursorHalfHeight_; - CEGUI::Window * velocityProgress_; - CEGUI::Window * velocityProgressImg_; - Ogre::Real velocityProgressHeight_; + CEGUI::Window * pilotFlightCursor_; + Ogre::Real pilotFlightCursorHalfWidth_; + Ogre::Real pilotFlightCursorHalfHeight_; - CEGUI::Window * thrustProgress_; - CEGUI::Window * thrustProgressImg_; - Ogre::Real thrustProgressHeight_; + CEGUI::Window * targetFlightCursor_; + Ogre::Real targetFlightCursorHalfWidth_; + Ogre::Real targetFlightCursorHalfHeight_; - CEGUI::Window * fuelProgress_; - CEGUI::Window * fuelProgressImg_; - Ogre::Real fuelProgressHeight_; + CEGUI::Window * velocityProgress_; + CEGUI::Window * velocityProgressImg_; + Ogre::Real velocityProgressHeight_; - CEGUI::Window * capacitorProgress_; - CEGUI::Window * capacitorProgressImg_; - Ogre::Real capacitorProgressHeight_; + CEGUI::Window * thrustProgress_; + CEGUI::Window * thrustProgressImg_; + Ogre::Real thrustProgressHeight_; - CEGUI::Window * armorProgress_; - CEGUI::Window * armorProgressLeftImg_; - CEGUI::Window * armorProgressRightImg_; - Ogre::Real armorProgressHeight_; + CEGUI::Window * fuelProgress_; + CEGUI::Window * fuelProgressImg_; + Ogre::Real fuelProgressHeight_; - CEGUI::Window * shieldProgress_; - CEGUI::Window * shieldProgressLeftImg_; - CEGUI::Window * shieldProgressRightImg_; - Ogre::Real shieldProgressHeight_; + CEGUI::Window * capacitorProgress_; + CEGUI::Window * capacitorProgressImg_; + Ogre::Real capacitorProgressHeight_; - CEGUI::Window * velocityText_; - CEGUI::Window * conText_; - CEGUI::Window * armorText_; - CEGUI::Window * shieldText_; + CEGUI::Window * armorProgress_; + CEGUI::Window * armorProgressLeftImg_; + CEGUI::Window * armorProgressRightImg_; + Ogre::Real armorProgressHeight_; - CEGUI::Window * targetDistanceText_; - CEGUI::Window * targetVelocity_; - CEGUI::Window * targetShieldText_; - CEGUI::Window * targetArmorText_; + CEGUI::Window * shieldProgress_; + CEGUI::Window * shieldProgressLeftImg_; + CEGUI::Window * shieldProgressRightImg_; + Ogre::Real shieldProgressHeight_; - std::string overlayName_; - bool hudIsVisible_; - Ogre::Overlay * hudOverlay_; - Ogre::OverlayElement * mousePointer_; - // Ogre::SceneNode * hudTarget_; - // Ogre::SceneNode * targetPointer_; - SectorObject * target_; - // Ogre::Billboard *targetPointerBB_; + CEGUI::Window * velocityText_; + CEGUI::Window * conText_; + CEGUI::Window * armorText_; + CEGUI::Window * shieldText_; - Ogre::ParticleSystem * spaceDustParticleSystem_; + CEGUI::Window * targetDistanceText_; + CEGUI::Window * targetVelocity_; + CEGUI::Window * targetShieldText_; + CEGUI::Window * targetArmorText_; - bool enterDockedState_; + std::string overlayName_; + bool hudIsVisible_; + Ogre::Overlay * hudOverlay_; + Ogre::OverlayElement * mousePointer_; + // Ogre::SceneNode * hudTarget_; + // Ogre::SceneNode * targetPointer_; + SectorObject * target_; + // Ogre::Billboard *targetPointerBB_; - double timeSinceLastSectorUpdate_; - double timeSinceLastNetworkUpdate_; - double timeSinceLastHudUpdate_; - int cameraMode_; - int cameraViewKey_; - Ogre::Real cameraZoom_; - Ogre::Degree cameraRotateX_; - Ogre::Degree cameraRotateY_; + Ogre::ParticleSystem * spaceDustParticleSystem_; - int windowsWidth_; - int windowsHeight_; - int windowsHalfWidth_; - int windowsHalfHeight_; + bool enterDockedState_; - std::string chatString_; - bool chatMode_; - bool configMode_; - bool consoleMax_; - bool duelistPilot_; - bool duelistTarget_; + double timeSinceLastSectorUpdate_; + double timeSinceLastNetworkUpdate_; + double timeSinceLastHudUpdate_; + int cameraMode_; + int cameraViewKey_; + Ogre::Real cameraZoom_; + Ogre::Degree cameraRotateX_; + Ogre::Degree cameraRotateY_; - int sceneDetailIndex_ ; - int ambientLight_; - int schemeIdx_; - Ogre::TextureFilterOptions filtering_; - int aniso_; + int windowsWidth_; + int windowsHeight_; + int windowsHalfWidth_; + int windowsHalfHeight_; + std::string chatString_; + bool chatMode_; + bool configMode_; + bool consoleMax_; + bool duelistPilot_; + bool duelistTarget_; - OpenALSoundSource * soundBackround_; + int sceneDetailIndex_ ; + int ambientLight_; + int schemeIdx_; + Ogre::TextureFilterOptions filtering_; + int aniso_; + + OpenALSoundSource * soundBackround_; }; }; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
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(); + double a = vesselObject_->brakingAcc(); 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 @@ -268,9 +271,9 @@ } double AiObject::brakingDistance( 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(); + double a = vesselObject_->brakingAcc(); double th = m * a; double t = brakingTime( v ); @@ -284,9 +287,9 @@ double AiObject::timeToSpeed( double v, double thrustRate ) const { //** t(th,d,m,v):=( m * atanh( v / vmax ) ) / sqrt( d * th ) - 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 ); v = min( v, 0.99 * vmax ); Modified: trunk/src/AiObject.h =================================================================== --- trunk/src/AiObject.h 2008-05-01 18:29:14 UTC (rev 887) +++ trunk/src/AiObject.h 2008-05-04 12:13:52 UTC (rev 888) @@ -38,7 +38,7 @@ namespace OpenGate{ class ResourceManager; -class SectorObjectMoveableLocal; +class SectorObjectVessel; class StationObject; class AiManager; class AiObject; @@ -57,10 +57,10 @@ virtual void run(); /*! Set the instance which is controled by this ai */ - void setSectorObject( SectorObjectMoveableLocal * obj ); + void setVesselObject( SectorObjectVessel * obj ); /*! Get the instance which is controled by this ai */ - inline SectorObjectMoveableLocal * sectorObject( ){ return sectorObject_; } + inline SectorObjectVessel * vesselObject( ){ return vesselObject_; } bool isAlive() const { return isAlive_; } @@ -117,7 +117,7 @@ void copy_( const AiObject & ai ); //! the graphical representation - SectorObjectMoveableLocal * sectorObject_; + SectorObjectVessel * vesselObject_; std::deque< AiCommand * > cmdQueue_; Modified: trunk/src/Avatar.cpp =================================================================== --- trunk/src/Avatar.cpp 2008-05-01 18:29:14 UTC (rev 887) +++ trunk/src/Avatar.cpp 2008-05-04 12:13:52 UTC (rev 888) @@ -20,6 +20,7 @@ #include "Avatar.h" #include "VesselManager.h" +#include "Equipment.h" namespace OpenGate{ Modified: trunk/src/Avatar.h =================================================================== --- trunk/src/Avatar.h 2008-05-01 18:29:14 UTC (rev 887) +++ trunk/src/Avatar.h 2008-05-04 12:13:52 UTC (rev 888) @@ -59,16 +59,16 @@ bool loadItem( Entity * item ); bool unLoadItem( Entity * item ); - + protected: - std::string name_; - Uint32 id_; + std::string name_; + Uint32 id_; - Vessel * vessel_; - - Uint16 maxCargoHold_; - Uint16 cargoHold_; - std::list< std::deque < Entity * > > floorCargo_; + Vessel * vessel_; + + Uint16 maxCargoHold_; + Uint16 cargoHold_; + std::list< std::deque < Entity * > > floorCargo_; }; } // namespace OpenGate{ Added: trunk/src/BaseObject.cpp =================================================================== --- trunk/src/BaseObject.cpp (rev 0) +++ trunk/src/BaseObject.cpp 2008-05-04 12:13:52 UTC (rev 888) @@ -0,0 +1,52 @@ +/*************************************************************************** + * Copyright (C) 2006-2007 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 "BaseObject.h" +#include "Sector.h" + +#include <OgreEntity.h> + +#include <string> + +namespace OpenGate{ + +BaseObject::BaseObject( const Ogre::String & name, Sector * sector, Uint32 userID, Uint8 childID ) + : name_( name ), sector_( sector ), userID_( userID ), childID_( childID ), mainNode_( NULL ){ + globalID_ = createGlobalID( userID, childID ); + + 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; +} + +BaseObject::~BaseObject(){ + sceneMgr_->getRootSceneNode()->removeAndDestroyChild( mainNode_->getName() ); +} + + +} // namespace OpenGate Added: trunk/src/BaseObject.h =================================================================== --- trunk/src/BaseObject.h (rev 0) +++ trunk/src/BaseObject.h 2008-05-04 12:13:52 UTC (rev 888) @@ -0,0 +1,112 @@ +/*************************************************************************** + * Copyright (C) 2006-2007 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_BASEOBJECT__H +#define _OPENGATE_BASEOBJECT__H + +//#include <OgrePrerequisites.h> + +#include "common.h" + +#include <OgreSceneNode.h> + +namespace OgreOpcode{ + class CollisionObject; +} + +namespace OpenGate{ + +#define PROJECTILE_RTTI 100001 +#define SECTOROBJECT_RTTI 100002 +#define SECTOROBJECTMOVABLE_RTTI 100003 +#define SECTOROBJECTVESSEL_RTTI 100004 +#define SECTOROBJECTMISSILE_RTTI 100005 +#define AVATAR_RTTI 100006 +#define DOCKPAD_RTTI 100007 +#define STATIONPAD_RTTI 100008 +#define STATION_RTTI 100009 + +class Sector; + +class BaseObject{ +public: + BaseObject( const Ogre::String & name, Sector * sector, Uint32 userId = 0, Uint8 childId = 0 ); + + virtual ~BaseObject(); + + virtual long rtti() const = 0; + + virtual void collide( BaseObject * object ) = 0; + + inline virtual Uint32 userID() const { return userID_; } + + inline virtual Uint8 childID() const { return childID_; } + + inline virtual Uint32 globalID() const { return globalID_; } + + virtual bool isChild() const { return childID_ > 0; } + + Ogre::String name() const { return name_; } + + inline Ogre::SceneNode * mainNode() { return mainNode_; } + + inline Ogre::SceneNode mainNode() const { return *mainNode_; } + + virtual bool update( Ogre::Real elapsedTime ) = 0; + + virtual void hitByAmmo( Uint32 damage ){} + + Sector * sector( ) { return sector_; } + + virtual Ogre::Vector3 velocity() const { return Ogre::Vector3::ZERO; } + + 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 */ + void destroy() { destroyRequest_ = true; } + + bool isSetDestroyRequest() const { return destroyRequest_; } + +protected: + 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_; +}; + +} //namespace OpenGate + +#endif + + Modified: trunk/src/Entity.h =================================================================== --- trunk/src/Entity.h 2008-05-01 18:29:14 UTC (rev 887) +++ trunk/src/Entity.h 2008-05-04 12:13:52 UTC (rev 888) @@ -45,390 +45,113 @@ class Entity{ public: + Entity(); - Entity(); + virtual ~Entity(){ } - virtual ~Entity(){ } - - virtual EntityType entityType() const { return rtti_; } + virtual EntityType entityType() const { return rtti_; } - inline std::string factionName( ) const { return factionName_; } + inline std::string factionName( ) const { return factionName_; } - void setFactionID( int id ); - inline int factionID( ) const { return factionID_; } + void setFactionID( int id ); + inline int factionID( ) const { return factionID_; } - inline void setName( const std::string & name ) { name_ = name; } - inline std::string name( ) const { return name_; } + inline void setName( const std::string & name ) { name_ = name; } + inline std::string name( ) const { return name_; } - inline void setClassName( const std::string & name ) { className_ = name; } - inline std::string className( ) const { return className_; } + inline void setClassName( const std::string & name ) { className_ = name; } + inline std::string className( ) const { return className_; } - inline void setID( int id ){ id_ = id; } - inline int id( ) const { return id_; } + inline void setID( int id ){ id_ = id; } + inline int id( ) const { return id_; } - void setBaseSize( float length, float width, float height ); + /*! Base sizes are necessary for resizing the ogremesh */ + void setBaseSize( float length, float width, float height ); - /*! If size is a scalar value, the length of the entity. */ - void setBaseSize( float size ); + /*! If size is a scalar value, the length of the entity.*/ + void setBaseSize( float size ); + Ogre::Vector3 baseSize( ) const; - Ogre::Vector3 baseSize( ) const; + /*! Base sizes are necessary for resizing the ogremesh */ + inline void setBaseYaw( Ogre::Real baseYaw ){ baseYaw_ = baseYaw; } + inline Ogre::Real baseYaw( ) const { return baseYaw_; } - inline void setBaseYaw( Ogre::Real baseYaw ){ baseYaw_ = baseYaw; } - inline Ogre::Real baseYaw( ) const { return baseYaw_; } + /*! Base sizes are necessary for resizing the ogremesh */ + inline void setBasePitch( Ogre::Real basePitch ){ basePitch_ = basePitch; } + inline Ogre::Real basePitch( ) const { return basePitch_; } - inline void setBasePitch( Ogre::Real basePitch ){ basePitch_ = basePitch; } - inline Ogre::Real basePitch( ) const { return basePitch_; } + /*! Base sizes are necessary for resizing the ogremesh */ + inline void setBaseRoll( Ogre::Real baseRoll ){ baseRoll_ = baseRoll; } + inline Ogre::Real baseRoll( ) const { return baseRoll_; } - inline void setBaseRoll( Ogre::Real baseRoll ){ baseRoll_ = baseRoll; } - inline Ogre::Real baseRoll( ) const { return baseRoll_; } + inline void setTechLevel( int level ){ techLevel_ = level; } + inline int techLevel( ) const { return techLevel_; } - inline void setTechLevel( int level ){ techLevel_ = level; } - inline int techLevel( ) const { return techLevel_; } + inline void setMass( long mass ){ mass_ = mass; } + inline Uint32 mass( ) const { return mass_; } - inline void setMass( long mass ){ mass_ = mass; } - inline Uint32 mass( ) const { return mass_; } + inline void setSize( int size ){ size_ = size; } + inline int size( ) const { return size_; } - inline void setSize( int size ){ size_ = size; } - inline int size( ) const { return size_; } + inline void setDescription( const std::string & description ){ description_ = description; } + inline std::string description( ) const { return description_; } - inline void setDescription( const std::string & description ){ description_ = description; } - inline std::string description( ) const { return description_; } + inline void setImageName( const std::string & imageFileName ) { imageFileName_ = imageFileName; } + inline std::string imageName() const { return imageFileName_; } + inline std::string ceguiImageName() { if ( !imageInitialised_ ) loadImages_(); return ceguiImageName_; } + inline std::string ceguiSmallImageName() { if ( !imageInitialised_ ) loadImages_(); return ceguiSmallImageName_; } - inline void setImageName( const std::string & imageFileName ) { imageFileName_ = imageFileName; } - inline std::string imageName() const { return imageFileName_; } - inline std::string ceguiImageName() { if ( !imageInitialised_ ) loadImages_(); return ceguiImageName_; } - inline std::string ceguiSmallImageName() { if ( !imageInitialised_ ) loadImages_(); return ceguiSmallImageName_; } + bool initialiseImage( const std::string & imageName, const std::string & targetName, bool verbose = false ); - 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 std::set < std::string > productionCenters( ) const { return productionCenters_; } - inline void setProductionCenters( const std::set < std::string > & productionCenters ) { - productionCenters_ = productionCenters; } - inline std::set < std::string > productionCenters( ) const { return productionCenters_; } + inline void setRequieredComponents( const std::set < Commodity * > & requieredComponents ) { + requieredComponents_ = requieredComponents; } + inline std::set < Commodity * > requieredComponents( ) const { return requieredComponents_; } - inline void setRequieredComponents( const std::set < Commodity * > & requieredComponents ) { - requieredComponents_ = requieredComponents; } - inline std::set < Commodity * > requieredComponents( ) const { return requieredComponents_; } - protected: - inline void setFactionName_( const std::string & name ) { factionName_ = name; } - void loadImages_( ); + inline void setFactionName_( const std::string & name ) { factionName_ = name; } + void loadImages_( ); - std::string name_; - std::string className_; - /*! A rather long description of this component */ - std::string description_; - - std::string factionName_; - int factionID_; - - //** geometric parameters - Ogre::Vector3 baseSize_; - Ogre::Real baseYaw_; - Ogre::Real basePitch_; - Ogre::Real baseRoll_; - - std::string imageFileName_; - std::string ceguiSmallImageName_; - std::string ceguiImageName_; - bool imageInitialised_; - - /*! The places where this part of equipment is built */ - std::set < std::string > productionCenters_; - - /*! The components required to build this equipment part */ - std::set < Commodity * > requieredComponents_; - - /*! A unique ID to find this object \todo maybe push to a string and merge with Commodity.commodityID_ */ - Uint16 id_; - /*! The required tech level to interact with this object */ - int techLevel_; - /*! The mass of this entity. */ - Uint32 mass_; - /*! The amount of slots necessary to plug in such a device. */ - int size_; - - /*! For runtime identification of an entity item. */ - EntityType rtti_; -}; - -/** - * \brief This abstract class defines the basics for Eqiupment that is plugged - * into a vessel. - * - * So if you plug in an engine (which is a child class of this) you plug in an - * equipment part. It has power consumption etc. This class only - * defines whatever is common for all equipments parts. - * - * \author Christoph Brill <eg...@us...> - */ - -class Equipment : public Entity{ -public: - - inline void setManufacturer( const std::string & manufacturer ) { manufacturer_ = manufacturer; } - inline std::string manufacturer( ) const { return manufacturer_; } - - /*! Sets the Efficiency of this Equipment between 0(min) and 1(max) */ - inline void setEfficiency( double efficiency ) { efficiency_ = efficiency; } - inline double efficiency( ) const { return efficiency_; } - - virtual void setPowerConsumption( Uint32 powerConsumption ) { - powerConsumption_ = powerConsumption; - //** if input power is < 1000, then input is scaled in kW - if ( powerConsumption_ < 1e3 ) powerConsumption_ *= 1000; - } - virtual Uint32 powerConsumption( ) const { return powerConsumption_; } - -protected: - Equipment() : Entity(), manufacturer_( "unkown" ) { - size_ = 0; - efficiency_ = 1.0; - powerConsumption_ = 0; - } - - virtual ~Equipment() { } - - /*! Name of the company that produces this equipment */ - std::string manufacturer_; - - /*! Stores the efficiency of this equipment */ - double efficiency_; - - /*! Stores the power consumption of this equipment */ - Uint32 powerConsumption_; -}; - -/*! - * \brief This class stores the basical information of a PowerPlant - * - * This class, like all other equipment classes, is filled by loading the - * information from an XML file. It defines the details for a PowerPlant, which - * is a component that is plugged into the ship. - * \author Christoph Brill <eg...@us...> - */ -class PowerPlant : public Equipment { -public: - PowerPlant() : Equipment(){ - rtti_ = POWERPLANT; - powerOutput_ = 0; - } - inline void setPowerOutput( Uint32 power ) { - powerOutput_ = power; - //** if input power is < 100kW, then input is scaled in kW - if ( powerOutput_ < 1e5 ) powerOutput_ *= 1000; - } - inline Uint32 powerOutput( ) const { return powerOutput_; } - -protected: - Uint32 powerOutput_; -}; - -/*! - * \brief This class stores the basical information of an engine - * - * This class, like all other equipment classes, is filled by loading the - * information from an XML file. It defines the details for an engine, which - * is a component that is plugged into the ship. - * \author Christoph Brill <eg...@us...> - */ -class Engine : public Equipment { -public: - - Engine() : Equipment() { - rtti_ = ENGINE; - maxThrust_ = 0; - } - - inline void setMaxThrust( Uint32 maxThrust ) { - maxThrust_ = maxThrust; - //** if input thrust is < 100kN, then input is scaled in kN - if ( maxThrust_ < 1e5 ) maxThrust_ *= 1000; - } - inline Uint32 maxThrust( ) { return maxThrust_; } - - virtual Uint32 powerConsumption( ) const { return (Uint32)rint( (float)maxThrust_ / efficiency_ ); } - -private: - /*! Stores the maximum thrust of this engine */ - Uint32 maxThrust_; -}; - -/*! - * \brief This class stores the basical information of a radar - * - * This class, like all other equipment classes, is filled by loading the - * information from an XML file. It defines the details for a radar, which - * is a component that is plugged into the ship. - * \author Christoph Brill <eg...@us...> - */ -class Radar : public Equipment { -public: - Radar() : Equipment(){ - rtti_ = RADAR; - } - inline void setMaxRange( Uint32 range ){ range_ = range; } - inline Uint32 maxRange() const{ return range_; } - -protected: - Uint32 range_; -}; - -/*! - * \brief This class stores the basical information of an Ecm (Evasion and Counter Measures) - * - * This class, like all other equipment classes, is filled by loading the - * information from an XML file. It defines the details for a Ecm, which - * is a component that is plugged into the ship. - * \author Christoph Brill <eg...@us...> - */ -class Ecm : public Equipment{ -public: - - Ecm() : Equipment() { - rtti_ = ECM; - sensorLevel_ = 0; - } - - inline void setSensorLevel( short sensorLevel ) { sensorLevel_ = sensorLevel; } - inline short sensorLevel( ) { return sensorLevel_; } - -private: - /*! Stores the sensorlevel of this Ecm */ - short sensorLevel_; -}; - -/*! - * \brief This class stores the basical information of a Shield - * - * This class, like all other equipment classes, is filled by loading the - * information from an XML file. It defines the details for a shield, which - * is a component that is plugged into the ship. - * \author Christoph Brill <eg...@us...> - */ -class Shield : public Equipment { -public: - Shield() : Equipment(){ - rtti_ = SHIELD; - } - - inline void setMaxDeflection( Uint32 deflection ){ - setMaximumDeflection_ = deflection; - //** if input deflection is < 100kJ, then input is scaled in kJ - if ( setMaximumDeflection_ < 1e5 ) setMaximumDeflection_ *= 1000; - } - inline Uint32 maxDeflection( ) const { return setMaximumDeflection_; } - - inline void setRegenerationRate( Uint32 regenRate ){ - regenerationRate_ = regenRate; - //** if input regeneration rate is < 10kJ, then input is scaled in kJ - if ( regenerationRate_ < 1e4 ) regenerationRate_ *= 1000; - } - inline Uint32 regenerationRate( ) const { return regenerationRate_; } - - inline Uint32 powerConsumption( ) const { return (Uint32) rint( regenerationRate_ / efficiency_ ); } - -protected: - Uint32 regenerationRate_; - Uint32 setMaximumDeflection_; -}; - -/*! - * \brief This class stores the basical information of a capactitor - * - * This class, like all other equipment classes, is filled by loading the - * information from an XML file. It defines the details for a capacitor, which - * is a component that is plugged into the ship. - * \author Christoph Brill <eg...@us...> - */ -class Capacitor : public Equipment{ -public: - - Capacitor() : Equipment() { - rtti_ = CAPACITOR; - capacity_ = 0; - } - - inline void setCapacity( Uint32 capacity ) { - capacity_ = capacity; - //** if input capacity is < 100kJ, then input is scaled in kJ - if ( capacity_ < 1e5 ) capacity_ *= 1000; - } - inline Uint32 capacity( ) { return capacity_; } - -private: - /*! Stores the capacity of a capacitor */ - Uint32 capacity_; -}; - -class Gun : public Equipment{ -public: - Gun(): Equipment(){ - rtti_ = GUN; - type_ = UNKNOWN; - } - - inline void setType( GunType type ) { type_ = type; } - inline GunType type() const { return type_; } - - inline void setEnergy( Uint32 energy ){ - powerConsumption_ = energy; if ( powerConsumption_ < 1e4 ) powerConsumption_ *= 1000; } + std::string name_; + std::string className_; - inline void setDamage( Uint32 damage ) { - damage_ = damage; if ( damage_ < 1e4 ) damage_ *= 1000; } + /*! A rather long description of this component */ + std::string description_; - inline Uint32 damage( ) const { return damage_; } + std::string factionName_; + int factionID_; - inline void setSpeed( Uint32 speed ) { speed_ = speed; } - inline Uint32 speed() const { return speed_; } + //** geometric parameters + Ogre::Vector3 baseSize_; + Ogre::Real baseYaw_; + Ogre::Real basePitch_; + Ogre::Real baseRoll_; - inline void setLifeTime( Ogre::Real lifeTime ) { lifeTime_ = lifeTime; } - inline Ogre::Real lifeTime() const { return lifeTime_; }; + std::string imageFileName_; + std::string ceguiSmallImageName_; + std::string ceguiImageName_; + bool imageInitialised_; - inline void setFireDelay( Ogre::Real fireDelay ) { fireDelay_ = fireDelay; } - inline Ogre::Real fireDelay() const { return fireDelay_; } + /*! The places where this part of equipment is built */ + std::set < std::string > productionCenters_; -protected: - GunType type_; - Uint32 damage_; - Uint32 speed_; - Ogre::Real lifeTime_; - Ogre::Real fireDelay_; -}; + /*! The components required to build this equipment part */ + std::set < Commodity * > requieredComponents_; + /*! A unique ID to find this object \todo maybe push to a string and merge with Commodity.commodityID_ */ + Uint16 id_; + /*! The required tech level to interact with this object */ + int techLevel_; + /*! The mass of this entity. */ + Uint32 mass_; + /*! The amount of slots necessary to plug in such a device. */ + int size_; -/*! - * \brief This class defines a commodity (goods, ore, etc. to build stuff from) - * - * This class is handled like equipment. But since it's not plugable into a - * ship it's a seperate class. This stores some information about a commodity, - * like its mass, its melting point, etc. - * \author Christoph Brill <eg...@us...> - */ -class Commodity : public Entity{ -public: - - Commodity(): Entity(), commodityID_( "unknownID" ) { - rtti_ = COMMODITY; - meltingPoint_ = 0; - graviticSig_ = 0.0; - } - - inline void setMeltingPoint( int meltingPoint ){ meltingPoint_ = meltingPoint; } - inline int meltingPoint( ) const { return meltingPoint_; } - - inline void setGraviticSig( double graviticSig ){ graviticSig_ = graviticSig; } - inline double graviticSig( ) const { return graviticSig_; } - - inline void setCommodityID( const std::string & commodityID ) { commodityID_ = commodityID; } - inline std::string commodityID( ) const { return commodityID_; } - -protected: - /*! The unique name of this commodity \todo check if that can be merged with EntityTemlpate.id_ */ - std::string commodityID_; - /*! The specific melting point of this commodity */ - int meltingPoint_; - /*! The specific atomic wheight of this commodity */ - double graviticSig_; + /*! For runtime identification of an entity item. */ + EntityType rtti_; }; } // namespace OpenGate Modified: trunk/src/EntityManager.cpp =================================================================== --- trunk/src/EntityManager.cpp 2008-05-01 18:29:14 UTC (rev 887) +++ trunk/src/EntityManager.cpp 2008-05-04 12:13:52 UTC (rev 888) @@ -21,6 +21,9 @@ #include "EntityManager.h" #include "ResourceManager.h" #include "tinyxml/tinyxml.h" +#include "Vessel.h" +#include "Equipment.h" + #include <OgreArchive.h> #include <OgreArchiveManager.h> #include <OgreFileSystem.h> @@ -35,6 +38,55 @@ templatesByID_.end(); } +EntityType EntityManager::categoryType( const std::string & category ){ + if ( category == "Commodity" || category == "Commoditys" || + category == "commodity" || category == "commoditys" ) return COMMODITY; + else if ( category == "Power Plant" || category == "Power Plants" || + category == "Powerplant" || category == "Powerplants" || + category == "Power plant" || category == "Power plants" || + category == "powerplant" || category == "powerplants" ) return POWERPLANT; + else if ( category == "Engine" || category == "Engines" || + category == "engine" || category == "engines" ) return ENGINE; + 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" ) return GUN; + else if ( category == "Missile" || category == "Missiles" || + category == "missile" || category == "missiles" ) return MISSILE; + else if ( category == "MODX" || category == "MODXs" || + category == "MODx" || category == "MODxs" || + category == "modx" || category == "modxs" ) return MODX; + + LogManager::getSingleton().warn("Request entity rtti for " + category + " unknown" ); + return ENTITY; +} + + +Entity * EntityManager::entity( const std::string & name ){ + if ( templatesByName_.count( name ) ){ + return templatesByName_[ name ]; + } else { + ... [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{ - + AiObject::AiObject( uint id ) : id_( id ), sectorObject_( NULL ){ + livetime_ = new Ogre::Timer(); reset(); } AiObject::~AiObject(){ + for_each( cmdQueue_.begin(), cmdQueue_.end(), deletePtr() ); + delete livetime_; } //** protected copy constructor @@ -47,32 +57,244 @@ } void AiObject::copy_( const AiObject & ai ){ - } void AiObject::reset( ){ - livetime_ = 0.0; + livetime_->reset(); + lasttime_ = 0; refCounter_ = 0; name_ = "unknown"; isAlive_ = true; die_ = false; + activeCmd_ = NULL; } -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 ); + sectorObject_->setControler( this ); } } +void AiObject::run(){ __D( name_ ) + isAlive_ = true; + livetime_->reset(); + do { + if ( activeCmd_ ){ + unsigned long tmpTime = livetime_->getMicroseconds(); + // std::cout << tmpTime << " " << lasttime_ << std::endl; + if ( !activeCmd_->update( ( tmpTime - lasttime_ ) / 1e6 ) ) { + delete activeCmd_; + activeCmd_ = NULL; + } + lasttime_ = tmpTime; + } else if ( !cmdQueue_.empty() ){ + activeCmd_ = cmdQueue_.front(); + cmdQueue_.pop_front(); + } + myMSleep( 10 ); // 100fps + + //usleep( 100 ); // 100fps + + } while ( isAlive_ ); + + if ( activeCmd_ ) activeCmd_->abort(); + delete activeCmd_; + for_each( cmdQueue_.begin(), cmdQueue_.end(), deletePtr() ); cmdQueue_.clear(); + activeCmd_ = NULL; +} + +void AiObject::dance( ){ + cmdQueue_.push_back( new AiCommandWait( this, 2.0 ) ); + cmdQueue_.push_back( new AiCommandYaw( this, 90.0 ) ); + cmdQueue_.push_back( new AiCommandYaw( this, -90.0 ) ); + cmdQueue_.push_back( new AiCommandYaw( this, 180.0 ) ); + cmdQueue_.push_back( new AiCommandYaw( this, -27.0 ) ); + cmdQueue_.push_back( new AiCommandYaw( this, 90.0 ) ); + cmdQueue_.push_back( new AiCommandYaw( this, -45.0 ) ); + cmdQueue_.push_back( new AiCommandYaw( this, 180.0 ) ); + cmdQueue_.push_back( new AiCommandYaw( this, -15.0 ) ); + cmdQueue_.push_back( new AiCommandYaw( this, 15.0 ) ); + cmdQueue_.push_back( new AiCommandYaw( this, -18.0 ) ); + cmdQueue_.push_back( new AiCommandWait( this, 2.0 ) ); + + cmdQueue_.push_back( new AiCommandRoll( this, 90.0 ) ); + cmdQueue_.push_back( new AiCommandRoll( this, -90.0 ) ); + cmdQueue_.push_back( new AiCommandRoll( this, 180.0 ) ); + cmdQueue_.push_back( new AiCommandRoll( this, -27.0 ) ); + cmdQueue_.push_back( new AiCommandRoll( this, 90.0 ) ); + cmdQueue_.push_back( new AiCommandRoll( this, -45.0 ) ); + cmdQueue_.push_back( new AiCommandRoll( this, 180.0 ) ); + cmdQueue_.push_back( new AiCommandRoll( this, -15.0 ) ); + cmdQueue_.push_back( new AiCommandRoll( this, 15.0 ) ); + cmdQueue_.push_back( new AiCommandRoll( this, -18.0 ) ); + +// cmdQueue_.push_back( new AiCommandPitch( this, 90.0 ) ); +// cmdQueue_.push_back( new AiCommandPitch( this, -90.0 ) ); +// cmdQueue_.push_back( new AiCommandPitch( this, 180.0 ) ); +// cmdQueue_.push_back( new AiCommandPitch( this, -27.0 ) ); +// cmdQueue_.push_back( new AiCommandPitch( this, 90.0 ) ); +// cmdQueue_.push_back( new AiCommandPitch( this, -45.0 ) ); +// cmdQueue_.push_back( new AiCommandPitch( this, 180.0 ) ); +// cmdQueue_.push_back( new AiCommandPitch( this, -15.0 ) ); +// cmdQueue_.push_back( new AiCommandPitch( this, 15.0 ) ); +// cmdQueue_.push_back( new AiCommandPitch( this, -18.0 ) ); +// cmdQueue_.push_back( new AiCommandYaw( this, 90.0 ) ); +// cmdQueue_.push_back( new AiCommandYaw( this, -180.0 ) ); +// cmdQueue_.push_back( new AiCommandYaw( this, -90.0 ) ); +// cmdQueue_.push_back( new AiCommandYaw( this, 180.0 ) ); +// cmdQueue_.push_back( new AiCommandPitch( this, 90.0 ) ); +// cmdQueue_.push_back( new AiCommandPitch( this, -180.0 ) ); +// cmdQueue_.push_back( new AiCommandPitch( this, 90.0 ) ); +// cmdQueue_.push_back( new AiCommandPitch( this, -180.0 ) ); + + cmdQueue_.push_back( new AiCommandPitch( this, -15.0 ) );cmdQueue_.push_back( new AiCommandWait( this, 0.5 ) ); + cmdQueue_.push_back( new AiCommandYaw( this, -15.0 ) );cmdQueue_.push_back( new AiCommandWait( this, 0.5 ) ); + cmdQueue_.push_back( new AiCommandPitch( this, -15.0 ) );cmdQueue_.push_back( new AiCommandWait( this, 0.5 ) ); + cmdQueue_.push_back( new AiCommandYaw( this, -15.0 ) );cmdQueue_.push_back( new AiCommandWait( this, 0.5 ) ); + cmdQueue_.push_back( new AiCommandPitch( this, -15.0 ) );cmdQueue_.push_back( new AiCommandWait( this, 0.5 ) ); + cmdQueue_.push_back( new AiCommandYaw( this, -15.0 ) );cmdQueue_.push_back( new AiCommandWait( this, 0.5 ) ); + cmdQueue_.push_back( new AiCommandPitch( this, -15.0 ) );cmdQueue_.push_back( new AiCommandWait( this, 0.5 ) ); + cmdQueue_.push_back( new AiCommandYaw( this, -15.0 ) );cmdQueue_.push_back( new AiCommandWait( this, 0.5 ) ); + cmdQueue_.push_back( new AiCommandPitch( this, -15.0 ) );cmdQueue_.push_back( new AiCommandWait( this, 0.5 ) ); + cmdQueue_.push_back( new AiCommandYaw( this, -15.0 ) );cmdQueue_.push_back( new AiCommandWait( this, 0.5 ) ); + cmdQueue_.push_back( new AiCommandPitch( this, -15.0 ) );cmdQueue_.push_back( new AiCommandWait( this, 0.5 ) ); + cmdQueue_.push_back( new AiCommandYaw( this, -15.0 ) );cmdQueue_.push_back( new AiCommandWait( this, 0.5 ) ); + cmdQueue_.push_back( new AiCommandPitch( this, -15.0 ) );cmdQueue_.push_back( new AiCommandWait( this, 0.5 ) ); + cmdQueue_.push_back( new AiCommandLookAt( this, Ogre::Vector3( 0.0, 0.0, 1.0 ) ) ); +} + +void AiObject::land( const StationObject & station ){ + cmdQueue_.push_back( new AiCommandWait( this, 2.0 ) ); + //Vector3(-0.563038, -77.3473, -1348.36) // dockpad + std::cout << "station docking pad: " << station.dockPadPosition( ) << std::endl; + + std::cout << "station ring end:" << station.dockingRingEnd( ) << std::endl; + // Vector3(-66.7835, -78.9126, -433.894) + std::cout << "station ring start:" << station.dockingRingStart( ) << std::endl; + + const_cast< StationObject * > (&station)->sector()->koordAxis()->setPosition( station.dockPadPosition( ) ) ; + // Vector3(-261.482, -5.00386, -1384.19) + std::cout << "station launch pad: " << station.launchPadPosition( ) << std::endl; + + //cmdQueue_.push_back( new AiCommandApproach( this, station.dockingRingStart( ), true ) ); + cmdQueue_.push_back( new AiCommandApproach( this, station.dockingRingStart( ), true ) ); + cmdQueue_.push_back( new AiCommandWait( this, 1.0 ) ); + cmdQueue_.push_back( new AiCommandApproach( this, station.dockPadPosition( ), true ) ); + + cmdQueue_.push_back( new AiCommandWait( this, 5.0 ) ); + cmdQueue_.push_back( new AiCommandSelfDestruct( this ) ); +} + +void AiObject::test( ){ + + cmdQueue_.push_back( new AiCommandWait( this, 0.5 ) ); + cmdQueue_.push_back( new AiCommandYaw( this, -90.0 ) ); + //cmdQueue_.push_back( new AiCommandYaw( this, 180.0 ) ); + cmdQueue_.push_back( new AiCommandTimedAccelerate( this, timeToSpeed( 200.0, 1.0 ), 1.0 ) ); + cmdQueue_.push_back( new AiCommandStop( this, true ) ); + cmdQueue_.push_back( new AiCommandWait( this, 2.0 ) ); + cmdQueue_.push_back( new AiCommandSelfDestruct( this ) ); +} + +// void AiObject::stop( ){ +// thrust( 0.0 ); +// yaw( 180 ); +// thrust( 1.0, time ); +// } +// + +//** v = a * t; +//** friction = drag * v^2; + +//** thrust = mass * a; +//** a = thrust / mass; + +//** s = v * t; + +//** vmax(th,d):=sqrt(th / d) +//** v(t):=(th-d * v(t)*v(t))/m * t + +//** t( thrust, v ) = v +//** v( thrust, t ) = +//** thrustFri = v * friction +//**a = ( -trust1 * thrust() - flightDir * friction ) / mass_; + + +// dg: 'diff(v,t) + d/m *v*v= th/m +// v[t] := v_max tanh( th / vmax * t) + +double AiObject::maxSpeed( double thrustRate ) const { + //** vmax(th,d):=sqrt( th/d ) ** P + double d = sectorObject_->vessel()->dragFactor(); + double th = sectorObject_->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 vmax = maxSpeed( thrustRate ); + double v = vmax * std::tanh( th / m / vmax * time ); +// std::cout << " th: " << th << "; m: " << m << "; d: " << d << "; vmax: " << vmax << "; t: " << time +// << " v: " << v << std::endl; + return v; +} + +double AiObject::wayAfterTime( double time, double thrustRate ) const { + //** 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 vmax = maxSpeed( thrustRate ); + double a = th / m; + double s = ( vmax * vmax ) / a * std::log( std::cosh( a / vmax * time ) ); +// std::cout << " th: " << th << "; m: " << m << "; d: " << d << "; vmax: " << vmax << "; t: " << time +// << " s: " << s << std::endl; + return s; +} +double AiObject::brakingTime( double v ) const { + double d = sectorObject_->vessel()->dragFactor(); + double m = sectorObject_->mass(); + double a = sectorObject_->brakingAcc(); + 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; +} + +double AiObject::brakingDistance( double v ) const { + double d = sectorObject_->vessel()->dragFactor(); + double m = sectorObject_->mass(); + double a = sectorObject_->brakingAcc(); + 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 + //double s = ( v * v ) / a * std::log( std::cosh( a / v * brakingTime( v ) ) ); + return s; +} + +double atanh( double x ) { return 0.5 * std::log( ( 1.0 + x ) / ( 1.0 - x ) ); } + +double AiObject::timeToSpeed( double v, double thrustRate ) const { + + //** t(th,d,m,v):=( m * atanh( v / vmax ) ) / sqrt( d * th ) + double d = sectorObject_->vessel()->dragFactor(); + double m = sectorObject_->mass(); + double th = sectorObject_->maxThrust() * thrustRate; + double vmax = maxSpeed( thrustRate ); + v = min( v, 0.99 * vmax ); + + double t = m * atanh( v / vmax ) / sqrt( d * th ); +// std::cout << " th: " << th << "; m: " << m << "; d: " << d << "; vmax: " << vmax << "; v: " << v +// << " t: " << t << std::endl; + return t; +} + + } // namespace OpenGate{ - Modified: trunk/src/AiObject.h =================================================================== --- trunk/src/AiObject.h 2008-04-24 20:30:07 UTC (rev 886) +++ trunk/src/AiObject.h 2008-05-01 18:29:14 UTC (rev 887) @@ -29,11 +29,20 @@ #include <boost/thread.hpp> +namespace Ogre{ + class Timer; + class Vector3; +} +#include <OgreVector3.h> + namespace OpenGate{ class ResourceManager; class SectorObjectMoveableLocal; +class StationObject; class AiManager; +class AiObject; +class AiCommand; class AiObject{ public: @@ -51,13 +60,11 @@ void setSectorObject( SectorObjectMoveableLocal * obj ); /*! Get the instance which is controled by this ai */ - SectorObjectMoveableLocal * sectorObject( ){ return sectorObject_; } - - double livetime( ) const { return livetime_; } + inline SectorObjectMoveableLocal * sectorObject( ){ return sectorObject_; } bool isAlive() const { return isAlive_; } - void kill() { die_ = true; } + void kill() { isAlive_ = false; } void reset(); @@ -67,6 +74,37 @@ uint id() const { return id_;} + void dance( ); + + void test( ); + + void land( const StationObject & station ); + + /*! Idle and look every second for new orders */ + bool cmdIdle( ); + /*! Wait and do nothing */ + bool cmdWait( double time ); + /*! Accelerate a given time with a given thrustRate */ + bool cmdAccelerate( double time, double thrustRate ); + + /*! Calculate maximum speed from a given thrustRate [0..1]*/ + double maxSpeed( double thrustRate = 1.0 ) const; + + /*! Calculate speed from 0 with a given thrustRate [0..1] for a given time.*/ + double speedAfterTime( double time, double thrustRate = 1.0 ) const; + + /*! Calculate linear way starting with speed 0 and a given thrustRate [0..1] for a given time.*/ + double wayAfterTime( double time, double thrustRate ) const; + + /*! Calculate time until reach a speed from 0 with a given thrustRate [0..1].*/ + double timeToSpeed( double speed, double thrustRate = 1.0 ) const; + + /*! Calculate the braking distance without turnaround.*/ + double brakingDistance( double v ) const; + + /*! Calculate the braking time without turnaround.*/ + double brakingTime( double v ) const; + //! reference counting used for threading, prob. better using smart pointer uint referenceCounter() const { return refCounter_; } void incReferenceCounter() { refCounter_ ++; } @@ -81,15 +119,22 @@ //! the graphical representation SectorObjectMoveableLocal * sectorObject_; + std::deque< AiCommand * > cmdQueue_; + + AiCommand * activeCmd_; + //! holds objects live status bool isAlive_; - //! prepare object to die + //! prepare object to die, called by kill() and evaluated in run loop bool die_; //! holds objects livetime - double livetime_; + Ogre::Timer * livetime_; + //! time from last livecyle in microseconds + unsigned long lasttime_; + //! objects name std::string name_; @@ -98,6 +143,7 @@ //! reference counter for threadholder uint refCounter_; + }; } // namespace OpenGate{ Modified: trunk/src/Console.cpp =================================================================== --- trunk/src/Console.cpp 2008-04-24 20:30:07 UTC (rev 886) +++ trunk/src/Console.cpp 2008-05-01 18:29:14 UTC (rev 887) @@ -161,6 +161,10 @@ LogManager::getSingleton().info( "wrote: " + tmp ); } return true; } +bool Console::keyActionShutdown_DEV( bool pressed ){ + if ( pressed ) ResourceManager::getSingleton().gameStateRoot->shutdown(); + return true; +} void Console::print( const std::string & t ){ CEGUI::colour col(1.0, 1.0, 1.0, 1.0); Modified: trunk/src/Console.h =================================================================== --- trunk/src/Console.h 2008-04-24 20:30:07 UTC (rev 886) +++ trunk/src/Console.h 2008-05-01 18:29:14 UTC (rev 887) @@ -65,6 +65,7 @@ bool keyActionDoNothing( bool pressed = true ) { return false; } bool keyActionScreenshot( bool pressed = true ); + bool keyActionShutdown_DEV( bool pressed = true ); private: Modified: trunk/src/GameStateManager.cpp =================================================================== --- trunk/src/GameStateManager.cpp 2008-04-24 20:30:07 UTC (rev 886) +++ trunk/src/GameStateManager.cpp 2008-05-01 18:29:14 UTC (rev 887) @@ -419,7 +419,7 @@ "initialise equipment manager" ) ); loadResourcesVector_.push_back( std::pair< bool (GameStateManager::*)( ), std::string >( &GameStateManager::initialiseAiManager, - "initialise ai manager" ) ); + "initialise ai manager" ) ); loadResourcesVector_.push_back( std::pair< bool (GameStateManager::*)( ), std::string >( &GameStateManager::createAvatar, "create avatar" ) ); Modified: trunk/src/KeyMap.cpp =================================================================== --- trunk/src/KeyMap.cpp 2008-04-24 20:30:07 UTC (rev 886) +++ trunk/src/KeyMap.cpp 2008-05-01 18:29:14 UTC (rev 887) @@ -66,7 +66,8 @@ /*! Actions for console. */ consoleActionMap_[ keycode( OIS::KC_SYSRQ ) ] = &Console::keyActionScreenshot; - + consoleActionMap_[ keycode( OIS::KC_Q, KEY_CONTROL ) ]= &Console::keyActionShutdown_DEV; + /*! Actions for development, will removed later. */ unDockedActionMap_[ keycode( OIS::KC_F ) ] = &UnDockedState::keyActionToggleFiltering_DEV; unDockedActionMap_[ keycode( OIS::KC_R, KEY_CONTROL ) ] = &UnDockedState::keyActionTogglePolygonMode_DEV; @@ -82,6 +83,7 @@ unDockedActionMap_[ keycode( OIS::KC_F4 ) ] = &UnDockedState::keyActionAvatarChangeDockedState_DEV; unDockedActionMap_[ keycode( OIS::KC_F8 ) ] = &UnDockedState::keyActionAvatarSelfDestruct_DEV; unDockedActionMap_[ keycode( OIS::KC_F7 ) ] = &UnDockedState::keyActionSpawnAi_DEV; + unDockedActionMap_[ keycode( OIS::KC_I, KEY_CONTROL ) ] = &UnDockedState::keyActionShowInfos_DEV; } bool(UnDockedState::*KeyMap::unDockedKeyAction( const OIS::KeyEvent & e ))(bool) { Modified: trunk/src/Makefile.am =================================================================== --- trunk/src/Makefile.am 2008-04-24 20:30:07 UTC (rev 886) +++ trunk/src/Makefile.am 2008-05-01 18:29:14 UTC (rev 887) @@ -19,6 +19,8 @@ tinyxml/tinyxmlparser.cpp \ Avatar.h \ Avatar.cpp \ + AiCommands.h \ + AiCommands.cpp \ AiManager.h \ AiManager.cpp \ AiObject.h \ @@ -131,6 +133,8 @@ AiManager.cpp \ AiObject.h \ AiObject.cpp \ + AiCommands.h \ + AiCommands.cpp \ BaseDialog.h \ BaseDialog.cpp \ ConfigDialog.h \ Modified: trunk/src/OpcodeWrapper.cpp =================================================================== --- trunk/src/OpcodeWrapper.cpp 2008-04-24 20:30:07 UTC (rev 886) +++ trunk/src/OpcodeWrapper.cpp 2008-05-01 18:29:14 UTC (rev 887) @@ -131,9 +131,9 @@ if ( active_ ){ OgreOpcode::ICollisionShape * shape = obj->getShape(); collideInSectorContext_->destroyObject( obj ); - collisionManager_->detachShape( shape ); collisionManager_->destroyShape( shape ); + obj = NULL; } } @@ -155,7 +155,7 @@ // << static_cast< BaseObject * >( col1->getClientData() )->name() << "<->" // << static_cast< BaseObject * >( col2->getClientData() )->name() << std::endl; - if ( obj->getTypeID() == PROJECTILE_RTTI ){ + if ( obj->rtti() == PROJECTILE_RTTI ){ if ( dynamic_cast< Projectile * >( obj )->parent() != static_cast< BaseObject * >( col1->getClientData() ) ){ obj->mainNode()->setPosition( rayPickReport[ i ]->contact ); Modified: trunk/src/Projectile.h =================================================================== --- trunk/src/Projectile.h 2008-04-24 20:30:07 UTC (rev 886) +++ trunk/src/Projectile.h 2008-05-01 18:29:14 UTC (rev 887) @@ -34,10 +34,10 @@ virtual ~Projectile(); + inline virtual long rtti() const { return PROJECTILE_RTTI; } + 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 ); inline Uint32 damage( ) const { return damage_; } Modified: trunk/src/Sector.cpp =================================================================== --- trunk/src/Sector.cpp 2008-04-24 20:30:07 UTC (rev 886) +++ trunk/src/Sector.cpp 2008-05-01 18:29:14 UTC (rev 887) @@ -68,13 +68,14 @@ Sector::Sector( Ogre::SceneManager * sceneMgr, NetworkClient * network ) : sceneMgr_( sceneMgr ), network_( network ) { - radar_ = true; - planetNode_ = NULL; - planet_ = NULL; - starsNode_ = NULL; - avatar_ = NULL; - station_ = NULL; - log_ = LogManager::getSingletonPtr(); + radar_ = true; + planetNode_ = NULL; + planet_ = NULL; + koordAxisNode_ = NULL; + starsNode_ = NULL; + avatar_ = NULL; + station_ = NULL; + log_ = LogManager::getSingletonPtr(); avatarDeathSequenceTime_ = 0.0; @@ -123,7 +124,7 @@ mainLight->setPosition(-50000, 0, -40000 ); 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 ); planet_ = new Planet( "planet", sceneMgr_, Ogre::Vector3( 0000.0, 0000.0, 50000 ), 15000.0f, 64 ); @@ -156,6 +157,7 @@ } populate( "testsector.xml" ); + createKoordAxis( ); } Sector::~Sector( ){ @@ -192,6 +194,16 @@ if ( collisionDetection_ ) delete collisionDetection_; collisionDetection_ = NULL; + + + + if ( koordAxisNode_ ) { + koordAxisNode_->detachObject( koordAxisMO_ ); + sceneMgr_->destroyManualObject( koordAxisMO_->getName() ); + sceneMgr_->getRootSceneNode()->removeAndDestroyChild( koordAxisNode_->getName() ); + koordAxisNode_ = NULL; + } + } void Sector::populate( const std::string & fileName ){ @@ -550,18 +562,17 @@ SectorObjectMoveableAi * Sector::createAiMoveableObject( const Ogre::String & name, Uint32 userID, Uint8 childID, Vessel & vessel ){ + SectorObjectMoveableAi * obj = new SectorObjectMoveableAi( name, this, userID, childID, new Vessel( vessel ) ); + sectorObjects_.insert( obj ); + movableObjects_[ obj->globalID() ] = obj; + localAiObjects_[ obj->globalID() ] = obj; - SectorObjectMoveableAi * obj = new SectorObjectMoveableAi( name, this, userID, childID, new Vessel( vessel ) ); - sectorObjects_.insert( obj ); - movableObjects_[ obj->globalID() ] = obj; - localAiObjects_[ obj->globalID() ] = obj; - - return obj; + return obj; } void Sector::destruct_( SectorObject * obj ){ if ( obj ){ - log_->debug( "destruct Object: " + obj->name() + " " + toStr( obj->getTypeID() ) ); + log_->debug( "destruct Object: " + obj->name() + " " + toStr( obj->rtti() ) ); sectorObjects_.erase( obj ); if ( listener_->target() == obj ) selectNextTarget( ); @@ -579,7 +590,7 @@ } } - switch ( obj->getTypeID() ){ + switch ( obj->rtti() ){ case SECTOROBJECTMOVABLE_RTTI: movableObjects_.erase( obj->globalID() ); delete obj; @@ -601,7 +612,7 @@ obj = NULL; } break; default: - log_->fatal( "destructMoveableObject: object type unknown. this should not happen: " + toStr( obj->getTypeID() ) ); + log_->fatal( "destructMoveableObject: object type unknown. this should not happen: " + toStr( obj->rtti() ) ); } } else { log_->fatal( "destructMoveableObject: object is no valid: " ); @@ -627,7 +638,7 @@ obj->mainNode()->setPosition( Ogre::Math::RangeRandom( xmin, xmax ), Ogre::Math::RangeRandom( ymin, ymax ), Ogre::Math::RangeRandom( zmin, zmax ) ); - obj->setThrust( obj->maxThrust() ); + obj->setThrustRate( 1.0 ); // obj->mainNode()->setPosition( 0.0f, 0.0f, 200.0f); @@ -644,13 +655,13 @@ avatar_->reset(); if ( station_ ){ log_->info( std::string( "launch avatar from station " ) ); - avatar_->mainNode()->setPosition( station_->launchPadPosition() + station_->launchPadOrientation().zAxis() * -5.0); - avatar_->mainNode()->setOrientation( station_->launchPadOrientation() ); - avatar_->setVelocity( station_->launchPadOrientation().zAxis() * -20.0 ); + avatar_->mainNode()->setPosition( station_->launchPadPosition() + station_->launchPadDirection() * 5.0); + avatar_->mainNode()->setDirection( station_->launchPadDirection() ); + avatar_->setVelocity( station_->launchPadDirection() * 20.0 ); } else{ log_->info( std::string( "launch avatar from free position " ) ); - avatar_->mainNode()->setPosition( 0.0, 0.0, 500.0 ); - avatar_->mainNode()->setOrientation( Ogre::Quaternion( 1.0, 0.0, 0.0, 0.0 ) ); + avatar_->mainNode()->setPosition( 0.0, 0.0, 100.0 ); + avatar_->mainNode()->setDirection( Ogre::Vector3( 0.0, 0.0, -1.0 ) ); avatar_->setVelocity( Ogre::Vector3( 0.0, 0.0, -50.0 ) ); } @@ -714,6 +725,32 @@ return avatar_; } +void Sector::createKoordAxis( ){ + 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_->position( 0.0, 0.0, 0.0 ); + koordAxisMO_->position( 1.0, 0.0, 0.0 ); + koordAxisMO_->position( 0.0, 0.0, 0.0 ); + koordAxisMO_->position( 0.0, 1.0, 0.0 ); + koordAxisMO_->position( 0.0, 0.0, 0.0 ); + koordAxisMO_->position( 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_->position( 0.0, -1.0, 0.0 ); + koordAxisMO_->position( 0.0, 0.0, 0.0 ); + koordAxisMO_->position( 0.0, 0.0, -1.0 ); +// koordAxisMO_->line( 0, 1 ); +// koordAxisMO_->line( 0, 2 ); +// koordAxisMO_->line( 0, 3 ); + koordAxisMO_->end(); + koordAxisNode_->attachObject( koordAxisMO_ ); + koordAxisNode_->scale( length, length, length ); +} + void Sector::createCircle( ){ Ogre::String name = "testcircle"; @@ -784,7 +821,7 @@ obj->mainNode()->getPosition().ptr(), obj->velocity().ptr(), obj->mainNode()->getOrientation().ptr(), - obj->thrust(), + obj->thrustRate(), obj->scaledYaw(), obj->scaledPitch(), obj->scaledRoll(), Modified: trunk/src/Sector.h =================================================================== --- trunk/src/Sector.h 2008-04-24 20:30:07 UTC (rev 886) +++ trunk/src/Sector.h 2008-05-01 18:29:14 UTC (rev 887) @@ -75,6 +75,8 @@ void spawnAiObject( const std::string & vesselName ); void createCircle( ); + void createKoordAxis( ); + Ogre::SceneNode * koordAxis() { return koordAxisNode_; } void selectNextTarget( ); @@ -108,11 +110,12 @@ void sendProjectile( const Projectile & projectile ); void receiveProjectile( const MessageBodyShipProjectileFired & msg ); + StationObject * station() { return station_; } protected: - //** do not destruct objects manualy, let them send false during update loop + +//** do not destruct objects manualy, let them send false during update loop void destruct_( SectorObject * obj ); - Ogre::SceneManager * sceneMgr_; NetworkClient * network_; LogManager * log_; @@ -126,7 +129,9 @@ Ogre::SceneNode * planetNode_; Ogre::SceneNode * starsNode_; - + Ogre::SceneNode * koordAxisNode_; + Ogre::ManualObject * koordAxisMO_; + std::set< SectorObject * > sectorObjects_; std::map< long, SectorObjectMoveable * > movableObjects_; Modified: trunk/src/SectorObjects.cpp =================================================================== --- trunk/src/SectorObjects.cpp 2008-04-24 20:30:07 UTC (rev 886) +++ trunk/src/SectorObjects.cpp 2008-05-01 18:29:14 UTC (rev 887) @@ -136,33 +136,24 @@ } void SectorObject::setShape( const Ogre::String & meshname ){ - entity_ = sceneMgr_->createEntity( name_ + "_shape", meshname ); - mainNodeEntityRot_->attachObject( entity_ ); - // mainNodeEntityRot_->_update( true, true ); - collObj_ = OpcodeCollisionDetection::getSingleton().createObject( this ); + entity_ = sceneMgr_->createEntity( name_ + "_shape", meshname ); + mainNodeEntityRot_->attachObject( entity_ ); + collObj_ = OpcodeCollisionDetection::getSingleton().createObject( this ); } void SectorObject::setBaseRot( const Ogre::Real & yaw, const Ogre::Real & pitch, const Ogre::Real & roll ){ - mainNodeEntityRot_->yaw( Ogre::Degree( yaw ) ); - mainNodeEntityRot_->pitch( Ogre::Degree( pitch ) ); - mainNodeEntityRot_->roll( Ogre::Degree( roll ) ); - // mainNodeEntityRot_->_update( true, true ); - std::cout << mainNodeEntityRot_->_getWorldAABB().getMaximum() << " " << - mainNodeEntityRot_->_getWorldAABB().getMinimum() << " " << - mainNodeEntityRot_->_getWorldAABB().getMaximum()-mainNodeEntityRot_->_getWorldAABB().getMinimum() - << std::endl; + mainNodeEntityRot_->yaw( Ogre::Degree( yaw ) ); + mainNodeEntityRot_->pitch( Ogre::Degree( pitch ) ); + mainNodeEntityRot_->roll( Ogre::Degree( roll ) ); } void SectorObject::scale( const Ogre::Vector3 & scale ){ mainNodeEntityScale_->scale( scale ); - //mainNodeEntityScale_->_update( true, true ); baseSize_ = scale * ( entity_->getBoundingBox().getMaximum() - entity_->getBoundingBox().getMinimum() ); } void SectorObject::setBaseSize( const Ogre::Vector3 & size ){ - // mainNode_->_update( true, true ); - - Ogre::Vector3 oldSize( mainNodeEntityRot_->getOrientation() * ( + Ogre::Vector3 oldSize( mainNodeEntityRot_->getOrientation() * ( mainNodeEntityRot_->_getWorldAABB().getMaximum()- mainNodeEntityRot_->_getWorldAABB().getMinimum() ) ); @@ -175,21 +166,21 @@ // entity_->getBoundingBox().getMinimum() ) ); // Ogre::Vector3 oldSize( mainNode_->_getWorldAABB().getMaximum() - mainNode_->_getWorldAABB().getMinimum() ); - Ogre::Vector3 scale( size / oldSize ); + Ogr... [truncated message content] |
From: <spo...@us...> - 2008-04-24 20:30:03
|
Revision: 886 http://opengate.svn.sourceforge.net/opengate/?rev=886&view=rev Author: spom_spom Date: 2008-04-24 13:30:07 -0700 (Thu, 24 Apr 2008) Log Message: ----------- fixed wrong station size Modified Paths: -------------- trunk/src/SectorObjects.cpp Modified: trunk/src/SectorObjects.cpp =================================================================== --- trunk/src/SectorObjects.cpp 2008-04-24 19:45:36 UTC (rev 885) +++ trunk/src/SectorObjects.cpp 2008-04-24 20:30:07 UTC (rev 886) @@ -138,7 +138,7 @@ void SectorObject::setShape( const Ogre::String & meshname ){ entity_ = sceneMgr_->createEntity( name_ + "_shape", meshname ); mainNodeEntityRot_->attachObject( entity_ ); - mainNodeEntityRot_->_update( true, true ); + // mainNodeEntityRot_->_update( true, true ); collObj_ = OpcodeCollisionDetection::getSingleton().createObject( this ); } @@ -146,21 +146,26 @@ mainNodeEntityRot_->yaw( Ogre::Degree( yaw ) ); mainNodeEntityRot_->pitch( Ogre::Degree( pitch ) ); mainNodeEntityRot_->roll( Ogre::Degree( roll ) ); - mainNodeEntityRot_->_update( true, true ); + // mainNodeEntityRot_->_update( true, true ); + std::cout << mainNodeEntityRot_->_getWorldAABB().getMaximum() << " " << + mainNodeEntityRot_->_getWorldAABB().getMinimum() << " " << + mainNodeEntityRot_->_getWorldAABB().getMaximum()-mainNodeEntityRot_->_getWorldAABB().getMinimum() + << std::endl; } void SectorObject::scale( const Ogre::Vector3 & scale ){ mainNodeEntityScale_->scale( scale ); - mainNodeEntityScale_->_update( true, true ); + //mainNodeEntityScale_->_update( true, true ); baseSize_ = scale * ( entity_->getBoundingBox().getMaximum() - entity_->getBoundingBox().getMinimum() ); } void SectorObject::setBaseSize( const Ogre::Vector3 & size ){ - mainNode_->_update( true, true ); -// Ogre::Vector3 oldSize( mainNodeEntityRot_->getOrientation() * ( -// mainNodeEntityRot_->_getWorldAABB().getMaximum()- -// mainNodeEntityRot_->_getWorldAABB().getMinimum() ) ); -// + // mainNode_->_update( true, true ); + + Ogre::Vector3 oldSize( mainNodeEntityRot_->getOrientation() * ( + mainNodeEntityRot_->_getWorldAABB().getMaximum()- + mainNodeEntityRot_->_getWorldAABB().getMinimum() ) ); + /* Ogre::Vector3 oldSize( mainNodeEntityScale_->getOrientation() * ( mainNodeEntityScale_->_getWorldAABB().getMaximum()- mainNodeEntityScale_->_getWorldAABB().getMinimum() ) );*/ @@ -168,7 +173,7 @@ // Ogre::Vector3 oldSize( mainNodeEntityRot_->getOrientation() * ( // entity_->getBoundingBox().getMaximum()- // entity_->getBoundingBox().getMinimum() ) ); - Ogre::Vector3 oldSize( mainNode_->_getWorldAABB().getMaximum() - mainNode_->_getWorldAABB().getMinimum() ); + // Ogre::Vector3 oldSize( mainNode_->_getWorldAABB().getMaximum() - mainNode_->_getWorldAABB().getMinimum() ); Ogre::Vector3 scale( size / oldSize ); @@ -186,22 +191,26 @@ scale[ 2 ] = scale[ 0 ]; scale[ 1 ] = scale[ 0 ]; } - std::cout << name_ << std::endl; - std::cout << size << std::endl; - std::cout << oldSize << std::endl; - std::cout << scale << std::endl; - - - std::cout << entity_->getBoundingBox().getMaximum()- entity_->getBoundingBox().getMinimum() << std::endl; - - std::cout << mainNodeEntityRot_->getOrientation() * ( entity_->getBoundingBox().getMaximum()- - entity_->getBoundingBox().getMinimum() ) << std::endl; - - std::cout << mainNode_->_getWorldAABB().getMaximum() - mainNode_->_getWorldAABB().getMinimum() << std::endl; - std::cout << mainNode_->_getDerivedScale() << std::endl; +// std::cout << name_ << std::endl; +// std::cout << "sol: " << size << std::endl; +// std::cout << "ist: " << oldSize << std::endl; +// std::cout << scale << std::endl; +// +// std::cout << mainNodeEntityRot_->_getWorldAABB().getMaximum() << " " << +// mainNodeEntityRot_->_getWorldAABB().getMinimum() << " " << +// mainNodeEntityRot_->_getWorldAABB().getMaximum()-mainNodeEntityRot_->_getWorldAABB().getMinimum() +// << std::endl; +// std::cout << entity_->getBoundingBox().getMaximum()- entity_->getBoundingBox().getMinimum() << std::endl; +// +// std::cout << mainNodeEntityRot_->getOrientation() * ( entity_->getBoundingBox().getMaximum()- +// entity_->getBoundingBox().getMinimum() ) << std::endl; +// +// std::cout << mainNode_->_getWorldAABB().getMaximum() - mainNode_->_getWorldAABB().getMinimum() << std::endl; +// std::cout << mainNode_->_getDerivedScale() << std::endl; + mainNodeEntityScale_->scale( scale ); - mainNodeEntityScale_->_update( true, true ); + //mainNodeEntityScale_->_update( true, true ); baseSize_ = size; baseScale_ = scale; } @@ -365,6 +374,8 @@ //** because of the discrete jumps between to frames we have to check for collisions via ray; if ( !destroyRequest_ && collObj_ ){ Ogre::Ray rayNoNextPos( mainNode_->getPosition(), vel_.normalisedCopy() ); + + //** bitte bitte check, ob das vor oder nach dem Move soll bzw, ob die richtung stimmt OpcodeCollisionDetection::getSingleton().checkCollideRay( this, rayNoNextPos, (vel_ * elapsedTime).length() ); } 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 (GameStateManager::*)( ), std::string >( &GameStateManager::initialiseEquipmentManager, - "initialise equipment manager" ) ); + "initialise equipment manager" ) ); loadResourcesVector_.push_back( std::pair< bool (GameStateManager::*)( ), + std::string >( &GameStateManager::initialiseAiManager, + "initialise ai manager" ) ); + loadResourcesVector_.push_back( std::pair< bool (GameStateManager::*)( ), std::string >( &GameStateManager::createAvatar, "create avatar" ) ); loadResourcesVector_.push_back( std::pair< bool (GameStateManager::*)( ), @@ -456,11 +467,12 @@ resources_.ogreRoot->addFrameListener( resources_.console ); LogManager::getSingleton().setConsole( resources_.console ); - resources_.console->addCommand( "/q", &GameStateManager::CMD_shutdown, "Shutting down the client. Shortcut for /quit" ); - resources_.console->addCommand( "/quit", &GameStateManager::CMD_shutdown, "Shutting down the client" ); - resources_.console->addCommand( "/help", &GameStateManager::CMD_printHelp,"Show this help" ); - resources_.console->addCommand( "/time", &GameStateManager::CMD_printTime,"Show current system time" ); - resources_.console->addCommand( "/ai", &GameStateManager::CMD_spawnAi, "[name] Spawn ai subject. /ai help show all available ships." ); + resources_.console->addCommand( "/q", &GameStateManager::CMD_shutdown, "Shutting down the client. Shortcut for /quit" ); + resources_.console->addCommand( "/quit", &GameStateManager::CMD_shutdown, "Shutting down the client" ); + resources_.console->addCommand( "/help", &GameStateManager::CMD_printHelp,"Show this help" ); + resources_.console->addCommand( "/time", &GameStateManager::CMD_printTime,"Show current system time" ); + resources_.console->addCommand( "/spawn", &GameStateManager::CMD_spawnAi, "[name] Spawn ai subject. /spawn help show all available ships." ); + resources_.console->addCommand( "/ai", &GameStateManager::CMD_ai, " [command] interact with aimanager. /ai help show all commands." ); return true; } @@ -476,6 +488,16 @@ return true; } +bool GameStateManager::initialiseAiManager(){ + resources_.aiManager = new AiManager( &resources_ ); + return true; +} + +bool GameStateManager::initialiseCollisionManager(){ + resources_.collisionManager = new OpcodeCollisionDetection( &resources_ ); + return true; +} + bool GameStateManager::initialiseVesselManager(){ vesselManager_ = new VesselManager( ); vesselManager_->load( resources_.resourcePaths(), "ships" ); @@ -614,6 +636,10 @@ resources_.console->print( asctime( time ) ); } +void GameStateManager::CMD_ai( const std::vector < std::string > & argv ){ + resources_.aiManager->cmd( argv ); +} + void GameStateManager::CMD_spawnAi( const std::vector < std::string > & argv ){ std::string aiName = "Squid"; if ( argv.size() > 1 ){ Modified: trunk/src/GameStateManager.h =================================================================== --- trunk/src/GameStateManager.h 2008-02-04 22:31:01 UTC (rev 884) +++ trunk/src/GameStateManager.h 2008-04-24 19:45:36 UTC (rev 885) @@ -68,7 +68,7 @@ bool initialiseOgreResources( ); bool initialiseCEGUIEngine( ); bool initialiseInputManager( ); - + bool initialiseConsole(); //** load id, rank matrix etc. @@ -77,12 +77,13 @@ bool initialiseVesselManager(); bool initialiseCommodityManager(); bool initialiseEquipmentManager(); + bool initialiseAiManager(); + bool initialiseCollisionManager(); bool createAvatar(); bool createConfigDialog(); bool createDockedState(); bool createUnDockedState(); - ConfigDialog * configDialog() { return configDialog_; } void switchConfigDialog( ); @@ -102,6 +103,9 @@ /*! Find a game state by name. \Remarks returns 0 on failure. */ virtual GameState * findByName( const std::string & stateName); + /*! Get the active gamestate. */ + GameState * activeState( ) { return stateStack_.back(); } + /*! Change to a game state. This replaces the current game state with a new game state. The current game state ends before the new begins. */ void changeGameState( GameState * state ); @@ -115,12 +119,11 @@ void CMD_printHelp( const std::vector < std::string > & argv ); void CMD_printTime( const std::vector < std::string > & argv ); void CMD_spawnAi( const std::vector < std::string > & argv ); + void CMD_ai( const std::vector < std::string > & argv ); /*! This is a special case function to cause a shutdown. */ void shutdown( ); -// bool enterDockedStateHack_; - std::vector< std::pair< bool (GameStateManager::*)( ), std::string > > * pLoadResourcesVector(){ return &loadResourcesVector_; } Modified: trunk/src/InputManager.cpp =================================================================== --- trunk/src/InputManager.cpp 2008-02-04 22:31:01 UTC (rev 884) +++ trunk/src/InputManager.cpp 2008-04-24 19:45:36 UTC (rev 885) @@ -84,7 +84,8 @@ keyboard_->setEventCallback( this ); #ifndef WIN32 - if ( inputSystem_->numJoySticks() > 0 ) { + //** temporaly disabled + //if ( inputSystem_->numJoySticks() > 0 ) { // mJoysticks.resize( inputSystem_->numJoysticks() ); @@ -94,9 +95,9 @@ // (*itJoystick) = static_cast<OIS::JoyStick*>( inputSystem_->createInputObject( OIS::OISJoyStick, true ) ); // (*itJoystick)->setEventCallback( this ); // } - joyStick_ = static_cast<OIS::JoyStick*>(inputSystem_->createInputObject( OIS::OISJoyStick, true)); - joyStick_->setEventCallback( this ); - } +// joyStick_ = static_cast<OIS::JoyStick*>(inputSystem_->createInputObject( OIS::OISJoyStick, true)); +// joyStick_->setEventCallback( this ); +// } #endif } } Modified: trunk/src/KeyMap.cpp =================================================================== --- trunk/src/KeyMap.cpp 2008-02-04 22:31:01 UTC (rev 884) +++ trunk/src/KeyMap.cpp 2008-04-24 19:45:36 UTC (rev 885) @@ -81,6 +81,7 @@ unDockedActionMap_[ keycode( OIS::KC_F6 ) ] = &UnDockedState::keyActionAvatarSwitchDuelistTarget_DEV; unDockedActionMap_[ keycode( OIS::KC_F4 ) ] = &UnDockedState::keyActionAvatarChangeDockedState_DEV; unDockedActionMap_[ keycode( OIS::KC_F8 ) ] = &UnDockedState::keyActionAvatarSelfDestruct_DEV; + unDockedActionMap_[ keycode( OIS::KC_F7 ) ] = &UnDockedState::keyActionSpawnAi_DEV; } bool(UnDockedState::*KeyMap::unDockedKeyAction( const OIS::KeyEvent & e ))(bool) { Modified: trunk/src/Makefile.am =================================================================== --- trunk/src/Makefile.am 2008-02-04 22:31:01 UTC (rev 884) +++ trunk/src/Makefile.am 2008-04-24 19:45:36 UTC (rev 885) @@ -1,6 +1,7 @@ bin_PROGRAMS = \ opengateclient \ - opengateserver + opengateserver \ + testaimanager opengateclient_SOURCES = \ opengateclient.cpp \ @@ -18,6 +19,10 @@ tinyxml/tinyxmlparser.cpp \ Avatar.h \ Avatar.cpp \ + AiManager.h \ + AiManager.cpp \ + AiObject.h \ + AiObject.cpp \ BaseDialog.h \ BaseDialog.cpp \ ConfigDialog.h \ @@ -108,6 +113,94 @@ opengateserver_CXXFLAGS = \ $(ogreopcode_CFLAGS) +testaimanager_SOURCES = \ + testaimanager.cpp \ + commonWithOgre.h \ + commonWithOgre.cpp \ + networkProtocol.h \ + networkProtocol.cpp \ + networkClient.h \ + networkClient.cpp \ + tinyxml/tinyxml.h \ + tinyxml/tinyxml.cpp \ + tinyxml/tinyxmlerror.cpp \ + tinyxml/tinyxmlparser.cpp \ + Avatar.h \ + Avatar.cpp \ + AiManager.h \ + AiManager.cpp \ + AiObject.h \ + AiObject.cpp \ + BaseDialog.h \ + BaseDialog.cpp \ + ConfigDialog.h \ + ConfigDialog.cpp \ + Console.h \ + Console.cpp \ + DockedState.h \ + DockedState.cpp \ + Entity.h \ + Entity.cpp \ + EntityManager.h \ + EntityManager.cpp \ + GameState.h \ + GameState.cpp \ + GameStateManager.h \ + GameStateManager.cpp \ + InputManager.h \ + InputManager.cpp \ + InitState.h \ + InitState.cpp \ + KeyMap.h \ + KeyMap.cpp \ + LogManager.h \ + LogManager.cpp \ + LogManagerBase.h \ + LogManagerBase.cpp \ + MarketDialog.h \ + MarketDialog.cpp \ + OpcodeWrapper.h \ + OpcodeWrapper.cpp \ + OpenALSoundManager.h \ + OpenALSoundManager.cpp \ + Planet.h \ + Planet.cpp \ + Projectile.h \ + Projectile.cpp \ + ResourceManager.h \ + ResourceManager.cpp \ + Sector.h \ + Sector.cpp \ + SectorObjects.h \ + SectorObjects.cpp \ + ShipConfigDialog.h \ + ShipConfigDialog.cpp \ + Station.h \ + Station.cpp \ + UnDockedState.cpp \ + UnDockedState.h \ + Vessel.h \ + Vessel.cpp \ + VesselManager.h \ + VesselManager.cpp \ + metaserver.h \ + metaserver.cpp \ + common.h \ + common.cpp + +testaimanager_LDFLAGS = $(OGRE_LIBS) \ + $(CEGUI_LIBS) \ + $(CEGUIOGRE_LIBS) \ + $(freealut_LIBS) \ + $(vorbisfile_LIBS) \ + $(OIS_LIBS) \ + $(ogreopcode_LIBS) + +testaimanager_CXXFLAGS = \ + $(OGRE_CFLAGS) \ + $(CEGUI_CFLAGS) \ + $(ogreopcode_CFLAGS) + #testopenalmanager_SOURCES = \ # testopenalmanager.cpp \ # common.h \ Modified: trunk/src/OpcodeWrapper.cpp =================================================================== --- trunk/src/OpcodeWrapper.cpp 2008-02-04 22:31:01 UTC (rev 884) +++ trunk/src/OpcodeWrapper.cpp 2008-04-24 19:45:36 UTC (rev 885) @@ -21,6 +21,7 @@ #include "OpcodeWrapper.h" #include "SectorObjects.h" +#include "ResourceManager.h" #include "Projectile.h" #include <OgreOpcode.h> @@ -32,126 +33,148 @@ template<> OpcodeCollisionDetection * Ogre::Singleton< OpcodeCollisionDetection >::ms_Singleton = 0; +OpcodeCollisionDetection::OpcodeCollisionDetection( ResourceManager * resources ){ + std::cout << "OpcodeCollisionDetection::OpcodeCollisionDetection implement this " << std::endl; +} + OpcodeCollisionDetection::OpcodeCollisionDetection( Ogre::SceneManager * sceneMgr ){ - new OgreOpcode::CollisionManager( sceneMgr ); + active_ = true; + if ( active_ ){ + collisionManager_ = new OgreOpcode::CollisionManager( sceneMgr ); - OgreOpcode::CollisionManager::getSingletonPtr()->addCollClass( "SectorObject" ); - OgreOpcode::CollisionManager::getSingletonPtr()->addCollClass( "Station" ); - OgreOpcode::CollisionManager::getSingletonPtr()->addCollClass( "DockPad" ); - OgreOpcode::CollisionManager::getSingletonPtr()->addCollClass( "Bullet" ); + collisionManager_->addCollClass( "SectorObject" ); + collisionManager_->addCollClass( "Station" ); + collisionManager_->addCollClass( "DockPad" ); + collisionManager_->addCollClass( "Bullet" ); - OgreOpcode::CollisionManager::getSingletonPtr()->addCollType( "Bullet", "Bullet", OgreOpcode::COLLTYPE_IGNORE ); - OgreOpcode::CollisionManager::getSingletonPtr()->addCollType( "SectorObject", "Bullet", OgreOpcode::COLLTYPE_EXACT ); - OgreOpcode::CollisionManager::getSingletonPtr()->addCollType( "SectorObject", "SectorObject", OgreOpcode::COLLTYPE_EXACT ); - OgreOpcode::CollisionManager::getSingletonPtr()->addCollType( "Station", "SectorObject", OgreOpcode::COLLTYPE_EXACT ); - OgreOpcode::CollisionManager::getSingletonPtr()->addCollType( "Station", "DockPad", OgreOpcode::COLLTYPE_IGNORE ); - OgreOpcode::CollisionManager::getSingletonPtr()->addCollType( "Station", "Bullet", OgreOpcode::COLLTYPE_EXACT ); - 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(); + collisionManager_->addCollType( "Bullet", "Bullet", OgreOpcode::COLLTYPE_IGNORE ); + collisionManager_->addCollType( "SectorObject", "Bullet", OgreOpcode::COLLTYPE_EXACT ); + collisionManager_->addCollType( "SectorObject", "SectorObject", OgreOpcode::COLLTYPE_EXACT ); + collisionManager_->addCollType( "Station", "SectorObject", OgreOpcode::COLLTYPE_EXACT ); + collisionManager_->addCollType( "Station", "DockPad", OgreOpcode::COLLTYPE_IGNORE ); + collisionManager_->addCollType( "Station", "Bullet", OgreOpcode::COLLTYPE_EXACT ); + collisionManager_->addCollType( "DockPad", "SectorObject", OgreOpcode::COLLTYPE_EXACT ); + + // collisionManager_->addCollType( "SectorObject", "SectorObject", OgreOpcode::COLLTYPE_CONTACT ); + // collisionManager_->addCollType( "SectorObject", "SectorObject", OgreOpcode::COLLTYPE_QUICK ); + + collideInSectorContext_ = collisionManager_->getDefaultContext(); + } else { + std::cout << "OpcodeCollisionDetection deactivated" << std::endl; + } } OpcodeCollisionDetection::~OpcodeCollisionDetection(){ - delete OgreOpcode::CollisionManager::getSingletonPtr(); + delete collisionManager_; } bool OpcodeCollisionDetection::update( Ogre::Real elapsedTime ){ - collideInSectorContext_->collide( elapsedTime ); + if ( active_ ){ + collideInSectorContext_->collide( elapsedTime ); - OgreOpcode::CollisionReporter report( collideInSectorContext_->getCollisionReport() ); + OgreOpcode::CollisionReporter report( collideInSectorContext_->getCollisionReport() ); - int nCollids = report.getNumCollisions(); - if ( nCollids > 0 ){ - // std::cout << "Collisions: " << nCollids << std::endl; + int nCollids = report.getNumCollisions(); + if ( nCollids > 0 ){ + // std::cout << "Collisions: " << nCollids << std::endl; - OgreOpcode::CollisionPair **collisionReport; - report.getAllCollisions( collisionReport ); + OgreOpcode::CollisionPair **collisionReport; + report.getAllCollisions( collisionReport ); - for ( int i = 0; i < nCollids; i ++ ){ - OgreOpcode::CollisionObject* col1 = collisionReport[ i ]->this_object; - OgreOpcode::CollisionObject* col2 = collisionReport[ i ]->other_object; + for ( int i = 0; i < nCollids; i ++ ){ + OgreOpcode::CollisionObject* col1 = collisionReport[ i ]->this_object; + OgreOpcode::CollisionObject* col2 = collisionReport[ i ]->other_object; - static_cast< BaseObject * >( col1->getClientData() )->collide( static_cast< BaseObject * >( col2->getClientData() ) ); - static_cast< BaseObject * >( col2->getClientData() )->collide( static_cast< BaseObject * >( col1->getClientData() ) ); - } + static_cast< BaseObject * >( col1->getClientData() )->collide( static_cast< BaseObject * >( + col2->getClientData() ) ); + static_cast< BaseObject * >( col2->getClientData() )->collide( static_cast< BaseObject * >( + col1->getClientData() ) ); + } // std::cout << "CollisionContext attached objects: " + Ogre::StringConverter::toString(collideInSectorContext_->getAttachedObjectCount()) << std::endl; // std::cout << "CollisionContext owned objects: " + Ogre::StringConverter::toString(collideInSectorContext_->getOwnedObjectCount()) << std::endl; -// std::cout << "CollisionManager shapes: " + Ogre::StringConverter::toString(OgreOpcode::CollisionManager::getSingletonPtr()->getShapeCount())<< std::endl; +// std::cout << "CollisionManager shapes: " + Ogre::StringConverter::toString(collisionManager_->getShapeCount())<< std::endl; - } + } // if ncols + } return true; } OgreOpcode::CollisionObject * OpcodeCollisionDetection::createObject( Ogre::Entity * entity, BaseObject * obj, const std::string & collClass ){ + OgreOpcode::CollisionObject * collObj = NULL; + + if ( active_ ){ + OgreOpcode::EntityCollisionShape * collShape = collisionManager_ + ->createEntityCollisionShape( obj->name() + "/CollShape" ); + collShape->load( entity ); - OgreOpcode::EntityCollisionShape * collShape = OgreOpcode::CollisionManager::getSingletonPtr() - ->createEntityCollisionShape( obj->name() + "/CollShape" ); - collShape->load( entity ); + collObj = collideInSectorContext_->createObject( obj->name() + "/CollObj" ); + collObj->setCollClass( collisionManager_->queryCollClass( collClass ) ); + collObj->setShape( collShape ); - OgreOpcode::CollisionObject * collObj = collideInSectorContext_->createObject( obj->name() + "/CollObj" ); - collObj->setCollClass( OgreOpcode::CollisionManager::getSingletonPtr()->queryCollClass( collClass ) ); - collObj->setShape( collShape ); + collideInSectorContext_->addObject( collObj ); - collideInSectorContext_->addObject( collObj ); - - collObj->setClientData( obj ); + collObj->setClientData( obj ); + } return collObj; } OgreOpcode::CollisionObject * OpcodeCollisionDetection::createObject( SectorObject * obj ){ - return createObject( obj->entity(), obj, "SectorObject" ); + return createObject( obj->entity(), obj, "SectorObject" ); } -void OpcodeCollisionDetection::destroyObject( OgreOpcode::CollisionObject * obj ){ - - OgreOpcode::ICollisionShape *shape = obj->getShape(); - OgreOpcode::CollisionManager::getSingletonPtr()->detachShape(shape); - OgreOpcode::CollisionManager::getSingletonPtr()->destroyShape(shape); - - - collideInSectorContext_->destroyObject( obj ); - // OgreOpcode::CollisionManager::getSingletonPtr()->destroyShape( obj->getShape() ); +void OpcodeCollisionDetection::destroyObject( OgreOpcode::CollisionObject * obj ){ + + if ( active_ ){ + OgreOpcode::ICollisionShape * shape = obj->getShape(); + collideInSectorContext_->destroyObject( obj ); + + collisionManager_->detachShape( shape ); + collisionManager_->destroyShape( shape ); + } } bool OpcodeCollisionDetection::checkCollideRay( BaseObject * obj, const Ogre::Ray & ray, double rayLength){ - if ( !obj->isSetDestroyRequest() ){ - OgreOpcode::CollisionPair ** rayPickReport; - uint nColl = collideInSectorContext_->rayCheck( ray, rayLength, OgreOpcode::COLLTYPE_EXACT, - OgreOpcode::COLLTYPE_ALWAYS_EXACT, rayPickReport ); + if ( active_ ){ + if ( !obj->isSetDestroyRequest() ){ + 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; + 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 false; + 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 false; } void OpcodeCollisionDetection::changeCollClass( OgreOpcode::CollisionObject * collObj, const std::string & collClass ){ - if ( collObj ) collObj->setCollClass( OgreOpcode::CollisionManager::getSingletonPtr()->queryCollClass( collClass ) ); + if ( collObj ) collObj->setCollClass( collisionManager_->queryCollClass( collClass ) ); } OpcodeCollisionDetection & OpcodeCollisionDetection::getSingleton( ){ Modified: trunk/src/OpcodeWrapper.h =================================================================== --- trunk/src/OpcodeWrapper.h 2008-02-04 22:31:01 UTC (rev 884) +++ trunk/src/OpcodeWrapper.h 2008-04-24 19:45:36 UTC (rev 885) @@ -26,6 +26,7 @@ namespace OgreOpcode{ class CollisionContext; + class CollisionManager; class CollisionObject; } @@ -34,9 +35,12 @@ class BaseObject; class SectorObject; class Projectile; +class ResourceManager; class OpcodeCollisionDetection : public Ogre::Singleton< OpcodeCollisionDetection >{ public: + OpcodeCollisionDetection( ResourceManager * resources = NULL ); + OpcodeCollisionDetection( Ogre::SceneManager * sceneMgr ); ~OpcodeCollisionDetection(); @@ -44,6 +48,7 @@ bool update( Ogre::Real elapsedTime ); OgreOpcode::CollisionObject * createObject( Ogre::Entity * entity, BaseObject * obj, const std::string & collClass ); + OgreOpcode::CollisionObject * createObject( SectorObject * obj ); void destroyObject( OgreOpcode::CollisionObject * obj ); @@ -58,6 +63,8 @@ protected: OgreOpcode::CollisionContext * collideInSectorContext_; + OgreOpcode::CollisionManager * collisionManager_; + bool active_; }; Modified: trunk/src/OpenALSoundManager.cpp =================================================================== --- trunk/src/OpenALSoundManager.cpp 2008-02-04 22:31:01 UTC (rev 884) +++ trunk/src/OpenALSoundManager.cpp 2008-04-24 19:45:36 UTC (rev 885) @@ -277,7 +277,16 @@ bool OpenALOggStreamSource::release(){ alSourceStop( source_ ); empty_(); - alDeleteSources(1, &source_ ); + + //** alDeleteSources(1, & source_ ); + //** valgrind says:; + // Invalid read of size 4 +// ==10954== at 0x6129E42: (within /usr/lib64/libopenal.so.0.0.0) +// ==10954== by 0x612D083: (within /usr/lib64/libopenal.so.0.0.0) +// ==10954== by 0x6129B7F: alDeleteSources (in /usr/lib64/libopenal.so.0.0.0) +// ==10954== by 0x48ADCD: OpenGate::OpenALOggStreamSource::release() (OpenALSoundManager.cpp:280) +// ==10954== by 0x4899A6: OpenGate::OpenALSoundManager::destroySoundSource(OpenGate::OpenALSoundSource*) (OpenALSoundManager.cpp:639) + if ( soundMgr_->checkOpenALError( "OpenALOggStreamSource::release::alDeleteSources" ) ) return false; alDeleteBuffers(1, buffers_ ); if ( soundMgr_->checkOpenALError( "OpenALOggStreamSource::release::alDeleteBuffers" ) ) return false; @@ -455,7 +464,6 @@ OpenALSoundManager::~OpenALSoundManager(){ Ogre::Root::getSingleton().removeFrameListener( this ); - log_->info( "Shoutdown soundmanager." ); for ( std::map< std::string, OpenALSoundSource * >::iterator it = mapSoundSources_.begin(); it != mapSoundSources_.end(); ){ destroySoundSource( it++->second ); @@ -533,10 +541,13 @@ // } // deviceSpecifiers += strlen( deviceSpecifiers ) + 1; // } - - ALCdevice * device = alcOpenDevice( NULL ); +bool disable_ = false; +ALCdevice * device = NULL; + if ( !disable_ ){ + device = alcOpenDevice( NULL ); // Device = alcOpenDevice((ALubyte*)"DirectSound3D"); - + } + if ( !device ){ log_->warn( "No sound device detected." ); haveSoundDevice_ = false; Modified: trunk/src/Projectile.h =================================================================== --- trunk/src/Projectile.h 2008-02-04 22:31:01 UTC (rev 884) +++ trunk/src/Projectile.h 2008-04-24 19:45:36 UTC (rev 885) @@ -56,8 +56,6 @@ Gun * gun() const { return gun_; } - virtual void destroyRequest(){} - protected: BaseObject * parent_; Modified: trunk/src/ResourceManager.cpp =================================================================== --- trunk/src/ResourceManager.cpp 2008-02-04 22:31:01 UTC (rev 884) +++ trunk/src/ResourceManager.cpp 2008-04-24 19:45:36 UTC (rev 885) @@ -36,16 +36,18 @@ ResourceManager::ResourceManager( ){ log_ = LogManager::getSingletonPtr(); - ogreRoot = NULL; - renderWindow = NULL; - inputManager = NULL; - soundManager = NULL; - guiRenderer = NULL; - guiSystem = NULL; - console = NULL; - network = NULL; - gameStateRoot = NULL; - avatar = NULL; + ogreRoot = NULL; + renderWindow = NULL; + inputManager = NULL; + soundManager = NULL; + aiManager = NULL; + guiRenderer = NULL; + guiSystem = NULL; + console = NULL; + network = NULL; + gameStateRoot = NULL; + avatar = NULL; + collisionManager = NULL; keymap_ = new KeyMap(); keymap_->setDefaults(); languageSuffix_ = "en"; Modified: trunk/src/ResourceManager.h =================================================================== --- trunk/src/ResourceManager.h 2008-02-04 22:31:01 UTC (rev 884) +++ trunk/src/ResourceManager.h 2008-04-24 19:45:36 UTC (rev 885) @@ -41,6 +41,7 @@ class NetworkClient; class InputManager; class LogManager; +class AiManager; class OpenALSoundManager; class GameState; class GameStateManager; @@ -49,6 +50,7 @@ class Entity; class Station; class KeyMap; +class OpcodeCollisionDetection; class ResourceManager : public Ogre::Singleton< ResourceManager > { public: @@ -62,7 +64,9 @@ Console * console; GameStateManager * gameStateRoot; Avatar * avatar; - + AiManager * aiManager; + OpcodeCollisionDetection * collisionManager; + ResourceManager( ); ~ResourceManager( ); Modified: trunk/src/Sector.cpp =================================================================== --- trunk/src/Sector.cpp 2008-02-04 22:31:01 UTC (rev 884) +++ trunk/src/Sector.cpp 2008-04-24 19:45:36 UTC (rev 885) @@ -20,6 +20,7 @@ #include "Sector.h" #include "Avatar.h" +#include "AiObject.h" #include "OpcodeWrapper.h" #include "tinyxml/tinyxml.h" #include "ResourceManager.h" @@ -155,34 +156,28 @@ } populate( "testsector.xml" ); - -// createCircle(); - - itTarget_ = sectorObjects_.begin(); } Sector::~Sector( ){ for ( std::map< long, SectorObjectMoveable * >::iterator it = movableObjects_.begin(); it != movableObjects_.end();){ // log_->info( "Destructing: " + it->second->name() ); - destructMoveableObject_( (it++)->second ); + destruct_( (it++)->second ); // log_->info( "done: " ); } for ( std::set< SectorObject * >::iterator it = sectorObjects_.begin(); it != sectorObjects_.end(); ){ // log_->info( "Destructing: " + (*it)->name() ); - - if ( (*it)->isOnRadar() && radar_ ){ - Ogre::Overlay * radar = Ogre::OverlayManager::getSingleton().getByName( "Radar" ); - Ogre::OverlayContainer * radarMap = radar->getChild( "Radar/Map" ); - radarMap->removeChild( (*it)->dotA()->getName() ); - radarMap->removeChild( (*it)->dotB()->getName() ); + + if ( radar_ && (*it)->isOnRadar() ){ + Ogre::Overlay * radar = Ogre::OverlayManager::getSingleton().getByName( "Radar" ); + Ogre::OverlayContainer * radarMap = radar->getChild( "Radar/Map" ); + radarMap->removeChild( (*it)->dotA()->getName() ); + radarMap->removeChild( (*it)->dotB()->getName() ); } delete *it; sectorObjects_.erase( (*it++) ); - -// log_->info( "done: " ); } sceneMgr_->destroyLight("MainLight" ); @@ -264,7 +259,6 @@ } } - //** Load stations for ( pElem = hRoot.FirstChild( "station" ).Element(); pElem != 0; pElem = pElem->NextSiblingElement("station") ) { std::string name; @@ -292,7 +286,6 @@ Ogre::Quaternion rot = ( obj->mainNode()->getOrientation().zAxis()* -1.0).getRotationTo( targetDirection ); obj->mainNode()->rotate( rot ); } - } //** Load passive sector objects @@ -313,7 +306,7 @@ mesh = std::string( pSubElem->FirstChild()->Value() ) + ".mesh"; Ogre::MeshPtr pMesh = Ogre::MeshManager::getSingleton().load( mesh, - Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, + Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, Ogre::HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY, Ogre::HardwareBuffer::HBU_STATIC_WRITE_ONLY, true, true); @@ -417,47 +410,48 @@ for ( std::set< SectorObject * >::iterator it = sectorObjects_.begin(); it != sectorObjects_.end(); it++){ - Ogre::Vector3 relativPosition( (*it)->mainNode()->getPosition( ) - avatar_->mainNode()->getPosition( ) ); - Ogre::OverlayElement * dotA = (*it)->dotA(); - Ogre::OverlayElement * dotB = (*it)->dotB(); + if ( (*it) != avatar_ ){ + Ogre::Vector3 relativPosition( (*it)->mainNode()->getPosition( ) - avatar_->mainNode()->getPosition( ) ); + Ogre::OverlayElement * dotA = (*it)->dotA(); + Ogre::OverlayElement * dotB = (*it)->dotB(); - if ( relativPosition.length() < radarRange ){ + if ( relativPosition.length() < radarRange ){ - Ogre::Quaternion q; - q.FromAngleAxis( -avatar_->mainNode()->getOrientation( ).getYaw(), Ogre::Vector3::UNIT_Y); - relativPosition = q * relativPosition; + Ogre::Quaternion q; + q.FromAn... [truncated message content] |
From: <spo...@us...> - 2008-02-04 22:31:01
|
Revision: 884 http://opengate.svn.sourceforge.net/opengate/?rev=884&view=rev Author: spom_spom Date: 2008-02-04 14:31:01 -0800 (Mon, 04 Feb 2008) Log Message: ----------- Add screenie for an impression Added Paths: ----------- branches/ogEditor/ogEditorFirst-Impression-2.png Added: branches/ogEditor/ogEditorFirst-Impression-2.png =================================================================== (Binary files differ) Property changes on: branches/ogEditor/ogEditorFirst-Impression-2.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <spo...@us...> - 2008-02-04 22:24:51
|
Revision: 883 http://opengate.svn.sourceforge.net/opengate/?rev=883&view=rev Author: spom_spom Date: 2008-02-04 14:24:41 -0800 (Mon, 04 Feb 2008) Log Message: ----------- start a veryvery basic TPoC for an wxpython based python-ogre editor for OpenGate Added Paths: ----------- branches/ogEditor/ branches/ogEditor/ObjectInspectorPanels.py branches/ogEditor/OgreWindowWx.py branches/ogEditor/PropertyGrid.py branches/ogEditor/PythonOgreConfig.py branches/ogEditor/ResourceTreePane.py branches/ogEditor/build.wxogre_util.sh branches/ogEditor/ogEditor.py branches/ogEditor/ogEditor.sh branches/ogEditor/ogre.cfg branches/ogEditor/plugins.cfg branches/ogEditor/propgridtest.py branches/ogEditor/resources.cfg branches/ogEditor/treetest.py branches/ogEditor/wxogre_util.cpp branches/ogEditor/wxogre_util.py Added: branches/ogEditor/ObjectInspectorPanels.py =================================================================== --- branches/ogEditor/ObjectInspectorPanels.py (rev 0) +++ branches/ogEditor/ObjectInspectorPanels.py 2008-02-04 22:24:41 UTC (rev 883) @@ -0,0 +1,214 @@ +#!/usr/bin/env python +# -*- coding: ansi_x3.4-1968 -*- +# generated by wxGlade 0.6.2 on Mon Jan 7 21:02:32 2008 + +import wx +import sys + +import PythonOgreConfig +import ogre.renderer.OGRE as ogre + +from PropertyGrid import * + +class PropertyCollapsibleOgreFogPane( PropertyPaneItem ): + def __init__( self, parent, name, object = None ): + PropertyPaneItem.__init__(self, parent, name) + + self.object = object + self.colour = [255, 255, 255, 255] + self.mode = 0 + self.expDensity = 0.01 + self.linearStart = 0.0 + self.linearEnd = 1.0 +# self.fogmodes = {"FOG_NONE" :"No fog. Duh.", +# "FOG_EXP": "Fog density increases exponentially from the camera (fog = 1/e^(distance * density)).", +# "FOG_EXP2": "Fog density increases at the square of FOG_EXP, i.e. even quicker (fog = 1/e^(distance * density)^2)." +# "FOG_LINEAR": "Fog density increases linearly between the start and end distances."} +# + modes = ((ogre.FOG_NONE, "FOG_NONE"), + (ogre.FOG_EXP, "FOG_EXP"), + (ogre.FOG_EXP2, "FOG_EXP2"), + (ogre.FOG_LINEAR,"FOG_LINEAR")) + + self.m = self.appendRowItemChoice( "Mode", itemMap=modes, cback = self.setMode ) + self.c = self.appendRowItemColourSelect( "Colour", cback = self.setRGBA ) + self.min = self.appendRowItemSlider( "linearStart", 0, 1, format = SLIDER_FLOAT, cback = self.setLinMin ) + self.max = self.appendRowItemSlider( "linearEnd", 0, 1, format = SLIDER_FLOAT, cback = self.setLinMax ) + self.exp = self.appendRowItemSlider( "expDensity", 0.0001, 0.01, format = SLIDER_LOG10, cback = self.setExpDens ) + + if object != None: + mode = object.getFogMode() + #self.mode = ogre.mode + col = object.getFogColour() + print col + self.colour = map( lambda x: x * 255.0, [col[0],col[1], col[2], col[3]] ) + self.linearStart = object.getFogStart() + self.linearEnd = object.getFogEnd() + self.expDensity= object.getFogDensity() + + self.applyValues( False ) + + def setMode( self, value ): + self.mode = value + self.applyValues( ) + def setRGBA( self, value ): + self.colour[ 0:3 ] = value + self.applyValues( ) + def setLinMin( self, value ): + self.linearStart = value + self.applyValues( ) + def setLinMax( self, value ): + self.linearEnd = value + self.applyValues( ) + def setExpDens( self, value ): + self.expDensity = value + self.applyValues( ) + + def applyValues(self, update = True): + self.m.setValue( self.mode ) + self.c.setValue( self.colour ) + self.min.setValue( self.linearStart ) + self.max.setValue( self.linearEnd ) + self.exp.setValue( self.expDensity ) + + if update == True: + if self.object != None: + col = map( lambda x: x / 255.0, self.colour ) + self.object.setFog(self.mode, col, self.expDensity, self.linearStart, self.linearEnd ) + +class ObjectInspectorPanel(wx.Panel): + def __init__(self, *args, **kwds): + kwds["style"] = wx.TAB_TRAVERSAL + wx.Panel.__init__(self, *args, **kwds) + self.typeStaticText = wx.StaticText(self, -1, "Type") + self.propertyGrid = PropertyMainGrid( self, -1, style=wx.SIMPLE_BORDER ) + + self.__set_properties() + self.__do_layout() + + il = wx.ImageList(16, 16) + self.ColourIconID = il.Add( wx.ArtProvider_GetBitmap( wx.ART_GO_DOWN, wx.ART_TOOLBAR, ( 16, 16 ) ) ) + #self.propertyList.AssignImageList( il, wx.IMAGE_LIST_SMALL ) + + def __set_properties(self): + self.SetBackgroundColour(wx.Colour(255, 255, 255)) + self.SetFont(wx.Font(8, wx.DEFAULT, wx.NORMAL, wx.NORMAL, 0, "")) + self.typeStaticText.SetFont(wx.Font(8, wx.DEFAULT, wx.NORMAL, wx.NORMAL, 0, "")) + + def __do_layout(self): + sizer_1 = wx.BoxSizer(wx.HORIZONTAL) + content = wx.BoxSizer(wx.VERTICAL) + sizer_1.Add((5, 20), 0, 0, 0) + content.Add((20, 5), 0, 0, 0) + content.Add(self.typeStaticText, 0, 0, 0) + content.Add((20, 3), 0, 0, 0) + content.Add(self.propertyGrid, 1, wx.EXPAND, 0) + content.Add((20, 5), 0, 0, 0) + sizer_1.Add(content, 1, wx.EXPAND, 0) + sizer_1.Add((5, 20), 0, 0, 0) + self.SetSizer(sizer_1) + sizer_1.Fit(self) + + def showData( self, data ): + self.propertyGrid.clean() + if type( data ) == None: + self.showNone() + if type( data ) == ogre.SceneNode: + self.showSceneNode( data ) + elif issubclass( type( data ), ogre.SceneManager): + self.showSceneManager( data ) + elif issubclass( type( data ), ogre.Resource ): + self.showResource( data ) + elif issubclass( type( data ), ogre.MovableObject ): + self.showMovableObject( data ) + elif issubclass( type( data ), ogre.ResourceManager ): + self.showResourceManager( data ) + else: + self.showUnknown( data ) + self.propertyGrid.sizer.Layout() + + def showNone( self ): + self.typeStaticText.SetLabel( "None" ) + + def showUnknown( self, data ): + self.typeStaticText.SetLabel( "Unknown" ) + self.showName( data ); + + def showSceneManager( self, data ): + self.typeStaticText.SetLabel( "SceneManager" ) + self.showName( data ); + + self.propertyGrid.appendRowItemName( "Type name", data.getTypeName() ) + self.propertyGrid.appendPaneColourSelect( "Ambient color", + cfront = data.getAmbientLight, + cback = data.setAmbientLight ) + + print data + fog = PropertyCollapsibleOgreFogPane( self.propertyGrid, "Fog", object = data ) + self.propertyGrid.appendPane( fog ) + +# self.propertyTree.createTextBoolRow( "SkyPlane", data.isSkyPlaneEnabled() ) +# self.propertyTree.createTextBoolRow( "SkyBox", data.isSkyBoxEnabled() ) +# self.propertyTree.createTextBoolRow( "SkyDone", data.isSkyDomeEnabled() ) +# +# fogmodes = {"FOG_NONE":"No fog. Duh.", +# "FOG_EXP": "Fog density increases exponentially from the camera (fog = 1/e^(distance * density)).", +# "FOG_EXP2": "Fog density increases at the square of FOG_EXP, i.e. even quicker (fog = 1/e^(distance * density)^2)." +# "FOG_LINEAR": "Fog density increases linearly between the start and end distances."} +# +# pane = self.propertyTree.createPane( "Fog" ) + + #pane.AppendSelectFromDictRow( "Mode", fogmodes ) + #self.propertyTree.createColourPane( "fog color" ) + + +# getFogColour (void) const +# virtual Real getFogStart (void) const +# virtual Real getFogEnd (void) const +# virtual Real getFogDensity (void) const +# getRenderQueue +# showBoundingBoxes (bool bShow) +# getShowBoundingBoxes () +# getCameraIterator +# getAnimationIterator +# getShadowTechnique +# many props + + def showSceneNode( self, data ): + self.typeStaticText.SetLabel( "SceneNode" ) + self.showName( data ); + + def showResource( self, data ): + self.typeStaticText.SetLabel( "Resource: " + data.getCreator().getResourceType() ) + self.showName( data ); + self.appendRowItemName( "Group", data.getGroup() ) + self.appendRowItemName( "Origin", data.getOrigin() ) + +# params = data.getParameters() +# if len( params ) > 0: +# pane = self.propertyTree.createPane( "Parameters" ) +# +# for i in params: +# self.propertyTree.createTextRow( i.name, data.getParameter( i.name ), pane ) +# +# if type( data ) == ogre.Texture: +# print "Texture" + + def showMovableObject( self, data ): + self.typeStaticText.SetLabel( "Movable object: " + data.getMovableType() ) + self.showName( data ); + + def showResourceManager( self, data ): + self.typeStaticText.SetLabel( "Resourcemanager: " + data.getResourceType() ) + self.propertyGrid.appendRowItemName( "Memory budget", "%.3g Mb" + % (data.getMemoryBudget()/ 1024.0 /1024.0 ) ) + self.propertyGrid.appendRowItemName( "Memory usage", "%.3g Mb" + % (data.getMemoryUsage()/ 1024.0 /1024.0 ) ) + + def showName( self, data ): + self.propertyGrid.appendRowItemName( "Name", data.getName() ) + + +# end of class ObjectInspectorPanel + + Added: branches/ogEditor/OgreWindowWx.py =================================================================== --- branches/ogEditor/OgreWindowWx.py (rev 0) +++ branches/ogEditor/OgreWindowWx.py 2008-02-04 22:24:41 UTC (rev 883) @@ -0,0 +1,262 @@ +import wx +import ogre.renderer.OGRE as ogre +import wxogre_util as wxHandle +import os +import os.path + +try : + import psyco #use psyco if available (JIT compiler) + psyco.full() +except ImportError: + pass + +def getPluginPath(): + """Return the absolute path to a valid plugins.cfg file.""" +# import sys + + paths = [ os.path.join( os.getcwd(), 'plugins.cfg'), + os.path.join( os.path.dirname( os.path.abspath( __file__ ) ), 'plugins.cfg'), + '/etc/OGRE/plugins.cfg' ] + + for path in paths: + if os.path.exists(path): + return path + + sys.stderr.write("\n" + "** Warning: Unable to locate a suitable plugins.cfg file.\n" + "** Warning: Please check your ogre installation and copy a\n" + "** Warning: working plugins.cfg file to the current directory.\n\n") + raise ogre.Exception(0, "can't locate the 'plugins.cfg' file", "") + +class Struct: + "simple dummy class to regroup scene entities in a single parameter" + pass + +class OgreWindow( wx.PyWindow ): + """wx.Frame subclass to embed an Ogre window in wxPython + It is somewhat inspired from SampleFramework.py""" + + #all animation states included in this dictionary will be automatically updated at each render + animStates = {} #the values have to be (AnimationState, SpeedFactor) tuples + + #namespace for holding a reference to the entities you create. You can comment it out + #if you don't like the idea + sceneEntities = Struct() + + def __init__( self, parent, ID, size = wx.Size( 800, 600 ), renderSystem = "OpenGL", **kwargs ): + self.parent = parent + wx.PyWindow.__init__( self, parent, ID, size = size, **kwargs ) + #Event bindings + self.Bind( wx.EVT_CLOSE, self._OnCloseWindow) + self.Bind( wx.EVT_SIZE, self._OnSize) + self.Bind( wx.EVT_TIMER, self.UpdateRender) #Bind the timer events to Ogre rendering + self.Bind( wx.EVT_ERASE_BACKGROUND, self._OnEraseBackground) + + #Timer creation + self.timer = wx.Timer() + self.timer.SetOwner( self ) #Sets the timer to notify self: binding the timer event is not enough + + #Ogre Initialisation + self._OgreInit( size, renderSystem ) + self.SceneInitialisation() + self.UpdateRender() + self.SetFocus() #Gives KeyboardFocus + + def _OgreInit(self,size,renderSystem): + #Root creation + root = ogre.Root( getPluginPath(), "ogre.cfg" ) + self.ogreRoot = root + + # setup resources + config = ogre.ConfigFile() + config.load( 'resources.cfg' ) + + section_iter = config.getSectionIterator() + while section_iter.hasMoreElements(): + section_name = section_iter.peekNextKey() + settings = section_iter.getNext() + for key, path in settings: + ogre.ResourceGroupManager.getSingleton().addResourceLocation( path, key, section_name, False) + + if os.path.exists( "ogre.cfg" ): + root.restoreConfig() + else: + carryOn = root.showConfigDialog() + if not carryOn: + sys.exit('Quit from Config Dialog') + + #The following section tries to avoid showing the configuration dilaog. +# rsList = root.getAvailableRenderers() #Gets the available RenderSystems +# rs = None +# CouldNotFindRequestedRenderer = False +# for i in rsList: +# print i + +# if renderSystem in i.name: #Tries to locate the requested render system +# rs=i +# if rs is not None : +# root.renderSystem=rs +# rs.setConfigOption("Full Screen","No") +# try : +# rs.setConfigOption("Video Mode","800 x 600 @ 16-bit colour") +# except : +# CouldNotFindRequestedRenderer=True +# else : +# CouldNotFindRequestedRenderer=True +# +# if CouldNotFindRequestedRenderer: #Calls Ogre's default Config dialog if failed +# carryOn = root.showConfigDialog() +# if not carryOn: +# sys.exit('Quit from Config Dialog') + +# carryOn = root.showConfigDialog() +# if not carryOn: +# sys.exit('Quit from Config Dialog') + +#get the topmost window and make it visible, otherwise we cant get a valid windowhandle + + lastValid = self.parent + parent = lastValid + while parent != None: + lastValid = parent + parent = lastValid.GetParent() + lastValid.Show( True ) + + root.initialise(False) + renderParameters = ogre.NameValuePairList() + handle = wxHandle.get_window_handle_str( self ) + if handle == "No window found": + print handle + renderParameters = ogre.NameValuePairList(); + else: + renderParameters['externalWindowHandle'] = handle + print handle, lastValid.GetHandle(), self.parent.GetHandle() + + renderWindow = root.createRenderWindow('wxPython render window', size[ 0 ], size[ 1 ], False, renderParameters) + renderWindow.active = True + self.renderWindow = renderWindow + ogre.ResourceGroupManager.getSingleton().initialiseAllResourceGroups() + + def _OnSize(self, event): + if getattr(self, 'ogreRoot', None): + self.UpdateRender() + self.renderWindow.windowMovedOrResized() + event.Skip() + + def _OnEraseBackground(self, event): + pass # Do nothing, to avoid flashing on MSW. + + def _OnCloseWindow(self, event): + self.Destroy() + + def AcceptsFocus(self): + return True + + def StartRendering(self,interval=33): + "Activates the timer. A rendering will be triggered at each interval (default :33ms)" + self.timer.Start(interval) + + def OnFrameStarted(self,event): + "SubClass and fill in this declaration if you want something done before each rendering" + pass + + def OnFrameEnded(self,event): + "SubClass and fill in this declaration if you want something done after each rendering" + pass + + def UpdateRender(self,event=None): + """Method that can be called manually or by a wx.Timer + If the method is called by timer, the animation states contained in + the self.animStates variable get updated before rendering the frame""" + + #Enables the user to define actions to be undertaken before the frame is started + self.OnFrameStarted(event) + + if hasattr(event ,"GetInterval"): #Timer Events have a GetInterval method that returns the time interval between events + for anim,speed in self.animStates.itervalues(): + anim.addTime(speed*event.GetInterval()/1000.0) #updates the animations + + self.ogreRoot.renderOneFrame()#Asks Ogre to render a frame + + #Enables the user to define actions to be undertaken after the frame has been drawn + self.OnFrameEnded(event) + + def SceneInitialisation(self): + """This method can be replaced completely to suit your needs or you can + subclass only the helper methods such as self._CreateCamera""" + self._ChooseSceneManager() + self._CreateCamera() + self._CreateViewport() + self._PopulateScene() + self._MouseAndKeysBindings() + + #You will want to subclass the following methods to suit your needs + + def _ChooseSceneManager(self): + "choose SceneManager" + self.sceneManager = self.ogreRoot.createSceneManager(ogre.ST_GENERIC,"ExampleSMInstance") + + def _CreateCamera(self): + "create a Camera" + camera = self.sceneManager.createCamera('Camera') + camera.lookAt(ogre.Vector3(0, 0, 0)) + camera.nearClipDistance = 1 + camera.setAutoAspectRatio( True ) + + self.sceneEntities.camera = camera + + # create the camera nodes & attach camera + cameraNode = self.sceneManager.getRootSceneNode().createChildSceneNode( camera.getName() + "/Node", + ogre.Vector3( 0, 0, 250 ) ) + pitchNode = cameraNode.createChildSceneNode( cameraNode.getName() + "/PitchNode" ) + pitchNode.attachObject( camera ) + + self.sceneEntities.cameraNode = cameraNode + self.sceneEntities.cameraPitchNode = pitchNode + + def _CreateViewport(self): + "create a Viewport" + renderWindow=self.renderWindow + viewport = renderWindow.addViewport( self.sceneEntities.camera, 0, 0.0, 0.0, 1.0, 1.0) + viewport.backgroundColour = ogre.ColourValue(0, 0, 0) + + def _PopulateScene(self): + "Implement this method to put entities in your scene" + pass + + def _MouseAndKeysBindings(self): + "Some Additional mouse and keys bindings" + d=10.0 #displacement for key strokes + self.ControlKeyDict={ wx.WXK_LEFT :ogre.Vector3( -d, 0.0, 0.0), + wx.WXK_RIGHT :ogre.Vector3( d, 0.0, 0.0), + wx.WXK_UP :ogre.Vector3( 0.0, 0.0, -d), + wx.WXK_DOWN :ogre.Vector3( 0.0, 0.0, d), + wx.WXK_PAGEUP :ogre.Vector3( 0.0, d, 0.0), + wx.WXK_PAGEDOWN :ogre.Vector3( 0.0, -d, 0.0)} + self.Bind( wx.EVT_KEY_DOWN, self._DefaultKeyDownManager ) + self.Bind( wx.EVT_MOUSE_EVENTS, self._DefaultMouseEventManager) + ##self.Bind(wx.EVT_ENTER_WINDOW,lambda evt : self.SetFocus()) + + def _DefaultKeyDownManager( self, event ): + "If you want to implement a similar callback function, do not forget the event.Skip() at the end" + validMove = self.ControlKeyDict.get( event.m_keyCode, False ) + if validMove: + self.sceneEntities.cameraNode.translate( validMove, self.sceneEntities.cameraNode.TS_LOCAL ) + event.Skip() + + def _DefaultMouseEventManager( self, event ): + "If you want to implement a similar callback function, do not forget the event.Skip() at the end" + self.SetFocus() #Gives Keyboard focus to the window + + if event.RightDown(): #Precedes dragging + self.StartDragX, self.StartDragY = event.GetPosition() #saves position of initial click + + if event.Dragging() and event.RightIsDown(): #Dragging with RMB + x,y = event.GetPosition() + dx = x-self.StartDragX + dy = y-self.StartDragY + self.StartDragX, self.StartDragY = x, y + + self.sceneEntities.cameraNode.yaw( ogre.Degree( dx / 3.0 ) ) + self.sceneEntities.cameraPitchNode.pitch( ogre.Degree( dy / 3.0 ) ) + event.Skip() Added: branches/ogEditor/PropertyGrid.py =================================================================== --- branches/ogEditor/PropertyGrid.py (rev 0) +++ branches/ogEditor/PropertyGrid.py 2008-02-04 22:24:41 UTC (rev 883) @@ -0,0 +1,435 @@ +#!/usr/bin/env python + +import wx +import wx.combo +import wx.lib.colourselect as csel + +SLIDER_INT=0 +SLIDER_FLOAT=1 +SLIDER_LOG10=2 + +class NullLog: + def write(*args): + pass + +class SimpleLog: + def write(*args): + print args + + +class ListCtrlComboPopup( wx.ListCtrl, wx.combo.ComboPopup ): + def __init__( self, log = None, cback = None ): + if log: + self.log = log + else: + self.log = NullLog() + + self.cback = cback + + # Since we are using multiple inheritance, and don't know yet + # which window is to be the parent, we'll do 2-phase create of + # the ListCtrl instead, and call its Create method later in + # our Create method. (See Create below.) + self.PostCreate(wx.PreListCtrl()) + + # Also init the ComboPopup base class. + wx.combo.ComboPopup.__init__(self) + + def AddItem(self, txt): + self.InsertStringItem(self.GetItemCount(), txt) + + def OnMotion(self, evt): + item, flags = self.HitTest(evt.GetPosition()) + if item >= 0: + self.Select(item) + self.curitem = item + + def OnLeftDown(self, evt): + self.value = self.curitem + self.Dismiss() + + # The following methods are those that are overridable from the + # ComboPopup base class. Most of them are not required, but all + # are shown here for demonstration purposes. + + + # This is called immediately after construction finishes. You can + # use self.GetCombo if needed to get to the ComboCtrl instance. + def Init(self): + self.log.write("ListCtrlComboPopup.Init") + self.value = -1 + self.curitem = -1 + + # Create the popup child control. Return true for success. + def Create(self, parent): + self.log.write("ListCtrlComboPopup.Create") + wx.ListCtrl.Create(self, parent, + style=wx.LC_LIST|wx.LC_SINGLE_SEL|wx.SIMPLE_BORDER) + self.Bind(wx.EVT_MOTION, self.OnMotion) + self.Bind(wx.EVT_LEFT_DOWN, self.OnLeftDown) + return True + + # Return the widget that is to be used for the popup + def GetControl(self): + return self + + # Called just prior to displaying the popup, you can use it to + # 'select' the current item. + def SetStringValue(self, val): + self.log.write("ListCtrlComboPopup.SetStringValue") + idx = self.FindItem(-1, val) + if idx != wx.NOT_FOUND: + self.Select(idx) + + # Return a string representation of the current item. + def GetStringValue(self): + self.log.write("ListCtrlComboPopup.GetStringValue") + if self.value >= 0: + return self.GetItemText(self.value) + return "" + + # Called immediately after the popup is shown + def OnPopup(self): + self.log.write("ListCtrlComboPopup.OnPopup") + wx.combo.ComboPopup.OnPopup(self) + + # Called when popup is dismissed + def OnDismiss(self): + self.log.write("ListCtrlComboPopup.OnDismiss") + if self.cback != None: + self.cback( self.value ) + wx.combo.ComboPopup.OnDismiss(self) + + # This is called to custom paint in the combo control itself + # (ie. not the popup). Default implementation draws value as + # string. + def PaintComboControl(self, dc, rect): + self.log.write("ListCtrlComboPopup.PaintComboControl") + wx.combo.ComboPopup.PaintComboControl(self, dc, rect) + + # Receives key events from the parent ComboCtrl. Events not + # handled should be skipped, as usual. + def OnComboKeyEvent(self, event): + self.log.write("ListCtrlComboPopup.OnComboKeyEvent") + wx.combo.ComboPopup.OnComboKeyEvent(self, event) + + # Implement if you need to support special action when user + # double-clicks on the parent wxComboCtrl. + def OnComboDoubleClick(self): + self.log.write("ListCtrlComboPopup.OnComboDoubleClick") + wx.combo.ComboPopup.OnComboDoubleClick(self) + + # Return final size of popup. Called on every popup, just prior to OnPopup. + # minWidth = preferred minimum width for window + # prefHeight = preferred height. Only applies if > 0, + # maxHeight = max height for window, as limited by screen size + # and should only be rounded down, if necessary. + def GetAdjustedSize(self, minWidth, prefHeight, maxHeight): + self.log.write("ListCtrlComboPopup.GetAdjustedSize: %d, %d, %d" % (minWidth, prefHeight, maxHeight)) + return wx.combo.ComboPopup.GetAdjustedSize(self, minWidth, prefHeight, maxHeight) + + # Return true if you want delay the call to Create until the popup + # is shown for the first time. It is more efficient, but note that + # it is often more convenient to have the control created + # immediately. + # Default returns false. + def LazyCreate(self): + self.log.write("ListCtrlComboPopup.LazyCreate") + return wx.combo.ComboPopup.LazyCreate(self) + + +class PropertyRowItem( ): + def __init__( self, parent, name ): + self.sizer = wx.BoxSizer( wx.HORIZONTAL ) + + labelTextCtrl = wx.TextCtrl( parent, -1, name, + style = wx.NO_BORDER | wx.ALIGN_LEFT ) + self.rowHeight = labelTextCtrl.GetSize()[ 1 ] + labelTextCtrl.SetEditable( False ) + self.sizer.Add( labelTextCtrl, 0, wx.EXPAND | wx.ALIGN_RIGHT ) + +class PropertyRowItemName( PropertyRowItem ): + def __init__( self, parent, name, value = "" ): + PropertyRowItem.__init__( self, parent, name ) + self.valueTextCtrl = wx.TextCtrl( parent, -1, value, + size = wx.Size( 30, self.rowHeight ), + style = wx.NO_BORDER | wx.ALIGN_LEFT | wx.EXPAND) + self.sizer.AddSpacer( 1 ) + self.sizer.Add( self.valueTextCtrl, 1, wx.EXPAND | wx.ALIGN_LEFT ) + +class PropertyRowItemSlider( PropertyRowItem ): + def __init__( self, parent, name, start = 0, end = 100, format = SLIDER_INT, cback = None ): + PropertyRowItem.__init__( self, parent, name ) + self.format = format + self.cback = cback + self.value = 0 + self.start = start + self.end = end + self.sliderValue = 0 + + if self.format == SLIDER_INT: + self.sliderStart = start + self.sliderEnd = end + else: + self.sliderStart = 0 + self.sliderEnd = 100 + + self.scale = float( self.end - self.start )/( self.sliderEnd - self.sliderStart ) + + self.valueTextCtrl = wx.TextCtrl( parent, -1, "", + size = wx.Size( 30, self.rowHeight ), + style = wx.NO_BORDER | wx.ALIGN_LEFT | wx.EXPAND) + + self.slider = wx.Slider( parent, -1, self.sliderValue, self.sliderStart, self.sliderEnd, + size = wx.Size( 100, self.rowHeight ), + style = wx.NO_BORDER | wx.NO_3D ) + + self.sizer.AddSpacer( 1 ) + self.sizer.Add( self.valueTextCtrl, 0, wx.EXPAND | wx.ALIGN_LEFT ) + self.sizer.Add( self.slider, 1, wx.EXPAND | wx.ALIGN_LEFT ) + self.slider.Bind(wx.EVT_SLIDER, self.OnSlide ) + + def OnSlide(self, event): + val = event.GetEventObject().GetValue() + self.value = self.start + self.scale * val; + self.applyValue() + + def setValue(self, value): + self.value = value + self.applyValue( False ) + + def applyValue( self, update = True ): + if self.format == SLIDER_INT: + self.valueTextCtrl.SetValue( "%d" % self.value ) + else: + self.valueTextCtrl.SetValue( "%.1g" % self.value ) + + self.slider.SetValue( (self.value -self.start)/ self.scale ) + + if update == True: + if self.cback != None: + self.cback( self.value ) + +class PropertyRowItemChoice( PropertyRowItem ): + def __init__( self, parent, name, itemList = None, itemMap = None, cback = None): + PropertyRowItem.__init__( self, parent, name ) + + self.cback = cback + self.value = "None" + + if itemList != None: + self.ITEMDICT = False + self.itemList = itemList + elif itemMap != None: + self.ITEMDICT = True + self.itemList = itemMap + + self.choice = wx.combo.ComboCtrl( parent, -1, + size = wx.Size( 100, self.rowHeight ), + style = wx.NO_BORDER | wx.NO_3D | wx.CB_READONLY ) + + #self.choice.SetFont(wx.Font(8, wx.DEFAULT, wx.NORMAL, wx.NORMAL, 0, "")) + + self.popup = ListCtrlComboPopup( cback = self.choiceChanged ) + self.popup.SetFont(wx.Font(8, wx.DEFAULT, wx.NORMAL, wx.NORMAL, 0, "")) + + self.choice.SetPopupControl( self.popup ) + + + if self.ITEMDICT == False: + for i in self.itemList: + self.popup.AddItem( i ) + else: + for i in self.itemList: + self.popup.AddItem( i[ 1 ] ) + + self.sizer.AddSpacer( 1 ) + self.sizer.Add( self.choice, 1, wx.EXPAND | wx.ALIGN_LEFT ) + + def choiceChanged(self, idx): + if self.ITEMDICT == False: + self.value = self.itemList[ idx ] + else: + self.value = self.itemList[idx][ 0 ] + + self.applyValue() + + def setValue(self, value): + self.value = value + self.applyValue( False ) + + def applyValue( self, update = True ): + #print self.value + #item = self.value in self.itemList + # for val in self.itemList: +# if self.ITEMDICT == False: +# if self.value == val: +# item = val +# else: +# if self.value == val[0]: +# item = val +# print item + + if update == True: + if self.cback != None: + self.cback( self.value ) + +class PropertyRowItemColourSelect( PropertyRowItemName ): + def __init__( self, parent, name, cback = None ): + PropertyRowItemName.__init__( self, parent, name ) + self.cback = cback + self.value = wx.Colour(0,0,0) + + self.colourButton = csel.ColourSelect( parent, -1, "", + colour = self.value, + size = wx.Size( self.rowHeight,self.rowHeight ), + style = wx.NO_BORDER ) + + self.sizer.AddSpacer( 1 ) + self.sizer.Add( self.colourButton, 0, wx.EXPAND ) + self.colourButton.Bind( csel.EVT_COLOURSELECT, self.OnColour ) + + def OnColour(self, event): + self.value = event.GetValue() + self.applyValue() + + def setValue(self, value): + self.value = value + self.applyValue( False ) + + def applyValue( self, update = True ): + self.valueTextCtrl.SetValue( "%d,%d,%d" % (self.value[0],self.value[1],self.value[2]) ) + self.colourButton.SetColour( self.value ) + if update == True: + if self.cback != None: + self.cback( self.value ) + + +class PropertyGrid( ): + def __init__(self): + self.sizer = wx.BoxSizer( wx.VERTICAL ) + self.SetSizer( self.sizer ) + self.widthCol0 = 70 + self.widthCol2 = 24 + self.xOffset = 17 + + def appendRow(self, row ): + self.sizer.AddSpacer(1) + self.sizer.Add( row.sizer, 0, wx.EXPAND ) + + def appendRowItemName(self, name, value = "" ): + item = PropertyRowItemName( self.pane, name, value ) + self.appendRow( item ) + return item + + def appendRowItemChoice(self, name, itemList = None, itemMap = None, cback = None ): + item = PropertyRowItemChoice( self.pane, name, itemList, itemMap, cback ) + self.appendRow( item ) + return item + + def appendRowItemSlider(self, name, start = 0, end = 100, format = SLIDER_INT, cback = None ): + item = PropertyRowItemSlider( self.pane, name, start, end, format, cback ) + self.appendRow( item ) + return item + + def appendRowItemColourSelect( self, name, cback = None ): + item = PropertyRowItemColourSelect( self.pane, name, cback ) + self.appendRow( item ) + return item + + def appendPane(self, pane ): + self.sizer.AddSpacer(1) + self.sizer.Add( pane, 0, wx.EXPAND ) + + def appendPaneColourSelect( self, name, cfront = None, cback = None ): + pane = PropertyPaneItemColour( self.pane, name, cfront, cback ) + self.appendPane( pane ) + return pane + + +class PropertyPaneItem( wx.CollapsiblePane, PropertyGrid ): + def __init__(self, parent, name): + + wx.CollapsiblePane.__init__( self, parent, -1, name, + style = wx.CP_DEFAULT_STYLE + | wx.CP_NO_TLW_RESIZE ) + PropertyGrid.__init__(self) + + + self.SetFont(wx.Font(8, wx.DEFAULT, wx.NORMAL, wx.NORMAL, 0, "")) + self.Bind(wx.EVT_COLLAPSIBLEPANE_CHANGED, self.OnPaneChanged ) + + self.pane = self.GetPane() + self.pane.SetFont( wx.Font( 8, wx.DEFAULT, wx.NORMAL, wx.NORMAL, 0, "" ) ) + self.sizer = wx.BoxSizer( wx.VERTICAL ) + self.pane.SetSizer( self.sizer ) + + def OnPaneChanged(self, event = None): + if event: + if ( event.Collapsed ): + event.GetEventObject().GetPane().Hide() + else: + event.GetEventObject().GetPane().Show() + parent = self.GetParent().Layout() + + +class PropertyPaneItemColour( PropertyPaneItem ): + def __init__( self, parent, name, cfront = None, cback = None ): + PropertyPaneItem.__init__(self, parent, name) + self.cback = cback + self.cfront = cfront + self.value = [0, 0, 0, 0] + self.scale = 255.0 + + self.c = self.appendRowItemColourSelect( "Colour", cback = self.setRGB ) + self.r = self.appendRowItemSlider( "red", 0, 255, cback = self.setRed ) + self.g = self.appendRowItemSlider( "green", 0, 255, cback = self.setGreen ) + self.b = self.appendRowItemSlider( "blue", 0, 255, cback = self.setBlue ) + self.a = self.appendRowItemSlider( "alpha", 0, 255, cback = self.setAlpha ) + + if self.cfront != None: + colour = self.cfront() + self.value = map(lambda x: x * self.scale, [colour[0], colour[1], colour[2], colour[3]] ) + self.applyValue( False ) + + def setRGB(self, value): + self.value[0:3] = value + self.applyValue() + def setRed(self, value): + self.value[0] = value + self.applyValue() + def setGreen(self, value): + self.value[1] = value + self.applyValue() + def setBlue(self, value): + self.value[2] = value + self.applyValue() + def setAlpha(self, value): + self.value[3] = value + self.applyValue() + + def applyValue(self, update = True ): + self.r.setValue( self.value[ 0 ] ) + self.g.setValue( self.value[ 1 ] ) + self.b.setValue( self.value[ 2 ] ) + self.a.setValue( self.value[ 3 ] ) + self.c.setValue( self.value ) + if update == True: + if self.cback != None: + self.cback( map(lambda x: x / self.scale, self.value) ) + + +class PropertyMainGrid( wx.Panel, PropertyGrid ): + def __init__(self, *argc, **argv): + argv["style"] = wx.TAB_TRAVERSAL + wx.Panel.__init__(self, *argc, **argv) + PropertyGrid.__init__(self) + self.SetFont(wx.Font(8, wx.DEFAULT, wx.NORMAL, wx.NORMAL, 0, "")) + #self.SetBackgroundColour( wx.Colour(200, 200, 200) ) + + self.pane = self + + def clean( self ): + self.sizer.Clear( True ) + self.sizer.Layout() + Added: branches/ogEditor/PythonOgreConfig.py =================================================================== --- branches/ogEditor/PythonOgreConfig.py (rev 0) +++ branches/ogEditor/PythonOgreConfig.py 2008-02-04 22:24:41 UTC (rev 883) @@ -0,0 +1,43 @@ +#!/usr/bin/env python +# a single config file that is imported 'first' by the Python-Ogre demos +# this is primarly used to manage Linux demos when we have binaries in non standard (safe) locations + +import os,sys + +######################################################################### +### Override this setting if you are using non standard locations + +libpath = "/home/carsten/local/python-ogre.work/root/usr/lib" +libpathpyton = "/home/carsten/local/python-ogre.work/root/usr/lib64/" + +######################################################################### + +if os.name == 'nt': + libpath="" + libpathpyton="" + pythonpath = "" +else: + if libpathpyton == "" : # we need to find this ourselves + localpath = os.path.abspath(os.path.dirname(__file__) ) # assume that this module is in the ./demos directory + libpathpyton = os.path.abspath(os.path.join(localpath,'../lib')) # so in the binary release the lib is one path back up + if not os.path.exists ( libpathpyton ): #we must be running from the development environment + libpathpyton = os.path.abspath(os.path.join(localpath,'../../root/usr/lib')) + if not os.path.exists ( libpathpyton ): + ## should die here + print "**Problem finding libraries" + libpathpyton=localpath + + ## path to the Python-Ogre modules + pythonpath = os.path.abspath(os.path.join(libpathpyton, 'python2.5/site-packages') ) + ## and insert it into the system path + sys.path.insert(0,pythonpath) + + ## now we need to set the library path so the shared libraries can be found + try: + ldpath = os.environ['LD_LIBRARY_PATH'] + except: + ldpath="" + newldpath = libpath + ":" + ldpath + os.environ['LD_LIBRARY_PATH'] = newldpath + os.putenv('LD_LIBRARY_PATH', newldpath) + print "export LD_LIBRARY_PATH=%s" % os.environ['LD_LIBRARY_PATH'] Added: branches/ogEditor/ResourceTreePane.py =================================================================== --- branches/ogEditor/ResourceTreePane.py (rev 0) +++ branches/ogEditor/ResourceTreePane.py 2008-02-04 22:24:41 UTC (rev 883) @@ -0,0 +1,68 @@ +import wx +import wx.lib.customtreectrl as CT +import ogre.renderer.OGRE as ogre + +class MyCustomTree( CT.CustomTreeCtrl ): + def __init__(self, parent, id=wx.ID_ANY, pos=wx.DefaultPosition, size=wx.DefaultSize, + style=wx.TR_DEFAULT_STYLE, ctstyle=0, validator=wx.DefaultValidator, + name="MyCustomTreeCtrl"): + CT.CustomTreeCtrl.__init__(self, parent, id, pos, size, style, ctstyle, validator, name) + + def OnInternalIdle(self): + wx.PyScrolledWindow.OnInternalIdle( self ) + CT.CustomTreeCtrl.OnInternalIdle( self ) + + +class ResourceTreePane( MyCustomTree ): + def __init__(self, parent, id=wx.ID_ANY, pos=wx.DefaultPosition, size=wx.DefaultSize, + style=wx.TR_DEFAULT_STYLE, ctstyle=0, validator=wx.DefaultValidator, + name="MyCustomTreeCtrl"): + CT.CustomTreeCtrl.__init__(self, parent, id, pos, size, style, ctstyle, validator, name) + + CT.CustomTreeCtrl.SetConnectionPen( self, wx.Pen( wx.Colour(100,100,100), 1, wx.SOLID) ) + CT.CustomTreeCtrl.SetFont( self, wx.Font( 8, wx.FONTFAMILY_DEFAULT, wx.TR_DEFAULT_STYLE, wx.FONTWEIGHT_NORMAL ) ) + + def OnInternalIdle(self): + wx.PyScrolledWindow.OnInternalIdle( self ) + CT.CustomTreeCtrl.OnInternalIdle( self ) + + def addItem( self, node, name, data ): + newNode = self.AppendItem( node, name ) + self.SetPyData( newNode, data ) + return newNode + + def buildResourceTree( self ): + root = self.AddRoot( "Ogre resources" ) + resManNode = self.AppendItem( root, "Resource manager" ) + + resManIter = ogre.ResourceGroupManager.getSingleton().getResourceManagerIterator() + while resManIter.hasMoreElements(): + resManNodeIter = self.addItem( resManNode, resManIter.peekNextKey(), resManIter.peekNextValue() ) + resIter = resManIter.peekNextValue().getResourceIterator() + while resIter.hasMoreElements(): + self.addItem( resManNodeIter, resIter.peekNextValue().getName(), resIter.peekNextValue() ) + resIter.getNext() + + resManIter.getNext() + + resGroupManNode = self.addItem( root, "Resource groups", ogre.ResourceGroupManager.getSingleton() ) + + resGroups = ogre.ResourceGroupManager.getSingleton().getResourceGroups( ) + for resGroupName in resGroups: + resGroupNode = self.addItem( resGroupManNode, resGroupName, None ) + + resLocNode = self.addItem( resGroupNode, "Resource locations", None ) + + resLocationList = ogre.ResourceGroupManager.getSingleton().getResourceDeclarationList( resGroupName ) + for resLocation in resLocationList: + print resLocation.resourceName + self.addItem( resLocNode, resLocation.resourceName, None ) + + resNameNode = self.addItem( resGroupNode, "Resources", None ) + resNameList = ogre.ResourceGroupManager.getSingleton().listResourceNames( resGroupName ) + for res in resNameList: + self.addItem( resNameNode, res, None ); + + # this fails ??? + #fileInfoList = ogre.ResourceGroupManager.getSingleton().findResourceFileInfo( "General", "*.png") + #fileNameList = ogre.ResourceGroupManager.getSingleton().listResourceFileInfo( resGroupName ) Added: branches/ogEditor/build.wxogre_util.sh =================================================================== --- branches/ogEditor/build.wxogre_util.sh (rev 0) +++ branches/ogEditor/build.wxogre_util.sh 2008-02-04 22:24:41 UTC (rev 883) @@ -0,0 +1,8 @@ +#! /bin/bash + +#RELEASE=ansi-release-2.6 +#RELEASE=unicode-release-2.6 +RELEASE=unicode-release-2.8 + +g++ -shared -fPIC `/usr/lib/wx/config/gtk2-$RELEASE --cflags` `pkg-config gtk+-2.0 --cflags` `/usr/lib/wx/config/gtk2-$RELEASE --libs` `pkg-config gtk+-2.0 --libs` -lGL wxogre_util.cpp -o libwxogre_util.so + Property changes on: branches/ogEditor/build.wxogre_util.sh ___________________________________________________________________ Name: svn:executable + * Added: branches/ogEditor/ogEditor.py =================================================================== --- branches/ogEditor/ogEditor.py (rev 0) +++ branches/ogEditor/ogEditor.py 2008-02-04 22:24:41 UTC (rev 883) @@ -0,0 +1,276 @@ +#!/usr/bin/env python +# -*- coding: ansi_x3.4-1968 -*- + +import wxversion +wxversion.ensureMinimal('2.8') + +import wx +import wx.aui +import wx.py as py +import wx.lib.customtreectrl as CT + +from OgreWindowWx import * +from ObjectInspectorPanels import * +from ResourceTreePane import * + +class OGView3D( OgreWindow ): + def _PopulateScene(self): + #automatic called by parent init +# self.headEnt = self.sceneManager.createEntity("ogreHead", "athene.mesh") + self.headEnt = self.sceneManager.createEntity("ogreHead", "ogrehead.mesh") + self.headNode = self.sceneManager.getRootSceneNode().createChildSceneNode( ) + self.headNode.attachObject( self.headEnt ) + #self.sceneManager.setAmbientLight( (0.0, 0.0, 1.0, 1.0) ) + +ID_MB_FILE_EXIT = wx.NewId() +ID_MB_VIEW_SCENETREE = wx.NewId() +ID_MB_VIEW_OBJECT = wx.NewId() +ID_MB_VIEW_RESOURCE = wx.NewId() +ID_MB_VIEW_PYCRUST = wx.NewId() +ID_TB_EXIT = wx.NewId() +ID_TB_TMP = wx.NewId() + +NAME_SCENETREE = "Scene tree" +NAME_OBJECT = "Property inspector" +NAME_RESOURCE = "Resource browser" +NAME_PYCRUST = "PyCrust" + +class MainFrame(wx.Frame): + def __init__(self, *args, **kwds): + kwds["style"] = wx.DEFAULT_FRAME_STYLE + wx.Frame.__init__(self, *args, **kwds) + self.SetSize( wx.Size( 1024, 768 ) ) + + self.initMenuBar_() + self.initToolBar_() + self.initStatusBar_() + self.initFrameManager_() + + self.setDefaultProperties_(); + self.auiMgr.Update() + + def initMenuBar_( self ): + self.mb = wx.MenuBar() + + self.mbFile = wx.Menu() + self.mbFile.Append( wx.ID_EXIT, "E&xit" ) + self.mb.Append( self.mbFile, "&File" ) + + self.mbView = wx.Menu() + self.mbViewScenetree = wx.MenuItem( self.mbView, ID_MB_VIEW_SCENETREE, NAME_SCENETREE + "\tF1", "", wx.ITEM_CHECK) + self.mbViewObject = wx.MenuItem( self.mbView, ID_MB_VIEW_OBJECT, NAME_OBJECT + "\tF2", "", wx.ITEM_CHECK) + self.mbViewResource = wx.MenuItem( self.mbView, ID_MB_VIEW_RESOURCE, NAME_RESOURCE + "\tF3", "", wx.ITEM_CHECK) + self.mbViewPyCrust = wx.MenuItem( self.mbView, ID_MB_VIEW_PYCRUST, NAME_PYCRUST + "\tF9", "", wx.ITEM_CHECK) + self.mbView.AppendItem( self.mbViewScenetree ) + self.mbView.AppendItem( self.mbViewObject ) + self.mbView.AppendItem( self.mbViewResource ) + self.mbView.AppendItem( self.mbViewPyCrust ) + self.mb.Append( self.mbView, "&View") + + self.SetMenuBar( self.mb ) + + self.Bind( wx.EVT_MENU, self.doExit, id = wx.ID_EXIT ) + self.Bind( wx.EVT_MENU, self.doSwitchViewPane, id = ID_MB_VIEW_SCENETREE) + self.Bind( wx.EVT_MENU, self.doSwitchViewPane, id = ID_MB_VIEW_OBJECT) + self.Bind( wx.EVT_MENU, self.doSwitchViewPane, id = ID_MB_VIEW_RESOURCE) + self.Bind( wx.EVT_MENU, self.doSwitchViewPane, id = ID_MB_VIEW_PYCRUST) + + def initToolBar_( self ): + self.tb = wx.ToolBar(self, -1) + self.SetToolBar( self.tb ) + self.tb.AddLabelTool( ID_TB_EXIT, "Exit", wx.ArtProvider_GetBitmap(wx.ART_QUIT), + wx.NullBitmap, wx.ITEM_NORMAL, "", "") + self.tb.AddLabelTool( ID_TB_TMP, "Up", wx.ArtProvider_GetBitmap(wx.ART_QUESTION), + wx.NullBitmap, wx.ITEM_NORMAL, "", "") + + self.Bind( wx.EVT_TOOL, self.doExit, id = ID_TB_EXIT ) + self.Bind( wx.EVT_TOOL, self.UpdateSceneGraphEvent, id = ID_TB_TMP ) + + self.tb.Realize() + + def initStatusBar_( self ): + self.sb = self.CreateStatusBar(1, 0) +# statusbar_fields = ["frame_1_statusbar"] +# for i in range(len(frame_1_statusbar_fields)): +# self.frame_1_statusbar.SetStatusText(frame_1_statusbar_fields[i], i) + + + def initFrameManager_( self ): + self.auiMgr = wx.aui.AuiManager() + self.auiMgr.SetManagedWindow( self ) + + self.auiMgr.AddPane( self.createRenderWindow_(), + wx.aui.AuiPaneInfo().Name("OgreRenderWindow").CenterPane() ) + + self.auiMgr.AddPane( self.createCrustWindow_(), + wx.aui.AuiPaneInfo().Name( NAME_PYCRUST ).Caption( NAME_PYCRUST ). + BestSize( wx.Size( 200, 100 ) ).MinSize( wx.Size( 200, 100 ) ). + Bottom().Layer( 1 ).CloseButton(True).MaximizeButton(True)) + + self.auiMgr.AddPane( self.createSceneTree_(), + wx.aui.AuiPaneInfo().Name( NAME_SCENETREE ).Caption( NAME_SCENETREE ). + BestSize( wx.Size( 250, 200 ) ).MinSize( wx.Size( 250, 200 ) ). + Left().Layer( 1 ).Position( 1 ).CloseButton(True).MaximizeButton(True)) + + self.auiMgr.AddPane( self.createObjectInspector_(), + wx.aui.AuiPaneInfo().Name( NAME_OBJECT ).Caption( NAME_OBJECT ). + BestSize( wx.Size( 250, 200 ) ).MinSize( wx.Size( 250, 200 ) ). + Left().Layer( 1 ).Position( 2 ).CloseButton(True).MaximizeButton(True)) + + self.auiMgr.AddPane( self.createResourceInspector_(), + wx.aui.AuiPaneInfo().Name( NAME_RESOURCE ).Caption( NAME_RESOURCE ). + BestSize( wx.Size( 250, 200 ) ).MinSize( wx.Size( 250, 200 ) ). + Left().Layer( 1 ).Position( 3 ).CloseButton(True).MaximizeButton(True)) + self.Bind( wx.aui.EVT_AUI_PANE_CLOSE, self.doClosePane ) + +################################################################################# +# create panes +################################################################################# + + def createRenderWindow_( self ): + self.ogreRenderWindow = OGView3D( self, -1 ) + return self.ogreRenderWindow + + def createCrustWindow_( self ): + self.crust = wx.py.crust.Crust(self, -1) + return self.crust + + def createSceneTree_( self ): + self.sceneTree = MyCustomTree( self, -1, wx.Point(0, 0), wx.Size(160, 250), + style=wx.SUNKEN_BORDER | CT.TR_HAS_BUTTONS | + CT.TR_HAS_VARIABLE_ROW_HEIGHT | wx.WANTS_CHARS | wx.TR_TWIST_BUTTONS ) + self.sceneTree.SetConnectionPen( wx.Pen( wx.Colour(100,100,100), 1, wx.SOLID) ) + self.sceneTree.SetFont( wx.Font( 8, wx.FONTFAMILY_DEFAULT, wx.TR_DEFAULT_STYLE, wx.FONTWEIGHT_NORMAL ) ) + + il = wx.ImageList(12, 12) + self.SceneNodeIconID = il.Add( wx.ArtProvider_GetBitmap( wx.ART_GO_FORWARD, wx.ART_TOOLBAR, ( 12, 12 ) ) ) + self.SceneEntityIconID = il.Add( wx.ArtProvider_GetBitmap( wx.ART_TICK_MARK, wx.ART_TOOLBAR, ( 12, 12 ) ) ) + self.SceneUnknownIconID = il.Add( wx.ArtProvider_GetBitmap( wx.ART_QUESTION, wx.ART_TOOLBAR, ( 12, 12 ) ) ) + + self.sceneTree.AssignImageList( il ) + + self.Bind( wx.EVT_TREE_SEL_CHANGED, self.doSelectTreeObject, self.sceneTree ) + return self.sceneTree + + def createObjectInspector_( self ): + self.objectInspector = ObjectInspectorPanel( self, -1, wx.Point(0, 0), wx.Size(160, 250) ) + return self.objectInspector + + def createResourceInspector_( self ): + 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 ) + return self.resourceTree + + def setDefaultProperties_( self ): + self.SetTitle("ogEditor") + self.sb.SetStatusWidths([-1]) + + self.mbViewScenetree.Check( ) + self.auiMgr.GetPane( NAME_SCENETREE ).Show() + + self.mbViewObject.Check( ) + self.auiMgr.GetPane( NAME_OBJECT ).Show() + + self.mbViewResource.Check( False ) + self.auiMgr.GetPane( NAME_RESOURCE ).Hide() + + self.mbViewPyCrust.Check( False ) + self.auiMgr.GetPane( NAME_PYCRUST ).Hide() + + self.UpdateSceneGraphEvent( None ) + self.resourceTree.buildResourceTree( ) + +################################################################################# +# events +################################################################################# + + def doExit( self, event ): + self.Close( True ) + event.Skip() + + def doClosePane( self, event ): + caption = event.GetPane().caption + if caption == NAME_SCENETREE: + self.mb.Check( ID_MB_VIEW_SCENETREE, False ) + elif caption == NAME_OBJECT: + self.mb.Check( ID_MB_VIEW_OBJECT, False ) + elif caption == NAME_RESOURCE: + self.mb.Check( ID_MB_VIEW_RESOURCE, False ) + elif caption == NAME_PYCRUST: + self.mb.Check( ID_MB_VIEW_PYCRUST, False ) + + def doSwitchViewPane( self, event ): + if event.GetId() == ID_MB_VIEW_SCENETREE: + pane = self.auiMgr.GetPane( NAME_SCENETREE ) + elif event.GetId() == ID_MB_VIEW_OBJECT: + pane = self.auiMgr.GetPane( NAME_OBJECT ) + elif event.GetId() == ID_MB_VIEW_RESOURCE: + pane = self.auiMgr.GetPane( NAME_RESOURCE ) + elif event.GetId() == ID_MB_VIEW_PYCRUST: + pane = self.auiMgr.GetPane( NAME_PYCRUST ) + + if event.IsChecked(): + pane.Show( ) + else: + pane.Hide() + self.auiMgr.Update() + event.Skip() + + def doSelectTreeObject( self, event ): + self.objectInspector.showData( event.GetEventObject().GetPyData( event.GetEventObject().GetSelection() ) ); + event.Skip() + +################################################################################# +# utils +################################################################################# + + def UpdateSceneGraphEvent(self, event): + root = self.sceneTree.AddRoot( "SceneManager" ) + self.sceneTree.SetPyData( root, self.ogreRenderWindow.sceneManager ) + + rootSceneNode = self.ogreRenderWindow.sceneManager.getRootSceneNode() + rootSceneNodeTreeNode = self.sceneTree.AppendItem( root, rootSceneNode.getName() ) + self.sceneTree.SetPyData( rootSceneNodeTreeNode, rootSceneNode ) + + self.dumpSceneNode_( rootSceneNodeTreeNode, rootSceneNode ) + self.sceneTree.Expand( root ) + if event != None: + event.Skip() + + def dumpSceneNode_( self, treenode, scenenode ): + node_it = scenenode.getChildIterator() + while node_it.hasMoreElements(): + nextnode = node_it.getNext() +# print nextnode.getName() + nexttreenode = self.sceneTree.AppendItem( treenode, nextnode.getName(), 1 ) + self.sceneTree.SetItemImage(nexttreenode, self.SceneNodeIconID, CT.TreeItemIcon_Normal) + self.sceneTree.SetItemImage(nexttreenode, self.SceneNodeIconID, CT.TreeItemIcon_Selected) + self.sceneTree.SetPyData( nexttreenode, nextnode ) + + self.dumpAttachedMovableObjects_( nexttreenode, nextnode ) + self.dumpSceneNode_( nexttreenode, nextnode ) + + def dumpAttachedMovableObjects_( self, treenode, scenenode ): + object_it = scenenode.getAttachedObjectIterator() + while object_it.hasMoreElements(): + m = object_it.getNext() + item = self.sceneTree.AppendItem( treenode, m.getMovableType() + "-" + m.getName() ) + + if m.getMovableType() == "Entity": + id = self.SceneEntityIconID + else: + id = self.SceneUnknownIconID + + self.sceneTree.SetItemImage(item, id, CT.TreeItemIcon_Normal) + self.sceneTree.SetItemImage(item, id, CT.TreeItemIcon_Selected) + self.sceneTree.SetPyData( item, m ) + +if __name__ == "__main__": + ogEditor = wx.PySimpleApp(0) + wx.InitAllImageHandlers() + mainFrame = MainFrame(None, -1, "") + ogEditor.SetTopWindow(mainFrame) + mainFrame.Show() + mainFrame.ogreRenderWindow.StartRendering() + ogEditor.MainLoop() Property changes on: branches/ogEditor/ogEditor.py ___________________________________________________________________ Name: svn:executable + * Added: branches/ogEditor/ogEditor.sh =================================================================== --- branches/ogEditor/ogEditor.sh (rev 0) +++ branches/ogEditor/ogEditor.sh 2008-02-04 22:24:41 UTC (rev 883) @@ -0,0 +1,3 @@ +export LD_LIBRARY_PATH=~/local/python-ogre.work/root/usr/lib +export PYTHONPATH=/home/carsten/local/python-ogre.work/root/usr/lib64/python2.5/site-packages +python ogEditor.py Added: branches/ogEditor/ogre.cfg =================================================================== --- branches/ogEditor/ogre.cfg (rev 0) +++ branches/ogEditor/ogre.cfg 2008-02-04 22:24:41 UTC (rev 883) @@ -0,0 +1,7 @@ +Render System=OpenGL Rendering Subsystem + +[OpenGL Rendering Subsystem] +FSAA=0 +Full Screen=Yes +RTT Preferred Mode=FBO +Video Mode=800 x 600 Added: branches/ogEditor/plugins.cfg =================================================================== --- branches/ogEditor/plugins.cfg (rev 0) +++ branches/ogEditor/plugins.cfg 2008-02-04 22:24:41 UTC (rev 883) @@ -0,0 +1,20 @@ +# Defines plugins to load + +## Use this for Windows +# Define plugin folder +PluginFolder=/home/carsten/local/python-ogre.work/root/usr/lib/OGRE +#PluginFolder=/usr/lib/OGRE +#Plugin=RenderSystem_GL.dll +#Plugin=RenderSystem_Direct3D9.dll +#Plugin=Plugin_ParticleFX.dll +#Plugin=Plugin_BSPSceneManager.dll +#Plugin=Plugin_OctreeSceneManager.dll +#Plugin=Plugin_CgProgramManager.dll + +## +## NOTE use this for MacOS or Linux +Plugin=RenderSystem_GL +Plugin=Plugin_ParticleFX +#Plugin=Plugin_BSPSceneManager +#Plugin=Plugin_OctreeSceneManager +Plugin=Plugin_CgProgramManager Added: branches/ogEditor/propgridtest.py =================================================================== --- branches/ogEditor/propgridtest.py (rev 0) +++ branches/ogEditor/propgridtest.py 2008-02-04 22:24:41 UTC (rev 883) @@ -0,0 +1,49 @@ + +import wxversion +wxversion.ensureMinimal('2.8') + +from PropertyGrid import * + +import sys +import wx + +class testClass(): + def printValue(self, value): + print "Here am I with:", value + +class MainFrame(wx.Frame): + def __init__(self, *args, **kwds): + kwds["style"] = wx.DEFAULT_FRAME_STYLE + wx.Frame.__init__(self, *args, **kwds) + + test = testClass() + + self.SetSize( wx.Size( 800, 600 ) ) + self.propertyGrid = PropertyMainGrid( self, -1, wx.DefaultPosition, wx.DefaultSize ) + + self.propertyGrid.appendRowItemName( "Main", "name" ) + self.propertyGrid.append... [truncated message content] |
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...> - 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-27 19:07:55
|
Revision: 880 http://opengate.svn.sourceforge.net/opengate/?rev=880&view=rev Author: spom_spom Date: 2007-12-27 11:07:56 -0800 (Thu, 27 Dec 2007) Log Message: ----------- Add surface/norm/spec-mapping shader for planet objects Modified Paths: -------------- trunk/src/Makefile.am trunk/src/Sector.cpp trunk/src/Sector.h trunk/src/SectorObjects.cpp trunk/src/UnDockedState.cpp Added Paths: ----------- trunk/src/Planet.cpp trunk/src/Planet.h Modified: trunk/src/Makefile.am =================================================================== --- trunk/src/Makefile.am 2007-12-08 12:45:39 UTC (rev 879) +++ trunk/src/Makefile.am 2007-12-27 19:07:56 UTC (rev 880) @@ -50,6 +50,8 @@ OpcodeWrapper.cpp \ OpenALSoundManager.h \ OpenALSoundManager.cpp \ + Planet.h \ + Planet.cpp \ Projectile.h \ Projectile.cpp \ ResourceManager.h \ Added: trunk/src/Planet.cpp =================================================================== --- trunk/src/Planet.cpp (rev 0) +++ trunk/src/Planet.cpp 2007-12-27 19:07:56 UTC (rev 880) @@ -0,0 +1,157 @@ +/*************************************************************************** + * Copyright (C) 2006-2007 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 "Planet.h" + +#include <OgreSceneManager.h> +#include <OgreEntity.h> +#include <OgreSceneNode.h> +#include <OgreMeshManager.h> +#include <OgreSubMesh.h> +#include <OgreVector3.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_->pitch( Ogre::Degree(30) ); + + 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); + } + +void Planet::update( float elapsedTime ){ + planetNode_->yaw( Ogre::Degree( 0.2 * elapsedTime ) ); + planetCloudNode_->yaw( Ogre::Degree( 0.1 * elapsedTime ) ); +} + +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::SubMesh *pSphereVertex = pSphere->createSubMesh(); + + pSphere->sharedVertexData = new Ogre::VertexData(); + Ogre::VertexData* vertexData = pSphere->sharedVertexData; + + // define the vertex format + Ogre::VertexDeclaration* vertexDecl = vertexData->vertexDeclaration; + size_t currOffset = 0; + // positions + vertexDecl->addElement(0, currOffset, Ogre::VET_FLOAT3, Ogre::VES_POSITION); + currOffset += Ogre::VertexElement::getTypeSize(Ogre::VET_FLOAT3); + // normals + vertexDecl->addElement(0, currOffset, Ogre::VET_FLOAT3, Ogre::VES_NORMAL); + currOffset += Ogre::VertexElement::getTypeSize(Ogre::VET_FLOAT3); + // two dimensional texture coordinates + vertexDecl->addElement(0, currOffset, Ogre::VET_FLOAT2, Ogre::VES_TEXTURE_COORDINATES, 0); + currOffset += Ogre::VertexElement::getTypeSize(Ogre::VET_FLOAT2); + + // allocate the vertex buffer + vertexData->vertexCount = (nRings + 1) * (nSegments+1); + Ogre::HardwareVertexBufferSharedPtr vBuf = Ogre::HardwareBufferManager::getSingleton().createVertexBuffer( vertexDecl->getVertexSize(0), vertexData->vertexCount, + Ogre::HardwareBuffer::HBU_STATIC_WRITE_ONLY, false); + Ogre::VertexBufferBinding* binding = vertexData->vertexBufferBinding; + binding->setBinding(0, vBuf); + float* pVertex = static_cast<float*>(vBuf->lock(Ogre::HardwareBuffer::HBL_DISCARD)); + + // allocate index buffer + pSphereVertex->indexData->indexCount = 6 * nRings * (nSegments + 1); + pSphereVertex->indexData->indexBuffer = Ogre::HardwareBufferManager::getSingleton().createIndexBuffer( + Ogre::HardwareIndexBuffer::IT_16BIT, pSphereVertex->indexData->indexCount, + Ogre::HardwareBuffer::HBU_STATIC_WRITE_ONLY, false); + Ogre::HardwareIndexBufferSharedPtr iBuf = pSphereVertex->indexData->indexBuffer; + unsigned short* pIndices = static_cast<unsigned short*>(iBuf->lock(Ogre::HardwareBuffer::HBL_DISCARD)); + + float fDeltaRingAngle = (Ogre::Math::PI / nRings); + float fDeltaSegAngle = (2.0 * Ogre::Math::PI / nSegments); + unsigned short wVerticeIndex = 0 ; + + // Generate the group of rings for the sphere + for ( int ring = 0; ring <= nRings; ring++ ) { + float r0 = r * sinf (ring * fDeltaRingAngle); + float y0 = r * cosf (ring * fDeltaRingAngle); + + // Generate the group of segments for the current ring + for (int seg = 0; seg <= nSegments; seg++) { + float x0 = r0 * sinf(seg * fDeltaSegAngle); + float z0 = r0 * cosf(seg * fDeltaSegAngle); + + // Add one vertex to the strip which makes up the sphere + *pVertex++ = x0; + *pVertex++ = y0; + *pVertex++ = z0; + + Ogre::Vector3 vNormal = Ogre::Vector3(x0, y0, z0).normalisedCopy(); + *pVertex++ = vNormal.x; + *pVertex++ = vNormal.y; + *pVertex++ = vNormal.z; + + *pVertex++ = (float) seg / (float) nSegments; + *pVertex++ = (float) ring / (float) nRings; + + if (ring != nRings) { + // each vertex (except the last) has six indices pointing to it + *pIndices++ = wVerticeIndex + nSegments + 1; + *pIndices++ = wVerticeIndex; + *pIndices++ = wVerticeIndex + nSegments; + *pIndices++ = wVerticeIndex + nSegments + 1; + *pIndices++ = wVerticeIndex + 1; + *pIndices++ = wVerticeIndex; + wVerticeIndex ++; + } + }; // end for seg + } // end for ring + + // Unlock + vBuf->unlock(); + iBuf->unlock(); + // Generate face list + pSphereVertex->useSharedVertices = true; + + // the original code was missing this line: + pSphere->_setBounds( Ogre::AxisAlignedBox( Ogre::Vector3(-r, -r, -r), Ogre::Vector3(r, r, r) ), false ); + pSphere->_setBoundingSphereRadius( r ); + // this line makes clear the mesh is loaded (avoids memory leaks) + pSphere->load(); + + Ogre::MeshPtr pMesh = Ogre::MeshManager::getSingleton().load( strName, + 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 ); + } +} + +} // namespace OpenGate + Added: trunk/src/Planet.h =================================================================== --- trunk/src/Planet.h (rev 0) +++ trunk/src/Planet.h 2007-12-27 19:07:56 UTC (rev 880) @@ -0,0 +1,49 @@ +/*************************************************************************** + * Copyright (C) 2006-2007 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_PLANET__H +#define _OPENGATE_PLANET__H + +#include <OgrePrerequisites.h> + +namespace OpenGate{ + +class Planet { +public: + + Planet( const std::string & name, Ogre::SceneManager * SceneMgr, const Ogre::Vector3 & relPos, Ogre::Real radius, int segments ); + void update( float elapsedTime ); + +protected: + + //** taken from ogre wiki: http://www.ogre3d.org/wiki/index.php/ManualSphereMeshes + void createSphere_( const std::string & strName, const float r, const int nRings, const int nSegments ); + + std::string name_; + Ogre::SceneManager * sceneMgr_; + + Ogre::SceneNode * planetNode_; + Ogre::SceneNode * planetCloudNode_; +}; + +} // namespace OpenGate + + +#endif // _OPENGATE_SECTOR__H Modified: trunk/src/Sector.cpp =================================================================== --- trunk/src/Sector.cpp 2007-12-08 12:45:39 UTC (rev 879) +++ trunk/src/Sector.cpp 2007-12-27 19:07:56 UTC (rev 880) @@ -25,6 +25,7 @@ #include "ResourceManager.h" #include "Projectile.h" #include "Station.h" +#include "Planet.h" #include <OgreManualObject.h> #include <OgreMaterialManager.h> @@ -66,12 +67,13 @@ Sector::Sector( Ogre::SceneManager * sceneMgr, NetworkClient * network ) : sceneMgr_( sceneMgr ), network_( network ) { - log_ = LogManager::getSingletonPtr(); - radar_ = true; + radar_ = true; planetNode_ = NULL; - starsNode_ = NULL; - avatar_ = NULL; - station_ = NULL; + planet_ = NULL; + starsNode_ = NULL; + avatar_ = NULL; + station_ = NULL; + log_ = LogManager::getSingletonPtr(); avatarDeathSequenceTime_ = 0.0; @@ -114,9 +116,21 @@ //*** 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 ); + 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 ); + planet_ = new Planet( "planet", sceneMgr_, Ogre::Vector3( 0000.0, 0000.0, 50000 ), 15000.0f, 64 ); + } + + if ( !1 ) { planetNode_ = sceneMgr_->getRootSceneNode()->createChildSceneNode( "PlanetNode" ); + Ogre::ManualObject * planet = sceneMgr_->createManualObject( "Planet" ); // planet->setUseIdentityProjection( true ); // planet->setUseIdentityView( true ); @@ -139,8 +153,6 @@ planetNode_->setPosition( Ogre::Vector3( 20000.0, 10000.0, 50000 ) ); } - sceneMgr_->setAmbientLight( Ogre::ColourValue( 0.2, 0.2, 0.2 ) ); - populate( "testsector.xml" ); // createCircle(); @@ -219,7 +231,7 @@ if ( pElem ){ sceneMgr_->setSkyBox( true, pElem->FirstChild()->Value(), 10000 ); } else{ -// sceneMgr_->setSkyBox( true, "OpenGate/SimpleSkyBox1" ); + sceneMgr_->setSkyBox( true, "OpenGate/SimpleSkyBox1" ); } pElem = hRoot.ChildElement( "vesselschool", 0 ).Element(); @@ -368,6 +380,9 @@ if ( collisionDetection_ ) collisionDetection_->update( elapsedTime ); if ( avatar_ ) { + if ( planet_ ){ + planet_->update( elapsedTime ); + } if ( planetNode_ ){ Ogre::Vector3 src = planetNode_->getWorldOrientation() * Ogre::Vector3::UNIT_Z; src.normalise(); Modified: trunk/src/Sector.h =================================================================== --- trunk/src/Sector.h 2007-12-08 12:45:39 UTC (rev 879) +++ trunk/src/Sector.h 2007-12-27 19:07:56 UTC (rev 880) @@ -31,6 +31,7 @@ class Avatar; class Station; +class Planet; class StationObject; class Sector { @@ -122,6 +123,8 @@ std::string sectorname_; SectorObjectAvatar * avatar_; + Planet * planet_; + Ogre::SceneNode * planetNode_; Ogre::SceneNode * starsNode_; Modified: trunk/src/SectorObjects.cpp =================================================================== --- trunk/src/SectorObjects.cpp 2007-12-08 12:45:39 UTC (rev 879) +++ trunk/src/SectorObjects.cpp 2007-12-27 19:07:56 UTC (rev 880) @@ -847,7 +847,7 @@ Ogre::Light * l = sceneMgr_->createLight("AvatarLight" ); l->setDiffuseColour( Ogre::ColourValue(1.0, 1.0, 1.0) ); l->setSpecularColour( Ogre::ColourValue(1.0, 1.0, 1.0) ); - l->setVisible( true ); + l->setVisible( false ); lightNode_ = mainNode_->createChildSceneNode( "AvatarLightNode" ); lightNode_->translate(50,0,10); lightNode_->attachObject( l ); Modified: trunk/src/UnDockedState.cpp =================================================================== --- trunk/src/UnDockedState.cpp 2007-12-08 12:45:39 UTC (rev 879) +++ trunk/src/UnDockedState.cpp 2007-12-27 19:07:56 UTC (rev 880) @@ -174,7 +174,7 @@ Ogre::Viewport* vp = window_->addViewport( sceneMgr_->getCamera( "MainCamera" ), 0, 0.0, 0.0, 1.0f, 1.0f ); vp->setBackgroundColour( Ogre::ColourValue( 0, 0, 0) ); - // camera->setAspectRatio( Real(vp->getActualWidth()) / Real(vp->getActualHeight())); + sceneMgr_->getCamera( "MainCamera" )->setAspectRatio( Ogre::Real(vp->getActualWidth()) / Ogre::Real(vp->getActualHeight())); Ogre::Viewport* vp1 = window_->addViewport( sceneMgr_->getCamera( "SecondCamera" ), 1, 0.01, 0.84, 0.15, 0.15 ); vp1->setBackgroundColour( Ogre::ColourValue( 0.1, 0.1, 0.1 ) ); @@ -383,6 +383,7 @@ return false; } + myMSleep( (int)min( 0.0f, 1 - ( evt.timeSinceLastFrame ) ) ); return true; } @@ -402,10 +403,18 @@ chatMode_ = true; } } else { // ** chatmode - if ( e.key == OIS::KC_RETURN && resources_->keymap()->globalKeyModifier( ) == KEY_CONTROL || - e.key == OIS::KC_ESCAPE ) { - CEGUI::WindowManager::getSingleton().getWindow( (CEGUI::utf8*)"ConsoleEdit")->deactivate(); - chatMode_ = false; + bool EnterHoldChatFokus = false; + if ( EnterHoldChatFokus ){ + if ( e.key == OIS::KC_RETURN && resources_->keymap()->globalKeyModifier( ) == KEY_CONTROL || + e.key == OIS::KC_ESCAPE ) { + CEGUI::WindowManager::getSingleton().getWindow( (CEGUI::utf8*)"ConsoleEdit")->deactivate(); + chatMode_ = false; + } + } else { + if ( e.key == OIS::KC_RETURN ) { + CEGUI::WindowManager::getSingleton().getWindow( (CEGUI::utf8*)"ConsoleEdit")->deactivate(); + chatMode_ = false; + } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <eg...@us...> - 2007-12-08 12:45:37
|
Revision: 879 http://opengate.svn.sourceforge.net/opengate/?rev=879&view=rev Author: egore Date: 2007-12-08 04:45:39 -0800 (Sat, 08 Dec 2007) Log Message: ----------- typo Modified Paths: -------------- trunk/data/Makefile.am Modified: trunk/data/Makefile.am =================================================================== --- trunk/data/Makefile.am 2007-12-08 12:40:12 UTC (rev 878) +++ trunk/data/Makefile.am 2007-12-08 12:45:39 UTC (rev 879) @@ -51,7 +51,6 @@ 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 \ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
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-03 20:34:19
|
Revision: 877 http://opengate.svn.sourceforge.net/opengate/?rev=877&view=rev Author: spom_spom Date: 2007-12-03 12:34:06 -0800 (Mon, 03 Dec 2007) Log Message: ----------- win compatibility commit, downgrade windows ogre binaries to 1.4.2, forgot 1 file Modified Paths: -------------- trunk/win32/ogsectorclient/OgreGUIRenderer.dll Modified: trunk/win32/ogsectorclient/OgreGUIRenderer.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-03 20:14:12
|
Revision: 876 http://opengate.svn.sourceforge.net/opengate/?rev=876&view=rev Author: spom_spom Date: 2007-12-03 12:14:14 -0800 (Mon, 03 Dec 2007) Log Message: ----------- win compatibility commit, downgrade windows ogre binaries to 1.4.2 Modified Paths: -------------- trunk/win32/ogsectorclient/OgreMain.dll trunk/win32/ogsectorclient/Plugin_CgProgramManager.dll trunk/win32/ogsectorclient/Plugin_ParticleFX.dll trunk/win32/ogsectorclient/RenderSystem_Direct3D9.dll trunk/win32/ogsectorclient/RenderSystem_GL.dll trunk/win32/ogsectorclient/ogreopcode.dll trunk/win32/ogsectorclient/ogsectorclient.exe trunk/win32/ogsectorclient/ois.dll Modified: trunk/win32/ogsectorclient/OgreMain.dll =================================================================== (Binary files differ) Modified: trunk/win32/ogsectorclient/Plugin_CgProgramManager.dll =================================================================== (Binary files differ) Modified: trunk/win32/ogsectorclient/Plugin_ParticleFX.dll =================================================================== (Binary files differ) Modified: trunk/win32/ogsectorclient/RenderSystem_Direct3D9.dll =================================================================== (Binary files differ) Modified: trunk/win32/ogsectorclient/RenderSystem_GL.dll =================================================================== (Binary files differ) Modified: trunk/win32/ogsectorclient/ogreopcode.dll =================================================================== --- trunk/win32/ogsectorclient/ogreopcode.dll 2007-12-02 21:26:14 UTC (rev 875) +++ trunk/win32/ogsectorclient/ogreopcode.dll 2007-12-03 20:14:14 UTC (rev 876) @@ -1,302 +1,311 @@ MZ\x90 |