Thread: [Yake-svn] SF.net SVN: yake: [1824] trunk/yake (Page 5)
Status: Beta
Brought to you by:
psyclonist
|
From: <psy...@us...> - 2007-08-28 17:53:02
|
Revision: 1824
http://yake.svn.sourceforge.net/yake/?rev=1824&view=rev
Author: psyclonist
Date: 2007-08-28 10:53:02 -0700 (Tue, 28 Aug 2007)
Log Message:
-----------
* intermediate work for new property access and improved entity scripting
* src\bindings.lua\detail\property.lua.cpp needs more work! especially, the BindPropertySetFnList is disabled, at the moment.
Modified Paths:
--------------
trunk/yake/src/bindings.lua/detail/ent.lua.cpp
trunk/yake/src/bindings.lua/detail/property.lua.cpp
Added Paths:
-----------
trunk/yake/common/media/scripts/o_access.lua
Added: trunk/yake/common/media/scripts/o_access.lua
===================================================================
--- trunk/yake/common/media/scripts/o_access.lua (rev 0)
+++ trunk/yake/common/media/scripts/o_access.lua 2007-08-28 17:53:02 UTC (rev 1824)
@@ -0,0 +1,133 @@
+print("> Starting object script...");
+function startup()
+ --this:fsm("main"):connectTo("alive",fn) -- connects to 'enter', 'tick', 'exit'
+ --this:fsm("main"):connectToEnter("dead",fn) -- connects to 'enter' only
+ --this:fsm("main"):connect("alive", fnEnter, fnTick, fnExit)
+
+ this:events("spawn"):connect(
+ function()
+
+ end
+ )
+end
+properties = {}
+properties_mt = {}
+
+properties_mt.__index = function(t,k)
+ print("INDEX",t,k)
+ --for u,v in pairs(t) do print(u,v) end
+ --return events[k]
+ return this:properties():get(k):get()
+end
+properties_mt.__newindex = function(t,k,v)
+ print("NEWINDEX",t,"'"..tostring(k).."'",v)
+ --rawset(t,k,v)
+ --for u,v in pairs(t) do print(u,v) end
+ local exists = this:properties():get(k)
+ if exists then
+ print("EXISTS")
+ exists:set(v)
+ return true
+ end
+ this:properties():create(k,v)
+ return true
+end
+
+setmetatable(properties, properties_mt)
+
+properties.s = 1
+properties["s"] = 2
+print(properties["s"])
+
+event = {
+ on_spawn = function()
+ print(" script event.on_spawn")
+ this:properties():create("ticks",0)
+ end,
+ on_tick = function()
+ print(" script event.on_tick")
+ end,
+ on_die = function()
+ print(" script event.on_die")
+ end,
+ -- various:
+ onArrived = function() --triggered as a result of "go to"
+ end,
+ -- Trigger
+ on_toggle = function()
+ print("event.on_toggle")
+ end
+}
+fsm = {
+ main = {
+ states = {
+ awakening,
+ alive,
+ dead
+ },
+ transitions = {
+ {awakening,"spawn",alive},
+ {alive,"die",dead}
+ }
+ }
+}
+state = {
+ off = {
+ on_enter = function()
+ print("state.off.enter()")
+
+ this:setCondition(function() return (this:property("ticks"):get() >= 1 and this:property("ticks"):get() <= 3) end)
+ this:events():get("onTriggered"):connect( function(a) print("TRIGGER:onTriggered:",a) end )
+ end,
+ on_tick = function()
+ local ticks = this:property("ticks")
+ if ticks then
+ ticks:set( ticks:get() + 1 )
+ end
+ print("state.off.tick()") --,ticks:get()
+ --
+ --if (state.off.ticks == 1) then
+ -- this:processFsmEvent("trigger")
+ --end
+ --
+ --this:events():get("onTriggered"):fire(42)
+ end,
+ on_exit = function()
+ print("state.off.exit()")
+ end
+ }
+ ,
+ on = {
+ on_enter = function()
+ print("state.on.enter()")
+ end,
+ on_tick = function()
+ local ticks = this:property("ticks")
+ if ticks then
+ ticks:set( ticks:get() + 1 )
+ end
+ print("state.on.tick()") --,ticks:get()
+ end,
+ on_exit = function()
+ print("state.on.exit()")
+ end
+ }
+ ,
+ dead = {
+ on_enter = function()
+ print(" script state.dead.on_enter")
+ end,
+ on_tick = function()
+ print(" script state.dead.on_tick")
+ end,
+ on_exit = function()
+ print(" script state.dead.on_exit")
+ end
+ }
+}
+print("> Object script up.");
+
+function main()
+ print("main()")
+end
+
Modified: trunk/yake/src/bindings.lua/detail/ent.lua.cpp
===================================================================
--- trunk/yake/src/bindings.lua/detail/ent.lua.cpp 2007-08-27 17:13:37 UTC (rev 1823)
+++ trunk/yake/src/bindings.lua/detail/ent.lua.cpp 2007-08-28 17:53:02 UTC (rev 1824)
@@ -175,6 +175,10 @@
return 0;
}
}
+ static property::PropertyBase* createAndAddPropertyFromNumber(Object::PropertyAccess& access, const char* name, int number)
+ {
+ return createAndAddPropertyFromAny(access,name,boost::any(number));
+ }
};
//-------------------------------------------------------------------------
void bind( lua_State* L )
@@ -216,6 +220,7 @@
.def( "create", (property::PropertyBase*(*)(Object::PropertyAccess&,const char*,const boost::any&))&LuaBinder::createAndAddPropertyFromAny )
// For all other 'custom' registered and unknown types:
.def( "create", (property::PropertyBase*(*)(Object::PropertyAccess&,const char*,luabind::object))&LuaBinder::createAndAddProperty )
+ //.def( "create", &LuaBinder::createAndAddPropertyFromNumber)
;
module( YAKE_MODEL_MODULE )
[ x_Object_PropertyAccess ];
Modified: trunk/yake/src/bindings.lua/detail/property.lua.cpp
===================================================================
--- trunk/yake/src/bindings.lua/detail/property.lua.cpp 2007-08-27 17:13:37 UTC (rev 1823)
+++ trunk/yake/src/bindings.lua/detail/property.lua.cpp 2007-08-28 17:53:02 UTC (rev 1824)
@@ -156,15 +156,17 @@
LuabindClass_PropertyBase x( "PropertyBase" );
x
.def( "type", &PropertyBase::type )
- //.def( "set", &setPropertyValue ) // for boost::any
+ .def( "set", &setPropertyValue ) // for boost::any
.def( "get", (boost::any(PropertyBase::*)()const)&PropertyBase::getAny )
;
// register additional 'set' overloads:
+ /*
for (BindSetPropertyFnList::const_iterator it = setPropertyValue_binders().begin();
it != setPropertyValue_binders().end(); ++it)
{
(*it)(x);
}
+ */
//
module( YAKE_MODEL_MODULE )[ x ] ;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <psy...@us...> - 2007-08-28 23:34:23
|
Revision: 1825
http://yake.svn.sourceforge.net/yake/?rev=1825&view=rev
Author: psyclonist
Date: 2007-08-28 16:34:11 -0700 (Tue, 28 Aug 2007)
Log Message:
-----------
* [bindings.lua] improved yake.property bindings: no get() and set() accessors are necessary, anymore. Operators = and [] and . are enough. (Example: 'props.name = "jack"' instead of 'props:get("name"):set("jack")')
Modified Paths:
--------------
trunk/yake/common/media/samples/property/demo.lua
trunk/yake/samples/property/lua1/demo.cpp
trunk/yake/samples/raf/lua1/demo.cpp
trunk/yake/src/bindings.lua/detail/ent.lua.cpp
trunk/yake/src/bindings.lua/detail/property.lua.cpp
trunk/yake/src/ent/object.cpp
trunk/yake/yake/bindings.lua/detail/property.lua.h
trunk/yake/yake/ent/object.h
trunk/yake/yake/property/detail/property.impl.h
Modified: trunk/yake/common/media/samples/property/demo.lua
===================================================================
--- trunk/yake/common/media/samples/property/demo.lua 2007-08-28 17:53:02 UTC (rev 1824)
+++ trunk/yake/common/media/samples/property/demo.lua 2007-08-28 23:34:11 UTC (rev 1825)
@@ -55,4 +55,149 @@
assert( p:set( yake.Vector3(2,3,4) ) );
print(" value = (" .. p:get().x .. "," .. p:get().y .. "," .. p:get().z .. ")" );
+print("\n---- property access table (forwards to 'props') ----")
+properties = {}
+-- @param t (table) table to wrap (can be empty)
+-- @param propAccess () object of type ent.Object.PropertyAccess (bindings.lua:ent) or
+-- of type property.NamedPropertyContainer (bindings.lua:property).
+-- @param implicitCreation (boolean)
+-- @return nothing
+function wrapPropertiesTable(t,propAccess,implicitCreation)
+ t.list = {}
+ t.accessor = propAccess
+ t.create = function(self,k,v)
+ local p = self.accessor:create(k,v)
+ assert( p ~= nil )
+
+ -- @todo really provide this accessor a la __newindex and rawset below???
+ rawset(t.list,k,p)
+
+ return p
+ end
+
+ --@todo loop through all existing properties in propAccess and
+ -- create an accessor (with rawset) in t.list for each key.
+ -- same as in t.create() or __newindex().
+ --print(type(propAccess.size))
+ --print(propAccess.size)
+ for k = 1, propAccess.size do
+ local p = propAccess:get(k)
+ assert( p ~= nil )
+ --print("exist:",p.name)
+ rawset(t.list,p.name,p)
+ end
+
+ --
+ if implicitCreation == nil then
+ --print("defaulting")
+ implicitCreation = true
+ end
+ assert( type(implicitCreation) == "boolean" )
+ --print(implicitCreation)
+
+ setmetatable(t, {
+ __index = function(t,k)
+ assert( t.accessor ~= nil )
+ --print("INDEX",t,k)
+ if type(k) ~= "string" then
+ print("properties __index -> ERROR: key is not of type 'string' but of type '"..type(k).."'!")
+ return nil
+ end
+ local p = t.accessor:get(k)
+ if p then
+ return p:get()
+ end
+ return nil
+ end,
+ __newindex = function(t,k,v)
+ --print("NEWINDEX",t,"'"..tostring(k).."' ->",type(k),"value=",v)
+
+ if type(k) ~= "string" then
+ --print("-> ERROR: key is not a string!")
+ return nil
+ end
+ local exists = t.accessor:get(k)
+ if exists then
+ --print("=> EXISTS")
+ exists:set(v)
+ return true
+ end
+ print(implicitCreation)
+ if implicitCreation then
+ local p = t.accessor:create(k,v)
+ assert( p ~= nil )
+
+ -- @todo really provide an accessor???
+ rawset(t.list,k,p)
+
+ return true
+ else
+ return false
+ end
+ end
+ })
+end
+
+local bool demo_uses_implicit_creation = true -- set to true/false to test the different policies
+
+-- setup properties table
+wrapPropertiesTable(properties,props,demo_uses_implicit_creation)
+
+--
+print("> properties[\"sayHello\"]()")
+properties["sayHello"]()
+
+print("> properties.sayHello()")
+properties.sayHello()
+
+print("> print(properties[\"name\"])")
+print(properties["name"])
+assert( properties["name"] == "waikiki" )
+
+print("> print(properties.name)")
+print(properties.name)
+assert( properties.name == "waikiki" )
+
+if not demo_uses_implicit_creation then
+ properties:create("s",1)
+end
+
+print("> properties.s = 1")
+properties.s = 1
+assert( properties.s == 1 )
+
+print("> properties[42] = 1 => fails expectedly as key is not a string.")
+properties[42] = 1
+assert( properties[42] == nil )
+
+if not demo_uses_implicit_creation then
+ properties:create("42",1)
+end
+
+print("> properties[\"42\"] = 14 => ok")
+properties["42"] = 14
+assert( properties["42"] == 14 )
+
+print("> properties[\"s\"] = 2")
+properties["s"] = 2
+assert( properties["s"] == 2 )
+
+print("> print(properties.s)")
+print(properties.s)
+
+print("> properties[\"s\"] = 3")
+properties["s"] = 3
+assert( properties["s"] == 3 )
+
+--print("properties.list.n",#properties.list)
+--for k,v in pairs(properties.list) do
+-- print("PL",k)
+--end
+--for k,v in ipairs(properties) do
+-- print("P",k)
+--end
+--for i = 1,3 do
+-- print("I",properties[i])
+--end
+
print("\nAll tests done.");
\ No newline at end of file
Modified: trunk/yake/samples/property/lua1/demo.cpp
===================================================================
--- trunk/yake/samples/property/lua1/demo.cpp 2007-08-28 17:53:02 UTC (rev 1824)
+++ trunk/yake/samples/property/lua1/demo.cpp 2007-08-28 23:34:11 UTC (rev 1825)
@@ -1,11 +1,23 @@
#include <yake/plugins/scriptingLua/ScriptingSystemLua.h>
#include <yake/bindings.lua/bindings.lua.h>
+#include "yake/res/res.h"
+#include "yake/base/yakeLog.h"
+#include "yake/base/yakeStderrLog.h"
void main()
{
using namespace yake;
try {
+ // create and attach log listeners
+ typedef SharedPtr<logging::log_listener> log_listener_ptr;
+ log_listener_ptr toStdErr( new yake::logging::stderr_listener() );
+ logging::addListener( toStdErr.get() );
+
+ // Setup resources
+ res::SourceFactory::global().reg<res::FileSource>("file");
+ res::SourceManager::global().addSource("file","../../common/media/samples/");
+
// init scripting VM
typedef scripting::ScriptingSystemLua scripting_t;
scripting_t scriptingSys;
@@ -20,7 +32,7 @@
YAKE_ASSERT( vm );
// run Lua script
- scripting::ScriptPtr demoScript( scriptingSys.createScriptFromFile("../../../common/media/samples/property/demo.lua") );
+ scripting::ScriptPtr demoScript( scriptingSys.createScriptFromFile("property/demo.lua") );
vm->execute( demoScript );
// clean up
Modified: trunk/yake/samples/raf/lua1/demo.cpp
===================================================================
--- trunk/yake/samples/raf/lua1/demo.cpp 2007-08-28 17:53:02 UTC (rev 1824)
+++ trunk/yake/samples/raf/lua1/demo.cpp 2007-08-28 23:34:11 UTC (rev 1825)
@@ -11,24 +11,6 @@
using namespace yake;
-/** Configuration of the application */
-struct TheConfiguration : public raf::ApplicationConfiguration
-{
- // Use "inputOgre" for Ogre 1.2/1.3, "inputOgreOIS" for Ogre 1.4+.
- virtual StringVector getLibraries()
- { return MakeStringVector() << YAKE_LIB("scriptingLua") << YAKE_LIB("graphicsOgre") << YAKE_LIB("inputOgreOIS"); }
-
- // Use "ogre" for Ogre 1.2/1.3, "ois" for Ogre 1.4+.
- virtual StringVector getInputSystems()
- { return MakeStringVector() << "ois"; }
-
- virtual StringVector getScriptingSystems()
- { return MakeStringVector() << "lua"; }
-
- virtual StringVector getGraphicsSystems()
- { return MakeStringVector() << "ogre3d"; }
-};
-
/** Main application state */
class TheMainState : public raf::RtMainState
{
@@ -87,7 +69,13 @@
actionMap_.update(); //@todo here OK? ...
lua_State* L = static_cast<scripting::LuaVM*>(vm_.get())->getLuaState();
- luabind::call_function<void>( L, "onFrame", timeElapsed );
+ try {
+ luabind::call_function<void>( L, "onFrame", timeElapsed );
+ } catch (std::exception& ex)
+ {
+ YAKE_LOG_ERROR("demo",ex.what());
+ requestQuit();
+ }
}
private:
raf::Application& app_;
@@ -96,10 +84,13 @@
};
/** The mighty application itself! */
-class TheApp : public raf::ExampleApplication<TheConfiguration>
+class TheApp : public raf::ExampleApplication<>
{
public:
- TheApp() {}
+ TheApp()
+ {
+ getConfiguration().get().load("sampleRafLua1.cfg");
+ }
protected:
virtual raf::MainState* createMainState()
{
@@ -110,7 +101,7 @@
int main( int argc, char** argv )
{
// Use default executor for convenience.
- // It's always possible to manually execute TheApp::initialise() etc.
+ // It's always possible to manually execute TheApp::initialise() etc.
TheApp app;
return (raf::runApplication( app )) ? 0 : 1;
}
Modified: trunk/yake/src/bindings.lua/detail/ent.lua.cpp
===================================================================
--- trunk/yake/src/bindings.lua/detail/ent.lua.cpp 2007-08-28 17:53:02 UTC (rev 1824)
+++ trunk/yake/src/bindings.lua/detail/ent.lua.cpp 2007-08-28 23:34:11 UTC (rev 1825)
@@ -39,6 +39,7 @@
#include <luabind/iterator_policy.hpp>
#include <luabind/operator.hpp>
+#include <luabind/adopt_policy.hpp>
namespace yake {
namespace ent {
@@ -99,10 +100,32 @@
Object::PropertyAccess& x = o.properties();
return &x;
}
- static property::PropertyBase* Object_PropertyAccess_get(Object::PropertyAccess& o, const char* id)
+ static property::PropertyBase* Object_PropertyAccess_get(Object::PropertyAccess& o, const std::string& id)
{
return o.get( id ).get();
}
+ static property::NamePropertyPair* Object_PropertyAccess_get_byIndex(Object::PropertyAccess& o, int index)
+ {
+ index -= 1; // Lua tables usually start with 1
+ if (index >= o.size() || index < 0)
+ return 0;
+ YAKE_ASSERT( o.owner().__properties() ).debug("invalid internal state");
+ const NamedProperties& props = *o.owner().__properties();
+ if (props.size() == 0)
+ return 0;
+ NamedProperties::const_iterator it = props.begin();
+ for (size_t i=0;i<size_t(index);++i,++it)
+ {
+ if (it == props.end())
+ return 0;
+ }
+ if (it == props.end())
+ return 0;
+ property::NamePropertyPair* ret = new property::NamePropertyPair();
+ ret->name = it->first;
+ ret->prop = it->second.get();
+ return ret;
+ }
static Object::EventAccess* getObjectEvents(Object& o)
{
Object::EventAccess& x = o.events();
@@ -213,7 +236,9 @@
LuabindClass_Object_PropertyAccess x_Object_PropertyAccess("Object::PropertyAccess");
x_Object_PropertyAccess
+ .property( "size", &Object::PropertyAccess::size )
.def( "get", &Object_PropertyAccess_get )
+ .def( "get", &Object_PropertyAccess_get_byIndex, adopt(result) )
.def( "has", &Object::PropertyAccess::has )
// For native Lua types which can simply mapped to C++:
@@ -349,7 +374,7 @@
LuaFsmObjectListener::LuaFsmObjectListener(scripting::IScriptingSystem& scriptingSystem) :
scriptingSystem_(scriptingSystem)
{
- startScript_ = scriptingSystem_.createScriptFromFile("o_fsm_test.lua");
+ startScript_ = scriptingSystem_.createScriptFromFile("o_access.lua");
YAKE_ASSERT( startScript_.get() );
}
void LuaFsmObjectListener::onInit(Object& obj)
Modified: trunk/yake/src/bindings.lua/detail/property.lua.cpp
===================================================================
--- trunk/yake/src/bindings.lua/detail/property.lua.cpp 2007-08-28 17:53:02 UTC (rev 1824)
+++ trunk/yake/src/bindings.lua/detail/property.lua.cpp 2007-08-28 23:34:11 UTC (rev 1825)
@@ -39,6 +39,8 @@
#include <yake/bindings.lua/detail/private.h>
#include <yake/bindings.lua/detail/property.lua.h>
+#include <luabind/adopt_policy.hpp>
+
namespace yake {
namespace property {
PropertyFromAnyMap& any_property_creators()
@@ -125,6 +127,25 @@
PropertyPtr prop = ctr.getPtr(name);
return prop.get();
}
+ NamePropertyPair* getPropertyByIndex(NamedPropertyContainer& ctr, int index)
+ {
+ index -= 1; // Lua tables usually start with 1
+ if (index < 0 || index >= ctr.size() || ctr.size() == 0)
+ return 0;
+ NamedPropertyContainer::const_iterator it = ctr.begin();
+ for (size_t i=0; i<index; ++i, ++it)
+ {
+ if (it == ctr.end())
+ return 0;
+ }
+ if (it == ctr.end())
+ return 0;
+
+ NamePropertyPair* ret = new NamePropertyPair();
+ ret->name = it->first;
+ ret->prop = it->second.get();
+ return ret;
+ }
bool setPropertyValue(PropertyBase& prop, const boost::any& value)
{
try {
@@ -173,6 +194,10 @@
//
module( YAKE_MODEL_MODULE )
[
+ class_<NamePropertyPair>("NamePropertyPair")
+ .def_readonly("name", &NamePropertyPair::name)
+ .def_readonly("property", &NamePropertyPair::prop)
+ ,
class_<NamedPropertyContainer>( "NamedPropertyContainer" )
.def( constructor<>() )
//.def( "add", (void(NamedPropertyContainer::*)(const String&,PropertyPtr))&NamedPropertyContainer::add )
@@ -180,7 +205,10 @@
//.def( "get", (PropertyBase&(NamedPropertyContainer::*)(const String&))&NamedPropertyContainer::get )
//.def( "get", (PropertyPtr(NamedPropertyContainer::*)(const String&)const)&NamedPropertyContainer::getPtr )
.def( "get", &getProperty )
+ .def( "get", &getPropertyByIndex, adopt(result) )
+ .property("size", &NamedPropertyContainer::size)
+
// For native Lua types which can simply mapped to C++:
.def( "create", (PropertyBase*(*)(NamedPropertyContainer&,const char*,const boost::any&))&createAndAddPropertyFromAny )
// For all other 'custom' registered and unknown types:
Modified: trunk/yake/src/ent/object.cpp
===================================================================
--- trunk/yake/src/ent/object.cpp 2007-08-28 17:53:02 UTC (rev 1824)
+++ trunk/yake/src/ent/object.cpp 2007-08-28 23:34:11 UTC (rev 1825)
@@ -32,7 +32,7 @@
IMPL_OBJECT(Object)
- Object::Object() : propertyAcess_(properties_)
+ Object::Object() : propertyAcess_(*this,properties_)
{
properties().add("id", property::makePointerProperty<ObjectId>(&id_) );
}
@@ -124,7 +124,8 @@
events_[ id ] = evt;
return evt.get();
}
- Object::PropertyAccess::PropertyAccess(NamedProperties& props) : properties_(props)
+ Object::PropertyAccess::PropertyAccess(Object& owner,NamedProperties& props) :
+ owner_(owner), properties_(props)
{
}
PropertyPtr Object::PropertyAccess::get(const PropertyId& id) const
@@ -143,6 +144,14 @@
{
properties_.add( id, prop );
}
+ Object& Object::PropertyAccess::owner()
+ {
+ return owner_;
+ }
+ const Object& Object::PropertyAccess::owner() const
+ {
+ return owner_;
+ }
}
}
Modified: trunk/yake/yake/bindings.lua/detail/property.lua.h
===================================================================
--- trunk/yake/yake/bindings.lua/detail/property.lua.h 2007-08-28 17:53:02 UTC (rev 1824)
+++ trunk/yake/yake/bindings.lua/detail/property.lua.h 2007-08-28 23:34:11 UTC (rev 1825)
@@ -44,6 +44,11 @@
PropertyBase* createAndAddPropertyFromAny(NamedPropertyContainer& ctr, const char* name, const boost::any& o);
PropertyBase* getProperty(NamedPropertyContainer& ctr, const char* name);
bool setPropertyValue(PropertyBase& prop, const boost::any& value);
+ struct NamePropertyPair
+ {
+ std::string name;
+ property::PropertyBase* prop;
+ };
} // namespace property
} // namespace yake
Modified: trunk/yake/yake/ent/object.h
===================================================================
--- trunk/yake/yake/ent/object.h 2007-08-28 17:53:02 UTC (rev 1824)
+++ trunk/yake/yake/ent/object.h 2007-08-28 23:34:11 UTC (rev 1825)
@@ -104,8 +104,9 @@
friend struct LuaBinder;
friend struct Object;
private:
- PropertyAccess(NamedProperties&);
+ PropertyAccess(Object&,NamedProperties&);
NamedProperties& properties_;
+ Object& owner_;
public:
PropertyPtr get(const PropertyId&) const;
bool has(const PropertyId&) const;
@@ -113,6 +114,8 @@
void add(const PropertyId&, PropertyPtr); // <- may throw on error!
size_t size() const
{ return properties_.size(); }
+ Object& owner();
+ const Object& owner() const;
};
PropertyAccess& properties();
const PropertyAccess& properties() const;
Modified: trunk/yake/yake/property/detail/property.impl.h
===================================================================
--- trunk/yake/yake/property/detail/property.impl.h 2007-08-28 17:53:02 UTC (rev 1824)
+++ trunk/yake/yake/property/detail/property.impl.h 2007-08-28 23:34:11 UTC (rev 1825)
@@ -26,7 +26,7 @@
*/
#ifndef YAKE_PROPERTY_IMPL_H
#define YAKE_PROPERTY_IMPL_H
-
+
#include <yake/base/type_info.h>
#include "../prerequisites.h"
#include "../accessors.h"
@@ -44,9 +44,9 @@
/** */
struct PropertyBase : public boost::noncopyable
{
- PropertyBase( const String& type,
- const std::type_info* typeInfo) :
- typeName_(type),
+ PropertyBase( const String& type,
+ const std::type_info* typeInfo) :
+ typeName_(type),
typeInfo_(typeInfo)
{
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <psy...@us...> - 2007-08-29 22:58:31
|
Revision: 1829
http://yake.svn.sourceforge.net/yake/?rev=1829&view=rev
Author: psyclonist
Date: 2007-08-29 15:58:33 -0700 (Wed, 29 Aug 2007)
Log Message:
-----------
* [bindings.lua] added more bindings for yake.graphics and yake.graphicsOGRE
* [bindings.lua] improved bindings for object/entity properties and events
* various small improvements in bindings.lua, ent, property and premake scripts
Modified Paths:
--------------
trunk/yake/common/media/scripts/o_access.lua
trunk/yake/samples/ent/sampleEntFsm/demo.cpp
trunk/yake/scripts/premake/config.lua
trunk/yake/scripts/premake/yake.lua
trunk/yake/src/bindings.lua/detail/ent.lua.cpp
trunk/yake/src/bindings.lua/detail/graphics.lua.cpp
trunk/yake/src/bindings.lua/detail/res.lua.cpp
trunk/yake/src/ent/object.cpp
trunk/yake/src/ent/object_mgr.cpp
trunk/yake/src/ent/trigger.cpp
trunk/yake/yake/ent/object.h
trunk/yake/yake/ent/object_mgr.h
trunk/yake/yake/ent/trigger.h
trunk/yake/yake/property/property_container.h
Added Paths:
-----------
trunk/yake/common/media/scripts/entityeventaccess.lua
trunk/yake/common/media/scripts/entitypropertyaccess.lua
Added: trunk/yake/common/media/scripts/entityeventaccess.lua
===================================================================
--- trunk/yake/common/media/scripts/entityeventaccess.lua (rev 0)
+++ trunk/yake/common/media/scripts/entityeventaccess.lua 2007-08-29 22:58:33 UTC (rev 1829)
@@ -0,0 +1,91 @@
+--print("entityeventaccess.lua:START")
+
+-- @param t (table) table to wrap (can be empty)
+-- @param access () object of type ent.Object.PropertyAccess (bindings.lua:ent) or
+-- of type property.NamedPropertyContainer (bindings.lua:property).
+-- @param implicitCreation (boolean)
+-- @return nothing
+function wrapEventsTable(t,access,implicitCreation)
+ t.list = {}
+ t.accessor = access
+ assert( t.accessor )
+ t.create = function(self,k,v)
+ local p = self.accessor:create(k,v)
+ assert( p ~= nil )
+
+ -- @todo really provide this accessor a la __newindex and rawset below???
+ rawset(t.list,k,p)
+
+ return p
+ end
+
+ --@todo loop through all existing properties in propAccess and
+ -- create an accessor (with rawset) in t.list for each key.
+ -- same as in t.create() or __newindex().
+ --print(type(access.size))
+ --print(access.size)
+ for k = 1, access.size do
+ local p = access:get(k)
+ assert( p ~= nil )
+ --print("exist:",p.name)
+ rawset(t.list,p.name,p)
+ end
+
+ --
+ if implicitCreation == nil then
+ --print("defaulting")
+ implicitCreation = true
+ end
+ assert( type(implicitCreation) == "boolean" )
+ print("events implicitCreation:",implicitCreation)
+
+ setmetatable(t, {
+ __index = function(t,k)
+ assert( t.accessor ~= nil )
+ --print("INDEX",t,k)
+ if type(k) ~= "string" then
+ print("events __index -> ERROR: key is not of type 'string' but of type '"..type(k).."'!")
+ return nil
+ end
+ --print("GET",k)
+ local p = t.accessor:get(k)
+ --print("=",type(p))
+ assert( p~= nil )
+ if p then
+ return p
+ end
+ return nil
+ end,
+ __newindex = function(t,k,v)
+ --print("NEWINDEX",t,"'"..tostring(k).."' ->",type(k),"value=",v)
+
+ if type(k) ~= "string" then
+ --print("-> ERROR: key is not a string!")
+ return nil
+ end
+ local exists = t.accessor:get(k)
+ if exists then
+ --print("=> EXISTS")
+ exists:set(v)
+ return true
+ end
+ print(implicitCreation)
+ if implicitCreation then
+ local p = t.accessor:create(k,v)
+ assert( p ~= nil )
+
+ -- @todo really provide an accessor???
+ rawset(t.list,k,p)
+
+ return true
+ else
+ return false
+ end
+ end
+ })
+end
+--local bool demo_uses_implicit_creation = true -- set to true/false to test the different policies
+-- setup properties table
+--wrapPropertiesTable(properties,props,demo_uses_implicit_creation)
+
+--print("entityeventaccess.lua:END")
\ No newline at end of file
Added: trunk/yake/common/media/scripts/entitypropertyaccess.lua
===================================================================
--- trunk/yake/common/media/scripts/entitypropertyaccess.lua (rev 0)
+++ trunk/yake/common/media/scripts/entitypropertyaccess.lua 2007-08-29 22:58:33 UTC (rev 1829)
@@ -0,0 +1,89 @@
+--print("entitypropertyaccess.lua:START")
+
+-- @param t (table) table to wrap (can be empty)
+-- @param propAccess () object of type ent.Object.PropertyAccess (bindings.lua:ent) or
+-- of type property.NamedPropertyContainer (bindings.lua:property).
+-- @param implicitCreation (boolean)
+-- @return nothing
+function wrapPropertiesTable(t,propAccess,implicitCreation)
+ t.list = {}
+ t.accessor = propAccess
+ assert( t.accessor )
+ t.create = function(self,k,v)
+ local p = self.accessor:create(k,v)
+ assert( p ~= nil )
+
+ -- @todo really provide this accessor a la __newindex and rawset below???
+ rawset(t.list,k,p)
+
+ return p
+ end
+
+ --@todo loop through all existing properties in propAccess and
+ -- create an accessor (with rawset) in t.list for each key.
+ -- same as in t.create() or __newindex().
+ --print(type(propAccess.size))
+ --print(propAccess.size)
+ for k = 1, propAccess.size do
+ local p = propAccess:get(k)
+ assert( p ~= nil )
+ --print("exist:",p.name)
+ rawset(t.list,p.name,p)
+ end
+
+ --
+ if implicitCreation == nil then
+ --print("defaulting")
+ implicitCreation = true
+ end
+ assert( type(implicitCreation) == "boolean" )
+ --print(implicitCreation)
+
+ setmetatable(t, {
+ __index = function(t,k)
+ assert( t.accessor ~= nil )
+ --print("INDEX",t,k)
+ if type(k) ~= "string" then
+ print("properties __index -> ERROR: key is not of type 'string' but of type '"..type(k).."'!")
+ return nil
+ end
+ local p = t.accessor:get(k)
+ assert( p ~= nil )
+ if p then
+ return p:get()
+ end
+ return nil
+ end,
+ __newindex = function(t,k,v)
+ --print("NEWINDEX",t,"'"..tostring(k).."' ->",type(k),"value=",v)
+
+ if type(k) ~= "string" then
+ --print("-> ERROR: key is not a string!")
+ return nil
+ end
+ local exists = t.accessor:get(k)
+ if exists then
+ --print("=> EXISTS")
+ exists:set(v)
+ return true
+ end
+ print(implicitCreation)
+ if implicitCreation then
+ local p = t.accessor:create(k,v)
+ assert( p ~= nil )
+
+ -- @todo really provide an accessor???
+ rawset(t.list,k,p)
+
+ return true
+ else
+ return false
+ end
+ end
+ })
+end
+--local bool demo_uses_implicit_creation = true -- set to true/false to test the different policies
+-- setup properties table
+--wrapPropertiesTable(properties,props,demo_uses_implicit_creation)
+
+--print("entitypropertyaccess.lua:END")
\ No newline at end of file
Modified: trunk/yake/common/media/scripts/o_access.lua
===================================================================
--- trunk/yake/common/media/scripts/o_access.lua 2007-08-29 17:02:33 UTC (rev 1828)
+++ trunk/yake/common/media/scripts/o_access.lua 2007-08-29 22:58:33 UTC (rev 1829)
@@ -1,133 +1,62 @@
print("> Starting object script...");
-function startup()
- --this:fsm("main"):connectTo("alive",fn) -- connects to 'enter', 'tick', 'exit'
- --this:fsm("main"):connectToEnter("dead",fn) -- connects to 'enter' only
- --this:fsm("main"):connect("alive", fnEnter, fnTick, fnExit)
- this:events("spawn"):connect(
- function()
-
- end
- )
-end
-properties = {}
-properties_mt = {}
-
-properties_mt.__index = function(t,k)
- print("INDEX",t,k)
- --for u,v in pairs(t) do print(u,v) end
- --return events[k]
- return this:properties():get(k):get()
-end
-properties_mt.__newindex = function(t,k,v)
- print("NEWINDEX",t,"'"..tostring(k).."'",v)
- --rawset(t,k,v)
- --for u,v in pairs(t) do print(u,v) end
- local exists = this:properties():get(k)
- if exists then
- print("EXISTS")
- exists:set(v)
- return true
+-- replace loadfile and dofile with yake.loadfile and yake.dofile.
+-- the replacements use yake's resource system to locate the files.
+yake.old_loadfile = loadfile
+yake.old_dofile = dofile
+loadfile = nil
+dofile = nil
+yake.dofile = function(path)
+ local locator = yake.res.global.sourceManager
+ assert( locator ~= nil )
+ local succ = locator:find(path)
+ print(succ)
+ assert( succ.valid )
+ if succ.valid then
+ local f = yake.old_loadfile(succ.location)
+ assert( f )
+ return f() -- execute!
end
- this:properties():create(k,v)
- return true
+ return nil
end
-setmetatable(properties, properties_mt)
-properties.s = 1
-properties["s"] = 2
-print(properties["s"])
+print("* loading accessor scripts...")
+yake.dofile("entitypropertyaccess.lua")
+yake.dofile("entityeventaccess.lua")
-event = {
- on_spawn = function()
- print(" script event.on_spawn")
- this:properties():create("ticks",0)
- end,
- on_tick = function()
- print(" script event.on_tick")
- end,
- on_die = function()
- print(" script event.on_die")
- end,
- -- various:
- onArrived = function() --triggered as a result of "go to"
- end,
- -- Trigger
- on_toggle = function()
- print("event.on_toggle")
- end
-}
-fsm = {
- main = {
- states = {
- awakening,
- alive,
- dead
- },
- transitions = {
- {awakening,"spawn",alive},
- {alive,"die",dead}
- }
- }
-}
-state = {
- off = {
- on_enter = function()
- print("state.off.enter()")
+--local thisTrigger = yake.asTrigger(this)
+local no_implicit_creation = false
- this:setCondition(function() return (this:property("ticks"):get() >= 1 and this:property("ticks"):get() <= 3) end)
- this:events():get("onTriggered"):connect( function(a) print("TRIGGER:onTriggered:",a) end )
- end,
- on_tick = function()
- local ticks = this:property("ticks")
- if ticks then
- ticks:set( ticks:get() + 1 )
- end
- print("state.off.tick()") --,ticks:get()
- --
- --if (state.off.ticks == 1) then
- -- this:processFsmEvent("trigger")
- --end
- --
- --this:events():get("onTriggered"):fire(42)
- end,
- on_exit = function()
- print("state.off.exit()")
- end
- }
- ,
- on = {
- on_enter = function()
- print("state.on.enter()")
- end,
- on_tick = function()
- local ticks = this:property("ticks")
- if ticks then
- ticks:set( ticks:get() + 1 )
- end
- print("state.on.tick()") --,ticks:get()
- end,
- on_exit = function()
- print("state.on.exit()")
- end
- }
- ,
- dead = {
- on_enter = function()
- print(" script state.dead.on_enter")
- end,
- on_tick = function()
- print(" script state.dead.on_tick")
- end,
- on_exit = function()
- print(" script state.dead.on_exit")
- end
- }
-}
+properties = {}
+wrapPropertiesTable(properties,this:properties(),no_implicit_creation)
+assert( properties.accessor )
+
+events = {}
+wrapEventsTable(events,this:events(),no_implicit_creation)
+assert( events.accessor )
+
+--
+function onTick()
+ print(" script on_tick",properties.ticks)
+ properties.ticks = properties.ticks + 1
+ --properties.doesnotexist = properties.ticks -- <- results in Luabind exception if property does not exist
+end
+function startup()
+ -- common ent::Object events
+ events.spawn:connect( function() print(" script on_spawn ") end )
+ events.tick:connect( onTick )
+ events.preDestroy:connect( function() print(" script on_preDestroy") end )
+
+ -- ent::Triggere stuff
+ properties:create("ticks",0) -- create property of type 'number'
+ this:setCondition(function() return (properties.ticks >= 1 and properties.ticks <= 3) end)
+ events.onTriggered:connect( function(a) print(" script on_triggered",a) end )
+end
print("> Object script up.");
function main()
- print("main()")
+ print(" script main()")
+ startup()
end
Modified: trunk/yake/samples/ent/sampleEntFsm/demo.cpp
===================================================================
--- trunk/yake/samples/ent/sampleEntFsm/demo.cpp 2007-08-29 17:02:33 UTC (rev 1828)
+++ trunk/yake/samples/ent/sampleEntFsm/demo.cpp 2007-08-29 22:58:33 UTC (rev 1829)
@@ -283,6 +283,7 @@
*/
// clean up
+ objMgr.destroyAllObjects(); // <- may trigger Lua callbacks.
exappObjInitializer.reset();
luaSys.reset();
}
Modified: trunk/yake/scripts/premake/config.lua
===================================================================
--- trunk/yake/scripts/premake/config.lua 2007-08-29 17:02:33 UTC (rev 1828)
+++ trunk/yake/scripts/premake/config.lua 2007-08-29 22:58:33 UTC (rev 1829)
@@ -55,6 +55,7 @@
ENABLE_LUA_PROPERTY = true -- 'property' binder (with specialization for string based indexing)
ENABLE_LUA_ENT = true -- 'ent' binder (requires BASE, MODEL and PROPERTY binders!)
ENABLE_LUA_GRAPHICS = true
+ENABLE_LUA_GRAPHICS_OGRE = true
ENABLE_LUA_PHYSICS = true
ENABLE_LUA_INPUT = true
ENABLE_LUA_RAF = true -- example application framework
Modified: trunk/yake/scripts/premake/yake.lua
===================================================================
--- trunk/yake/scripts/premake/yake.lua 2007-08-29 17:02:33 UTC (rev 1828)
+++ trunk/yake/scripts/premake/yake.lua 2007-08-29 22:58:33 UTC (rev 1829)
@@ -74,6 +74,7 @@
f:write("#define YAKE_ENABLE_LUA_ENT " .. bool_to_int(ENABLE_LUA_ENT) .. "\n")
f:write("#define YAKE_ENABLE_LUA_PROPERTY " .. bool_to_int(ENABLE_LUA_PROPERTY) .. "\n")
f:write("#define YAKE_ENABLE_LUA_GRAPHICS " .. bool_to_int(ENABLE_LUA_GRAPHICS) .. "\n")
+ f:write("#define YAKE_ENABLE_LUA_GRAPHICS_OGRE " .. bool_to_int(ENABLE_LUA_GRAPHICS_OGRE) .. "\n")
f:write("#define YAKE_ENABLE_LUA_PHYSICS " .. bool_to_int(ENABLE_LUA_PHYSICS) .. "\n")
f:write("#define YAKE_ENABLE_LUA_INPUT " .. bool_to_int(ENABLE_LUA_INPUT) .. "\n")
f:write("#define YAKE_ENABLE_LUA_RAF " .. bool_to_int(ENABLE_LUA_RAF) .. "\n")
Modified: trunk/yake/src/bindings.lua/detail/ent.lua.cpp
===================================================================
--- trunk/yake/src/bindings.lua/detail/ent.lua.cpp 2007-08-29 17:02:33 UTC (rev 1828)
+++ trunk/yake/src/bindings.lua/detail/ent.lua.cpp 2007-08-29 22:58:33 UTC (rev 1829)
@@ -73,6 +73,17 @@
typedef luabind::class_<Object::PropertyAccess> LuabindClass_Object_PropertyAccess;
//-------------------------------------------------------------------------
+ typedef std::pair<Object::Event::ID,Object::Event::pointer> Object_NameEventPair;
+ static Object_NameEventPair* Object_EventAccess_getByIndex(Object::EventAccess& acc, int index)
+ {
+ index -= 1; // Lua arrays usually start with 1, so convert to 0-offset-array.
+ if (index < 0 || index > acc.size())
+ return 0;
+ Object_NameEventPair ret = acc.__getByIndex(index);
+ if (ret.first.empty())
+ return 0;
+ return new Object_NameEventPair(ret);
+ }
static void Object_Event_fire_noparams(Object::Event& evt)
{
evt.fire();
@@ -264,9 +275,15 @@
//.def( "fire", &Object::Event::fire ) // with 1 param
.def( "fire", &Object_Event_fire_1param )
,
- class_<Object::EventAccess>("Object::PropertyAccess")
+ class_<Object_NameEventPair>("Object_NameEventPair")
+ .def_readonly( "name", &Object_NameEventPair::first)
+ .def_readonly( "event", &Object_NameEventPair::second)
+ ,
+ class_<Object::EventAccess>("Object::EventAccess")
+ .property( "size", &Object::EventAccess::size )
.def( "has", &Object::EventAccess::has )
.def( "get", &Object::EventAccess::get )
+ .def( "get", &Object_EventAccess_getByIndex, adopt(result) )
.def( "add", &Object::EventAccess::add )
.def( "create", &Object::EventAccess::createAndAdd )
];
@@ -312,6 +329,12 @@
module( YAKE_MODEL_MODULE )
[
+ def( "asEntity", &Entity::cast ),
+ def( "asTrigger", &Trigger::cast )
+ ];
+
+ module( YAKE_MODEL_MODULE )
+ [
class_<ObjectManager>( "ObjectManager" )
.def( "makeObject", (Object*(ObjectManager::*)(const String&))&ObjectManager::makeObject )
.def( "getObject", &ObjectManager::getObject )
@@ -386,30 +409,48 @@
ent->getFsmVM()->execute("print('initializing...')");
ent->getFsmVM()->execute( startScript_ );
- ent->getFsmVM()->execute("c = coroutine.create(main)\ncoroutine.resume(c,1)");
+ scripting::LuaVM* vm = static_cast<scripting::LuaVM*>(ent->getFsmVM().get());
+ YAKE_ASSERT( vm );
+ //ent->getFsmVM()->execute("c = coroutine.create(main)\ncoroutine.resume(c,1)");
+ String err;
+ try
+ {
+ luabind::call_function<void>(vm->getLuaState(),"main");
+ }
+ catch (std::exception& ex)
+ {
+ err = ex.what();
+ YAKE_LOG_ERROR("ent.lua",String("LuaFsmObjectListener.onInit:") + err);
+ }
+ if (!err.empty())
+ YAKE_EXCEPT(err);
}
}
void LuaFsmObjectListener::onTick(Object& obj)
{
+#if 0
Entity* ent = Entity::cast(&obj);
if (ent)
{
scripting::VMPtr vm = ent->getFsmVM();
vm->execute("event.on_tick()");
- //vm->execute("state." + ent->getCurrentFsmState() + ".on_tick()");
detail::executeOfTable_2(*vm,"state",ent->getCurrentFsmState(),"on_tick");
}
+#endif
}
void LuaFsmObjectListener::onFsmEventHandled(Object& obj, const object_fsm&, const object_fsm::event_type& evt)
{
+#if 0
Entity* ent = Entity::cast(&obj);
if (ent)
{
ent->getFsmVM()->execute("event.on_" + evt + "()");
}
+#endif
}
void LuaFsmObjectListener::onFsmEnterState(Object& obj,/*const std::string& fsmName, */const object_fsm&, const object_fsm::state_type& state)
{
+#if 0
Entity* ent = Entity::cast(&obj);
if (ent)
{
@@ -417,9 +458,11 @@
YAKE_ASSERT( vm );
detail::executeOfTable_2(*vm,"state",state,"on_enter");
}
+#endif
}
void LuaFsmObjectListener::onFsmExitState(Object& obj,/*const std::string& fsmName, */const object_fsm&, const object_fsm::state_type& state)
{
+#if 0
Entity* ent = Entity::cast(&obj);
if (ent)
{
@@ -427,6 +470,7 @@
YAKE_ASSERT( vm );
detail::executeOfTable_2(*vm,"state",state,"on_exit");
}
+#endif
}
} // namespace detail
Modified: trunk/yake/src/bindings.lua/detail/graphics.lua.cpp
===================================================================
--- trunk/yake/src/bindings.lua/detail/graphics.lua.cpp 2007-08-29 17:02:33 UTC (rev 1828)
+++ trunk/yake/src/bindings.lua/detail/graphics.lua.cpp 2007-08-29 22:58:33 UTC (rev 1829)
@@ -25,6 +25,8 @@
------------------------------------------------------------------------------------
*/
#include <yake/config.h>
+#undef YAKE_ENABLE_LUA_GRAPHICS_OGRE
+#define YAKE_ENABLE_LUA_GRAPHICS_OGRE 0
#if YAKE_ENABLE_LUA_GRAPHICS == 1
// See task.lua.cpp
@@ -35,6 +37,16 @@
#include <yake/base/templates/yakeSmartAssert.h>
#include <yake/base/yake.h>
#include <yake/graphics/yakeGraphics.h>
+#if YAKE_ENABLE_LUA_GRAPHICS_OGRE == 1
+#include <yake/plugins/graphicsOgre/yakeGraphicsSystem.h>
+#include <yake/plugins/graphicsOgre/graphicsOgreNode.h>
+#include <yake/plugins/graphicsOgre/graphicsOgreEntity.h>
+#include <../../../dependencies/ogrenew/include/OgreNode.h>
+#include <../../../dependencies/ogrenew/include/OgreSceneNode.h>
+#include <../../../dependencies/ogrenew/include/OgreEntity.h>
+#include <../../../dependencies/ogrenew/include/OgreSubEntity.h>
+#include <../../../dependencies/ogrenew/include/OgreSceneManager.h>
+#endif
#include <yake/bindings.lua/detail/private.h>
#include <yake/bindings.lua/common/yake.lua.any_converter.h>
@@ -45,6 +57,33 @@
namespace yake {
namespace graphics {
+#if YAKE_ENABLE_LUA_GRAPHICS_OGRE == 1
+ struct OgreSubEntityHolder
+ {
+ Ogre::SubEntity* subEntity_;
+ static bool isVisible(const OgreSubEntityHolder& holder)
+ {
+ return (holder.subEntity_ ? holder.subEntity_->isVisible() : false);
+ }
+ static void setVisible(const OgreSubEntityHolder& holder, const bool yes)
+ {
+ if (holder.subEntity_)
+ holder.subEntity_->setVisible( yes );
+ }
+ };
+ OgreSubEntityHolder OgreEntity_getSubEntity_byIndex(const Ogre::Entity& entity, unsigned int index)
+ {
+ OgreSubEntityHolder holder;
+ holder.subEntity_ = entity.getSubEntity(index);
+ return holder;
+ }
+ OgreSubEntityHolder OgreEntity_getSubEntity(const Ogre::Entity& entity, const Ogre::String& name)
+ {
+ OgreSubEntityHolder holder;
+ holder.subEntity_ = entity.getSubEntity(name);
+ return holder;
+ }
+#endif
ISceneNode* ISceneNode_getChildByName_NameOnly(ISceneNode* n, const String& name)
{
return (n ? n->getChildByName(name,false) : 0);
@@ -142,6 +181,8 @@
.def("rotate", (void(ICamera::*)(const Quaternion&))&ICamera::rotate)
.def("rotate", (void(ICamera::*)(const Vector3&,real))&ICamera::rotate)
.property("aspectRatio", &ICamera::getAspectRatio, &ICamera::setAspectRatio)
+ .property("farClipDistance", &ICamera::getFarClipDistance, &ICamera::setFarClipDistance)
+ .property("nearClipDistance", &ICamera::getNearClipDistance, &ICamera::setNearClipDistance)
,
class_<IViewport>("Viewport")
//@todo
@@ -162,6 +203,50 @@
.def("pickEntity", &IWorld::pickEntity)
]
];
+#if YAKE_ENABLE_LUA_GRAPHICS_OGRE == 1
+ module( YAKE_GRAPHICS_MODULE )
+ [
+ namespace_("ogre")
+ [
+ class_<Ogre::SceneManager>("SceneManager")
+ ,
+ class_<Ogre::Node>("Node")
+ ,
+ class_<Ogre::SceneNode,Ogre::Node>("SceneNode")
+ .property("creator", &Ogre::SceneNode::getCreator)
+ .def("setVisible", &Ogre::SceneNode::setVisible)
+ ,
+ class_<Ogre::MovableObject>("MovableObject")
+ ,
+ class_<Ogre::Renderable>("Renderable")
+ ,
+ //@todo fails due to protected d'tor: class_<Ogre::SubEntity,Ogre::Renderable>("SubEntity")
+ //,
+ class_<OgreSubEntityHolder>("OgreSubEntityHolder")
+ .property("visible", &OgreSubEntityHolder::isVisible, &OgreSubEntityHolder::setVisible)
+ ,
+ class_<Ogre::Entity,Ogre::MovableObject>("Entity")
+ //.def("getSubEntity", (Ogre::SubEntity*(Ogre::Entity::*)(unsigned int)const)&Ogre::Entity::getSubEntity)
+ //.def("getSubEntity", (Ogre::SubEntity*(Ogre::Entity::*)(const Ogre::String& name)const)&Ogre::Entity::getSubEntity)
+ .def("getSubEntity", &OgreEntity_getSubEntity_byIndex)
+ .def("getSubEntity", &OgreEntity_getSubEntity)
+ ]
+ ];
+#endif
+#if YAKE_ENABLE_LUA_GRAPHICS_OGRE == 1
+ module( YAKE_GRAPHICS_MODULE )
+ [
+ namespace_("yake")
+ [
+ class_<ogre3d::OgreNode,ISceneNode>("OgreNode")
+ .property("parent", &ogre3d::OgreNode::_getParent)
+ .def("asOgre", &ogre3d::OgreNode::getSceneNode_)
+ ,
+ class_<ogre3d::OgreEntity,IEntity>("OgreEntity")
+ .def("asOgre", &ogre3d::OgreEntity::getEntity_)
+ ]
+ ];
+#endif
}
YAKE_WRAP_BINDER(graphics,::yake::graphics::bind);
Modified: trunk/yake/src/bindings.lua/detail/res.lua.cpp
===================================================================
--- trunk/yake/src/bindings.lua/detail/res.lua.cpp 2007-08-29 17:02:33 UTC (rev 1828)
+++ trunk/yake/src/bindings.lua/detail/res.lua.cpp 2007-08-29 22:58:33 UTC (rev 1829)
@@ -46,6 +46,11 @@
namespace yake {
namespace res {
+ std::ostream& operator << (std::ostream& out, const FindResult& rhs)
+ {
+ out << "FindResult(valid=" << rhs.isValid() << ",location='" << rhs.location() << "')";
+ return out;
+ }
void bind( lua_State* L )
{
@@ -85,6 +90,7 @@
.property("location",&FindResult::location)
.property("source",&FindResult::source)
.property("valid",&FindResult::isValid)
+ .def(tostring(const_self))
,
class_<SourceManager>("SourceManager")
.def(constructor<>())
Modified: trunk/yake/src/ent/object.cpp
===================================================================
--- trunk/yake/src/ent/object.cpp 2007-08-29 17:02:33 UTC (rev 1828)
+++ trunk/yake/src/ent/object.cpp 2007-08-29 22:58:33 UTC (rev 1829)
@@ -35,7 +35,22 @@
Object::Object() : propertyAcess_(*this,properties_)
{
properties().add("id", property::makePointerProperty<ObjectId>(&id_) );
+ events().createAndAdd("spawn");
+ events().createAndAdd("tick");
+ events().createAndAdd("preDestroy");
}
+ void Object::init()
+ {
+ listeners_init(*this);
+ onInit();
+ events().get("spawn")->fire();
+ }
+ void Object::tick()
+ {
+ listeners_tick(*this);
+ onTick();
+ events().get("tick")->fire();
+ }
void Object::setId(const ObjectId& id)
{
YAKE_ASSERT( id != MessageTraits::kNoSource )(MessageTraits::kNoSource)(id);
@@ -75,6 +90,17 @@
}
void Object::destroy()
{
+ events().get("preDestroy")->fire();
+ this->onPreDestroy();
+
+ /*YAKE_FOR_EACH(EventAccess::iterator,it,eventAccess_.events_)
+ {
+ EventAccess::storage evt = it->second;
+ evt->disconnectAll();
+ }*/
+ eventAccess_.events_.clear();
+ properties_.clear();
+
for (listenerconnetion_list::iterator it = listenerConnections_.begin(), itend = listenerConnections_.end();
it != itend; ++it)
{
@@ -101,6 +127,18 @@
Object::Event::Event()
{
}
+ Object::Event::~Event()
+ {
+ disconnectAll();
+ }
+ void Object::Event::disconnectAll()
+ {
+ sig_.disconnect_all_slots();
+ }
+ size_t Object::EventAccess::size() const
+ {
+ return events_.size();
+ }
bool Object::EventAccess::has(const Event::ID& id) const
{
return (events_.find(id) != events_.end());
@@ -110,6 +148,15 @@
EventMap::iterator it = events_.find(id);
return (it == events_.end()) ? 0 : it->second.get();
}
+ std::pair<Object::Event::ID,Object::Event::pointer> Object::EventAccess::__getByIndex(const size_t index)
+ {
+ if (events_.empty() || index >= events_.size()) //@todo assert?
+ return std::pair<Object::Event::ID,Object::Event::pointer>();
+ EventMap::iterator it = events_.begin();
+ for (size_t i=0; i<index; ++i, ++it)
+ ;
+ return std::pair<Object::Event::ID,Object::Event::pointer>(it->first,it->second.get());
+ }
void Object::EventAccess::add(const Event::ID& id, Event::pointer evt)
{
YAKE_ASSERT( !has(id) ).debug("duplicate entry - replacing original");
Modified: trunk/yake/src/ent/object_mgr.cpp
===================================================================
--- trunk/yake/src/ent/object_mgr.cpp 2007-08-29 17:02:33 UTC (rev 1828)
+++ trunk/yake/src/ent/object_mgr.cpp 2007-08-29 22:58:33 UTC (rev 1829)
@@ -30,6 +30,13 @@
namespace yake {
namespace ent {
+ ObjectManager::ObjectManager()
+ {
+ }
+ ObjectManager::~ObjectManager()
+ {
+ destroyAllObjects();
+ }
Object* ObjectManager::makeObject(const String& strClsId)
{
YAKE_ASSERT( !strClsId.empty() )(strClsId);
@@ -69,6 +76,19 @@
return obj;
}
+ void ObjectManager::destroyAllObjects()
+ {
+ YAKE_FOR_EACH(object_ptr_list::iterator, it, objs_)
+ {
+ Object* obj = *it;
+ YAKE_ASSERT( obj );
+
+ obj->destroy(); // <- triggers obj event 'preDestroy'
+ listeners_onDestroyObject( obj );
+ objMgr_.destroyObject( obj );
+ }
+ objs_.clear();
+ }
void ObjectManager::destroyObject(Object* obj)
{
YAKE_ASSERT( obj );
Modified: trunk/yake/src/ent/trigger.cpp
===================================================================
--- trunk/yake/src/ent/trigger.cpp 2007-08-29 17:02:33 UTC (rev 1828)
+++ trunk/yake/src/ent/trigger.cpp 2007-08-29 22:58:33 UTC (rev 1829)
@@ -36,6 +36,16 @@
{
cond_ = fn;
}
+ void Trigger::onPreDestroy()
+ {
+ // The reason we explicitely clear this condition here, is that
+ // the cond_ may be bound to certain objects (e.g. luabind::object)
+ // which need to be destroyed before (!) the object listeners are
+ // detached (e.g. the Lua object listener which manages the object's VMs).
+ // This can result in having a dangling object which tries to access resources
+ // (like the object's VMs) that have already been destroyed.
+ cond_.clear();
+ }
Trigger::Trigger()
{
this->attachListener( this, "this", ObjectListenerManager::kKeepOwnership );
Modified: trunk/yake/yake/ent/object.h
===================================================================
--- trunk/yake/yake/ent/object.h 2007-08-29 17:02:33 UTC (rev 1828)
+++ trunk/yake/yake/ent/object.h 2007-08-29 22:58:33 UTC (rev 1829)
@@ -81,16 +81,8 @@
{ return id_; }
// operations
- void init()
- {
- listeners_init(*this);
- onInit();
- }
- void tick()
- {
- listeners_tick(*this);
- onTick();
- }
+ void init();
+ void tick();
void destroy();
void processMessage(const int&);
@@ -128,8 +120,10 @@
struct YAKE_ENT_API Event : public noncopyable
{
friend struct EventAccess;
+ friend struct Object;
//private:
Event();
+ ~Event();
public:
typedef Event* pointer;
typedef String ID;
@@ -144,6 +138,8 @@
{ this->sig_(a0); }
void operator()(const param_type& a0 = param_type())
{ this->fire(a0); }
+
+ void disconnectAll();
private:
EventFireSignal sig_;
};
@@ -153,9 +149,17 @@
bool has(const Event::ID&) const;
void add(const Event::ID&, Event::pointer);
Event::pointer createAndAdd(const Event::ID&);
+ size_t size() const;
+
+ /** @note Mainly intended for internal use by the Lua bindings. */
+ std::pair<Event::ID,Event::pointer> __getByIndex(const size_t);
+
+ friend struct Object;
private:
typedef SharedPtr<Event> storage;
typedef std::map<Event::ID,storage> EventMap;
+ typedef EventMap::const_iterator const_iterator;
+ typedef EventMap::iterator iterator;
EventMap events_;
};
EventAccess& events();
@@ -163,6 +167,7 @@
protected:
virtual void onInit() {}
virtual void onTick() {}
+ virtual void onPreDestroy() {}
private:
ObjectId id_;
typedef std::deque<detail::ListenerConnection> listenerconnetion_list;
Modified: trunk/yake/yake/ent/object_mgr.h
===================================================================
--- trunk/yake/yake/ent/object_mgr.h 2007-08-29 17:02:33 UTC (rev 1828)
+++ trunk/yake/yake/ent/object_mgr.h 2007-08-29 22:58:33 UTC (rev 1829)
@@ -44,6 +44,8 @@
*/
struct YAKE_ENT_API ObjectManager : public ListenerManager<ObjectManagerListener>
{
+ ObjectManager();
+ virtual ~ObjectManager();
// operations
/** Creates an Object for the given clsId.
@@ -62,9 +64,12 @@
*/
Object* makeObject(const String& strClsId);
- /** Destroys the given Object. */
+ /** Destroys and removes the given Object. */
void destroyObject(Object*);
+ /** Do NOT call from within tick() ... */
+ void destroyAllObjects();
+
/** Returns the Object for the given id or ObjectId::kNull if the lookup failed.
*/
Object* getObject(const ObjectId objId) const;
Modified: trunk/yake/yake/ent/trigger.h
===================================================================
--- trunk/yake/yake/ent/trigger.h 2007-08-29 17:02:33 UTC (rev 1828)
+++ trunk/yake/yake/ent/trigger.h 2007-08-29 22:58:33 UTC (rev 1829)
@@ -45,6 +45,7 @@
private:
virtual void onTick();
+ virtual void onPreDestroy();
private:
virtual void onFsmEventHandled(Object&, const object_fsm&, const object_fsm::event_type&) {}
virtual void onFsmEnterState(Object&,/*const String& fsmName, */const object_fsm&, const object_fsm::state_type& state);
Modified: trunk/yake/yake/property/property_container.h
===================================================================
--- trunk/yake/yake/property/property_container.h 2007-08-29 17:02:33 UTC (rev 1828)
+++ trunk/yake/yake/property/property_container.h 2007-08-29 22:58:33 UTC (rev 1829)
@@ -80,7 +80,8 @@
bool has(const key_type& id) const;
size_t size() const
{ return properties_.size(); }
-
+ void clear()
+ { properties_.clear(); }
//
private:
typedef std::map<key_type,PropertyPtr> PropertyMap;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <psy...@us...> - 2007-09-04 17:17:58
|
Revision: 1832
http://yake.svn.sourceforge.net/yake/?rev=1832&view=rev
Author: psyclonist
Date: 2007-09-04 10:17:53 -0700 (Tue, 04 Sep 2007)
Log Message:
-----------
* [bindings.lua] extensive additions to the bindings for yake.ent, yake.graphics, yake.model and yake.base
* [ent/lua] added VolumeTrigger implementation completely scripted in Lua
* major API break: introduction of type Point3 which replaces Vector3 in the API when positions (or points) are meant.
* various API fixes
* added yake.Volume and yake.VolumeContainer (+ bindings for Lua)
Modified Paths:
--------------
trunk/yake/common/media/scripts/entitypropertyaccess.lua
trunk/yake/common/media/scripts/o_access.lua
trunk/yake/common/media/scripts/raf1.lua
trunk/yake/scripts/premake/samples.lua
trunk/yake/scripts/premake/yake.lua
trunk/yake/src/base/math/yakeMatrix3.cpp
trunk/yake/src/base/math/yakeQuaternion.cpp
trunk/yake/src/base/math/yakeRay.cpp
trunk/yake/src/base/math/yakeVector3.cpp
trunk/yake/src/bindings.lua/bindings.lua.cpp
trunk/yake/src/bindings.lua/detail/base.lua.cpp
trunk/yake/src/bindings.lua/detail/ent.lua.cpp
trunk/yake/src/bindings.lua/detail/graphics.lua.cpp
trunk/yake/src/bindings.lua/detail/model.lua.cpp
trunk/yake/src/bindings.lua/detail/physics.lua.cpp
trunk/yake/src/bindings.lua/detail/property.lua.cpp
trunk/yake/src/ent/entity.cpp
trunk/yake/src/ent/trigger.cpp
trunk/yake/src/graphics/yakeGraphicsSystem.cpp
trunk/yake/src/loader/yakeDotScene.cpp
trunk/yake/src/loader/yakeXODEParser.cpp
trunk/yake/src/model/yakeGraphicalDotSceneLoader.cpp
trunk/yake/src/model/yakeModelMovableLink.cpp
trunk/yake/src/plugins/graphicsOgre/graphicsOgreCamera.cpp
trunk/yake/src/plugins/graphicsOgre/graphicsOgreNode.cpp
trunk/yake/src/plugins/graphicsOgre/graphicsOgreParticleSystem.cpp
trunk/yake/src/plugins/inputOgreOIS/InputSystemOgreOIS.cpp
trunk/yake/src/plugins/physicsODE/OdeActor.cpp
trunk/yake/src/plugins/physicsODE/OdeAvatar.cpp
trunk/yake/src/plugins/physicsODE/OdeBallJoint.cpp
trunk/yake/src/plugins/physicsODE/OdeBody.cpp
trunk/yake/src/plugins/physicsODE/OdeFixedJoint.cpp
trunk/yake/src/plugins/physicsODE/OdeHinge2Joint.cpp
trunk/yake/src/plugins/physicsODE/OdeHingeJoint.cpp
trunk/yake/src/plugins/physicsODE/OdeRay.cpp
trunk/yake/src/plugins/physicsODE/OdeShapes.cpp
trunk/yake/src/plugins/physicsODE/OdeSliderJoint.cpp
trunk/yake/src/plugins/physicsODE/OdeUniversalJoint.cpp
trunk/yake/src/raf/yakeApplication.cpp
trunk/yake/yake/audio/yakeAudioSystem.h
trunk/yake/yake/base/math/yakeGeometry.h
trunk/yake/yake/base/math/yakeMatrix3.h
trunk/yake/yake/base/math/yakeQuaternion.h
trunk/yake/yake/base/math/yakeRay.h
trunk/yake/yake/base/yake.h
trunk/yake/yake/base/yakeMovable.h
trunk/yake/yake/bindings.lua/common/yake.lua.any_converter.h
trunk/yake/yake/ent/entity.h
trunk/yake/yake/ent/trigger.h
trunk/yake/yake/graphics/yakeGraphicalWorld.h
trunk/yake/yake/input/yakeInputSystem.h
trunk/yake/yake/loader/yakeDotScene.h
trunk/yake/yake/loader/yakeXODEParser.h
trunk/yake/yake/model/model_link.h
trunk/yake/yake/physics/yakePhysicsAffectors.h
trunk/yake/yake/physics/yakePhysicsAvatar.h
trunk/yake/yake/physics/yakePhysicsBody.h
trunk/yake/yake/physics/yakePhysicsJoint.h
trunk/yake/yake/physics/yakePhysicsShape.h
trunk/yake/yake/plugins/graphicsOgre/graphicsOgreCamera.h
trunk/yake/yake/plugins/graphicsOgre/graphicsOgreNode.h
trunk/yake/yake/plugins/graphicsOgre/yakePCH.h
trunk/yake/yake/plugins/inputOgreOIS/InputSystemOgreOIS.h
trunk/yake/yake/plugins/physicsODE/OdeActor.h
trunk/yake/yake/plugins/physicsODE/OdeAvatar.h
trunk/yake/yake/plugins/physicsODE/OdeBody.h
trunk/yake/yake/plugins/physicsODE/OdeJoint.h
trunk/yake/yake/plugins/physicsODE/OdeRay.h
trunk/yake/yake/plugins/physicsODE/OdeShapes.h
trunk/yake/yake/plugins/scriptingLua/ScriptingSystemLua.h
trunk/yake/yake/prop/rtti_class.h
trunk/yake/yake/scripting/yakeScriptingSystem.h
Added Paths:
-----------
trunk/yake/common/media/scripts/bind_resource_loaders.lua
trunk/yake/common/media/scripts/init_entity.lua
trunk/yake/common/media/scripts/o_entity.lua
trunk/yake/common/media/scripts/o_trigger2.lua
trunk/yake/common/media/scripts/raf2.lua
trunk/yake/src/base/math/yakeVolume.cpp
trunk/yake/yake/base/math/yakePoint3.h
trunk/yake/yake/base/math/yakeVolume.h
Added: trunk/yake/common/media/scripts/bind_resource_loaders.lua
===================================================================
--- trunk/yake/common/media/scripts/bind_resource_loaders.lua (rev 0)
+++ trunk/yake/common/media/scripts/bind_resource_loaders.lua 2007-09-04 17:17:53 UTC (rev 1832)
@@ -0,0 +1,24 @@
+
+if loadfile and dofile then
+ -- replace loadfile and dofile with yake.loadfile and yake.dofile.
+ -- the replacements use yake's resource system to locate the files.
+ yake.old_loadfile = loadfile
+ yake.old_dofile = dofile
+ loadfile = nil
+ dofile = nil
+ yake.dofile = function(path)
+ local locator = yake.res.global.sourceManager
+ assert( locator ~= nil, "global source manager not available" )
+ local succ = locator:find(path)
+ print(succ)
+ assert( succ.valid, "could not locate file " .. tostring(path) )
+ if succ.valid then
+ local f = yake.old_loadfile(succ.location)
+ assert( f )
+ return f() -- execute!
+ end
+ return nil
+ end
+else
+ assert( 1==0, "resource loaders already bound")
+end
Modified: trunk/yake/common/media/scripts/entitypropertyaccess.lua
===================================================================
--- trunk/yake/common/media/scripts/entitypropertyaccess.lua 2007-08-31 03:36:26 UTC (rev 1831)
+++ trunk/yake/common/media/scripts/entitypropertyaccess.lua 2007-09-04 17:17:53 UTC (rev 1832)
@@ -8,10 +8,10 @@
function wrapPropertiesTable(t,propAccess,implicitCreation)
t.list = {}
t.accessor = propAccess
- assert( t.accessor )
+ assert( t.accessor, "invalid accessor" )
t.create = function(self,k,v)
local p = self.accessor:create(k,v)
- assert( p ~= nil )
+ assert( p ~= nil, "failed to create" )
-- @todo really provide this accessor a la __newindex and rawset below???
rawset(t.list,k,p)
@@ -26,7 +26,7 @@
--print(propAccess.size)
for k = 1, propAccess.size do
local p = propAccess:get(k)
- assert( p ~= nil )
+ assert( p ~= nil, "could not get" )
--print("exist:",p.name)
rawset(t.list,p.name,p)
end
@@ -36,12 +36,12 @@
--print("defaulting")
implicitCreation = true
end
- assert( type(implicitCreation) == "boolean" )
+ assert( type(implicitCreation) == "boolean", "type mismatch, boolean expected" )
--print(implicitCreation)
setmetatable(t, {
__index = function(t,k)
- assert( t.accessor ~= nil )
+ assert( t.accessor ~= nil, "no accessor available" )
--print("INDEX",t,k)
if type(k) ~= "string" then
print("properties __index -> ERROR: key is not of type 'string' but of type '"..type(k).."'!")
@@ -70,7 +70,7 @@
print(implicitCreation)
if implicitCreation then
local p = t.accessor:create(k,v)
- assert( p ~= nil )
+ assert( p ~= nil, "failed to create" )
-- @todo really provide an accessor???
rawset(t.list,k,p)
Added: trunk/yake/common/media/scripts/init_entity.lua
===================================================================
--- trunk/yake/common/media/scripts/init_entity.lua (rev 0)
+++ trunk/yake/common/media/scripts/init_entity.lua 2007-09-04 17:17:53 UTC (rev 1832)
@@ -0,0 +1,39 @@
+print("> Starting init_entity.lua ...");
+
+-- replace loadfile and dofile with yake.loadfile and yake.dofile.
+-- the replacements use yake's resource system to locate the files.
+yake.old_loadfile = loadfile
+yake.old_dofile = dofile
+loadfile = nil
+dofile = nil
+yake.dofile = function(path)
+ local locator = yake.res.global.sourceManager
+ assert( locator ~= nil, "global source manager not available" )
+ local succ = locator:find(path)
+ print(succ)
+ assert( succ.valid, "could not locate file " .. tostring(path) )
+ if succ.valid then
+ local f = yake.old_loadfile(succ.location)
+ assert( f )
+ return f() -- execute!
+ end
+ return nil
+end
+
+
+print("* loading accessor scripts...")
+yake.dofile("entitypropertyaccess.lua")
+yake.dofile("entityeventaccess.lua")
+
+local no_implicit_creation = false
+
+properties = {}
+wrapPropertiesTable(properties,this:properties(),no_implicit_creation)
+assert( properties.accessor, "accessor not set" )
+
+events = {}
+wrapEventsTable(events,this:events(),no_implicit_creation)
+assert( events.accessor, "accessor not set" )
+
+--
+print("> init_entity.lua done.");
Modified: trunk/yake/common/media/scripts/o_access.lua
===================================================================
--- trunk/yake/common/media/scripts/o_access.lua 2007-08-31 03:36:26 UTC (rev 1831)
+++ trunk/yake/common/media/scripts/o_access.lua 2007-09-04 17:17:53 UTC (rev 1832)
@@ -1,4 +1,22 @@
print("> Starting object script...");
+local vols = yake.VolumeContainer()
+print("1")
+local sphere = yake.Sphere(2)
+print("2")
+vols:add(sphere)
+print("3")
+local pt = yake.Point3(0,0,0)
+print("4")
+print(sphere:intersectsWith(pt))
+print("5")
+print("numVols=",vols.size)
+print("6")
+print(vols:intersectsWith(pt))
+pt.x = 5
+print(vols:intersectsWith(pt))
+print("7")
+print(sphere:intersectsWith(pt))
+print("done")
-- replace loadfile and dofile with yake.loadfile and yake.dofile.
-- the replacements use yake's resource system to locate the files.
@@ -8,10 +26,10 @@
dofile = nil
yake.dofile = function(path)
local locator = yake.res.global.sourceManager
- assert( locator ~= nil )
+ assert( locator ~= nil, "global source manager not available" )
local succ = locator:find(path)
print(succ)
- assert( succ.valid )
+ assert( succ.valid, "could not locate file " .. tostring(path) )
if succ.valid then
local f = yake.old_loadfile(succ.location)
assert( f )
@@ -30,17 +48,26 @@
properties = {}
wrapPropertiesTable(properties,this:properties(),no_implicit_creation)
-assert( properties.accessor )
+assert( properties.accessor, "accessor not set" )
events = {}
wrapEventsTable(events,this:events(),no_implicit_creation)
-assert( events.accessor )
+assert( events.accessor, "accessor not set" )
--
function onTick()
print(" script on_tick",properties.ticks)
properties.ticks = properties.ticks + 1
--properties.doesnotexist = properties.ticks -- <- results in Luabind exception if property does not exist
+
+ if properties.volumes and properties.volumes.size > 0 then
+ --objMgr:getObjectsByClass(class)
+ local filter = yake.ObjectFilter()
+ filter:add( filterByClass("Player") )
+ filter:add( filterByClass("Entity",IgnoreDerived) )
+ filter.byClass("Player")
+ print(" - testing volumes")
+ end
end
function startup()
-- common ent::Object events
@@ -48,10 +75,13 @@
events.tick:connect( onTick )
events.preDestroy:connect( function() print(" script on_preDestroy") end )
- -- ent::Triggere stuff
+ -- ent::Trigger stuff
properties:create("ticks",0) -- create property of type 'number'
this:setCondition(function() return (properties.ticks >= 1 and properties.ticks <= 3) end)
events.onTriggered:connect( function(a) print(" script on_triggered",a) end )
+
+ -- VolumeTrigger stuff
+ properties:create("volumes", yake.VolumeContainer())
end
print("> Object script up.");
Added: trunk/yake/common/media/scripts/o_entity.lua
===================================================================
--- trunk/yake/common/media/scripts/o_entity.lua (rev 0)
+++ trunk/yake/common/media/scripts/o_entity.lua 2007-09-04 17:17:53 UTC (rev 1832)
@@ -0,0 +1,52 @@
+print("> Starting object script...");
+
+-- replace loadfile and dofile with yake.loadfile and yake.dofile.
+-- the replacements use yake's resource system to locate the files.
+yake.old_loadfile = loadfile
+yake.old_dofile = dofile
+loadfile = nil
+dofile = nil
+yake.dofile = function(path)
+ local locator = yake.res.global.sourceManager
+ assert( locator ~= nil, "global source manager not available" )
+ local succ = locator:find(path)
+ print(succ)
+ assert( succ.valid, "could not locate file " .. tostring(path) )
+ if succ.valid then
+ local f = yake.old_loadfile(succ.location)
+ assert( f )
+ return f() -- execute!
+ end
+ return nil
+end
+
+
+print("* loading accessor scripts...")
+yake.dofile("entitypropertyaccess.lua")
+yake.dofile("entityeventaccess.lua")
+
+--local thisTrigger = yake.asTrigger(this)
+local no_implicit_creation = false
+
+properties = {}
+wrapPropertiesTable(properties,this:properties(),no_implicit_creation)
+assert( properties.accessor, "accessor not set" )
+
+events = {}
+wrapEventsTable(events,this:events(),no_implicit_creation)
+assert( events.accessor, "accessor not set" )
+
+--
+function onTick()
+ --this.position = this.position + yake.Vector3( 0, 0, 1 )
+end
+function startup()
+ events.tick:connect( onTick )
+end
+print("> Object script up.");
+
+function main()
+ print(" script main()")
+ startup()
+end
+
Added: trunk/yake/common/media/scripts/o_trigger2.lua
===================================================================
--- trunk/yake/common/media/scripts/o_trigger2.lua (rev 0)
+++ trunk/yake/common/media/scripts/o_trigger2.lua 2007-09-04 17:17:53 UTC (rev 1832)
@@ -0,0 +1,86 @@
+print("> Starting object script...");
+
+-- replace loadfile and dofile with yake.loadfile and yake.dofile.
+-- the replacements use yake's resource system to locate the files.
+yake.old_loadfile = loadfile
+yake.old_dofile = dofile
+loadfile = nil
+dofile = nil
+yake.dofile = function(path)
+ local locator = yake.res.global.sourceManager
+ assert( locator ~= nil, "global source manager not available" )
+ local succ = locator:find(path)
+ print(succ)
+ assert( succ.valid, "could not locate file " .. tostring(path) )
+ if succ.valid then
+ local f = yake.old_loadfile(succ.location)
+ assert( f )
+ return f() -- execute!
+ end
+ return nil
+end
+
+
+print("* loading accessor scripts...")
+yake.dofile("entitypropertyaccess.lua")
+yake.dofile("entityeventaccess.lua")
+
+--local thisTrigger = yake.asTrigger(this)
+local no_implicit_creation = false
+
+properties = {}
+wrapPropertiesTable(properties,this:properties(),no_implicit_creation)
+assert( properties.accessor, "accessor not set" )
+
+events = {}
+wrapEventsTable(events,this:events(),no_implicit_creation)
+assert( events.accessor, "accessor not set" )
+
+--
+function onTick()
+ --print(" script on_tick",properties.ticks)
+
+ if properties.volumes and properties.volumes.size > 0 then
+ assert( objMgr, "no obj mgr" )
+ local objs = objMgr:getAllObjects()
+ for id,obj in pairs(objs) do
+ --print(obj:isA())
+ local ent = yake.asEntity(obj)
+ if ent and id ~= this.id then -- ignore self, and non-Entity objects
+ local intersects = properties.volumes:intersectsWith( ent.position )
+ if not this.on and intersects then
+ this:processFsmEvent("toggle")
+ elseif this.on and not intersects then
+ this:processFsmEvent("toggle")
+ end
+ end
+ end
+ --if filter then
+ -- local filter = yake.ObjectFilter()
+ -- filter:add( filterByClass("Player") )
+ -- filter:add( filterByClass("Entity",IgnoreDerived) )
+ -- filter.byClass("Player")
+ --end
+ end
+end
+function startup()
+ -- common ent::Object events
+ events.tick:connect( onTick )
+
+ -- ent::Trigger stuff
+ this:setCondition(function() return (this.on) end)
+
+ -- VolumeTrigger stuff
+ --properties:create("volumes", yake.VolumeContainer())
+ properties:create("volumes", yake.VolumeContainerRef())
+
+ -- move this out:
+ properties.volumes:add(yake.Sphere(2))
+end
+print("> Object script up.");
+
+function main()
+ print(" script main()")
+ startup()
+end
+
Modified: trunk/yake/common/media/scripts/raf1.lua
===================================================================
--- trunk/yake/common/media/scripts/raf1.lua 2007-08-31 03:36:26 UTC (rev 1831)
+++ trunk/yake/common/media/scripts/raf1.lua 2007-09-04 17:17:53 UTC (rev 1832)
@@ -31,9 +31,9 @@
local cam = scene.activeCamera
assert(cam)
-cam.position = yake.Vector3(100,20,-200)
+cam.position = yake.Point3(100,20,-200)
cam:setFixedYawAxis( yake.Vector3.UnitY ) -- keep upwards direction constant
-cam:lookAt( yake.Vector3(0,100,0) ) -- look at our ninja!
+cam:lookAt( yake.Point3(0,100,0) ) -- look at our ninja!
--------------------------------------
-- Configure input
Added: trunk/yake/common/media/scripts/raf2.lua
===================================================================
--- trunk/yake/common/media/scripts/raf2.lua (rev 0)
+++ trunk/yake/common/media/scripts/raf2.lua 2007-09-04 17:17:53 UTC (rev 1832)
@@ -0,0 +1,245 @@
+--
+-- raf/lua2 demo - main application script
+--
+-- available bindings:
+-- * res (including loads, i.e. yake.dofile)
+-- * graphics, ent, raf, and more
+--
+--
+
+local gworld = scene.gworld
+local defaultCam = scene.activeCamera
+local actionMap = app.actionMap
+local input = yake.input
+
+print(type(sim))
+print(type(sim.objMgr))
+local objMgr = sim.objMgr
+
+--------------------------------------
+-- Syntactic sugar for objMgr and
+-- objects / entities and their
+-- properties and events
+-- @todo do this on C++ side
+-- (g_casters -> probably as part of ThisBinder mechanism...)
+--------------------------------------
+
+-- register "Entity" -> DerivedEntity casters
+-- @todo lookup via "RtiiClass*" instead of string (-> faster...)
+g_casters = {}
+g_casters["Entity"] = yake.asEntity
+g_casters["Trigger"] = yake.asTrigger
+
+-- makes accessing properties and events
+-- syntactically simpler.
+-- -> Adds (syntactic) sugar. Instant pleasure.
+function wrapEventsAndProperties(obj)
+ assert( obj )
+ obj.events = {}
+ wrapEventsTable(obj.events,obj:eventAccessor(),false)
+ obj.properties = {}
+ wrapPropertiesTable(obj.properties,obj:propertyAccessor(),false)
+ return obj
+end
+
+-- Attempts to cast to most derived class.
+-- Returns the input object on failure, so obj stays valid.
+function tryCastToDerived(obj)
+ local caster = g_casters[obj:isA().name]
+ assert( caster, "no caster available - returning as-is "..tostring(obj:isA()) )
+ if not caster then
+ return obj, false
+ end
+ obj = caster( obj )
+ assert( obj, "cast failed" )
+ return obj, true
+end
+
+-- Attempts to cast to most derived class and
+-- also wraps event and property access for syntactic sugar.
+-- Returned obj is at least as valid as the original obj. :)
+function tryOpen(obj)
+ local ok = false
+ obj,ok = tryCastToDerived(obj)
+ obj = wrapEventsAndProperties(obj)
+ return obj
+end
+
+-- Redefine objMgr.makeObject() to take advantage of wrapEventsAndProperties()
+objMgr.old_makeObject = objMgr.makeObject
+objMgr.makeObject = function(self,clsid)
+ local o = tryOpen( self:old_makeObject(clsid) )
+ print("(lua)objMgr.makeObject created "..tostring(o.properties.id))
+ return o
+end
+
+--------------------------------------
+-- demo methods which make creating various objects simpler
+--------------------------------------
+function makeProximityTrigger()
+ local trigger = objMgr:makeObject("Trigger")
+ assert( trigger )
+ -- create DEBUG geometry
+ local m = yake.Model()
+ trigger.model = m
+ local g = yake.Graphical()
+ m:add(g)
+ local sn = gworld:createSceneNode()
+ local e = gworld:createEntity("sphere_d1.mesh")
+ sn:attach(e)
+ g:addSceneNode(sn)
+ --ent:setPositionSource(sn)
+ --
+ return trigger
+end
+yake.Entity.makeSimpleGraphical = function(self,meshname)
+ assert(self, "missing self")
+ assert(meshname, "missing mesh name")
+
+ local m = yake.Model()
+ self.model = m
+
+ local g = yake.Graphical()
+ m:add(g)
+
+ local sn = gworld:createSceneNode()
+ g:addSceneNode( sn )
+ local e = gworld:createEntity(meshname)
+ sn:attach(e)
+
+ self:setPositionSource(sn)
+end
+function makeNinja()
+ local ent = yake.asEntity( objMgr:makeObject("Entity") )
+ assert( ent )
+ ent.model = ent:makeSimpleGraphical("sphere_d1.mesh")
+ return ent
+end
+
+
+--------------------------------------
+-- Configure graphics
+--------------------------------------
+
+-- configure basic scene properties
+gworld:setShadowsEnabled(false)
+gworld:setAmbientLight(yake.Color(0,0,0,1))
+
+-- create directional light
+
+local light = gworld:createLight() -- create light
+
+local lightnode = gworld:createSceneNode() -- attach light to node
+lightnode:attach(light)
+
+light.type = yake.graphics.Light.LT_DIRECTIONAL -- configure light
+light:setDiffuseColour(yake.Color(1,1,1,1))
+light.direction = yake.Vector3(0,-1,1)
+
+-- configure active (=default) camera
+
+local cam = scene.activeCamera
+assert(cam)
+cam.nearClipDistance = 0.1
+cam.position = yake.Point3(10,2,10)
+cam:setFixedYawAxis( yake.Vector3.UnitY ) -- keep upwards direction constant
+
+--------------------------------------
+-- Create objects, entities etc
+--------------------------------------
+
+-- create ninja
+local ninja = makeNinja()
+ninja.translate = function(self,delta)
+ ninja.position = ninja.position + delta
+end
+cam:lookAt( ninja.position ) -- Now look at our ninja!
+
+-- create trigger
+local trigger = makeProximityTrigger()
+function onTrigger(yes)
+ if yes then
+ print("TRIGGERED")
+ else
+ print("UNtriggered")
+ end
+ print(trigger.properties.id)
+ print(trigger.on)
+end
+
+trigger.events.onTriggered:connect(onTrigger)
+--trigger:events().onTriggered:connect(onTrigger)
+--trigger:events():get("onTriggered"):connect(onTrigger)
+
+--------------------------------------
+-- Configure input
+--------------------------------------
+
+local activeKeys = {} -- Store the keys that are active in current frame.
+
+-- We demonstrate two ways to bind Lua callbacks to a keyboard action.
+-- #1 demonstrates the details
+-- #2 shows how to achieve the same thing fast and Lua-style
+
+------ #1: "The Long Way"
+
+--local idLeft = input.ActionId.fromName("left") -- look up ActionId by its name (useful for user-defined ones)
+local idLeft = input.ACTIONID_LEFT -- using an ActionId constant
+
+-- Connect key "Cursor Left" to action "left":
+local acLeft = input.KeyboardActionCondition(app.keyboard, input.KC_LEFT, input.KAM_CONTINUOUS)
+actionMap:reg(idLeft,acLeft)
+
+-- Our Lua callback handler:
+function onLeft()
+ activeKeys["left"] = true
+end
+
+actionMap:connectToAction(idLeft,onLeft) -- by Action ID
+
+------ #2: "Shortcut" (using action names and anonymous Lua functions)
+
+actionMap:reg("right", input.KeyboardActionCondition(app.keyboard, input.KC_RIGHT, input.KAM_CONTINUOUS))
+actionMap:connectToAction("right",
+ function()
+ activeKeys["right"] = true
+ end)
+
+------- Let's define a few helper functions to make things easier:
+
+function createKeyAction(action, key, keymode)
+ return actionMap:reg(action, input.KeyboardActionCondition(app.keyboard, key, keymode ))
+end
+function bindAction(action, handler)
+ return actionMap:connectToAction(action, handler)
+end
+
+------- Bind the rest of the keys to actions:
+
+createKeyAction("forward", input.KC_UP, input.KAM_CONTINUOUS)
+bindAction("forward", function()
+ activeKeys["forward"] = true
+ end)
+
+createKeyAction("reverse", input.KC_DOWN, input.KAM_CONTINUOUS)
+bindAction("reverse", function()
+ activeKeys["reverse"] = true
+ end)
+
+-----------------------------------
+function onFrame(timeElapsed)
+ local distance = 25 * timeElapsed
+ for k,v in pairs(activeKeys) do
+ if k == "left" then
+ ninja:translate( -1 * yake.Vector3.UnitX * distance )
+ elseif k == "right" then
+ ninja:translate( 1 * yake.Vector3.UnitX * distance )
+ elseif k == "forward" then
+ ninja:translate( -1 * yake.Vector3.UnitZ * distance )
+ elseif k == "reverse" then
+ ninja:translate( 1 * yake.Vector3.UnitZ * distance )
+ end
+ end
+ -- prepare for next frame:
+ activeKeys = {}
+end
\ No newline at end of file
Modified: trunk/yake/scripts/premake/samples.lua
===================================================================
--- trunk/yake/scripts/premake/samples.lua 2007-08-31 03:36:26 UTC (rev 1831)
+++ trunk/yake/scripts/premake/samples.lua 2007-09-04 17:17:53 UTC (rev 1832)
@@ -127,9 +127,16 @@
useComponent("base")
useComponent("raf")
useComponent("bindings.lua")
- --useComponent("scriptingLua")
useDep("lua")
useDep("luabind")
+
+ --------------------------------------
+ makeSample("sampleRafLuaDemo2","samples/raf/lua2")
+ useComponent("base")
+ useComponent("raf")
+ useComponent("bindings.lua")
+ useDep("lua")
+ useDep("luabind")
end
end
Modified: trunk/yake/scripts/premake/yake.lua
===================================================================
--- trunk/yake/scripts/premake/yake.lua 2007-08-31 03:36:26 UTC (rev 1831)
+++ trunk/yake/scripts/premake/yake.lua 2007-09-04 17:17:53 UTC (rev 1832)
@@ -97,8 +97,14 @@
addDefine("YAKE_BASE_EXPORTS")
--package.pchheader = "yake/base/yakePCH.h"
--package.pchsource = rootdir.."src/base/yakePCH.cpp"
+
addMatching("yake/base/*.h")
addMatching("yake/base/*.inl")
+ addMatching("yake/base/math/*.h")
+ addMatching("yake/base/math/*.inl")
+ addMatching("yake/base/templates/*.h")
+ addMatching("yake/base/templates/*.inl")
+
addMatching("src/base/*.cpp")
addMatching("src/base/math/*.cpp")
addMatching("src/base/templates/*.cpp")
Modified: trunk/yake/src/base/math/yakeMatrix3.cpp
===================================================================
--- trunk/yake/src/base/math/yakeMatrix3.cpp 2007-08-31 03:36:26 UTC (rev 1831)
+++ trunk/yake/src/base/math/yakeMatrix3.cpp 2007-09-04 17:17:53 UTC (rev 1832)
@@ -153,7 +153,33 @@
}
return kProd;
}
- //-----------------------------------------------------------------------
+ //-----------------------------------------------------------------------
+ Point3 Matrix3::operator* (const Point3& rkPoint) const
+ {
+ Point3 kProd;
+ for (int iRow = 0; iRow < 3; iRow++)
+ {
+ kProd[iRow] =
+ m[iRow][0]*rkPoint[0] +
+ m[iRow][1]*rkPoint[1] +
+ m[iRow][2]*rkPoint[2];
+ }
+ return kProd;
+ }
+ //-----------------------------------------------------------------------
+ Point3 operator* (const Point3& rkPoint, const Matrix3& rkMatrix)
+ {
+ Point3 kProd;
+ for (int iRow = 0; iRow < 3; iRow++)
+ {
+ kProd[iRow] =
+ rkPoint[0]*rkMatrix.m[0][iRow] +
+ rkPoint[1]*rkMatrix.m[1][iRow] +
+ rkPoint[2]*rkMatrix.m[2][iRow];
+ }
+ return kProd;
+ }
+ //-----------------------------------------------------------------------
Matrix3 Matrix3::operator- () const
{
Matrix3 kNeg;
Modified: trunk/yake/src/base/math/yakeQuaternion.cpp
===================================================================
--- trunk/yake/src/base/math/yakeQuaternion.cpp 2007-08-31 03:36:26 UTC (rev 1831)
+++ trunk/yake/src/base/math/yakeQuaternion.cpp 2007-09-04 17:17:53 UTC (rev 1832)
@@ -30,6 +30,7 @@
#include <yake/base/yakePCH.h>
#include <yake/base/math/yakeQuaternion.h>
#include <yake/base/math/yakeMatrix3.h>
+#include <yake/base/math/yakePoint3.h>
//============================================================================
@@ -364,6 +365,12 @@
return v + uv + uuv;
}
+ //-----------------------------------------------------------------------
+ Point3 Quaternion::operator* (const Point3& v) const
+ {
+ Vector3 ret = *this * v.asVector();
+ return Point3(ret.x,ret.y,ret.z);
+ }
//-----------------------------------------------------------------------
Quaternion Quaternion::Slerp (real fT, const Quaternion& rkP,
const Quaternion& rkQ, bool shortestPath)
Modified: trunk/yake/src/base/math/yakeRay.cpp
===================================================================
--- trunk/yake/src/base/math/yakeRay.cpp 2007-08-31 03:36:26 UTC (rev 1831)
+++ trunk/yake/src/base/math/yakeRay.cpp 2007-09-04 17:17:53 UTC (rev 1832)
@@ -41,7 +41,7 @@
}
else
{
- real nom = plane.normal.dotProduct(mOrigin) + plane.d;
+ real nom = plane.normal.dotProduct(mOrigin.asVector()) + plane.d;
real t = -(nom/denom);
return std::pair<bool, real>(t >= 0, t);
}
Modified: trunk/yake/src/base/math/yakeVector3.cpp
===================================================================
--- trunk/yake/src/base/math/yakeVector3.cpp 2007-08-31 03:36:26 UTC (rev 1831)
+++ trunk/yake/src/base/math/yakeVector3.cpp 2007-09-04 17:17:53 UTC (rev 1832)
@@ -29,6 +29,7 @@
//============================================================================
#include <yake/base/yakePCH.h>
#include <yake/base/math/yakeVector3.h>
+#include <yake/base/math/yakePoint3.h>
//============================================================================
// INTERFACE STRUCTURES / UTILITY CLASSES
@@ -36,6 +37,7 @@
namespace yake {
namespace math {
+ const Point3 Point3::kZero( 0, 0, 0 );
const Vector3 Vector3::kZero( 0, 0, 0 );
const Vector3 Vector3::kUnitX( 1, 0, 0 );
const Vector3 Vector3::kUnitY( 0, 1, 0 );
Added: trunk/yake/src/base/math/yakeVolume.cpp
===================================================================
--- trunk/yake/src/base/math/yakeVolume.cpp (rev 0)
+++ trunk/yake/src/base/math/yakeVolume.cpp 2007-09-04 17:17:53 UTC (rev 1832)
@@ -0,0 +1,104 @@
+/*
+ ------------------------------------------------------------------------------------
+ This file is part of YAKE
+ Copyright (c) 2004 - 2008 The YAKE Team
+ For the latest information visit http://www.yake.org
+ ------------------------------------------------------------------------------------
+ This program is free software; you can redistribute it and/or modify it under
+ the terms of the GNU Lesser 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 Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser 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, or go to
+ http://www.gnu.org/copyleft/lesser.txt.
+ ------------------------------------------------------------------------------------
+ If you are interested in another license model contact the Yake Team via
+ E-Mail: te...@ya....
+ For more information see the LICENSE file in the root directory of the
+ source code distribution.
+ ------------------------------------------------------------------------------------
+*/
+
+#include <yake/base/yakePCH.h>
+#include <yake/base/math/yakeVolume.h>
+
+namespace yake {
+
+ Volume::~Volume() {}
+
+ Sphere::Sphere(const real r, const Point3& pos) : radius(r), position(pos)
+ {}
+ bool Sphere::intersectsWith(const Sphere& other) const
+ {
+ const real dist = (position-other.position).length();
+ return (dist <= (radius + other.radius));
+ }
+ bool Sphere::intersectsWith(const Point3& other) const
+ {
+ const real dist = (position-other).squaredLength();
+ return (dist < radius*radius);
+ }
+
+ VolumeContainer::~VolumeContainer()
+ {
+ clear();
+ }
+ void VolumeContainer::add(Volume* vol)
+ {
+ YAKE_ASSERT( vol );
+ if (vol)
+ volumes_.insert( vol );
+ }
+ void VolumeContainer::destroy(Volume* vol)
+ {
+ YAKE_ASSERT( vol );
+ if (vol)
+ {
+ Volumes::iterator it = volumes_.find(vol);
+ if (it != volumes_.end())
+ {
+ delete (*it);
+ volumes_.erase(it);
+ }
+ }
+ }
+ void VolumeContainer::clear()
+ {
+ YAKE_FOR_EACH(Volumes::iterator, it, volumes_)
+ {
+ delete (*it);
+ }
+ volumes_.clear();
+ }
+ size_t VolumeContainer::size() const
+ {
+ return volumes_.size();
+ }
+ bool VolumeContainer::intersectsWith(const Sphere& other) const
+ {
+ YAKE_FOR_EACH(Volumes::const_iterator, it, volumes_)
+ {
+ Volume* vol = *it;
+ if (vol->intersectsWith(other))
+ return true;
+ }
+ return false;
+ }
+ bool VolumeContainer::intersectsWith(const Point3& other) const
+ {
+ YAKE_FOR_EACH(Volumes::const_iterator, it, volumes_)
+ {
+ Volume* vol = *it;
+ if (vol->intersectsWith(other))
+ return true;
+ }
+ return false;
+ }
+
+} // yake
Modified: trunk/yake/src/bindings.lua/bindings.lua.cpp
===================================================================
--- trunk/yake/src/bindings.lua/bindings.lua.cpp 2007-08-31 03:36:26 UTC (rev 1831)
+++ trunk/yake/src/bindings.lua/bindings.lua.cpp 2007-09-04 17:17:53 UTC (rev 1832)
@@ -67,9 +67,6 @@
#if YAKE_ENABLE_LUA_TASK == 1
bind_task(L);
#endif
-#if YAKE_ENABLE_LUA_MODEL == 1
- bind_model(L);
-#endif
#if YAKE_ENABLE_LUA_PROPERTY == 1
bind_property(L);
#endif
@@ -85,6 +82,9 @@
#if YAKE_ENABLE_LUA_INPUT == 1
bind_input(L);
#endif
+#if YAKE_ENABLE_LUA_MODEL == 1
+ bind_model(L);
+#endif
#if YAKE_ENABLE_LUA_RAF == 1
bind_raf(L);
#endif
Modified: trunk/yake/src/bindings.lua/detail/base.lua.cpp
===================================================================
--- trunk/yake/src/bindings.lua/detail/base.lua.cpp 2007-08-31 03:36:26 UTC (rev 1831)
+++ trunk/yake/src/bindings.lua/detail/base.lua.cpp 2007-09-04 17:17:53 UTC (rev 1832)
@@ -38,6 +38,7 @@
#include <yake/bindings.lua/common/yake.lua.any_converter.h>
#include <luabind/operator.hpp>
+#include <luabind/adopt_policy.hpp>
namespace yake {
namespace math {
@@ -49,7 +50,44 @@
{
return rhs * lhs;
}
+ inline Point3 operator * (const Point3& lhs, const Quaternion& rhs)
+ {
+ return rhs * lhs;
+ }
+ inline Point3 operator * (const Point3& lhs, const Matrix3& rhs)
+ {
+ return rhs * lhs;
+ }
//-------------------------------------------------------------------------
+ struct VolumeContainerRef
+ {
+ VolumeContainerRef() : px_(new VolumeContainer())
+ {
+ }
+ void add(Volume* vol)
+ {
+ YAKE_ASSERT( px_ );
+ px_->add( vol );
+ }
+ size_t size() const
+ {
+ YAKE_ASSERT( px_ );
+ return px_->size();
+ }
+ bool intersectsWith(const Point3& other) const
+ {
+ YAKE_ASSERT( px_ );
+ return px_->intersectsWith(other);
+ }
+ bool intersectsWith(const Sphere& other) const
+ {
+ YAKE_ASSERT( px_ );
+ return px_->intersectsWith(other);
+ }
+ typedef boost::shared_ptr<VolumeContainer> ctr_pointer;
+ ctr_pointer px_;
+ };
+ //-------------------------------------------------------------------------
namespace {
struct AnyConverterIniter
{
@@ -57,8 +95,15 @@
{
register_any_converter<Color>();
register_any_converter<Vector3>();
+ register_any_converter<Point3>();
register_any_converter<Quaternion>();
register_any_converter<Matrix3>();
+
+ //register_any_converter<Sphere*>();
+ //register_any_converter<VolumeContainer>();
+ register_any_converter<VolumeContainerRef>();
+ register_any_converter<VolumeContainer*>();
+ //register_any_converter<boost::shared_ptr<VolumeContainer> >();
}
} g_initer;
} // namespace
@@ -139,6 +184,31 @@
luabind::globals(L)["yake"]["Vector3"]["UnitY"] = Vector3::kUnitY;
luabind::globals(L)["yake"]["Vector3"]["UnitZ"] = Vector3::kUnitZ;
+ // Point3
+ module( YAKE_MATH_MODULE )
+ [
+ class_< Point3 >( "Point3" )
+ .def_readwrite( "x", &Point3::x )
+ .def_readwrite( "y", &Point3::y )
+ .def_readwrite( "z", &Point3::z )
+ .def( constructor<>() )
+ .def( constructor< real, real, real >() )
+ .def( constructor< const real* const >() )
+ .def( constructor< Point3 const& >() )
+ .def(const_self + other<Vector3>())
+ .def(const_self - other<Vector3>())
+ .def(const_self == other<Point3>())
+ .def(const_self / real())
+ .def(const_self * other<real>())
+ .def(const_self * Quaternion())
+ .def(const_self * Matrix3())
+ .def(real() * const_self)
+ .def(Quaternion() * const_self)
+ .def(Matrix3() * const_self)
+ .def(tostring(const_self))
+ ];
+ luabind::globals(L)["yake"]["Point3"]["Zero"] = Point3::kZero;
+
// Vector4
module( YAKE_MATH_MODULE )
[
@@ -184,18 +254,51 @@
[
class_< Ray >( "Ray" )
.def( constructor<>() )
- .def( constructor<const Vector3&, const Vector3&>() )
+ .def( constructor<const Point3&, const Vector3&>() )
.property( "origin", &Ray::getOrigin, &Ray::setOrigin )
.property( "direction", &Ray::getDirection, &Ray::setDirection )
.def("getPoint", &Ray::getPoint)
];
+ // Volumes
+ module( YAKE_MATH_MODULE )
+ [
+ class_<Volume>("Volume")
+ .def( "intersectsWith", (bool(Volume::*)(const Sphere&)const)&Volume::intersectsWith)
+ .def( "intersectsWith", (bool(Volume::*)(const Point3&)const)&Volume::intersectsWith)
+ ,
+ class_<Sphere,Volume>("Sphere")
+ .def_readwrite( "position", &Sphere::position )
+ .def_readwrite( "radius", &Sphere::radius )
+ .def( constructor<>() )
+ .def( constructor<real>() )
+ .def( constructor<real,Point3>() )
+ .def( "intersectsWith", (bool(Sphere::*)(const Sphere&)const)&Volume::intersectsWith)
+ .def( "intersectsWith", (bool(Sphere::*)(const Point3&)const)&Volume::intersectsWith)
+ ,
+ class_<VolumeContainer,boost::shared_ptr<VolumeContainer> >("VolumeContainer")
+ .def(constructor<>())
+ .def("add",&VolumeContainer::add,adopt(_2))
+ .def("destroy",&VolumeContainer::destroy)
+ .def("clear",&VolumeContainer::clear)
+ .property("size",&VolumeContainer::size)
+ .def( "intersectsWith", (bool(VolumeContainer::*)(const Sphere&)const)&VolumeContainer::intersectsWith)
+ .def( "intersectsWith", (bool(VolumeContainer::*)(const Point3&)const)&VolumeContainer::intersectsWith)
+ ,
+ class_<VolumeContainerRef>("VolumeContainerRef")
+ .def(constructor<>())
+ .def("add",&VolumeContainerRef::add,adopt(_2))
+ .property("size",&VolumeContainerRef::size)
+ .def( "intersectsWith", (bool(VolumeContainerRef::*)(const Sphere&)const)&VolumeContainerRef::intersectsWith)
+ .def( "intersectsWith", (bool(VolumeContainerRef::*)(const Point3&)const)&VolumeContainerRef::intersectsWith)
+ ];
+
// RandomNumberGenerator
typedef RandomNumberGenerator rng_type;
module( YAKE_MATH_MODULE )
[
class_< rng_type >( "RandomNumberGenerator" )
- .def( constructor<>() )
+ .def( constructor<>() )
.def( "setSeed", &rng_type::setSeed )
.def( "getSeed", &rng_type::getSeed )
.def( "randInt", &rng_type::randInt )
Modified: trunk/yake/src/bindings.lua/detail/ent.lua.cpp
===================================================================
--- trunk/yake/src/bindings.lua/detail/ent.lua.cpp 2007-08-31 03:36:26 UTC (rev 1831)
+++ trunk/yake/src/bindings.lua/detail/ent.lua.cpp 2007-09-04 17:17:53 UTC (rev 1832)
@@ -56,6 +56,21 @@
} // namespace
//-------------------------------------------------------------------------
+ luabind::object ObjectManager_getAllObjects(ObjectManager& objMgr, lua_State* L)
+ {
+ YAKE_ASSERT( L );
+ const ObjectManager::const_object_iterator itEnd = objMgr.endObjects();
+ ObjectManager::const_object_iterator it = objMgr.beginObjects();
+ luabind::object o = luabind::newtable(L);
+ for (; it != itEnd; ++it)
+ {
+ Object* obj = *it;
+ //@todo luabind::object[ obj->id() ] = cast_to_this(obj->isA());
+ o[ obj->id() ] = obj;
+ }
+ return o;
+ }
+ //-------------------------------------------------------------------------
// For Lua's tostring():
// std::ostream& operator<<(std::ostream& out, const ObjectId& rhs)
// {
@@ -77,7 +92,7 @@
static Object_NameEventPair* Object_EventAccess_getByIndex(Object::EventAccess& acc, int index)
{
index -= 1; // Lua arrays usually start with 1, so convert to 0-offset-array.
- if (index < 0 || index > acc.size())
+ if (index < 0 || index > int(acc.size()))
return 0;
Object_NameEventPair ret = acc.__getByIndex(index);
if (ret.first.empty())
@@ -106,6 +121,11 @@
{
return o.properties().get(id).get();
}
+ static Object::PropertyAccess* getObjectPopertiesAccessor(Object& o)
+ {
+ Object::PropertyAccess& x = o.properties();
+ return &x;
+ }
static Object::PropertyAccess* getObjectPoperties(Object& o)
{
Object::PropertyAccess& x = o.properties();
@@ -118,7 +138,7 @@
static property::NamePropertyPair* Object_PropertyAccess_get_byIndex(Object::PropertyAccess& o, int index)
{
index -= 1; // Lua tables usually start with 1
- if (index >= o.size() || index < 0)
+ if (index >= int(o.size()) || index < 0)
return 0;
YAKE_ASSERT( o.owner().__properties() ).debug("invalid internal state");
const NamedProperties& props = *o.owner().__properties();
@@ -137,11 +157,22 @@
ret->prop = it->second.get();
return ret;
}
- static Object::EventAccess* getObjectEvents(Object& o)
+ static Object::EventAccess* getObjectEventsAccessor(Object& o)
{
Object::EventAccess& x = o.events();
return &x;
}
+ static luabind::object getObjectEventsTable(Object& obj, lua_State* L)
+ {
+ YAKE_ASSERT(L);
+ luabind::object o = luabind::newtable(L);
+ for (size_t i=0; i<obj.events().size(); ++i)
+ {
+ std::pair<Object::Event::ID,Object::Event::pointer> succ = obj.events().__getByIndex( i );
+ o[ succ.first ] = succ.second;
+ }
+ return o;
+ }
struct TriggerConditionWrapper
{
luabind::object fn_;
@@ -156,6 +187,16 @@
YAKE_LOG_ERROR("ent.lua",String("TriggerConditionWrapper: cast_failed: ") + ex.what());
return false;
}
+ catch (luabind::error& ex)
+ {
+ YAKE_LOG_ERROR("ent.lua",String("TriggerConditionWrapper: error: ") + ex.what());
+ return false;
+ }
+ catch (std::exception& ex)
+ {
+ YAKE_LOG_ERROR("ent.lua",String("TriggerConditionWrapper: unknown: ") + ex.what());
+ return false;
+ }
}
};
static void Trigger_setCondition(Trigger& trigger, luabind::object o)
@@ -287,6 +328,12 @@
.def( "add", &Object::EventAccess::add )
.def( "create", &Object::EventAccess::createAndAdd )
];
+ module(YAKE_MODEL_MODULE)
+ [
+ class_<RttiClass>("RttiClass")
+ .property("name",&RttiClass::name)
+ .def(tostring(const_self))
+ ];
LuabindClass_Object x_Object("Object");
x_Object
@@ -294,9 +341,13 @@
//.def( "setId", &Object::setId )
//.def( "id", &Object::getId )
.property( "id", &Object::getId, &Object::setId )
- .def( "events", &getObjectEvents )
+ .def( "isA", &Object::isA)
+ .def( "evts", &getObjectEventsTable, raw(_2) )
+ .def( "events", &getObjectEventsAccessor )
+ .def( "eventAccessor", &getObjectEventsAccessor )
.def( "property", &getPropertyOfObject )
.def( "properties", &getObjectPoperties )
+ .def( "propertyAccessor", &getObjectPopertiesAccessor )
//.def( "properties", return_reference_to(_1) )
.def(tostring(const_self))
;
@@ -312,6 +363,9 @@
.def( "setModel", &Entity::setModel )
.def( "getModel", &Entity::getModel )
+ .property( "position", &Entity::getPosition, &Entity::setPosition )
+ .def( "setPositionSource", &Entity::setPositionSource )
+
.def( "addFsmState", &Entity::addFsmState )
.def( "addFsmTransition", &Entity::addFsmTransition )
.def( "setFsmState", &Entity::setFsmState )
@@ -329,6 +383,11 @@
module( YAKE_MODEL_MODULE )
[
+ class_<VolumeTrigger,Trigger>( "VolumeTrigger" )
+ ];
+
+ module( YAKE_MODEL_MODULE )
+ [
def( "asEntity", &Entity::cast ),
def( "asTrigger", &Trigger::cast )
];
@@ -340,6 +399,7 @@
.def( "getObject", &ObjectManager::getObject )
.def( "destroyObject", &ObjectManager::destroyObject )
.def( "getClassNamesAndIds", &ObjectManager::getClassNamesAndIds )
+ .def( "getAllObjects", &ObjectManager_getAllObjects, raw(_2) )
];
}
@@ -397,8 +457,8 @@
LuaFsmObjectListener::LuaFsmObjectListener(scripting::IScriptingSystem& scriptingSystem) :
scriptingSystem_(scriptingSystem)
{
- startScript_ = scriptingSystem_.createScriptFromFile("o_access.lua");
- YAKE_ASSERT( startScript_.get() );
+ //startScript_ = scriptingSystem_.createScriptFromFile("o_access.lua");
+ //YAKE_ASSERT( startScript_.get() );
}
void LuaFsmObjectListener::onInit(Object& obj)
{
@@ -407,7 +467,8 @@
{
YAKE_ASSERT( ent->getFsmVM() );
ent->getFsmVM()->execute("print('initializing...')");
- ent->getFsmVM()->execute( startScript_ );
+ if (startScript_)
+ ent->getFsmVM()->execute( startScript_ );
scripting::LuaVM* vm = static_cast<scripting::LuaVM*>(ent->getFsmVM().get());
YAKE_ASSERT( vm );
Modified: trunk/yake/src/bindings.lua/detail/graphics.lua.cpp
===================================================================
--- trunk/yake/src/bindings.lua/detail/graphics.lua.cpp 2007-08-31 03:36:26 UTC (rev 1831)
+++ trunk/yake/src/bindings.lua/detail/graphics.lua.cpp 2007-09-04 17:17:53 UTC (rev 1832)
@@ -54,6 +54,7 @@
#include <luabind/discard_result_policy.hpp>
#include <luabind/iterator_policy.hpp>
#include <luabind/operator.hpp>
+#include <luabind/adopt_policy.hpp>
namespace yake {
namespace graphics {
@@ -190,13 +191,15 @@
//@todo ISkeleton etc pp
//
class_<IWorld>("World")
- .def("createSceneNode", &IWorld::createSceneNode)
- .def("createSceneNode", &IWorld_createSceneNode_NoName)
- .def("createEntity", &IWorld::createEntity)
- .def("createParticleSystem", &IWorld::createParticleSystem)
- .def("createLight", &IWorld::createLight)
- .def("createCamera", &IWorld::createCamera)
- .def("createViewport", &IWorld::createViewport)
+ //.def("createSceneNode", &IWorld::createSceneNode, adopt(result))
+ //.def("createSceneNode", &IWorld_createSceneNode_NoName, adopt(result))
+ .def("createSceneNode", &IWorld::createSceneNode, dependency(result,_1))
+ .def("createSceneNode", &IWorld_createSceneNode_NoName, dependency(result,_1))
+ .def("createEntity", &IWorld::createEntity, dependency(result,_1))
+ .def("createParticleSystem", &IWorld::createParticleSystem, dependency(result,_1))
+ .def("createLight", &IWorld::createLight, dependency(result,_1))
+ .def("createCamera", &IWorld::createCamera, dependency(result,_1))
+ .def("createViewport", &IWorld::createViewport, dependency(result,_1))
.def("load", &IWorld::load)
.def("setShadowsEnabled", &IWorld::setShadowsEnabled)
.def("setAmbientLight", &IWorld::setAmbientLight)
Modified: trunk/yake/src/bindings.lua/detail/model.lua.cpp
===================================================================
--- trunk/yake/src/bindings.lua/detail/model.lua.cpp 2007-08-31 03:36:26 UTC (rev 1831)
+++ trunk/yake/src/bindings.lua/detail/model.lua.cpp 2007-09-04 17:17:53 UTC (rev 1832)
@@ -38,9 +38,26 @@
#include <luabind/discard_result_policy.hpp>
#include <luabind/iterator_policy.hpp>
+#include <luabind/adopt_policy.hpp>
namespace yake {
namespace model {
+ Graphical* Model_createGraphical(Model& m)
+ {
+ Graphical* c = new Graphical();
+ m.addComponent( c );
+ return c;
+ }
+ void Graphical_addSceneNode(Graphical* g, graphics::ISceneNode* node)
+ {
+ YAKE_ASSERT(g);
+ g->addSceneNode( node, uniqueName::create("bindings.lua_model_sn") );
+ }
+ void Graphical_addSceneNodeWithPath(Graphical* g, graphics::ISceneNode* node, const String& path)
+ {
+ YAKE_ASSERT(g);
+ g->addSceneNode( node, path );
+ }
Model* ModelManager_createModel(ModelManager* mgr, const String& modelName, const String& def)
{
return (mgr ? mgr->createModel(modelName,def).get() : 0);
@@ -56,7 +73,7 @@
return false;
if (!link)
return false;
- typedef boost::function<void(const Vector3&)> Fn;
+ typedef boost::function<void(const Point3&)> Fn;
link->subscribeToPositionChanged( boost::bind(Fn(o),_1) );
return true;
}
@@ -87,7 +104,11 @@
[
class_<Graphical,ModelComponent>( "Graphical" )
.def( constructor<>() )
- .def( "addSceneNode", &Graphical::addSceneNode )
+ //.def( "addSceneNode", &Graphical_addSceneNode, adopt(_2) )
+ //.def( "addSceneNode", &Graphical_addSceneNodeWithPath, adopt(_2) )
+ .def( "addSceneNode", &Graphical_addSceneNode )
+ .def( "addSceneNode", &Graphical_addSceneNodeWithPath )
+
//.def( "getSceneNodes", &Graphical::getSceneNodes )
.def( "getSceneNode", &Graphical::getSceneNode )
.def( "getEntity", &Graphical::getEntity )
@@ -133,6 +154,10 @@
.def( "createLink", &Model::createLink)
.def( "createDirectLink", &Model::createDirectLink)
.def( "createWorldSpaceLink", &Model::createWorldSpaceLink)
+ .def( "add", (void(Model::*)(ModelComponent*))&Model::addComponent, adopt(_2))
+ .def( "add", (void(Model::*)(ModelComponent*,const String&))&Model::addComponent, adopt(_2))
+ //----------
+ .def( "createGraphical", &Model_createGraphical )
,
class_<ModelManager>( "ModelManager" )
.def("clear", &ModelManager::clear)
Modified: trunk/yake/src/bindings.lua/detail/physics.lua.cpp
===================================================================
--- trunk/yake/src/bindings.lua/detail/physics.lua.cpp 2007-08-31 03:36:26 UTC (rev 1831)
+++ trunk/yake/src/bindings.lua/detail/physics.lua.cpp 2007-09-04 17:17:53 UTC (rev 1832)
@@ -124,28 +124,28 @@
,
class_<IShape::SphereDesc,IShape::Desc>("SphereDesc")
.def(constructor<real>())
- .def(constructor<real,const Vector3&>())
- .def(constructor<real,const Vector3&,const Quaternion&>())
+ .def(constructor<real,const Point3&>())
+ .def(constructor<real,const Point3&,const Quaternion&>())
,
class_<IShape::BoxDesc,IShape::Desc>("BoxDesc")
.def(constructor<const Vector3&>())
- .def(constructor<const Vector3&,const Vector3&>())
- .def(constructor<const Vector3&,const Vector3&,const Quaternion&>())
+ .def(constructor<const Vector3&,const Point3&>())
+ .def(constructor<const Vector3&,const Point3&,const Quaternion&>())
,
class_<IShape::PlaneDesc,IShape::Desc>("PlaneDesc")
.def(constructor<const Vector3&,real>())
- .def(constructor<const Vector3&,real,const Vector3&>())
- .def(constructor<const Vector3&,real,const Vector3&,const Quaternion&>())
+ .def(constructor<const Vector3&,real,const Point3&>())
+ .def(constructor<const Vector3&,real,const Point3&,const Quaternion&>())
,
class_<IShape::CapsuleDesc,IShape::Desc>("CapsuleDesc")
.def(constructor<real,real>())
- .def(constructor<real,real,const Vector3&>())
- .def(constructor<real,real,const Vector3&,const Quaternion&>())
+ .def(constructor<real,real,const Point3&>())
+ .def(constructor<real,real,const Point3&,const Quaternion&>())
,
class_<IShape::TriMeshDesc,IShape::Desc>("TriMeshDesc")
.def(constructor<TriangleMeshId>())
- .def(constructor<TriangleMeshId,const Vector3&>())
- .def(constructor<TriangleMeshId,const Vector3&,const Quaternion&>())
+ .def(constructor<TriangleMeshId,const Point3&>())
+ .def(constructor<TriangleMeshId,const Point3&,const Quaternion&>())
]
,
class_<IActor,Movable>("Actor")
Modified: trunk/yake/src/bindings.lua/detail/property.lua.cpp
===================================================================
--- trunk/yake/src/bindings.lua/detail/property.lua.cpp 2007-08-31 03:36:26 UTC (rev 1831)
+++ trunk/yake/src/bindings.lua/detail/property.lua.cpp 2007-09-04 17:17:53 UTC (rev 1832)
@@ -97,10 +97,11 @@
// As a last resort try to convert to luabind::object property:
// For details read the comments for register_any_converter<luabind::object>()
// specialization.
+#if 0
PropertyPtr prop( convert_any<luabind::object>::yake_createValuePropertyFromObject( o ) );
if (prop.get())
return prop;
-
+#endif
//@todo use proper logging:
std::cerr << "ERROR: bindings.lua:yake.property.createProperty: unhandled type\n";
return PropertyPtr();
Modified: trunk/yake/src/ent/entity.cpp
===================================================================
--- trunk/yake/src/ent/entity.cpp 2007-08-31 03:36:26 UTC (rev 1831)
+++ trunk/yake/src/ent/entity.cpp 2007-09-04 17:17:53 UTC (rev 1832)
@@ -32,10 +32,30 @@
IMPL_OBJECT(Entity)
- Entity::Entity()
+ Entity::Entity() : posSource_(0)
{
properties().add("model", property::makePointerProperty<ModelPtr>(&model_) );
}
+ void Entity::setPositionSource(PositionSource source)
+ {
+ posSource_ = source;
+ if (posSource_)
+ pos_ = posSource_->getDerivedPosition();
+ }
+ Point3 Entity::getPosition() const
+ {
+ return (posSource_ ? posSource_->getDerivedPosition() : pos_);
+ }
+ void Entity::setPosition(const Point3& pos)
+ {
+ if (posSource_)
+ {
+ posSource_->setPosition( pos );
+ pos_ = posSource_->getDerivedPosition();
+ }
+ else
+ pos_ = pos;
+ }
void Entity::processFsmEvent(const fsm_event_type& evt)
{
// On MSVC8 the following line of code works but fails miserable with GCC 3.4.2 (MinGW).
Modified: trunk/yake/src/ent/trigger.cpp
===================================================================
--- trunk/yake/src/ent/trigger.cpp 2007-08-31 03:36:26 UTC (rev 1831)
+++ trunk/yake/src/ent/trigger.cpp 2007-09-04 17:17:53 UTC (rev 1832)
@@ -79,5 +79,28 @@
this->events().get("onTriggered")->fire( (state=="on") );
}
+
+ IMPL_OBJECT(VolumeTrigger)
+
+ VolumeTrigger::VolumeTrigger()
+ {
+ }
+ const VolumeContainer& VolumeTrigger::volumes() const
+ {
+ return volumes_;
+ }
+ VolumeContainer& VolumeTrigger::volumes()
+ {
+ return volumes_;
+ }
+ void VolumeTrigger::onTick()
+ {
+ Trigger::onTick();
+ }
+ void VolumeTrigger::onPreDestroy()
+ {
+ volumes_.clear();
+ }
+
} // namespace ent
} // namespace yake
Modified: trunk/yake/src/graphics/yakeGraphicsSystem.cpp
===================================================================
--- trunk/yake/src/graphics/yakeGraphicsSystem.cpp 2007-08-31 03:36:26 UTC (rev 1831)
+++ trunk/yake/src/graphics/yakeGraphicsSystem.cpp 2007-09-04 17:17:53 UTC (rev 1832)
@@ -94,18 +94,19 @@
}
/** @Remarks Code has been taken more or less directly from Ogre's OgreCamera.cpp. */
- math::Ray ICamera::createCameraToViewportRay(const real screenX, const real screenY) const
+ Ray ICamera::createCameraToViewportRay(const real screenX, const real screenY) const
{
real centeredScreenX = (screenX - 0.5f);
real centeredScreenY = (0.5f - screenY);
const real nearDist = getNearClipDistance();
- real normalizedSlope = math::Math::Tan(getFOV() / 2); // getFOV() returns FOVy
+ real normalizedSlope = Math::Tan(getFOV() / 2); // getFOV() returns FOVy
real viewportYToWorldY = normalizedSlope * nearDist * 2;
real viewportXToWorldX = viewportYToWorldY * getAspectRatio();
- math::Vector3 rayOrigin, rayDirection;
+ Point3 rayOrigin;
+ Vector3 rayDirection;
if (getProjectionType() == PT_PERSPECTIVE)
{
rayOrigin = getPosition(); //@todo fixme should be: getDerivedPosition()
@@ -123,9 +124,9 @@
rayOrigin.z = 0.0f;
rayOrigin = getOrientation() * rayOrigin; //@todo fixme should be: getDerivedOrientation() * rayOrigin;
rayOrigin = getPosition() + rayOrigin; //@todo fixme should be: getDerivedPosition() + rayOrigin;
- rayDirection = getOrientation() * math::Vector3::kUnitZ; //@todo fixme should be: getDerivedDirection();
+ rayDirection = getOrientation() * Vector3::kUnitZ; //@todo fixme should be: getDerivedDirection();
}
- return math::Ray( rayOrigin, rayDirection );
+ return Ray( rayOrigin, rayDirection );
}
} // graphics
Modified: trunk/yake/src/loader/yakeDotScene.cpp
===================================================================
--- trunk/yake/src/loader/yakeDotScene.cpp 2007-08-31 03:36:26 UTC (rev 1831)
+++ trunk/yake/src/loader/yakeDotScene.cpp 2007-09-04 17:17:53 UTC (rev 1832)
@@ -205,7 +205,7 @@
}
//------------------------------------------------------
- void DotSceneParser::readVector( const SharedPtr<dom::INode>& pNode, math::Vector3& rVec )
+ void DotSceneParser::readVector( const SharedPtr<dom::INode>& pNode, Vector3& rVec )
{
YAKE_ASSERT( pNode );
rVec.x = StringUtil::parseReal( pNode->getAttributeValueAs<String>("x") );
@@ -214,19 +214,28 @@
}
//------------------------------------------------------
- void DotSceneParser::readPosition( const SharedPtr<dom::INode> & pNode, math::Vector3 & position )
+ void DotSceneParser::readPoint( const SharedPtr<dom::INode>& pNode, Point3& rVec )
{
- readVector( pNode, position );
+ YAKE_ASSERT( pNode );
+ rVec.x = StringUtil::parseReal( pNode->getAttributeValueAs<String>("x") );
+ rVec.y = StringUtil::parseReal( pNode->getAttributeValueAs<String>("y") );
+ rVec.z = StringUtil::parseReal( pNode->getAttributeValueAs<String>("z") );
}
//------------------------------------------------------
- void DotSceneParser::readScale( const SharedPtr<dom::INode>& pNode, math::Vector3& rScale )
+ void DotSceneParser::readPosition( const SharedPtr<dom::INode> & pNode, Point3 & position )
{
+ readPoint( pNode, position );
+ }
+
+ //------------------------------------------------------
+ void DotSceneParser::readScale( const SharedPtr<dom::INode>& pNode, Vector3& rScale )
+ {
readVector( pNode, rScale );
}
//------------------------------------------------------
- void DotSceneParser::readRotation( const SharedPtr<dom::INode>& pNode, math::Quaternion& rotation )
+ void DotSceneParser::readRotation( const SharedPtr<dom::INode>& pNode, Quaternion& rotation )
{
YAKE_ASSERT( pNode );
if ( pNode->getAttributeValueAs<String>("qx") != "" )
@@ -238,7 +247,7 @@
}
else if ( pNode->getAttributeValueAs<String>("axisX") != "" )
{
- math::Vector3 axis;
+ Vector3 axis;
axis.x = StringUtil::parseReal( pNode->getAttributeValueAs<String>("axisX") );
axis.y = StringUtil::parseReal( pNode->getAttributeValueAs<String>("axisY") );
axis.z = StringUtil::parseReal( pNode->getAttributeValueAs<String>("axisZ") );
@@ -246,7 +255,7 @@
}
else if ( pNode->getAttributeValueAs<String>("angleX") != "" )
{
- math::Vector3 axis;
+ Vector3 axis;
axis.x = StringUtil::parseReal( pNode->getAttributeValueAs<String>("angleX") );
axis.y = StringUtil::parseReal( pNode->getAttributeValueAs<String>("angleY") );
axis.z = StringUtil::parseReal( pNode->getAttributeValueAs<String>("angleZ") );
@@ -255,7 +264,7 @@
}
}
//------------------------------------------------------
- void DotSceneParser::readColour( const SharedPtr<dom::INode>& pNode, math::Color& colour )
+ void DotSceneParser::readColour( const SharedPtr<dom::INode>& pNode, Color& colour )
{
YAKE_ASSERT( pNode );
Modified: trunk/yake/src/loader/yakeXODEParser.cpp
===================================================================
--- trunk/yake/src/loader/yakeXODEParser.cpp 2007-08-31 03:36:26 UTC (rev 1831)
+++ trunk/yake/src/loader/yakeXODEParser.cpp 2007-09-04 17:17:53 UTC (rev 1832)
@@ -143,25 +143,35 @@
};
//------------------------------------------------------
- void XODEParser::readVector3( const NodeSharedPtr pVecNode, math::Vector3& rVec )
+ void XODEParser::readVector3( const NodeSharedPtr pVecNode, Vector3& rVec )
{
real x = StringUtil::parseReal( pVecNode->getAttributeValueAs<String>( "x" ) );
real y = StringUtil::parseReal( pVecNode->getAttributeValueAs<String>( "y" ) );
real z = StringUtil::parseReal( pVecNode->getAttributeValueAs<String>( "z" ) );
- rVec = math::Vector3( x, y, z );
+ rVec = Vector3( x, y, z );
}
- //------------------------------------------------------
- void XODEParser::readScale( const NodeSharedPtr pScaleNode, math::Vector3& rScale )
+ //------------------------------------------------------
+ void XODEParser::readPoint3( const NodeSharedPtr pVecNode, Point3& rVec )
+ {
+ real x = StringUtil::parseReal( pVecNode->getAttributeValueAs<String>( "x" ) );
+ real y = StringUtil::parseReal( pVecNode->getAttributeValueAs<String>( "y" ) );
+ real z = StringUtil::parseReal( pVecNode->getAttributeValueAs<String>( "z" ) );
+
+ rVec = Point3( x, y, z );
+ }
+
+ //------------------------------------------------------
+ void XODEParser::readScale( const NodeSharedPtr pScaleNode, Vector3& rScale )
{
readVector3( pScaleNode, rScale );
}
//------------------------------------------------------
- void XODEParser::readPosition( c...
[truncated message content] |
|
From: <psy...@us...> - 2007-09-04 21:41:10
|
Revision: 1833
http://yake.svn.sourceforge.net/yake/?rev=1833&view=rev
Author: psyclonist
Date: 2007-09-04 14:41:13 -0700 (Tue, 04 Sep 2007)
Log Message:
-----------
* [property] added try_get()
* [base] pull in math types into yake namespace
Modified Paths:
--------------
trunk/yake/common/media/scripts/raf1.lua
trunk/yake/src/bindings.lua/detail/ent.lua.cpp
trunk/yake/yake/base/math/yakeColor.h
trunk/yake/yake/base/math/yakeMatrix4.h
trunk/yake/yake/base/math/yakePoint3.h
trunk/yake/yake/base/math/yakeQuaternion.h
trunk/yake/yake/base/math/yakeRay.h
trunk/yake/yake/base/math/yakeVector3.h
trunk/yake/yake/base/yakeMovable.h
trunk/yake/yake/bindings.lua/common/yake.lua.any_converter.h
trunk/yake/yake/property/detail/property.impl.h
Modified: trunk/yake/common/media/scripts/raf1.lua
===================================================================
--- trunk/yake/common/media/scripts/raf1.lua 2007-09-04 17:17:53 UTC (rev 1832)
+++ trunk/yake/common/media/scripts/raf1.lua 2007-09-04 21:41:13 UTC (rev 1833)
@@ -2,6 +2,7 @@
local defaultCam = scene.activeCamera
local actionMap = app.actionMap
local input = yake.input
+local objMgr = sim.objMgr
--------------------------------------
-- Configure graphics
@@ -36,6 +37,12 @@
cam:lookAt( yake.Point3(0,100,0) ) -- look at our ninja!
--------------------------------------
+-- Create objects
+--------------------------------------
+
+local ninja = objMgr:makeObject("Entity")
+
+--------------------------------------
-- Configure input
--------------------------------------
Modified: trunk/yake/src/bindings.lua/detail/ent.lua.cpp
===================================================================
--- trunk/yake/src/bindings.lua/detail/ent.lua.cpp 2007-09-04 17:17:53 UTC (rev 1832)
+++ trunk/yake/src/bindings.lua/detail/ent.lua.cpp 2007-09-04 21:41:13 UTC (rev 1833)
@@ -117,6 +117,15 @@
evt.connect( o );
return true;
}
+ template<typename T>
+ T getPropertyValue(Object& o, const PropertyId& id)
+ {
+ PropertyPtr p = o.properties().get(id);
+ YAKE_ASSERT( p )(id)(o.id()).debug("property not found");
+ boost::optional<T> val = property::try_get<T>(*p);
+ YAKE_ASSERT( val ).debug("type mismatch");
+ return val ? *val : T();
+ }
static property::PropertyBase* getPropertyOfObject(Object& o, const PropertyId& id)
{
return o.properties().get(id).get();
Modified: trunk/yake/yake/base/math/yakeColor.h
===================================================================
--- trunk/yake/yake/base/math/yakeColor.h 2007-09-04 17:17:53 UTC (rev 1832)
+++ trunk/yake/yake/base/math/yakeColor.h 2007-09-04 21:41:13 UTC (rev 1833)
@@ -136,6 +136,7 @@
Color operator*( real fScalar, const Color& rColor );
} // math
+using math::Color;
} // yake
// Fast Inline Implementation.
Modified: trunk/yake/yake/base/math/yakeMatrix4.h
===================================================================
--- trunk/yake/yake/base/math/yakeMatrix4.h 2007-09-04 17:17:53 UTC (rev 1832)
+++ trunk/yake/yake/base/math/yakeMatrix4.h 2007-09-04 21:41:13 UTC (rev 1833)
@@ -434,6 +434,7 @@
}
} // math
+using math::Matrix4;
} // yake
#endif
Modified: trunk/yake/yake/base/math/yakePoint3.h
===================================================================
--- trunk/yake/yake/base/math/yakePoint3.h 2007-09-04 17:17:53 UTC (rev 1832)
+++ trunk/yake/yake/base/math/yakePoint3.h 2007-09-04 21:41:13 UTC (rev 1833)
@@ -244,6 +244,7 @@
}
} // math
+using math::Point3;
} // yake
#endif // YAKE_BASE_MATH_POINT3_H
Modified: trunk/yake/yake/base/math/yakeQuaternion.h
===================================================================
--- trunk/yake/yake/base/math/yakeQuaternion.h 2007-09-04 17:17:53 UTC (rev 1832)
+++ trunk/yake/yake/base/math/yakeQuaternion.h 2007-09-04 21:41:13 UTC (rev 1833)
@@ -147,6 +147,7 @@
}
} // math
+using math::Quaternion;
} // yake
#endif // YAKE_MATH_QUATERNION_H
Modified: trunk/yake/yake/base/math/yakeRay.h
===================================================================
--- trunk/yake/yake/base/math/yakeRay.h 2007-09-04 17:17:53 UTC (rev 1832)
+++ trunk/yake/yake/base/math/yakeRay.h 2007-09-04 21:41:13 UTC (rev 1833)
@@ -76,6 +76,7 @@
};
}
+using math::Ray;
}
#endif
Modified: trunk/yake/yake/base/math/yakeVector3.h
===================================================================
--- trunk/yake/yake/base/math/yakeVector3.h 2007-09-04 17:17:53 UTC (rev 1832)
+++ trunk/yake/yake/base/math/yakeVector3.h 2007-09-04 21:41:13 UTC (rev 1833)
@@ -426,6 +426,7 @@
}
} // math
+using math::Vector3;
} // yake
#endif // YAKE_BASE_MATH_VECTOR3_H
Modified: trunk/yake/yake/base/yakeMovable.h
===================================================================
--- trunk/yake/yake/base/yakeMovable.h 2007-09-04 17:17:53 UTC (rev 1832)
+++ trunk/yake/yake/base/yakeMovable.h 2007-09-04 21:41:13 UTC (rev 1833)
@@ -34,6 +34,7 @@
#include <yake/base/yakePrerequisites.h>
#include <yake/base/math/yakeVector3.h>
#include <yake/base/math/yakePoint3.h>
+#include <yake/base/math/yakeQuaternion.h>
// Yake
//============================================================================
@@ -41,7 +42,6 @@
//============================================================================
namespace yake {
- using namespace ::yake::math;
/** Interface for movable objects and basic implementation of
methods for convenience (like translate()).
Modified: trunk/yake/yake/bindings.lua/common/yake.lua.any_converter.h
===================================================================
--- trunk/yake/yake/bindings.lua/common/yake.lua.any_converter.h 2007-09-04 17:17:53 UTC (rev 1832)
+++ trunk/yake/yake/bindings.lua/common/yake.lua.any_converter.h 2007-09-04 21:41:13 UTC (rev 1833)
@@ -37,7 +37,7 @@
#define YAKE_LUA_ANY_CONVERTER_API YAKE_BINDINGS_LUA_API
-#define YAKE_LUA_ANY_CONVERTER_POINTERS 1
+#define YAKE_LUA_ANY_CONVERTER_POINTERS 0
#if YAKE_ENABLE_LUA_PROPERTY == 1 // extension for yake::property:
# include <yake/property/property.h>
Modified: trunk/yake/yake/property/detail/property.impl.h
===================================================================
--- trunk/yake/yake/property/detail/property.impl.h 2007-09-04 17:17:53 UTC (rev 1832)
+++ trunk/yake/yake/property/detail/property.impl.h 2007-09-04 21:41:13 UTC (rev 1833)
@@ -34,6 +34,7 @@
#include <yake/base/templates/yakeSignals.h>
#include <yake/base/templates/yakePointer.h>
#include <yake/base/templates/yakeSmartAssert.h>
+#include <boost/optional.hpp>
namespace yake {
namespace property {
@@ -139,12 +140,25 @@
return static_cast<to_t&>(prop);
}
template<typename T/*, template <typename> class AccT*/>
- void try_cast_set(PropertyBase& prop, const T& newValue)
+ void try_set(PropertyBase& prop, const T& newValue)
{
typedef Property<T> to_t;
to_t& propCasted = try_cast<T>(prop);
propCasted.set( newValue );
}
+ template<typename T/*, template <typename> class AccT*/>
+ boost::optional<T> try_get(const PropertyBase& prop)
+ {
+ typedef Property<T> to_t;
+ try {
+ const to_t& propCasted = try_cast<T>(prop);
+ return propCasted.get();
+ }
+ catch (BadCastException&)
+ {
+ return false;
+ }
+ }
template<typename T>
void try_cast_set_from_any(PropertyBase& prop, const boost::any& rhs)
{
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <psy...@us...> - 2007-09-05 22:57:36
|
Revision: 1835
http://yake.svn.sourceforge.net/yake/?rev=1835&view=rev
Author: psyclonist
Date: 2007-09-05 15:57:37 -0700 (Wed, 05 Sep 2007)
Log Message:
-----------
* [base,audioOpenAL] Vector3 -> Point3 fixes
Modified Paths:
--------------
trunk/yake/src/plugins/audioOpenAL/yakeAudioListenerOpenAL.cpp
trunk/yake/src/plugins/audioOpenAL/yakeAudioSourceOpenAL.cpp
trunk/yake/yake/base/math/yakeGeometry.h
trunk/yake/yake/plugins/audioOpenAL/yakeAudioSystemOpenAL.h
Modified: trunk/yake/src/plugins/audioOpenAL/yakeAudioListenerOpenAL.cpp
===================================================================
--- trunk/yake/src/plugins/audioOpenAL/yakeAudioListenerOpenAL.cpp 2007-09-05 18:18:39 UTC (rev 1834)
+++ trunk/yake/src/plugins/audioOpenAL/yakeAudioListenerOpenAL.cpp 2007-09-05 22:57:37 UTC (rev 1835)
@@ -67,18 +67,18 @@
return orientation;*/
}
- void ListenerOpenAL::setPosition( const Vector3 & position )
+ void ListenerOpenAL::setPosition( const Point3 & position )
{
YAKE_ASSERT( mListener.valid() );
mListener->setPosition( position.x, position.y, position.z );
}
- Vector3 ListenerOpenAL::getPosition() const
+ Point3 ListenerOpenAL::getPosition() const
{
YAKE_ASSERT( mListener.valid() );
float x,y,z;
mListener->getPosition( x, y, z );
- return Vector3( x, y, z );
+ return Point3( x, y, z );
}
void ListenerOpenAL::setVelocity( const Vector3 & velocity )
Modified: trunk/yake/src/plugins/audioOpenAL/yakeAudioSourceOpenAL.cpp
===================================================================
--- trunk/yake/src/plugins/audioOpenAL/yakeAudioSourceOpenAL.cpp 2007-09-05 18:18:39 UTC (rev 1834)
+++ trunk/yake/src/plugins/audioOpenAL/yakeAudioSourceOpenAL.cpp 2007-09-05 22:57:37 UTC (rev 1835)
@@ -77,17 +77,17 @@
YAKE_ASSERT( mSource.valid() );
return mOrientation;
}
- void SourceOpenAL::setPosition( const Vector3 & position )
+ void SourceOpenAL::setPosition( const Point3 & position )
{
YAKE_ASSERT( mSource.valid() );
mSource->setPosition( position.x, position.y, position.z );
}
- Vector3 SourceOpenAL::getPosition() const
+ Point3 SourceOpenAL::getPosition() const
{
YAKE_ASSERT( mSource.valid() );
float x,y,z;
mSource->getPosition(x,y,z);
- return Vector3(x,y,z);
+ return Point3(x,y,z);
}
void SourceOpenAL::setVelocity( const Vector3 & velocity )
Modified: trunk/yake/yake/base/math/yakeGeometry.h
===================================================================
--- trunk/yake/yake/base/math/yakeGeometry.h 2007-09-05 18:18:39 UTC (rev 1834)
+++ trunk/yake/yake/base/math/yakeGeometry.h 2007-09-05 22:57:37 UTC (rev 1835)
@@ -118,6 +118,7 @@
};
}
+using math::Rectangle;
}
#endif
Modified: trunk/yake/yake/plugins/audioOpenAL/yakeAudioSystemOpenAL.h
===================================================================
--- trunk/yake/yake/plugins/audioOpenAL/yakeAudioSystemOpenAL.h 2007-09-05 18:18:39 UTC (rev 1834)
+++ trunk/yake/yake/plugins/audioOpenAL/yakeAudioSystemOpenAL.h 2007-09-05 22:57:37 UTC (rev 1835)
@@ -107,8 +107,8 @@
virtual void setOrientation( const Quaternion & orientation );
virtual Quaternion getOrientation() const;
- virtual void setPosition( const Vector3 & position );
- virtual Vector3 getPosition() const;
+ virtual void setPosition( const Point3 & position );
+ virtual Point3 getPosition() const;
protected:
openalpp::ref_ptr<openalpp::SourceBase> mSource;
SoundDataOpenALBase* mSoundData;
@@ -126,8 +126,8 @@
virtual void setOrientation( const Quaternion & orientation );
virtual Quaternion getOrientation() const;
- virtual void setPosition( const Vector3 & position );
- virtual Vector3 getPosition() const;
+ virtual void setPosition( const Point3 & position );
+ virtual Point3 getPosition() const;
protected:
openalpp::ref_ptr<openalpp::Listener> mListener;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <psy...@us...> - 2007-09-09 23:04:11
|
Revision: 1843
http://yake.svn.sourceforge.net/yake/?rev=1843&view=rev
Author: psyclonist
Date: 2007-09-09 16:04:14 -0700 (Sun, 09 Sep 2007)
Log Message:
-----------
* [bindings.lua] added implicit casting to derived classes for makeObject() etc
* [bindings.lua] added class registry for implicit casters etc
* [scriptingLua] added 'package' package
* [ent] added ObjectCreationParameters
* [demos] cleaned up Lua entity scripts
* [base] improved ParamHolder interface
Modified Paths:
--------------
trunk/yake/common/media/scripts/o_entity.lua
trunk/yake/common/media/scripts/o_trigger2.lua
trunk/yake/common/media/scripts/raf2.lua
trunk/yake/samples/raf/lua2/demo.cpp
trunk/yake/src/base/yakeParamHolder.cpp
trunk/yake/src/bindings.lua/detail/ent.lua.cpp
trunk/yake/src/ent/object_mgr.cpp
trunk/yake/src/ent/vm_holder.cpp
trunk/yake/src/plugins/scriptingLua/ScriptingSystemLua.cpp
trunk/yake/yake/base/yakeParamHolder.h
trunk/yake/yake/base/yakeString.h
trunk/yake/yake/bindings.lua/bindings.lua.ent.h
trunk/yake/yake/ent/object.h
trunk/yake/yake/ent/object_mgr.h
trunk/yake/yake/ent/object_mgr_listener.h
trunk/yake/yake/plugins/scriptingLua/ScriptingSystemLua.h
Added Paths:
-----------
trunk/yake/common/media/scripts/o_ball.lua
trunk/yake/src/bindings.lua/detail/ent.listener.lua.cpp
trunk/yake/src/bindings.lua/detail/ent.registry.lua.cpp
trunk/yake/yake/bindings.lua/bindings.lua.ent.registry.h
Removed Paths:
-------------
trunk/yake/common/media/scripts/o_trigger.lua
Added: trunk/yake/common/media/scripts/o_ball.lua
===================================================================
--- trunk/yake/common/media/scripts/o_ball.lua (rev 0)
+++ trunk/yake/common/media/scripts/o_ball.lua 2007-09-09 23:04:14 UTC (rev 1843)
@@ -0,0 +1,16 @@
+function onTick()
+end
+function main()
+ this.events.tick:connect( onTick )
+ this.model = yake.Model()
+
+ local g = yake.Graphical()
+ this.model:add(g)
+
+ local sn = sim.gworld:createSceneNode()
+ g:addSceneNode( sn )
+ local e = sim.gworld:createEntity("sphere_d1.mesh")
+ sn:attach(e)
+
+ this:setPositionSource(sn)
+end
Modified: trunk/yake/common/media/scripts/o_entity.lua
===================================================================
--- trunk/yake/common/media/scripts/o_entity.lua 2007-09-07 13:57:17 UTC (rev 1842)
+++ trunk/yake/common/media/scripts/o_entity.lua 2007-09-09 23:04:14 UTC (rev 1843)
@@ -1,14 +1,7 @@
-print("> Starting object script...");
function onTick()
- --this.position = this.position + yake.Vector3( 0, 0, 1 )
+ -- TODO your code here
end
-function startup()
+function main()
this.events.tick:connect( onTick )
end
-print("> Object script up.");
-function main()
- print(" script main()")
- startup()
-end
-
Deleted: trunk/yake/common/media/scripts/o_trigger.lua
===================================================================
--- trunk/yake/common/media/scripts/o_trigger.lua 2007-09-07 13:57:17 UTC (rev 1842)
+++ trunk/yake/common/media/scripts/o_trigger.lua 2007-09-09 23:04:14 UTC (rev 1843)
@@ -1,99 +0,0 @@
-print("> Starting object script...");
-function startup()
- --this:fsm("main"):connectTo("alive",fn) -- connects to 'enter', 'tick', 'exit'
- --this:fsm("main"):connectToEnter("dead",fn) -- connects to 'enter' only
- --this:fsm("main"):connect("alive", fnEnter, fnTick, fnExit)
-
- this:events("spawn"):connect(
- function()
-
- end
- )
-end
-event = {
- on_spawn = function()
- print(" script event.on_spawn")
- end,
- on_tick = function()
- print(" script event.on_tick")
- end,
- on_die = function()
- print(" script event.on_die")
- end,
- -- various:
- onArrived = function() --triggered as a result of "go to"
- end,
- -- Trigger
- on_toggle = function(a)
- print("event.on_toggle")
- end
-}
-fsm = {
- main = {
- states = {
- awakening,
- alive,
- dead
- },
- transitions = {
- {awakening,"spawn",alive},
- {alive,"die",dead}
- }
- }
-}
-state = {
- ticks = 0,
- off = {
- on_enter = function()
- print("state.off.enter()")
-
- this:setCondition(function() return (state.ticks >= 1 and state.ticks <= 3) end)
- this:events():get("onTriggered"):connect( function(a) print("TRIGGER:onTriggered:",a) end )
- end,
- on_tick = function()
- state.ticks = state.ticks + 1
- print("TRIGGER off.tick()",state.ticks)
- --
- --if (state.off.ticks == 1) then
- -- this:processFsmEvent("trigger")
- --end
- --
- end,
- on_exit = function()
- print("state.off.exit()")
- end
- }
- ,
- on = {
- on_enter = function()
- print("state.on.enter()")
- --this:processFsmEvent("trigger")
- --this:events():get("onTriggered"):fire()
- end,
- on_tick = function()
- state.ticks = state.ticks + 1
- print("TRIGGER on.tick()",state.ticks)
- end,
- on_exit = function()
- print("state.on.exit()")
- end
- }
- ,
- dead = {
- on_enter = function()
- print(" script state.dead.on_enter")
- end,
- on_tick = function()
- print(" script state.dead.on_tick")
- end,
- on_exit = function()
- print(" script state.dead.on_exit")
- end
- }
-}
-print("> Object script up.");
-
-function main()
- print("main()")
-end
-
Modified: trunk/yake/common/media/scripts/o_trigger2.lua
===================================================================
--- trunk/yake/common/media/scripts/o_trigger2.lua 2007-09-07 13:57:17 UTC (rev 1842)
+++ trunk/yake/common/media/scripts/o_trigger2.lua 2007-09-09 23:04:14 UTC (rev 1843)
@@ -4,12 +4,10 @@
function onTick()
if this.volumes and this.volumes.size > 0 then
- assert( objMgr, "no obj mgr" )
- local objs = objMgr:getAllObjects()
+ assert( sim.objMgr, "no obj mgr" )
+ local objs = sim.objMgr:getAllObjects()
- for id,obj in pairs(objs) do
- --print(obj:isA())
- local ent = yake.asEntity(obj)
+ for id,ent in pairs(objs) do
if ent and id ~= this.id then -- ignore self, and non-Entity objects
local intersects = this.volumes:intersectsWith( ent.position )
if not this.on and intersects then
@@ -28,7 +26,7 @@
--end
end
end
-function startup()
+function main()
-- common ent::Object events
this.events.tick:connect( onTick )
@@ -39,12 +37,5 @@
-- VolumeTrigger stuff
this.properties:create("volumes", yake.VolumeContainerRef())
- --this.createProperty("volumes", yake.VolumeContainerRef())
end
print("> Object script up.");
-
-function main()
- print(" script main()")
- startup()
-end
-
Modified: trunk/yake/common/media/scripts/raf2.lua
===================================================================
--- trunk/yake/common/media/scripts/raf2.lua 2007-09-07 13:57:17 UTC (rev 1842)
+++ trunk/yake/common/media/scripts/raf2.lua 2007-09-09 23:04:14 UTC (rev 1843)
@@ -1,85 +1,28 @@
-
--
-- raf/lua2 demo - main application script
--
-- available bindings:
--- * res (including loads, i.e. yake.dofile)
--- * graphics, ent, raf, and more
+-- * res (including yake.dofile)
+-- * graphics, physics, ent, raf, model and more
+-- * demo specific bindings (sim.* and app.*)
--
---
-local gworld = scene.gworld
-local defaultCam = scene.activeCamera
+local gworld = sim.gworld
+local defaultCam = sim.activeCamera
+local objMgr = sim.objMgr
local actionMap = app.actionMap
local input = yake.input
-print(type(sim))
-print(type(sim.objMgr))
-local objMgr = sim.objMgr
+local io = require 'io'
--------------------------------------
--- Syntactic sugar for objMgr and
--- objects / entities and their
--- properties and events
--- @todo do this on C++ side
--- (g_casters -> probably as part of ThisBinder mechanism...)
---------------------------------------
-
--- register "Entity" -> DerivedEntity casters
--- @todo lookup via "RtiiClass*" instead of string (-> faster...)
-g_casters = {}
-g_casters["Entity"] = yake.asEntity
-g_casters["Trigger"] = yake.asTrigger
-
--- makes accessing properties and events
--- syntactically simpler.
--- -> Adds (syntactic) sugar. Instant pleasure.
-function wrapEventsAndProperties(obj)
- assert( obj )
- --obj.events = {}
- --wrapEventsTable(obj.events,obj:eventAccessor(),false)
- --obj.properties = {}
- --wrapPropertiesTable(obj.properties,obj:propertyAccessor(),false)
- return obj
-end
-
--- Attempts to cast to most derived class.
--- Returns the input object on failure, so obj stays valid.
-function tryCastToDerived(obj)
- local caster = g_casters[obj:isA().name]
- assert( caster, "no caster available - returning as-is "..tostring(obj:isA()) )
- if not caster then
- return obj, false
- end
- obj = caster( obj )
- assert( obj, "cast failed" )
- return obj, true
-end
-
--- Attempts to cast to most derived class and
--- also wraps event and property access for syntactic sugar.
--- Returned obj is at least as valid as the original obj. :)
-function tryOpen(obj)
- local ok = false
- obj,ok = tryCastToDerived(obj)
- obj = wrapEventsAndProperties(obj)
- return obj
-end
-
--- Redefine objMgr.makeObject() to take advantage of wrapEventsAndProperties()
-objMgr.old_makeObject = objMgr.makeObject
-objMgr.makeObject = function(self,clsid)
- local o = tryOpen( self:old_makeObject(clsid) )
- print("(lua)objMgr.makeObject created "..tostring(o.id))
- return o
-end
-
---------------------------------------
-- demo methods which make creating various objects simpler
--------------------------------------
function makeProximityTrigger(radius)
local trigger = objMgr:makeObject("Trigger")
assert( trigger )
+ trigger.volumes:add( yake.Sphere(radius or 2) )
+
-- create DEBUG geometry
local m = yake.Model()
trigger.model = m
@@ -96,31 +39,11 @@
g:addSceneNode(sn)
--ent:setPositionSource(sn)
--
- trigger.volumes:add( yake.Sphere(radius or 2) )
- --
return trigger
end
-yake.Entity.makeSimpleGraphical = function(self,meshname)
- assert(self, "missing self")
- assert(meshname, "missing mesh name")
-
- local m = yake.Model()
- self.model = m
-
- local g = yake.Graphical()
- m:add(g)
-
- local sn = gworld:createSceneNode()
- g:addSceneNode( sn )
- local e = gworld:createEntity(meshname)
- sn:attach(e)
-
- self:setPositionSource(sn)
-end
function createBall()
- local ent = yake.asEntity( objMgr:makeObject("Entity") )
- assert( ent )
- ent.model = ent:makeSimpleGraphical("sphere_d1.mesh")
+ local ent = objMgr:makeObject("Ball")
+ print("BALL at position ",ent.position) --< This actually accesses a static (!) property of a derived (!) class!
return ent
end
@@ -146,7 +69,7 @@
-- configure active (=default) camera
-local cam = scene.activeCamera
+local cam = sim.activeCamera
assert(cam)
cam.nearClipDistance = 0.1
cam.position = yake.Point3(0,2,-10)
@@ -158,14 +81,12 @@
-- create ball
local ball = createBall()
-ball.translate = function(self,delta)
- ball.position = ball.position + delta
-end
cam:lookAt( ball.position ) -- Now look at our ball!
-- create trigger
local trigger = makeProximityTrigger(2)
+-- trigger callback
function onTrigger(yes)
if yes then
print("TRIGGERED",trigger.id,trigger.on)
@@ -176,12 +97,20 @@
end
end
+-- connect trigger callback to trigger event
trigger.events.onTriggered:connect(onTrigger)
--------------------------------------
-- Configure input
--------------------------------------
+--class 'DemoApp'
+--function DemoApp:__init()
+-- self.actionMap = app.actionMap
+--end
+--local app = DemoApp()
+--
+
local activeKeys = {} -- Store the keys that are active in current frame.
-- We demonstrate two ways to bind Lua callbacks to a keyboard action.
@@ -234,12 +163,12 @@
end)
----------------- F r a m e H a n d l e r ---------------
-local currAngle = 0.
+ball.currAngle = 0.
function onFrame(timeElapsed)
-- Move our little ball on a spherical trajectory so
-- that it regularly passes the trigger volume boundary.
- currAngle = currAngle + 1.2 * timeElapsed
- ball.position = yake.Point3( math.cos(currAngle), math.sin(currAngle), 0 ) + yake.Vector3(-2,0,0)
+ ball.currAngle = ball.currAngle + 1.2 * timeElapsed
+ ball.position = yake.Point3( math.cos(ball.currAngle), math.sin(ball.currAngle), 0 ) + yake.Vector3(-2,0,0)
-- Handle user moving the camera:
local distance = 25 * timeElapsed
@@ -257,4 +186,4 @@
-- prepare for next frame:
activeKeys = {}
-end
\ No newline at end of file
+end
Modified: trunk/yake/samples/raf/lua2/demo.cpp
===================================================================
--- trunk/yake/samples/raf/lua2/demo.cpp 2007-09-07 13:57:17 UTC (rev 1842)
+++ trunk/yake/samples/raf/lua2/demo.cpp 2007-09-09 23:04:14 UTC (rev 1843)
@@ -10,6 +10,7 @@
#include "yake/bindings.lua/bindings.lua.h"
#include "yake/bindings.lua/common/yake.lua.common.h"
#include "yake/bindings.lua/bindings.lua.ent.h"
+#include "yake/bindings.lua/bindings.lua.ent.registry.h"
#include "yake/res/res.h"
using namespace yake;
@@ -19,17 +20,7 @@
YAKE_ASSERT( script );
vm.execute( script );
}
-void enable_entity_accessorwrappers(scripting::IVM& vm)
-{
- scripting::ScriptPtr script = vm.getCreator()->createScriptFromFile("entityeventaccess.lua");
- YAKE_ASSERT( script );
- vm.execute( script );
- script = vm.getCreator()->createScriptFromFile("entitypropertyaccess.lua");
- YAKE_ASSERT( script );
- vm.execute( script );
-}
-
namespace env {
struct Environment : public noncopyable
{
@@ -41,6 +32,12 @@
}
~Environment()
{
+ YAKE_FOR_EACH(Instances::const_iterator, it, instances_)
+ {
+ if (it->second.deleter)
+ it->second.deleter();
+ }
+ instances_.clear();
}
private:
template<typename T>
@@ -49,13 +46,19 @@
delete t;
}
public:
+ enum OwnershipTransfer
+ {
+ DoNotTransferOwnership = 0,
+ TransferOwnership = 1
+ };
template<typename T>
- void set(T* t)
+ void set(T* t, const OwnershipTransfer ownership = DoNotTransferOwnership)
{
InstanceEntry e;
e.px = t;
- e.deleter =boost::bind(&Environment::doDelete<T>,t);
+ if (ownership == TransferOwnership)
+ e.deleter =boost::bind(&Environment::doDelete<T>,t);
instances_[ TypeId<T>() ] = e;
}
template<typename T>
@@ -82,85 +85,14 @@
};
} // namespace env
-struct entObject_InstanceBinder_Traits
-{
- typedef ent::Object base_type;
- typedef RttiClass* index_type;
-
- template<class ConcreteT>
- static index_type getIndex()
+namespace {
+ struct RegisterObjectClasses
{
- return ConcreteT::cls();
- }
-
- static index_type getIndex(const base_type& o)
- {
- return o.isA();
- }
-};
-
-template<class TraitsT>
-struct ClassInstanceBinder
-{
- typedef TraitsT traits_type;
- typedef typename TraitsT::base_type base_type;
- typedef typename TraitsT::index_type index_type;
- typedef base_type* base_pointer;
-
- typedef boost::function<void(luabind::object,base_pointer)> BinderFn;
-
- template<class ConcreteT>
- void registerBinder(BinderFn fn)
- {
- binders_[ traits_type::getIndex<ConcreteT>() ] = fn;
- }
-
- void bind(luabind::object tbl, base_pointer obj)
- {
- YAKE_ASSERT( obj );
- YAKE_ASSERT( tbl.is_valid() );
- YAKE_ASSERT( luabind::type(tbl) == LUA_TTABLE );
- BinderMap::const_iterator it = binders_.find( traits_type::getIndex(*obj) );
- YAKE_ASSERT( it != binders_.end() ).debug("Cannot lookup ThisBinder through parents, at the moment!");
- it->second(tbl,obj);
- }
-private:
- typedef std::map<index_type,BinderFn> BinderMap;
-
- BinderMap binders_;
-};
-typedef ClassInstanceBinder<entObject_InstanceBinder_Traits> ObjectThisBinders;
-ObjectThisBinders& thisBinders()
-{
- static ObjectThisBinders s_instance;
- return s_instance;
-}
-
-template<class T>
-void do_register_bindThis(luabind::object tbl, ent::Object* o)
-{
- YAKE_ASSERT(o);
- YAKE_ASSERT(tbl.is_valid());
- YAKE_ASSERT(luabind::type(tbl) == LUA_TTABLE);
- T* t = T::cast(o);
- YAKE_ASSERT(t)(o->isA()->name()).error("Type mismatch!");
- tbl["this"] = t;
-}
-
-template<class T>
-void register_bindThis()
-{
- thisBinders().registerBinder<T>( boost::bind(&do_register_bindThis<T>,_1,_2) );
-}
-
-namespace {
- struct RegisterThisBinders
- {
- RegisterThisBinders()
+ RegisterObjectClasses()
{
- register_bindThis<ent::Object>();
- register_bindThis<ent::Entity>();
- register_bindThis<ent::Trigger>();
+ ent::registerClass<ent::Object>();
+ ent::registerClass<ent::Entity>();
+ ent::registerClass<ent::Trigger>();
}
} g_doRegister;
} // namespace
@@ -168,136 +100,58 @@
/** Binds 'this' in object's Lua VMs. */
struct My_ObjectListener : public ent::ObjectManagerListener
{
- My_ObjectListener(scripting::IScriptingSystem& scriptingSys,
- const StringVector& startupScripts,
- ent::ObjectManager* objMgr) :
- scriptingSys_(scriptingSys), objMgr_(objMgr)
+ My_ObjectListener()
{
- YAKE_ASSERT( objMgr_ );
- YAKE_FOR_EACH( StringVector::const_iterator, it, startupScripts )
- {
- ScriptPtr script = scriptingSys_.createScriptFromFile( *it );
- YAKE_ASSERT( script != 0 );
- if (script)
- startupScripts_.push_back( script );
- }
}
private:
- scripting::IScriptingSystem& scriptingSys_;
- typedef scripting::ScriptPtr ScriptPtr;
- typedef std::deque<ScriptPtr> ScriptPtrList;
- ScriptPtrList startupScripts_;
- ent::ObjectManager* objMgr_;
-private:
- virtual void onObjectCreated(ent::Object* obj)
+ virtual void onObjectCreated(ent::Object* obj, const ent::ObjectCreationParameters& params)
{
YAKE_ASSERT( obj );
YAKE_LOG( "MOL", "onObjectCreated: class is '" + obj->isA()->name() + "'" );
-
- ent::Entity* ent = ent::Entity::cast(obj);
- YAKE_ASSERT( ent );
- if (!ent)
- return;
-
- scripting::VMPtr vm = scriptingSys_.createVM();
- YAKE_ASSERT( vm );
- bind_all( vm.get() );
-
- ent->attachVM(vm,"main");
-
- lua_State* L = static_cast<scripting::LuaVM*>(vm.get())->getLuaState();
- YAKE_ASSERT(L);
-
- //
- enable_entity_accessorwrappers( *vm );
- thisBinders().bind( luabind::globals(L), obj );
-
- //
- luabind::globals(L)["objMgr"] = objMgr_;
-
- String err;
- try
- {
- ScriptPtr script;
- if (ent::Trigger::cast(ent))
- script = scriptingSys_.createScriptFromFile("o_trigger2.lua");
- else
- script = scriptingSys_.createScriptFromFile("o_entity.lua");
- vm->execute( script );
- }
- catch (std::exception& ex)
- {
- err += "Failed to run startup script:";
- err += ex.what();
- }
- if (!err.empty())
- YAKE_EXCEPT( err );
-
- /*@todo
- YAKE_FOR_EACH( ScriptPtrList::const_iterator, it, startupScripts_ )
- {
- String err;
- try
- {
- vm->execute( *it );
- }
- catch (std::exception& ex)
- {
- err += "Failed to run startup script:";
- err += ex.what();
- }
- if (!err.empty())
- YAKE_EXCEPT( err );
- }
- */
}
virtual void onDestroyObject(ent::Object* obj)
{
- ent::Entity* ent = ent::Entity::cast(obj);
- YAKE_ASSERT( ent );
-
- scripting::VMPtr vm = ent->detachVM("main");
- YAKE_ASSERT( vm );
- // vm will destruct when scope is left.
}
- virtual void onObjectInitialized(ent::Object* obj)
+ virtual void onObjectInitialized(ent::Object* obj, const ent::ObjectCreationParameters& params)
{
- ent::Entity* ent = ent::Entity::cast(obj);
- YAKE_ASSERT( ent );
-
- ent->processFsmEvent("spawn");
}
};
struct Simulation : public noncopyable
{
- Simulation(env::Environment& parentEnv) : env_(parentEnv)
+ Simulation(env::Environment& parentEnv,
+ ent::LuaObjectManagerListener::BinderFn appBinderFn) : env_(parentEnv), appBinderFn_(appBinderFn)
{
scripting::IScriptingSystem* scriptSys = env_.get<scripting::IScriptingSystem>();
YAKE_ASSERT( scriptSys );
// Register object class(es) that we may want to use in this simulation:
- ent::RegistrationResult ret = objMgr_.registerClass<ent::Entity>("Entity");
+ ent::ObjectCreationParameters params;
+ params.set("lua.startup",(MakeStringVector() << "o_entity.lua").get());
+ ent::RegistrationResult ret = objMgr_.registerClass<ent::Entity>("Entity",params);
YAKE_ASSERT( ret.first == object::RC_OK );
- ret = objMgr_.registerClass<ent::Trigger>("Trigger");
+ params.set("lua.startup",(MakeStringVector() << "o_trigger2.lua").get());
+ ret = objMgr_.registerClass<ent::Trigger>("Trigger",params);
YAKE_ASSERT( ret.first == object::RC_OK );
+ params.set("lua.startup",(MakeStringVector() << "o_ball.lua").get());
+ ret = objMgr_.registerClass<ent::Entity>("Ball",params);
+ YAKE_ASSERT( ret.first == object::RC_OK );
//
// Create & attach the listener which handles the connection to the Lua VM and the bindings.
- luaObjListener_.reset( new ent::LuaObjectManagerListener(*scriptSys) );
- objMgr_.attachListener( luaObjListener_.get(), "luaFsm", ent::ObjectManager::kKeepOwnership );
+ luaObjListener_.reset( new ent::LuaObjectManagerListener(*scriptSys,"main") );
+ luaObjListener_->addBinder( appBinderFn_ ); //@todo allow more
+ objMgr_.attachListener( luaObjListener_.get(), "luaOML", ent::ObjectManager::kKeepOwnership );
// Object listener for init'ing our objects
- StringVector startupScripts;
- startupScripts.push_back("o_trigger2.lua");
- myObjListener_.reset( new My_ObjectListener(*scriptSys,startupScripts,&this->objMgr_) );
+ myObjListener_.reset( new My_ObjectListener() );
objMgr_.attachListener( myObjListener_.get(), "Simulation.myObjListener_", ent::ObjectManager::kKeepOwnership );
}
void start()
{
- // Create trigger
+ // Create objects
{
//ent::Trigger* trigger = ent::Trigger::cast(objMgr_.makeObject("Trigger"));
//YAKE_ASSERT( trigger );
@@ -311,16 +165,28 @@
}
void step()
{
- objMgr_.tick();
+ String err;
+ try
+ {
+ objMgr_.tick();
+ }
+ catch (luabind::error& e)
+ {
+ const char* code = lua_tostring(e.state(),-1);
+ err = e.what();
+ err += code;
+ }
+ if (!err.empty())
+ YAKE_EXCEPT("Simulation.step(): " + err);
}
ent::ObjectManager* __getObjMgr()
{ return &objMgr_; }
private:
- env::Environment env_;
- ent::ObjectManager objMgr_;
- SharedPtr<My_ObjectListener> myObjListener_;
+ env::Environment env_;
+ ent::ObjectManager objMgr_;
+ SharedPtr<My_ObjectListener> myObjListener_;
SharedPtr<ent::LuaObjectManagerListener> luaObjListener_;
- //ent::LuaObjectManagerListener luaObjMgrListener_;
+ ent::LuaObjectManagerListener::BinderFn appBinderFn_;
};
/** Main application state */
@@ -333,15 +199,51 @@
{
enableInstantQuitByKey( input::KC_ESCAPE );
env_.set<scripting::IScriptingSystem>(app_.getScriptingSystem());
+ env_.set<raf::Application>(&app_);
+ env_.set<input::ActionMap>(&actionMap_);
env_.set<graphics::IWorld>(this->getGraphicalWorld());
+ //env_.set<graphics::ICamera>(this->getDefaultCamera());
}
private:
SharedPtr<Simulation> sim_;
+private:
+ void onBindApplication(scripting::IVM& vm)
+ {
+ raf::Application* app = env_.get<raf::Application>();
+ YAKE_ASSERT(app);
+
+ scripting::LuaVM* luavm = static_cast<scripting::LuaVM*>(&vm);
+ YAKE_ASSERT(luavm);
+ lua_State* L = luavm->getLuaState();
+ YAKE_ASSERT(L);
+
+ // base
+
+ bind_all( &vm );
+
+ // application
+
+ luabind::globals(L)["app"] = app;
+ luabind::globals(L)["app"]["actionMap"] = env_.get<input::ActionMap>();
+
+ // sim
+
+ luabind::module(L)
+ [
+ luabind::class_<Simulation>("Simulation")
+ ];
+
+ YAKE_ASSERT(sim_);
+ luabind::globals(L)["sim"] = sim_.get();
+ luabind::globals(L)["sim"]["objMgr"] = sim_->__getObjMgr();
+ luabind::globals(L)["sim"]["gworld"] = this->getGraphicalWorld();
+ luabind::globals(L)["sim"]["activeCamera"] = this->getDefaultCamera();
+ }
protected:
virtual void onEnter()
{
actionMap_.start();
- sim_.reset( new Simulation(env_) );
+ sim_.reset( new Simulation(env_,boost::bind(&TheMainState::onBindApplication,this,_1)) );
raf::RtMainState::onEnter(); // triggers onCreateScene()
}
@@ -369,33 +271,12 @@
YAKE_ASSERT( sys );
YAKE_ASSERT( !vm_ );
vm_ = sys->createVM();
- bind_all(vm_.get());
-
- //bind application vm
- {
- lua_State* L = static_cast<scripting::LuaVM*>(vm_.get())->getLuaState();
- luabind::globals(L)["app"] = &app_;
- luabind::globals(L)["app"]["actionMap"] = &actionMap_;
-
- luabind::object scene = luabind::newtable(L);
- scene["gworld"] = this->getGraphicalWorld();
- scene["activeCamera"] = this->getDefaultCamera();
- luabind::globals(L)["scene"] = scene;
-
- luabind::module(L)
- [
- luabind::class_<Simulation>("Simulation")
- ];
-
- luabind::globals(L)["sim"] = sim_.get();
- luabind::globals(L)["sim"]["objMgr"] = sim_->__getObjMgr();
- }
-
- //
+ onBindApplication(*vm_);
enable_res_loaders( *vm_ );
- enable_entity_accessorwrappers( *vm_ );
+ ent::classRegistry().bindCasters( static_cast<scripting::LuaVM*>(vm_.get())->getLuaState() );
+
// Create ninja model, position camera and look at the ninja: All done in Lua script:
scripting::ScriptPtr script = sys->createScriptFromFile("raf2.lua");
vm_->execute( script );
Modified: trunk/yake/src/base/yakeParamHolder.cpp
===================================================================
--- trunk/yake/src/base/yakeParamHolder.cpp 2007-09-07 13:57:17 UTC (rev 1842)
+++ trunk/yake/src/base/yakeParamHolder.cpp 2007-09-09 23:04:14 UTC (rev 1843)
@@ -47,17 +47,28 @@
keys.push_back( it->first );
return keys;
}
- const ParamHolder::Value& ParamHolder::get( const String & id ) const
+ const ParamHolder::Value& ParamHolder::getValue( const String & id ) const
{
ParamMap::const_iterator itFind = mParams.find( id );
if (itFind != mParams.end())
return itFind->second;
- return mParamNone;
+ return mParamNone; //todo throw NotFound?
}
- ParamHolder::Value ParamHolder::operator [] ( const String & id ) const
+ ParamHolder::Value& ParamHolder::getValue( const String & id )
{
- return get( id );
+ ParamMap::iterator itFind = mParams.find( id );
+ if (itFind != mParams.end())
+ return itFind->second;
+ return mParamNone; //todo throw NotFound?
}
+ const ParamHolder::Value& ParamHolder::operator [] ( const String & id ) const
+ {
+ return getValue( id );
+ }
+ ParamHolder::Value& ParamHolder::operator [] ( const String & id )
+ {
+ return getValue( id );
+ }
bool ParamHolder::set( const String & id, const Value& value )
{
YAKE_ASSERT( !id.empty() );
Added: trunk/yake/src/bindings.lua/detail/ent.listener.lua.cpp
===================================================================
--- trunk/yake/src/bindings.lua/detail/ent.listener.lua.cpp (rev 0)
+++ trunk/yake/src/bindings.lua/detail/ent.listener.lua.cpp 2007-09-09 23:04:14 UTC (rev 1843)
@@ -0,0 +1,234 @@
+/*
+ ------------------------------------------------------------------------------------
+ This file is part of YAKE
+ Copyright (c) 2004 - 2008 The YAKE Team
+ For the latest information visit http://www.yake.org
+ ------------------------------------------------------------------------------------
+ This program is free software; you can redistribute it and/or modify it under
+ the terms of the GNU Lesser 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 Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser 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, or go to
+ http://www.gnu.org/copyleft/lesser.txt.
+ ------------------------------------------------------------------------------------
+ If you are interested in another license model contact the Yake Team via
+ E-Mail: te...@ya....
+ For more information see the LICENSE file in the root directory of the
+ source code distribution.
+ ------------------------------------------------------------------------------------
+*/
+#include <yake/config.h>
+#if YAKE_ENABLE_LUA_ENT == 1
+
+#include <yake/bindings.lua/bindings.lua.h> // Don't forget to include this for proper dllexport!
+
+#include <yake/base/templates/yakeSmartAssert.h>
+#include <yake/bindings.lua/bindings.lua.ent.h>
+#include <yake/bindings.lua/bindings.lua.ent.registry.h>
+
+#include <yake/bindings.lua/common/yake.lua.shared_ptr.h>
+#include <yake/bindings.lua/common/yake.lua.any_converter.h>
+#include <yake/bindings.lua/detail/private.h>
+#include <yake/bindings.lua/detail/property.lua.h>
+
+
+namespace yake {
+namespace ent {
+ //-------------------------------------------------------------------------
+ namespace detail {
+ LuaFsmObjectListener::LuaFsmObjectListener(scripting::IScriptingSystem& scriptingSystem,
+ const String& vmName) :
+ scriptingSystem_(scriptingSystem), vmName_(vmName)
+ {
+ }
+ void LuaFsmObjectListener::onInit(Object& obj)
+ {
+ Entity* ent = Entity::cast(&obj);
+ if (ent)
+ {
+ YAKE_ASSERT( ent->getFsmVM() );
+
+ // Retrieve Lua state
+ scripting::VMPtr vm = ent->getVM(vmName_);
+ YAKE_ASSERT(vm);
+ scripting::LuaVM* luavm = static_cast<scripting::LuaVM*>(vm.get());
+ YAKE_ASSERT( vm );
+ lua_State* L = luavm->getLuaState();
+ YAKE_ASSERT( L );
+
+ // Init VM
+ ent::classRegistry().bindCasters( L );
+ ent::classRegistry().bindThis( luabind::globals(L), &obj );
+
+ // Start 'main'
+ String err;
+ try
+ {
+ luabind::call_function<void>(L,"main");
+ }
+ catch (luabind::error& ex)
+ {
+ const char* code = lua_tostring( ex.state(), -1 );
+ err += ex.what();
+ err += ":";
+ err += code;
+ YAKE_LOG_ERROR("ent.lua",String("LuaFsmObjectListener.onInit:") + code);
+ }
+ catch (std::exception& ex)
+ {
+ err = ex.what();
+ YAKE_LOG_ERROR("ent.lua",String("LuaFsmObjectListener.onInit:") + err);
+ }
+ if (!err.empty())
+ YAKE_EXCEPT(err);
+ }
+ }
+ void LuaFsmObjectListener::onTick(Object& obj)
+ {
+#if 0
+ Entity* ent = Entity::cast(&obj);
+ if (ent)
+ {
+ scripting::VMPtr vm = ent->getFsmVM();
+ vm->execute("event.on_tick()");
+ detail::executeOfTable_2(*vm,"state",ent->getCurrentFsmState(),"on_tick");
+ }
+#endif
+ }
+ void LuaFsmObjectListener::onFsmEventHandled(Object& obj, const object_fsm&, const object_fsm::event_type& evt)
+ {
+#if 0
+ Entity* ent = Entity::cast(&obj);
+ if (ent)
+ {
+ ent->getFsmVM()->execute("event.on_" + evt + "()");
+ }
+#endif
+ }
+ void LuaFsmObjectListener::onFsmEnterState(Object& obj,/*const std::string& fsmName, */const object_fsm&, const object_fsm::state_type& state)
+ {
+#if 0
+ Entity* ent = Entity::cast(&obj);
+ if (ent)
+ {
+ scripting::VMPtr vm = ent->getFsmVM();
+ YAKE_ASSERT( vm );
+ detail::executeOfTable_2(*vm,"state",state,"on_enter");
+ }
+#endif
+ }
+ void LuaFsmObjectListener::onFsmExitState(Object& obj,/*const std::string& fsmName, */const object_fsm&, const object_fsm::state_type& state)
+ {
+#if 0
+ Entity* ent = Entity::cast(&obj);
+ if (ent)
+ {
+ scripting::VMPtr vm = ent->getFsmVM();
+ YAKE_ASSERT( vm );
+ detail::executeOfTable_2(*vm,"state",state,"on_exit");
+ }
+#endif
+ }
+ } // namespace detail
+
+ //-------------------------------------------------------------------------
+ LuaObjectManagerListener::LuaObjectManagerListener(scripting::IScriptingSystem& scriptingSystem, const String& vmName) :
+ fsmListener_(scriptingSystem,vmName),
+ scriptingSystem_(scriptingSystem),
+ vmName_(vmName)
+ {
+ }
+ void LuaObjectManagerListener::addBinder(BinderFn fn)
+ {
+ YAKE_ASSERT(fn);
+ if (fn)
+ binders_.push_back(fn);
+ }
+ void LuaObjectManagerListener::onDestroyObject(Object* obj)
+ {
+ ent::Entity* ent = ent::Entity::cast(obj);
+ if (ent)
+ {
+ scripting::VMPtr vm = ent->detachVM("main");
+ YAKE_ASSERT( vm );
+ // vm will destruct when scope is left.
+ }
+ }
+ void LuaObjectManagerListener::onObjectCreated(Object* obj, const ObjectCreationParameters& params)
+ {
+ YAKE_LOG( "LuaMOL", "onObjectCreated: class is '" + obj->isA()->name() + "'" );
+ Entity* ent = Entity::cast(obj);
+ if (ent)
+ {
+ // create & attach a Lua VM
+ scripting::VMPtr vm = ent->getVM(vmName_);
+ if (!vm)
+ {
+ vm = scriptingSystem_.createVM();
+ YAKE_ASSERT( vm );
+ ent->attachVM(vm,vmName_);
+ }
+
+ // attach object listener
+ YAKE_ASSERT( ent );
+ ent->attachListener( &fsmListener_, "lua_listener", ObjectListenerManager::kKeepOwnership );
+
+ // Do basic binding:
+
+ // Retrieve Lua state
+ lua_State* L = static_cast<scripting::LuaVM*>(vm.get())->getLuaState();
+ YAKE_ASSERT(L);
+
+ // Bind app specific code
+ YAKE_FOR_EACH(Binders::const_iterator, it, binders_)
+ {
+ (*it)(*vm);
+ }
+
+ // Run startup scripts and run 'spawn'
+ boost::optional<StringVector> startupScripts = params.get<StringVector>("lua.startup");
+ String err;
+ try
+ {
+ // Run class specific scripts
+ if (startupScripts)
+ {
+ YAKE_FOR_EACH( StringVector::const_iterator, it, (*startupScripts) )
+ {
+ scripting::ScriptPtr script;
+ const String& scriptFile = *it;
+ //@todo cache these scripts
+ script = scriptingSystem_.createScriptFromFile(scriptFile);
+ vm->execute( script );
+ }
+ }
+
+ // Trigger 'spawn' event //@todo trigger 'spawn' here???
+ ent->processFsmEvent("spawn");
+ }
+ catch (luabind::error& ex)
+ {
+ err += "Failed to run startup script:";
+ const char* code = lua_tostring(ex.state(),-1);
+ err += code;
+ }
+ catch (std::exception& ex)
+ {
+ err += "Failed to run startup script:";
+ err += ex.what();
+ }
+ if (!err.empty())
+ YAKE_EXCEPT( err );
+ }
+ }
+
+} // namespace ent
+} // namespace yake
+#endif // YAKE_ENABLE_LUA_ENT
Modified: trunk/yake/src/bindings.lua/detail/ent.lua.cpp
===================================================================
--- trunk/yake/src/bindings.lua/detail/ent.lua.cpp 2007-09-07 13:57:17 UTC (rev 1842)
+++ trunk/yake/src/bindings.lua/detail/ent.lua.cpp 2007-09-09 23:04:14 UTC (rev 1843)
@@ -56,20 +56,10 @@
} // namespace
//-------------------------------------------------------------------------
- luabind::object ObjectManager_getAllObjects(ObjectManager& objMgr, lua_State* L)
- {
- YAKE_ASSERT( L );
- const ObjectManager::const_object_iterator itEnd = objMgr.endObjects();
- ObjectManager::const_object_iterator it = objMgr.beginObjects();
- luabind::object o = luabind::newtable(L);
- for (; it != itEnd; ++it)
- {
- Object* obj = *it;
- //@todo luabind::object[ obj->id() ] = cast_to_this(obj->isA());
- o[ obj->id() ] = obj;
- }
- return o;
- }
+ luabind::object ObjectManager_makeObject(ObjectManager& objMgr, const char* clsid, lua_State* L);
+ //luabind::object ObjectManager_makeObject(ObjectManager& objMgr, const char* clsid);
+ luabind::object ObjectManager_getObject(ObjectManager& objMgr, const ObjectId& id, lua_State* L);
+ luabind::object ObjectManager_getAllObjects(ObjectManager& objMgr, lua_State* L);
//-------------------------------------------------------------------------
// For Lua's tostring():
// std::ostream& operator<<(std::ostream& out, const ObjectId& rhs)
@@ -454,8 +444,11 @@
module( YAKE_MODEL_MODULE )
[
class_<ObjectManager>( "ObjectManager" )
- .def( "makeObject", (Object*(ObjectManager::*)(const String&))&ObjectManager::makeObject )
- .def( "getObject", &ObjectManager::getObject )
+ //.def( "makeObject", (Object*(ObjectManager::*)(const String&))&ObjectManager::makeObject )
+ //.def( "getObject", &ObjectManager::getObject )
+ .def( "makeObject", &ObjectManager_makeObject, raw(_3) )
+ .def( "getObject", &ObjectManager_getObject, raw(_3) )
+
.def( "destroyObject", &ObjectManager::destroyObject )
.def( "getClassNamesAndIds", &ObjectManager::getClassNamesAndIds )
.def( "getAllObjects", &ObjectManager_getAllObjects, raw(_2) )
@@ -848,113 +841,6 @@
}
}
}
-
- //-------------------------------------------------------------------------
- namespace detail {
- LuaFsmObjectListener::LuaFsmObjectListener(scripting::IScriptingSystem& scriptingSystem) :
- scriptingSystem_(scriptingSystem)
- {
- //startScript_ = scriptingSystem_.createScriptFromFile("o_access.lua");
- //YAKE_ASSERT( startScript_.get() );
- }
- void LuaFsmObjectListener::onInit(Object& obj)
- {
- Entity* ent = Entity::cast(&obj);
- if (ent)
- {
- YAKE_ASSERT( ent->getFsmVM() );
- ent->getFsmVM()->execute("print('initializing...')");
- if (startScript_)
- ent->getFsmVM()->execute( startScript_ );
-
- scripting::LuaVM* vm = static_cast<scripting::LuaVM*>(ent->getFsmVM().get());
- YAKE_ASSERT( vm );
- //ent->getFsmVM()->execute("c = coroutine.create(main)\ncoroutine.resume(c,1)");
- String err;
- try
- {
- luabind::call_function<void>(vm->getLuaState(),"main");
- }
- catch (luabind::error& ex)
- {
- const char* code = lua_tostring( ex.state(), -1 );
- err += ex.what();
- err += ":";
- err += code;
- YAKE_LOG_ERROR("ent.lua",String("LuaFsmObjectListener.onInit:") + code);
- }
- catch (std::exception& ex)
- {
- err = ex.what();
- YAKE_LOG_ERROR("ent.lua",String("LuaFsmObjectListener.onInit:") + err);
- }
- if (!err.empty())
- YAKE_EXCEPT(err);
- }
- }
- void LuaFsmObjectListener::onTick(Object& obj)
- {
-#if 0
- Entity* ent = Entity::cast(&obj);
- if (ent)
- {
- scripting::VMPtr vm = ent->getFsmVM();
- vm->execute("event.on_tick()");
- detail::executeOfTable_2(*vm,"state",ent->getCurrentFsmState(),"on_tick");
- }
-#endif
- }
- void LuaFsmObjectListener::onFsmEventHandled(Object& obj, const object_fsm&, const object_fsm::event_type& evt)
- {
-#if 0
- Entity* ent = Entity::cast(&obj);
- if (ent)
- {
- ent->getFsmVM()->execute("event.on_" + evt + "()");
- }
-#endif
- }
- void LuaFsmObjectListener::onFsmEnterState(Object& obj,/*const std::string& fsmName, */const object_fsm&, const object_fsm::state_type& state)
- {
-#if 0
- Entity* ent = Entity::cast(&obj);
- if (ent)
- {
- scripting::VMPtr vm = ent->getFsmVM();
- YAKE_ASSERT( vm );
- detail::executeOfTable_2(*vm,"state",state,"on_enter");
- }
-#endif
- }
- void LuaFsmObjectListener::onFsmExitState(Object& obj,/*const std::string& fsmName, */const object_fsm&, const object_fsm::state_type& state)
- {
-#if 0
- Entity* ent = Entity::cast(&obj);
- if (ent)
- {
- scripting::VMPtr vm = ent->getFsmVM();
- YAKE_ASSERT( vm );
- detail::executeOfTable_2(*vm,"state",state,"on_exit");
- }
-#endif
- }
- } // namespace detail
-
- //-------------------------------------------------------------------------
- LuaObjectManagerListener::LuaObjectManagerListener(scripting::IScriptingSystem& scriptingSystem) :
- fsmListener_(scriptingSystem)
- {
- }
- void LuaObjectManagerListener::onObjectCreated(Object* obj)
- {
- Entity* ent = Entity::cast(obj);
- if (ent)
- {
- YAKE_ASSERT( ent );
- ent->attachListener( &fsmListener_, "lua_listener", ObjectListenerManager::kKeepOwnership );
- }
- }
-
} // namespace ent
//-------------------------------------------------------------------------
void bind_ent(lua_State* L)
Added: trunk/yake/src/bindings.lua/detail/ent.registry.lua.cpp
===================================================================
--- trunk/yake/src/bindings.lua/detail/ent.registry.lua.cpp (rev 0)
+++ trunk/yake/src/bindings.lua/detail/ent.registry.lua.cpp 2007-09-09 23:04:14 UTC (rev 1843)
@@ -0,0 +1,87 @@
+/*
+ ------------------------------------------------------------------------------------
+ This file is part of YAKE
+ Copyright (c) 2004 - 2008 The YAKE Team
+ For the latest information visit http://www.yake.org
+ ------------------------------------------------------------------------------------
+ This program is free software; you can redistribute it and/or modify it under
+ the terms of the GNU Lesser 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 Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser 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, or go to
+ http://www.gnu.org/copyleft/lesser.txt.
+ ------------------------------------------------------------------------------------
+ If you are interested in another license model contact the Yake Team via
+ E-Mail: te...@ya....
+ For more information see the LICENSE file in the root directory of the
+ source code distribution.
+ ------------------------------------------------------------------------------------
+*/
+#include <yake/config.h>
+#if YAKE_ENABLE_LUA_ENT == 1
+
+#include <yake/bindings.lua/bindings.lua.h> // Don't forget to include this for proper dllexport!
+
+#include <yake/base/templates/yakeSmartAssert.h>
+#include <yake/bindings.lua/bindings.lua.ent.registry.h>
+
+#include <yake/bindings.lua/common/yake.lua.shared_ptr.h>
+#include <yake/bindings.lua/detail/private.h>
+
+namespace yake {
+namespace ent {
+ //-------------------------------------------------------------------------
+ TheClassRegistry& classRegistry()
+ {
+ static TheClassRegistry s_instance;
+ return s_instance;
+ }
+
+ //-------------------------------------------------------------------------
+ luabind::object ObjectManager_makeObject(ObjectManager& objMgr, const char* clsid, lua_State* L)
+ {
+ Object* o = objMgr.makeObject(clsid);
+ if (!o)
+ return luabind::object(L,false);
+ boost::optional<luabind::object> out = classRegistry().castToDerived(L,o);
+ if (out)
+ return *out;
+ return luabind::object(L,false);
+ }
+ luabind::object ObjectManager_getObject(ObjectManager& objMgr, const ObjectId& id, lua_State* L)
+ {
+ Object* o = objMgr.getObject(id);
+ if (!o)
+ return luabind::object(L,false);
+ boost::optional<luabind::object> out = classRegistry().castToDerived(L,o);
+ if (out)
+ return *out;
+ return luabind::object(L,false);
+ }
+ luabind::object ObjectManager_getAllObjects(ObjectManager& objMgr, lua_State* L)
+ {
+ YAKE_ASSERT( L );
+ const ObjectManager::const_object_iterator itEnd = objMgr.endObjects();
+ ObjectManager::const_object_iterator it = objMgr.beginObjects();
+ luabind::object o = luabind::newtable(L);
+ for (; it != itEnd; ++it)
+ {
+ Object* obj = *it;
+ boost::optional<luabind::object> out = classRegistry().castToDerived(L,obj);
+ if (out)
+ o[ obj->id() ] = *out;
+ else
+ o[ obj->id() ] = obj;
+ }
+ return o;
+ }
+} // namespace ent
+} // namespace yake
+#endif // YAKE_ENABLE_LUA_ENT
Modified: trunk/yake/src/ent/object_mgr.cpp
===================================================================
--- trunk/yake/src/ent/object_mgr.cpp 2007-09-07 13:57:17 UTC (rev 1842)
+++ trunk/yake/src/ent/object_mgr.cpp 2007-09-09 23:04:14 UTC (rev 1843)
@@ -42,19 +42,20 @@
YAKE_ASSERT( !strClsId.empty() )(strClsId);
std::pair<object::ResultCode,ClassId> ret = objMgr_.getClassId(strClsId);
YAKE_ASSERT( ret.first == object::RC_OK )(ret.first)(ret.second);
+
return makeObject( ret.second );
}
- void ObjectManager::setupObjectPostCreate(Object* obj)
+ void ObjectManager::setupObjectPostCreate(Object* obj, const ObjectCreationParameters& params)
{
YAKE_ASSERT( obj );
obj->registerMessageListeners(msgRouter_);
- listeners_onObjectCreated(obj);
+ listeners_onObjectCreated(obj,params);
obj->init();
- listeners_onObjectInitialized(obj);
+ listeners_onObjectInitialized(obj,params);
}
Object* ObjectManager::makeObject(const ObjectId objId)
{
@@ -62,8 +63,10 @@
YAKE_ASSERT( obj )(objId);
objs_.push_back( obj );
- this->setupObjectPostCreate(obj);
+ class_option_map::const_iterator itOpt = objClsOptions_.find(objId.classId());
+ this->setupObjectPostCreate(obj, (itOpt != objClsOptions_.end()) ? (itOpt->second) : ObjectCreationParameters());
+
return obj;
}
Object* ObjectManager::makeObject(const ClassId clsId)
@@ -72,8 +75,10 @@
YAKE_ASSERT( obj )(clsId);
objs_.push_back( obj );
- this->setupObjectPostCreate(obj);
+ class_option_map::const_iterator itOpt = objClsOptions_.find(clsId);
+ this->setupObjectPostCreate(obj, (itOpt != objClsOptions_.end()) ? (itOpt->second) : ObjectCreationParameters());
+
return obj;
}
void ObjectManager::destroyAllObjects()
@@ -110,23 +115,23 @@
while (it.hasMoreElements())
it.getNext()->tick();
}
- void ObjectManager::listeners_onObjectCreated(Object* obj)
+ void ObjectManager::listeners_onObjectCreated(Object* obj, const ObjectCreationParameters& params)
{
assert( obj );
if (!obj)
return;
yake::ConstVectorIterator<listener_mgr_type::listener_list> it(listeners_);
while (it.hasMoreElements())
- it.getNext().first->onObjectCreated(obj);
+ it.getNext().first->onObjectCreated(obj,params);
}
- void ObjectManager::listeners_onObjectInitialized(Object* obj)
+ void ObjectManager::listeners_onObjectInitialized(Object* obj, const ObjectCreationParameters& params)
{
assert( obj );
if (!obj)
return;
yake::ConstVectorIterator<listener_mgr_type::listener_list> it(listeners_);
while (it.hasMoreElements())
- it.getNext().first->onObjectInitialized(obj);
+ it.getNext().first->onObjectInitialized(obj, params);
}
void ObjectManager::listeners_onDestroyObject(Object* obj)
{
Modified: trunk/yake/src/ent/vm_holder.cpp
===================================================================
--- trunk/yake/src/ent/vm_holder.cpp 2007-09-07 13:57:17 UTC (rev 1842)
+++ trunk/yake/src/ent/vm_holder.cpp 2007-09-09 23:04:14 UTC (rev 1843)
@@ -80,7 +80,7 @@
if (tag.empty())
return scripting::VMPtr();
VmMap::const_iterator it = vms_.find(tag);
- YAKE_ASSERT( it != vms_.end() )(tag).debug("tag not found.");
+ //YAKE_ASSERT( it != vms_.end() )(tag).debug("tag not found.");
if (vms_.end() == it)
return scripting::VMPtr();
return it->second;
Modified: trunk/yake/src/plugins/scriptingLua/ScriptingSystemLua.cpp
===================================================================
--- trunk/yake/src/plugins/scriptingLua/ScriptingSystemLua.cpp 2007-09-07 13:57:17 UTC (rev 1842)
+++ trunk/yake/src/plugins/scriptingLua/ScriptingSystemLua.cpp 2007-09-09 23:04:14 UTC (rev 1843)
@@ -70,6 +70,8 @@
luaopen_math( mLuaState );
if (IS_MASK_SET(libs, LUALIB_DEBUG))
luaopen_debug( mLuaState );
+ if (IS_MASK_SET(libs, LUALIB_PACKAGE))
+ luaopen_package( mLuaState );
luabind::open( mLuaState );
}
Modified: trunk/yake/yake/base/yakeParamHolder.h
===================================================================
--- trunk/yake/yake/base/yakeParamHolder.h 2007-09-07 13:57:17 UTC (rev 1842)
+++ trunk/yake/yake/base/yakeParamHolder.h 2007-09-09 23:04:14 UTC (rev 1843)
@@ -31,6 +31,7 @@
#include <yake/base/templates/yakeVector.h>
#include <yake/base/yakeString.h>
#include <boost/any.hpp>
+#include <boost/optional.hpp>
namespace yake {
@@ -53,10 +54,25 @@
StringVector getKeys() const;
/** Returns the parameter value for a given key (id). */
- const Value& get( const String & id ) const;
+ const Value& getValue( const String & id ) const;
+ Value& getValue( const String & id );
+ template<typename T>
+ boost::optional<T> get( const String & id ) const
+ {
+ try {
+ boost::optional<T> out = boost::any_cast<T>(getValue(id));
+ return out;
+ }
+ catch (boost::bad_any_cast&)
+ {
+ return false;
+ }
+ }
+
/** Returns the parameter value for a given key (id). */
- Value operator [] ( const String & id ) const;
+ const Value& operator [] ( const String & id ) const;
+ Value& operator [] ( const String & id );
/** Sets the value of a given parameter identified by a key (id) to an uint32. */
bool set( const String & id, const Value& value );
Modified: trunk/yake/yake/base/yakeString.h
===================================================================
--- trunk/yake/yake/base/yakeString.h 2007-09-07 13:57:17 UTC (rev 1842)
+++ trunk/yake/yake/base/yakeString.h 2007-09-09 23:04:14 UTC (rev 1843)
@@ -110,6 +110,10 @@
{
return m_strings;
}
+ const StringVector& get() const
+ {
+ return m_strings;
+ }
private:
StringVector m_strings;
};
Modified: trunk/yake/yake/bindings.lua/bindings.lua.ent.h
===================================================================
--- trunk/yake/yake/bindings.lua/bindings.lua.ent.h 2007-09-07 13:57:17 UTC (rev 1842)
+++ trunk/yake/yake/bindings.lua/bindings.lua.ent.h 2007-09-09 23:04:14 UTC (rev 1843)
@@ -39,7 +39,8 @@
namespace detail {
struct YAKE_BINDINGS_LUA_API LuaFsmObjectListener : public ObjectListener
{
- LuaFsmObjectListener(scripting::IScriptingSystem& scriptingSystem);
+ LuaFsmObjectListener(scripting::IScriptingSystem& scriptingSystem,
+ const String& vmName);
virtual void onInit(Object& obj);
virtual void onTick(Object& obj);
virtual void onFsmEventHandled(Object& obj, const object_fsm&, const object_fsm::event_type& evt);
@@ -48,14 +49,23 @@
private:
scripting::IScriptingSystem& scriptingSystem_;
boost::shared_ptr<scripting::IScript> startScript_;
+ String vmName_;
};
} // namespace detail
struct YAKE_BINDINGS_LUA_API LuaObjectManagerListener : public ObjectManagerListener
{
- LuaObjectManagerListener(scripting::IScriptingSystem& scriptingSystem);
- virtual void onObjectCreated(Object* obj);
+ typedef boost::function<void(scripting::IVM&)> BinderFn;
+ LuaObjectManagerListener(scripting::IScriptingSystem& scriptingSystem, const String& vmName);
+ void addBinder(BinderFn);
private:
+ virtual void onObjectCreated(Object* obj, const ObjectCreationParameters&);
+ virtual void onDestroyObject(Object* obj);
+ private:
detail::LuaFsmObjectListener fsmListener_;
+ scripting::IScriptingSystem& scriptingSystem_;
+ String vmName_;
+ typedef std::deque<BinderFn> Binders;
+ Binders binders_;
};
} // namespace ent
} // namespace yake
Added: trunk/yake/yake/bindings.lua/bindings.lua.ent.registry.h
===================================================================
--- trunk/yake/yake/bindings.lua/bindings.lua.ent.registry.h (rev 0)
+++ trunk/yake/yake/bindings.lua/bindings.lua.ent.registry.h 2007-09-09 23:04:14 UTC (rev 1843)
@@ -0,0 +1,245 @@
+/*
+ ------------------------------------------------------------------------------------
+ This file is part of YAKE
+ Copyright (c) 2004 - 2008 The YAKE Team
+ For the latest information visit http://www.yake.org
+ ------------------------------------------------------------------------------------
+ This program is free software; you can redistribute it and/or modify it under
+ the terms of the GNU Lesser 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 Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser 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, or go to
+ http://www.gnu.org/copyleft/lesser.txt.
+ ------------------------------------------------------------------------------------
+ If you are interested in another license model contact the Yake Team via
+ E-Mail: te...@ya....
+ For more information see the LICENSE file in the root directory of the
+ source code distribution.
+ ------------------------------------------------------------------------------------
+*/
+#ifndef YAKE_LUA_BINDINGS_ENT_REGISTRY_H
+#define YAKE_LUA_BINDINGS_ENT_REGISTRY_H
+
+#include <yake/bindings.lua/prerequisites.h>
+#include <yake/base/yake.h>
+#include <yake/base/templates/yakePointer.h>
+#include <yake/ent/ent.h>
+#include <yake/scripting/yakeScriptingSystem.h>
+#include <yake/bindings.lua/common/yake.lua.common.h>
+
+namespace yake {
+namespace ent {
+ //-----------------------------
+ struct entObject_InstanceBinder_Traits
+ {
+ typedef ent::Object root_type;
+ typedef RttiClass* index_type;
+
+ template<class ConcreteT>
+ static index_type getIndex()
+ {
+ return ConcreteT::cls();
+ }
+
+ static index_type getIndex(const root_type& o)
+ {
+ return o.isA();
+ }
+ };
+ //-----------------------------
+ template<typename T>
+ int entlua_castToDerived(lua_State* L)
+ {
+ luaL_argcheck(L,lua_isuserdata(L,-1),1,"object expected");
+ luaL_argcheck(L,lua_isuserdata(L,lua_upvalueindex(1)),2,"rx class as upvalue expected");
+
+ RttiClass* rx = static_cast<RttiClass*>(lua_touserdata(L,lua_upvalueindex(1)));
+ YAKE_ASSERT(rx);
+
+ luabind::detail::object_rep* orep = static_cast<luabind::detail::object_rep*>(lua_touserdata(L, -1));
+ YAKE_ASSERT(orep);
+
+ luabind::detail::class_rep* crep = orep->crep();
+ YAKE_ASSERT(crep);
+ void* p1 = 0; //@todo find out what's this for.
+ #if 0
+ void* p = crep->convert_to( LUABIND_TYPEID(T), orep, p1 );
+ T* derived = reinterpret_cast<T*>(p);
+ #else
+ void* p = crep->convert_to( LUABIND_TYPEID(ent::Object), orep, p1 );
+ ent::Object* obj = reinterpret_cast<ent::Object*>(p);
+ T* derived = dynamic_cast<T*>(obj);
+ #endif
+
+ YAKE_ASSERT(derived);
+ if (!derived)
+ {
+ lua_pushnil(L);
+ }
+ else
+ {
+ YAKE_ASSERT( derived->isA() == rx );
+ luabind::object out(L,derived);
+ out.push(L);
+ }
+ return 1;
+ }
+ //-----------------------------
+ template<class TraitsT>
+ struct ClassRegistry
+ {
+ typedef TraitsT traits_type;
+ typedef typename TraitsT::root_type root_type;
+ typedef typename TraitsT::index_type index_type;
+ typedef root_type* root_pointer;
+
+ // places casted pointer in "this" in table (param 1).
+ typedef boost::function<void(luabind::object,root_pointer)> ThisBinderFn;
+
+ private:
+ struct caster
+ {
+ virtual ~caster() = 0;
+ virtual void addToTable(lua_State* L) = 0;
+ virtual boost::optional<luabind::object> returnCastedToDerived(lua_State* L, root_pointer obj) = 0;
+ };
+ template<typename T>
+ caster* makeCaster()
+ {
+ struct caster_impl : public caster
+ {
+ caster_impl(RttiClass* rx) : rx_(rx)
+ {}
+ virtual void addToTable(lua_State* L)
+ {
+ luaL_checktype(L,-1,LUA_TTABLE);
+ lua_pushstring(L,rx_->name().c_str());
+ lua_pushlightuserdata(L,rx_);
+ lua_pushcclosure(L,&entlua_castToDerived<T>,1); // 1 up value
+ lua_rawset(L,-3);
+ }
+ virtual boost::optional<luabind::object> returnCastedToDerived(lua_State* L, root_pointer obj)
+ {
+ if (!obj)
+ return false;
+ T* derived = dynamic_cast<T*>(obj);
+ if (!derived)
+ return false;
+ luabind::object out(L,derived);
+ return out;
+ }
+ private:
+ RttiClass* rx_;
+ };
+ return new caster_impl(T::cls());
+ }
+ public:
+ template<class ConcreteT>
+ void registerClass(ThisBinderFn fn)
+ {
+ index_type idx = traits_type::getIndex<ConcreteT>();
+ ClassInfo cls;
+ cls.thisBinder = fn;
+ cls.castToDerived.reset( makeCaster<ConcreteT>() );
+ classes_[idx] = cls;
+ }
+ void bindThis(luabind::object tbl, root_pointer obj)
+ {
+ YAKE_ASSERT( obj );
+ YAKE_ASSERT( tbl.is_valid() );
+ YAKE_ASSERT( luabind::type(tbl) == LUA_TTABLE );
+ ClassMap::const_iterator it = classes_.find( traits_type::getIndex(*obj) );
+ YAKE_ASSERT( it != classes_.end() ).debug("Cannot lookup ThisBinder through parents, at the moment!");
+ const ClassInfo& cls = it->second;
+ YAKE_ASSERT( cls.thisBinder );
+ cls.thisBinder(tbl,obj);
+ }
+ void bindCasters(lua_State* L)
+ {
+ lua_pushstring(L,"__yake_ent_casters");
+ lua_newtable(L);
+ YAKE_FOR_EACH(ClassMap::const_iterator,it,classes_)
+ {
+ it->second.castToDerived->addToTable(L);
+ }
+ lua_settable(L, LUA_GLOBALSINDEX);
+ }
+ int returnCastedToDerived(lua_State* L, root_pointer obj)
+ {
+ YAKE_ASSERT(obj);
+ if (!obj)
+ {
+ lua_pushnil(L);
+ return 1;
+ }
+ ClassMap::const_iterator it = classes_.find( traits_type::getIndex(*obj) );
+ YAKE_ASSERT( it != classes_.end() ).debug("Cannot lookup ThisBinder through parents, at the moment!");
+ const ClassInfo& cls = it->second;
+ YAKE_ASSERT( cls.castToDerived );
+ boost::optional<luabind::object> derived = cls.castToDerived->returnCastedToDerived(L,obj);
+ if (derived)
+ {
+ (*derived).push(L);
+ }
+ else
+ lua_pushnil(L);
+ return 1;
+ }
+ boost::optional<luabind::object> castToDerived(lua_State* L, root_pointer obj)
+ {
+ YAKE_ASSERT(obj);
+ if (!obj)
+ return false;
+ ClassMap::const_iterator it = classes_.find( traits_type::getIndex(*obj) );
+ YAKE_ASSERT( it != classes_.end() ).debug("Cannot lookup ThisBinder through parents, at the moment!");
+ const ClassInfo& cls = it->second;
+ YAKE_ASSERT( cls.castToDerived );
+ boost::optional<luabind::object> out = cls.castToDerived->returnCastedToDerived(L,obj);
+ return out;
+ }
+ private:
+ struct ClassInfo
+ {
+ ThisBinderFn thisBinder;
+ SharedPtr<caster> castToDerived;
+ };
+ typedef std::map<index_type,ClassInfo> ClassMap;
+ ClassMap classes_;
+ };
+ template<class TraitsT>
+ ClassRegistry<TraitsT>::caster::~caster() {}
+
+ //-------------------------------------------------------------------------
+ typedef ClassRegistry<entObject_InstanceBinder_Traits> TheClassRegistry;
+ YAKE_BINDINGS_LUA_API TheClassRegistry& classRegistry();
+
+ //
+ namespace detail {
+ template<class T>
+ inline void do_register_bindThis(luabind::object tbl, ent::Object* o)
+ {
+ YAKE_ASSERT(o);
+ YAKE_ASSERT(tbl.is_valid());
+ YAKE_ASSERT(luabind::type(tbl) == LUA_TTABLE);
+ T* t = T::cast(o);
+ YAKE_ASSERT(t)(o->isA()->name()).error("Type mismatch!");
+ tbl["this"] = t;
+ }
+ } // namespace detail
+
+ template<class T>
+ inline void registerClass()
+ {
+ classRegistry().registerClass<T>( boost::bind(&detail::do_register_bindThis<T>,_1,_2) );
+ }
+} // namespace ent
+} // namespace yake
+
+#endif
Modified: trunk/yake/yake/ent/object.h
===================================================================
--- trunk/yake/yake/ent/object.h 2007-09-07 13:57:17 UTC (rev 1842)
+++ trunk/yake/yake/ent/object.h 2007-09-09 23:04:14 UTC (rev 1843)
@@ -39,6 +39,7 @@
namespace yake {
namespace ent {
+ typedef ParamHolder ObjectCreationParameters;
struct LuaBinder;
#define DECL_OBJECT(CLASS,DESC) \
Modified: trunk/yake/yake/ent/object_mgr.h
===================================================================
--- trunk/yake/yake/ent/object_mgr.h 2007-09-07 13:57:17 UTC (rev 1842)
+++ trunk/yake/yake/ent/object_mgr.h 2007-09-09 23:04:14 UTC (rev 1843)
@@ -86,12 +86,12 @@
string identifiers has to be maintained and C++ classes have been replaced with different ones.
*/
template<typename T>
- inline RegistrationResult registerClass(const String& name, const StringMap& options = MakeStringMap() )
+ inline RegistrationResult registerClass(const String& name, const ObjectCreationParameters& options = ObjectCreationParameters() )
{
RegistrationResult ret = objMgr_.registerClass(name,&T::create,&T::destroy);
if (ret.first == object::RC_OK)
{
- objClsOptions_[ name ] = options;
+ objClsOptions_[ ret.second ] = options;
clsNameIdMap_[ name ] = ret.second;
}
return ret;
@@ -173,11 +173,11 @@
private:
//
typedef ListenerManager<ObjectManagerListener> listener_mgr_type;
- void listeners_onObjectCreated(Object* obj);
- void listeners_onObjectInitialized(Object* obj);
+ void listeners_onObjectCreated(Object* obj,const ObjectCreationParameters&);
+ void listeners_onObjectInitialized(Object* obj,const ObjectCreationParameters&);
void listeners_onDestroyObject(Object* obj);
private:
- void setupObjectPostCreate(Object*);
+ void setupObjectPostCreate(Object*, const ObjectCreationParameters& params);
o...
[truncated message content] |
|
From: <psy...@us...> - 2007-09-11 23:14:26
|
Revision: 1845
http://yake.svn.sourceforge.net/yake/?rev=1845&view=rev
Author: psyclonist
Date: 2007-09-11 16:14:21 -0700 (Tue, 11 Sep 2007)
Log Message:
-----------
* [build] added cb_gnu_win/patch_cbp.lua for setting the "-s" option (strip symbols) in CodeBlocks project files
* [premake] various changes to the build files for compatibility with CodeBlocks
* [premake] precompiled headers are disabled by default (option for premake 3.4)
* [base] removed deprecated code (IInputStream, IInputStreamDecorator, ...)
* [base] fixed includes for use with premake 3.4 generated CodeBlocks projects
* [physics] fixed includes for use with premake 3.4 generated CodeBlocks projects
Modified Paths:
--------------
trunk/yake/scripts/cb_gnu_win/build.cmd
trunk/yake/scripts/premake/tools.lua
trunk/yake/yake/base/math/yakeAsmMath.h
trunk/yake/yake/base/math/yakeColor.h
trunk/yake/yake/base/math/yakeInterpolator.h
trunk/yake/yake/base/math/yakeMersenneTwister.h
trunk/yake/yake/base/math/yakePlane.h
trunk/yake/yake/base/math/yakePoint3.h
trunk/yake/yake/base/math/yakeQuaternion.h
trunk/yake/yake/base/math/yakeRay.h
trunk/yake/yake/base/math/yakeVector4.h
trunk/yake/yake/base/templates/yakeAssociator.h
trunk/yake/yake/base/yake.h
trunk/yake/yake/base/yakeResource.h
trunk/yake/yake/base/yakeTaggedListenerManager.h
trunk/yake/yake/base/yakeTimer.h
trunk/yake/yake/base/yakeUniqueId.h
trunk/yake/yake/base/yakeUniqueName.h
trunk/yake/yake/base/yakeVersion.h
trunk/yake/yake/physics/yakeAffectorZone.h
trunk/yake/yake/physics/yakePhysicsActor.h
trunk/yake/yake/physics/yakePhysicsAffectors.h
trunk/yake/yake/physics/yakePhysicsAvatar.h
trunk/yake/yake/physics/yakePhysicsBody.h
trunk/yake/yake/physics/yakePhysicsBodyGroup.h
trunk/yake/yake/physics/yakePhysicsMotors.h
trunk/yake/yake/physics/yakePhysicsPrerequisites.h
trunk/yake/yake/physics/yakePhysicsWorld.h
trunk/yake/yake/plugins/physicsODE/OdeActor.h
trunk/yake/yake/plugins/physicsODE/yakePrerequisites.h
Added Paths:
-----------
trunk/yake/scripts/cb_gnu_win/patch_cbp.lua
Removed Paths:
-------------
trunk/yake/src/base/yakeInputStream.cpp
trunk/yake/src/base/yakeOutputStream.cpp
trunk/yake/yake/base/yakeByteSwapInputStreamDecorator.h
trunk/yake/yake/base/yakeByteSwapOutputStreamDecorator.h
trunk/yake/yake/base/yakeDebugOutputStream.h
trunk/yake/yake/base/yakeInputStream.h
trunk/yake/yake/base/yakeInputStreamDecorator.h
trunk/yake/yake/base/yakeOutputStream.h
trunk/yake/yake/base/yakeOutputStreamDecorator.h
Modified: trunk/yake/scripts/cb_gnu_win/build.cmd
===================================================================
--- trunk/yake/scripts/cb_gnu_win/build.cmd 2007-09-10 21:31:51 UTC (rev 1844)
+++ trunk/yake/scripts/cb_gnu_win/build.cmd 2007-09-11 23:14:21 UTC (rev 1845)
@@ -4,4 +4,6 @@
set SOLUTION_TARGET_DIR=cb_gnu_win
premake --file yake.lua --target cb-gcc --os windows
popd
+for %%i in (*.cbp) do d:\tools\luabin\lua5.1 patch_cbp.lua %%i
+echo done
pause
Added: trunk/yake/scripts/cb_gnu_win/patch_cbp.lua
===================================================================
--- trunk/yake/scripts/cb_gnu_win/patch_cbp.lua (rev 0)
+++ trunk/yake/scripts/cb_gnu_win/patch_cbp.lua 2007-09-11 23:14:21 UTC (rev 1845)
@@ -0,0 +1,18 @@
+if not arg[1] then
+ print("patch_cbp: nothing to do")
+ return
+end
+local fname = arg[1]
+print("patching "..fname.." ...")
+os.rename(fname,fname..".orig")
+local cbp = io.open(fname,"w")
+for line in io.lines(fname..".orig") do
+ local s = string.gmatch(line,"%<Build%>")()
+ if s and #s > 0 then
+ cbp:write("\t\t<Linker>\n")
+ cbp:write("\t\t\t<Add option=\"-s\"/>\n")
+ cbp:write("\t\t</Linker>\n")
+ end
+ cbp:write(line.."\n")
+end
+cbp:close()
Modified: trunk/yake/scripts/premake/tools.lua
===================================================================
--- trunk/yake/scripts/premake/tools.lua 2007-09-10 21:31:51 UTC (rev 1844)
+++ trunk/yake/scripts/premake/tools.lua 2007-09-11 23:14:21 UTC (rev 1845)
@@ -148,7 +148,12 @@
package.objdir = rootdir.."common/obj/"..name
- package.buildflags = {}
+ package.buildflags = {"no-pch"}
+
+ package.buildoptions = {}
+ if (linux or cb_gcc) then --TODO should be 'if gcc'
+ package.buildoptions = {"-s"}
+ end
package.includepaths = {rootdir}
package.defines = {}
@@ -166,7 +171,7 @@
--debug.target = targetBaseDir.."debug/"..(LIBFILE_PREFIX)..name..(DEBUG_DLL_SUFFIX)
debug.target = (LIBFILE_PREFIX)..name..(DEBUG_DLL_SUFFIX)
debug.defines = {"_DEBUG"}
- debug.buildflags = {}
+ debug.buildflags = {"no-pch"}
if windows then
local targetfile = targetBaseDir .. debug.target .. "." .. DLL_EXTENSION
@@ -178,9 +183,7 @@
releaseWithSym = package.config.ReleaseWithSymbols
releaseWithSym.target = (LIBFILE_PREFIX)..name.."_sym"
releaseWithSym.defines = {}
- releaseWithSym.buildflags = {
- "optimize-speed"
- }
+ releaseWithSym.buildflags = {"optimize-speed","no-pch"}
if windows then
local targetfile = targetBaseDir .. releaseWithSym.target .. "." .. DLL_EXTENSION
@@ -193,6 +196,7 @@
release.target = (LIBFILE_PREFIX)..name
release.defines = {}
release.buildflags = {
+ "no-pch",
"no-symbols",
"optimize-speed",
"no-frame-pointer"
@@ -209,13 +213,14 @@
debugLib.kind = "lib"
debugLib.target = (LIBFILE_PREFIX)..name.."_s"..(DEBUG_DLL_SUFFIX)
debugLib.defines = {"_DEBUG","YAKE_STATIC"}
- debugLib.buildflags = {}
+ debugLib.buildflags = {"no-pch"}
releaseLib = package.config.ReleaseLib
releaseLib.kind = "lib"
releaseLib.target = (LIBFILE_PREFIX)..name.."_s"
releaseLib.defines = {"YAKE_STATIC"}
releaseLib.buildflags = {
+ "no-pch",
"no-symbols",
"optimize-speed",
"no-frame-pointer"
@@ -461,7 +466,13 @@
package.objdir = rootdir.."common/obj/"..name
package.bindir = rootdir.."samples/bin"
- package.buildflags = {}
+ package.buildflags = {"no-pch"}
+
+ package.buildoptions = {}
+ if (linux or cb_gcc) then --TODO should be 'if gcc'
+ package.buildoptions = {"-s"}
+ end
+
package.includepaths = {rootdir}
package.defines = {}
@@ -479,12 +490,13 @@
debug = package.config.Debug
debug.target = rootdir.."samples/bin/debug/"..name.."_d"..(EXEFILE_SUFFIX)
debug.defines = {"_DEBUG"}
- debug.buildflags = {}
+ debug.buildflags = {"no-pch"}
releaseWithSym = package.config.ReleaseWithSymbols
releaseWithSym.target = rootdir.."samples/bin/release_sym/"..name.."_sym"..(EXEFILE_SUFFIX)
releaseWithSym.defines = {}
releaseWithSym.buildflags = {
+ "no-pch",
"optimize-speed"
}
@@ -492,6 +504,7 @@
release.target = rootdir.."samples/bin/release/"..name..(EXEFILE_SUFFIX)
release.defines = {}
release.buildflags = {
+ "no-pch",
"no-symbols",
"optimize-speed",
"no-frame-pointer"
@@ -500,12 +513,12 @@
debugLib = package.config.DebugLib
debugLib.target = rootdir.."samples/bin/debug/"..name.."_s_d"..(EXEFILE_SUFFIX)
debugLib.defines = {"_DEBUG","YAKE_STATIC"}
- debugLib.buildflags = {}
+ debugLib.buildflags = {"no-pch"}
releaseLib = package.config.ReleaseLib
releaseLib.target = rootdir.."samples/bin/release/"..name.."_s"..(EXEFILE_SUFFIX)
releaseLib.defines = {"YAKE_STATIC"}
- releaseLib.buildflags = {}
+ releaseLib.buildflags = {"no-pch"}
-- add sources
addMatching(path.."/*.cpp")
Deleted: trunk/yake/src/base/yakeInputStream.cpp
===================================================================
--- trunk/yake/src/base/yakeInputStream.cpp 2007-09-10 21:31:51 UTC (rev 1844)
+++ trunk/yake/src/base/yakeInputStream.cpp 2007-09-11 23:14:21 UTC (rev 1845)
@@ -1,47 +0,0 @@
-/*
- ------------------------------------------------------------------------------------
- This file is part of YAKE
- Copyright (c) 2004 - 2008 The YAKE Team
- For the latest information visit http://www.yake.org
- ------------------------------------------------------------------------------------
- This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU Lesser 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 Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser 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, or go to
- http://www.gnu.org/copyleft/lesser.txt.
- ------------------------------------------------------------------------------------
- If you are interested in another license model contact the Yake Team via
- E-Mail: te...@ya....
- For more information see the LICENSE file in the root directory of the
- source code distribution.
- ------------------------------------------------------------------------------------
-*/
-
-//============================================================================
-// IMPLEMENTATION HEADERS
-//============================================================================
-#include <yake/base/yakePCH.h>
-#include <yake/base/yakeInputStream.h>
-
-//============================================================================
-// INTERFACE STRUCTURES / UTILITY CLASSES
-//============================================================================
-namespace yake
-{
-namespace base
-{
-
-IInputStream::~IInputStream()
-{
-}
-
-} // base
-} // yake
Deleted: trunk/yake/src/base/yakeOutputStream.cpp
===================================================================
--- trunk/yake/src/base/yakeOutputStream.cpp 2007-09-10 21:31:51 UTC (rev 1844)
+++ trunk/yake/src/base/yakeOutputStream.cpp 2007-09-11 23:14:21 UTC (rev 1845)
@@ -1,47 +0,0 @@
-/*
- ------------------------------------------------------------------------------------
- This file is part of YAKE
- Copyright (c) 2004 - 2008 The YAKE Team
- For the latest information visit http://www.yake.org
- ------------------------------------------------------------------------------------
- This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU Lesser 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 Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser 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, or go to
- http://www.gnu.org/copyleft/lesser.txt.
- ------------------------------------------------------------------------------------
- If you are interested in another license model contact the Yake Team via
- E-Mail: te...@ya....
- For more information see the LICENSE file in the root directory of the
- source code distribution.
- ------------------------------------------------------------------------------------
-*/
-
-//============================================================================
-// IMPLEMENTATION HEADERS
-//============================================================================
-#include <yake/base/yakePCH.h>
-#include <yake/base/yakeOutputStream.h>
-
-//============================================================================
-// INTERFACE STRUCTURES / UTILITY CLASSES
-//============================================================================
-namespace yake
-{
-namespace base
-{
-
-IOutputStream::~IOutputStream()
-{
-}
-
-} // base
-} // yake
Modified: trunk/yake/yake/base/math/yakeAsmMath.h
===================================================================
--- trunk/yake/yake/base/math/yakeAsmMath.h 2007-09-10 21:31:51 UTC (rev 1844)
+++ trunk/yake/yake/base/math/yakeAsmMath.h 2007-09-11 23:14:21 UTC (rev 1845)
@@ -27,6 +27,9 @@
#ifndef YAKE_BASE_MATH_ASMMATH_H
#define YAKE_BASE_MATH_ASMMATH_H
+#include "../yakePrerequisites.h"
+#include <math.h>
+
/*=============================================================================
ASM math routines posted by davepermen et al on flipcode forums
=============================================================================*/
@@ -35,16 +38,16 @@
const float half_pi = 0.5f * pi;
/*=============================================================================
- NO EXPLICIT RETURN REQUIRED FROM THESE METHODS!!
+ NO EXPLICIT RETURN REQUIRED FROM THESE METHODS!!
=============================================================================*/
#if YAKE_COMPILER == COMPILER_MSVC
# pragma warning( push )
-# pragma warning( disable: 4035 )
+# pragma warning( disable: 4035 )
#endif
float asm_arccos( float r ) {
// return half_pi + arctan( r / -sqr( 1.f - r * r ) );
-
+
#if YAKE_COMPILER == COMPILER_MSVC
float asm_one = 1.f;
@@ -139,7 +142,7 @@
} // returns r0
#elif YAKE_COMPILER == COMPILER_GNUC
-
+
return cos( r );
#endif
@@ -159,7 +162,7 @@
} // returns r0
#elif YAKE_COMPILER == COMPILER_GNUC
-
+
return tan( r );
#endif
@@ -279,7 +282,7 @@
#endif
// returns a random number
-FORCEINLINE float asm_rand()
+inline float asm_rand()
{
#if YAKE_COMPILER == COMPILER_MSVC
@@ -315,7 +318,7 @@
}
// returns the maximum random number
-FORCEINLINE float asm_rand_max()
+inline float asm_rand_max()
{
#if YAKE_COMPILER == COMPILER_MSVC
@@ -338,7 +341,7 @@
}
// returns log2( r ) / log2( e )
-float asm_ln( float r ) {
+inline float asm_ln( float r ) {
#if YAKE_COMPILER == COMPILER_MSVC
Modified: trunk/yake/yake/base/math/yakeColor.h
===================================================================
--- trunk/yake/yake/base/math/yakeColor.h 2007-09-10 21:31:51 UTC (rev 1844)
+++ trunk/yake/yake/base/math/yakeColor.h 2007-09-11 23:14:21 UTC (rev 1845)
@@ -32,7 +32,7 @@
//============================================================================
// Standard headers
#ifndef YAKE_BASE_PREREQUISITES_H
-# include "yakePrerequisites.h"
+# include "../yakePrerequisites.h"
#endif
// Yake
#include "yake/base/math/yakeMath.h"
Modified: trunk/yake/yake/base/math/yakeInterpolator.h
===================================================================
--- trunk/yake/yake/base/math/yakeInterpolator.h 2007-09-10 21:31:51 UTC (rev 1844)
+++ trunk/yake/yake/base/math/yakeInterpolator.h 2007-09-11 23:14:21 UTC (rev 1845)
@@ -27,6 +27,8 @@
#ifndef YAKE_BASE__MATH_INTERPOLATOR_H
#define YAKE_BASE__MATH_INTERPOLATOR_H
+#include "../yakePrerequisites.h"
+
//============================================================================
// INTERFACE STRUCTURES / UTILITY CLASSES
//============================================================================
@@ -83,7 +85,7 @@
{
mElapsed += time;
real pos = clamp< real >( mElapsed / mTotal, 0., 1. );
- mVal = mStart * ( 1 - pos ) + mEnd * pos;
+ Interpolator< T >::smVal = mStart * ( 1 - pos ) + mEnd * pos;
}
};
@@ -106,7 +108,7 @@
mElapsed += time;
real b = clamp< real >( mElapsed / mTotal, 0., 1. );
real a = 1 - b;
- mVal = mStart * a * a + mMid * 2 * a * b + mEnd * b * b;
+ Interpolator< T >::mVal = mStart * a * a + mMid * 2 * a * b + mEnd * b * b;
}
};
@@ -129,7 +131,7 @@
mElapsed += time;
real b = clamp< real >( mElapsed / mTotal, 0., 1. );
real a = 1 - b;
- mVal = mStart * a * a * a + mMid1 * 3 * a * a * b + mMid2 * 3 * a * b * b + mEnd * b * b * b;
+ Interpolator< T >::mVal = mStart * a * a * a + mMid1 * 3 * a * a * b + mMid2 * 3 * a * b * b + mEnd * b * b * b;
}
};
Modified: trunk/yake/yake/base/math/yakeMersenneTwister.h
===================================================================
--- trunk/yake/yake/base/math/yakeMersenneTwister.h 2007-09-10 21:31:51 UTC (rev 1844)
+++ trunk/yake/yake/base/math/yakeMersenneTwister.h 2007-09-11 23:14:21 UTC (rev 1845)
@@ -43,7 +43,7 @@
// Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura,
// Copyright (C) 2000 - 2003, Richard J. Wagner
-// All rights reserved.
+// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
@@ -56,8 +56,8 @@
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
-// 3. The names of its contributors may not be used to endorse or promote
-// products derived from this software without specific prior written
+// 3. The names of its contributors may not be used to endorse or promote
+// products derived from this software without specific prior written
// permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
@@ -91,8 +91,10 @@
//============================================================================
// Standard headers
#ifndef YAKE_BASE_PREREQUISITES_H
-# include "yakePrerequisites.h"
+# include "../yakePrerequisites.h"
#endif
+#include <iostream>
+#include <math.h>
//============================================================================
// INTERFACE STRUCTURES / UTILITY CLASSES
@@ -104,13 +106,13 @@
// Data
public:
typedef unsigned long uint32; // unsigned integer type, at least 32 bits
-
+
enum { N = 624 }; // length of state vector
enum { SAVE = N + 1 }; // length of array for save()
protected:
enum { M = 397 }; // period parameter
-
+
uint32 state[N]; // internal state
uint32 *pNext; // next value to get from state
int left; // number of values left before reload needed
@@ -121,11 +123,11 @@
MTRand( const uint32& oneSeed ); // initialize with a simple uint32
MTRand( uint32 *const bigSeed, uint32 const seedLength = N ); // or an array
MTRand(); // auto-initialize with /dev/urandom or time() and clock()
-
+
// Do NOT use for CRYPTOGRAPHY without securely hashing several returned
// values together, otherwise the generator state can be learned after
// reading 624 consecutive values.
-
+
// Access to 32-bit random numbers
double rand(); // real number in [0,1]
double rand( const double& n ); // real number in [0,n]
@@ -136,18 +138,18 @@
uint32 randInt(); // integer in [0,2^32-1]
uint32 randInt( const uint32& n ); // integer in [0,n] for n < 2^32
double operator()() { return rand(); } // same as rand()
-
+
// Access to 53-bit random numbers (capacity of IEEE double precision)
double rand53(); // real number in [0,1)
-
+
// Access to nonuniform random number distributions
double randNorm( const double& mean = 0.0, const double& variance = 0.0 );
-
+
// Re-seeding functions with same behavior as initializers
void seed( const uint32 oneSeed );
void seed( uint32 *const bigSeed, const uint32 seedLength = N );
void seed();
-
+
// Saving and loading generator state
void save( uint32* saveArray ) const; // to array of size SAVE
void load( uint32 *const loadArray ); // from such array
@@ -214,10 +216,10 @@
{
// Pull a 32-bit integer from the generator state
// Every other access function simply transforms the numbers extracted here
-
+
if( left == 0 ) reload();
--left;
-
+
register uint32 s1;
s1 = *pNext++;
s1 ^= (s1 >> 11);
@@ -236,7 +238,7 @@
used |= used >> 4;
used |= used >> 8;
used |= used >> 16;
-
+
// Draw numbers until one is found in [0,n]
uint32 i;
do
@@ -294,7 +296,7 @@
{
// Seed the generator with an array from /dev/urandom if available
// Otherwise use a hash of time() and clock() values
-
+
// First try getting an array from /dev/urandom
FILE* urandom = fopen( "/dev/urandom", "rb" );
if( urandom )
@@ -308,7 +310,7 @@
fclose(urandom);
if( success ) { seed( bigSeed, N ); return; }
}
-
+
// Was not successful, so use time() and clock() instead
seed( hash( time(NULL), clock() ) );
}
Modified: trunk/yake/yake/base/math/yakePlane.h
===================================================================
--- trunk/yake/yake/base/math/yakePlane.h 2007-09-10 21:31:51 UTC (rev 1844)
+++ trunk/yake/yake/base/math/yakePlane.h 2007-09-11 23:14:21 UTC (rev 1845)
@@ -29,7 +29,7 @@
// Yake
#ifndef YAKE_BASE_PREREQUISITES_H
-# include "yakePrerequisites.h"
+# include "../yakePrerequisites.h"
#endif
#include "yakeMath.h"
#include "yakeVector3.h"
Modified: trunk/yake/yake/base/math/yakePoint3.h
===================================================================
--- trunk/yake/yake/base/math/yakePoint3.h 2007-09-10 21:31:51 UTC (rev 1844)
+++ trunk/yake/yake/base/math/yakePoint3.h 2007-09-11 23:14:21 UTC (rev 1845)
@@ -30,6 +30,7 @@
#include "yake/base/yakePrerequisites.h"
#include "yake/base/math/yakeMath.h"
#include "yake/base/math/yakeQuaternion.h"
+#include "yake/base/math/yakeVector3.h"
namespace yake {
namespace math {
@@ -39,10 +40,10 @@
class YAKE_BASE_API Point3
{
public:
- real x, y, z;
+ real x, y, z;
public:
- inline Point3( real fX = 0, real fY = 0, real fZ = 0)
+ inline Point3( real fX = 0, real fY = 0, real fZ = 0)
: x( fX ), y( fY ), z( fZ )
{
}
@@ -87,7 +88,7 @@
{
x = rkVector.x;
y = rkVector.y;
- z = rkVector.z;
+ z = rkVector.z;
return *this;
}
Modified: trunk/yake/yake/base/math/yakeQuaternion.h
===================================================================
--- trunk/yake/yake/base/math/yakeQuaternion.h 2007-09-10 21:31:51 UTC (rev 1844)
+++ trunk/yake/yake/base/math/yakeQuaternion.h 2007-09-11 23:14:21 UTC (rev 1845)
@@ -32,10 +32,11 @@
//============================================================================
// Standard headers
#ifndef YAKE_BASE_PREREQUISITES_H
-# include "yake/base/math/yakePrerequisites.h"
+# include "../yakePrerequisites.h"
#endif
// Yake
#include "yake/base/math/yakeMath.h"
+#include <iostream>
//============================================================================
// INTERFACE STRUCTURES / UTILITY CLASSES
Modified: trunk/yake/yake/base/math/yakeRay.h
===================================================================
--- trunk/yake/yake/base/math/yakeRay.h 2007-09-10 21:31:51 UTC (rev 1844)
+++ trunk/yake/yake/base/math/yakeRay.h 2007-09-11 23:14:21 UTC (rev 1845)
@@ -29,7 +29,7 @@
// Yake
#ifndef YAKE_BASE_PREREQUISITES_H
-# include "yakePrerequisites.h"
+# include "../yakePrerequisites.h"
#endif
#include "yakeMath.h"
#include "yakeVector3.h"
Modified: trunk/yake/yake/base/math/yakeVector4.h
===================================================================
--- trunk/yake/yake/base/math/yakeVector4.h 2007-09-10 21:31:51 UTC (rev 1844)
+++ trunk/yake/yake/base/math/yakeVector4.h 2007-09-11 23:14:21 UTC (rev 1845)
@@ -28,8 +28,9 @@
#define YAKE_MATH_VECTOR4_H
#ifndef YAKE_BASE_PREREQUISITES_H
-# include <yake/base/yakePrerequisites.h>
+# include "../yakePrerequisites.h"
#endif
+#include "yakeVector3.h"
namespace yake {
namespace math {
@@ -43,7 +44,7 @@
public:
union {
struct {
- real x, y, z, w;
+ real x, y, z, w;
};
real val[4];
};
@@ -53,7 +54,7 @@
{
}
- inline Vector4( real fX, real fY, real fZ, real fW )
+ inline Vector4( real fX, real fY, real fZ, real fW )
: x( fX ), y( fY ), z( fZ ), w( fW)
{
}
@@ -61,7 +62,7 @@
inline Vector4( real afCoordinate[4] )
: x( afCoordinate[0] ),
y( afCoordinate[1] ),
- z( afCoordinate[2] ),
+ z( afCoordinate[2] ),
w (afCoordinate[3] )
{
}
@@ -106,24 +107,24 @@
{
x = rkVector.x;
y = rkVector.y;
- z = rkVector.z;
- w = rkVector.w;
+ z = rkVector.z;
+ w = rkVector.w;
return *this;
}
inline bool operator == ( const Vector4& rkVector ) const
{
- return ( x == rkVector.x &&
- y == rkVector.y &&
+ return ( x == rkVector.x &&
+ y == rkVector.y &&
z == rkVector.z &&
w == rkVector.w );
}
inline bool operator != ( const Vector4& rkVector ) const
{
- return ( x != rkVector.x ||
- y != rkVector.y ||
+ return ( x != rkVector.x ||
+ y != rkVector.y ||
z != rkVector.z ||
w != rkVector.w );
}
Modified: trunk/yake/yake/base/templates/yakeAssociator.h
===================================================================
--- trunk/yake/yake/base/templates/yakeAssociator.h 2007-09-10 21:31:51 UTC (rev 1844)
+++ trunk/yake/yake/base/templates/yakeAssociator.h 2007-09-11 23:14:21 UTC (rev 1845)
@@ -27,15 +27,12 @@
#ifndef YAKE_BASE_TEMPLATES_ASSOCIATOR_H
#define YAKE_BASE_TEMPLATES_ASSOCIATOR_H
-//============================================================================
-// IMPLEMENTATION HEADERS
-//============================================================================
-// Standard headers
#ifndef YAKE_BASEPREREQUISITES_H
-# include "yakePrerequisites.h"
+# include "../yakePrerequisites.h"
#endif
-// Yake
+#include "../yakeString.h"
+
//============================================================================
// INTERFACE STRUCTURES / UTILITY CLASSES
//============================================================================
@@ -77,7 +74,7 @@
virtual void removeAndDestroyAll()
{
- for (ObjectNameMap::const_iterator it = mObjectNames.begin(); it != mObjectNames.end(); ++it)
+ for (typename ObjectNameMap::const_iterator it = mObjectNames.begin(); it != mObjectNames.end(); ++it)
{
if (it->second)
delete it->second;
Modified: trunk/yake/yake/base/yake.h
===================================================================
--- trunk/yake/yake/base/yake.h 2007-09-10 21:31:51 UTC (rev 1844)
+++ trunk/yake/yake/base/yake.h 2007-09-11 23:14:21 UTC (rev 1845)
@@ -54,15 +54,14 @@
#include "yakeLog.h"
#include "yakeStderrLog.h"
#include "yakeFileLog.h"
-#include "yakeOutputStream.h"
#include "yakeUniqueName.h"
#include "yakePlugin.h"
-//#include "yakeDebugOutputStream.h"
#include "yakeLibrary.h"
#include <yake/base/type_info.h>
#include "math/yakeQuaternion.h"
#include "math/yakeVector3.h"
+#include "math/yakePoint3.h"
#include "math/yakeVector4.h"
#include "math/yakeMatrix3.h"
#include "math/yakeMatrix4.h"
Deleted: trunk/yake/yake/base/yakeByteSwapInputStreamDecorator.h
===================================================================
--- trunk/yake/yake/base/yakeByteSwapInputStreamDecorator.h 2007-09-10 21:31:51 UTC (rev 1844)
+++ trunk/yake/yake/base/yakeByteSwapInputStreamDecorator.h 2007-09-11 23:14:21 UTC (rev 1845)
@@ -1,93 +0,0 @@
-/*
- ------------------------------------------------------------------------------------
- This file is part of YAKE
- Copyright (c) 2004 - 2008 The YAKE Team
- For the latest information visit http://www.yake.org
- ------------------------------------------------------------------------------------
- This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU Lesser 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 Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser 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, or go to
- http://www.gnu.org/copyleft/lesser.txt.
- ------------------------------------------------------------------------------------
- If you are interested in another license model contact the Yake Team via
- E-Mail: te...@ya....
- For more information see the LICENSE file in the root directory of the
- source code distribution.
- ------------------------------------------------------------------------------------
-*/
-#ifndef YAKE_BASE_BYTESWAPINPUTSTREAMDECORATOR_H
-#define YAKE_BASE_BYTESWAPINPUTSTREAMDECORATOR_H
-
-//============================================================================
-// IMPLEMENTATION HEADERS
-//============================================================================
-// Standard headers
-#ifndef YAKE_BASE_PREREQUISITES_H
-# include "yakePrerequisites.h"
-#endif
-// Yake
-
-//============================================================================
-// INTERFACE STRUCTURES / UTILITY CLASSES
-//============================================================================
-namespace yake
-{
-namespace base
-{
-
-// This macro converts a native stream into a little endian stream.
-#ifdef YAKE_BIG_ENDIAN
-# define YAKE_LITTLE_ENDIAN_INPUT_STREAM( inputStreamPointer ) create< yake::base::ByteSwapInputStreamDecorator >( inputStreamPointer )
-#else
-# define YAKE_LITTLE_ENDIAN_INPUT_STREAM( inputStreamPointer ) inputStreamPointer
-#endif
-
-
-class YAKE_BASE_API ByteSwapInputStreamDecorator : public IInputStreamDecorator
-{
-// Class
-public:
- ByteSwapInputStreamDecorator( const SharedPtr< IInputStream >& pDecorated )
- : IInputStreamDecorator( pDecorated )
- {}
-
-// Methods
-public:
- IInputStream& operator>>( bool& rB ) { ( *getDecorated() ) >> rB; swapBytes( rB ); return *this; }
- IInputStream& operator>>( signed char& rChar ) { ( *getDecorated() ) >> rChar; swapBytes( rChar ); return *this; }
- IInputStream& operator>>( unsigned char& rChar ) { ( *getDecorated() ) >> rChar; swapBytes( rChar ); return *this; }
- IInputStream& operator>>( signed short& rNumber ) { ( *getDecorated() ) >> rNumber; swapBytes( rNumber ); return *this; }
- IInputStream& operator>>( unsigned short& rNumber ) { ( *getDecorated() ) >> rNumber; swapBytes( rNumber ); return *this; }
- IInputStream& operator>>( signed int& rNumber ) { ( *getDecorated() ) >> rNumber; swapBytes( rNumber ); return *this; }
- IInputStream& operator>>( unsigned int& rNumber ) { ( *getDecorated() ) >> rNumber; swapBytes( rNumber ); return *this; }
- IInputStream& operator>>( signed long& rNumber ) { ( *getDecorated() ) >> rNumber; swapBytes( rNumber ); return *this; }
- IInputStream& operator>>( unsigned long& rNumber ) { ( *getDecorated() ) >> rNumber; swapBytes( rNumber ); return *this; }
- IInputStream& operator>>( float& rNumber ) { ( *getDecorated() ) >> rNumber; swapBytes( rNumber ); return *this; }
- IInputStream& operator>>( double& rNumber ) { ( *getDecorated() ) >> rNumber; swapBytes( rNumber ); return *this; }
-
- int read( bool* pBuffer, int count ) { int read = getDecorated()->read( pBuffer, count ); swapBytes( pBuffer, read ); return read; }
- int read( signed char* pBuffer, int count ) { int read = getDecorated()->read( pBuffer, count ); swapBytes( pBuffer, read ); return read; }
- int read( unsigned char* pBuffer, int count ) { int read = getDecorated()->read( pBuffer, count ); swapBytes( pBuffer, read ); return read; }
- int read( signed short* pBuffer, int count ) { int read = getDecorated()->read( pBuffer, count ); swapBytes( pBuffer, read ); return read; }
- int read( unsigned short* pBuffer, int count ) { int read = getDecorated()->read( pBuffer, count ); swapBytes( pBuffer, read ); return read; }
- int read( signed int* pBuffer, int count ) { int read = getDecorated()->read( pBuffer, count ); swapBytes( pBuffer, read ); return read; }
- int read( unsigned int* pBuffer, int count ) { int read = getDecorated()->read( pBuffer, count ); swapBytes( pBuffer, read ); return read; }
- int read( signed long* pBuffer, int count ) { int read = getDecorated()->read( pBuffer, count ); swapBytes( pBuffer, read ); return read; }
- int read( unsigned long* pBuffer, int count ) { int read = getDecorated()->read( pBuffer, count ); swapBytes( pBuffer, read ); return read; }
- int read( float* pBuffer, int count ) { int read = getDecorated()->read( pBuffer, count ); swapBytes( pBuffer, read ); return read; }
- int read( double* pBuffer, int count ) { int read = getDecorated()->read( pBuffer, count ); swapBytes( pBuffer, read ); return read; }
-};
-
-} // base
-} // yake
-
-#endif // YAKE_BASE_BYTESWAPINPUTSTREAMDECORATOR_H
Deleted: trunk/yake/yake/base/yakeByteSwapOutputStreamDecorator.h
===================================================================
--- trunk/yake/yake/base/yakeByteSwapOutputStreamDecorator.h 2007-09-10 21:31:51 UTC (rev 1844)
+++ trunk/yake/yake/base/yakeByteSwapOutputStreamDecorator.h 2007-09-11 23:14:21 UTC (rev 1845)
@@ -1,126 +0,0 @@
-/*
- ------------------------------------------------------------------------------------
- This file is part of YAKE
- Copyright (c) 2004 - 2008 The YAKE Team
- For the latest information visit http://www.yake.org
- ------------------------------------------------------------------------------------
- This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU Lesser 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 Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser 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, or go to
- http://www.gnu.org/copyleft/lesser.txt.
- ------------------------------------------------------------------------------------
- If you are interested in another license model contact the Yake Team via
- E-Mail: te...@ya....
- For more information see the LICENSE file in the root directory of the
- source code distribution.
- ------------------------------------------------------------------------------------
-*/
-#ifndef YAKE_BASE_BYTESWAPOUTPUTSTREAMDECORATOR_H
-#define YAKE_BASE_BYTESWAPOUTPUTSTREAMDECORATOR_H
-
-//============================================================================
-// IMPLEMENTATION HEADERS
-//============================================================================
-// Standard headers
-#ifndef YAKE_BASE_PREREQUISITES_H
-# include "yakePrerequisites.h"
-#endif
-// Yake
-
-#define YAKE_SWAP_AND_OUTPUT_ARRAY( variable, type, count ) \
- type* temp = new type[ count ]; \
- memcpy( temp, variable, count ); \
- swapBytes( temp, count ); \
- int written = ( *getDecorated() ).write( temp, count ); \
- delete[] temp; \
- return written;
-
-//============================================================================
-// INTERFACE STRUCTURES / UTILITY CLASSES
-//============================================================================
-namespace yake
-{
-namespace base
-{
-
-// This macro converts a native stream into a little endian stream.
-#ifdef YAKE_BIG_ENDIAN
-# define YAKE_LITTLE_ENDIAN_OUTPUT_STREAM( outputStreamPointer ) create< yake::base::ByteSwapOutputStreamDecorator >( outputStreamPointer )
-#else
-# define YAKE_LITTLE_ENDIAN_OUTPUT_STREAM( outputStreamPointer ) outputStreamPointer
-#endif
-
-
-class YAKE_BASE_API ByteSwapOutputStreamDecorator : public IOutputStreamDecorator
-{
-// Class
-public:
- ByteSwapOutputStreamDecorator( const SharedPtr< IOutputStream >& pDecorated )
- : IOutputStreamDecorator( pDecorated )
- {}
-
-// Methods
-public:
- IOutputStream& operator<<( bool b ) { swapBytes( b ); return ( *getDecorated() ) << b; }
- IOutputStream& operator<<( signed char ch ) { swapBytes( ch ); return ( *getDecorated() ) << ch; }
- IOutputStream& operator<<( unsigned char ch ) { swapBytes( ch ); return ( *getDecorated() ) << ch; }
- IOutputStream& operator<<( signed short number ) { swapBytes( number ); return ( *getDecorated() ) << number; }
- IOutputStream& operator<<( unsigned short number ) { swapBytes( number ); return ( *getDecorated() ) << number; }
- IOutputStream& operator<<( signed int number ) { swapBytes( number ); return ( *getDecorated() ) << number; }
- IOutputStream& operator<<( unsigned int number ) { swapBytes( number ); return ( *getDecorated() ) << number; }
- IOutputStream& operator<<( signed long number ) { swapBytes( number ); return ( *getDecorated() ) << number; }
- IOutputStream& operator<<( unsigned long number ) { swapBytes( number ); return ( *getDecorated() ) << number; }
- IOutputStream& operator<<( float number ) { swapBytes( number ); return ( *getDecorated() ) << number; }
- IOutputStream& operator<<( double number ) { swapBytes( number ); return ( *getDecorated() ) << number; }
-
- IOutputStream& operator<<( const char* pString )
- {
- int count = strlen( pString );
- char* temp = new char[ count ];
- memcpy( temp, pString, count );
- swapBytes( temp, count );
- ( *getDecorated() ) << temp;
- delete[] temp;
- return *this;
- }
-
- IOutputStream& operator<<( const wchar_t* pString )
- {
- int count = wcslen( pString );
- wchar_t* temp = new wchar_t[ count ];
- memcpy( temp, pString, count );
- swapBytes( temp, count );
- ( *getDecorated() ) << temp;
- delete[] temp;
- return *this;
- }
-
-
- int write( const bool* pBuffer, int count ) { YAKE_SWAP_AND_OUTPUT_ARRAY( pBuffer, bool, count ) }
- int write( const signed char* pBuffer, int count ) { YAKE_SWAP_AND_OUTPUT_ARRAY( pBuffer, signed char, count ) }
- int write( const unsigned char* pBuffer, int count ) { YAKE_SWAP_AND_OUTPUT_ARRAY( pBuffer, unsigned char, count ) }
- int write( const signed short* pBuffer, int count ) { YAKE_SWAP_AND_OUTPUT_ARRAY( pBuffer, signed short, count ) }
- int write( const unsigned short* pBuffer, int count ) { YAKE_SWAP_AND_OUTPUT_ARRAY( pBuffer, unsigned short, count ) }
- int write( const signed int* pBuffer, int count ) { YAKE_SWAP_AND_OUTPUT_ARRAY( pBuffer, signed int, count ) }
- int write( const unsigned int* pBuffer, int count ) { YAKE_SWAP_AND_OUTPUT_ARRAY( pBuffer, unsigned int, count ) }
- int write( const signed long* pBuffer, int count ) { YAKE_SWAP_AND_OUTPUT_ARRAY( pBuffer, signed long, count ) }
- int write( const unsigned long* pBuffer, int count ) { YAKE_SWAP_AND_OUTPUT_ARRAY( pBuffer, unsigned long, count ) }
- int write( const float* pBuffer, int count ) { YAKE_SWAP_AND_OUTPUT_ARRAY( pBuffer, float, count ) }
- int write( const double* pBuffer, int count ) { YAKE_SWAP_AND_OUTPUT_ARRAY( pBuffer, double, count ) }
-};
-
-#undef YAKE_SWAP_AND_OUTPUT_ARRAY
-
-} // base
-} // yake
-
-#endif // YAKE_BASE_BYTESWAPOUTPUTSTREAMDECORATOR_H
Deleted: trunk/yake/yake/base/yakeDebugOutputStream.h
===================================================================
--- trunk/yake/yake/base/yakeDebugOutputStream.h 2007-09-10 21:31:51 UTC (rev 1844)
+++ trunk/yake/yake/base/yakeDebugOutputStream.h 2007-09-11 23:14:21 UTC (rev 1845)
@@ -1,93 +0,0 @@
-/*
- ------------------------------------------------------------------------------------
- This file is part of YAKE
- Copyright (c) 2004 - 2008 The YAKE Team
- For the latest information visit http://www.yake.org
- ------------------------------------------------------------------------------------
- This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU Lesser 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 Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser 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, or go to
- http://www.gnu.org/copyleft/lesser.txt.
- ------------------------------------------------------------------------------------
- If you are interested in another license model contact the Yake Team via
- E-Mail: te...@ya....
- For more information see the LICENSE file in the root directory of the
- source code distribution.
- ------------------------------------------------------------------------------------
-*/
-#ifndef YAKE_BASE_DEBUGOUTPUTSTREAM_H
-#define YAKE_BASE_DEBUGOUTPUTSTREAM_H
-
-//============================================================================
-// IMPLEMENTATION HEADERS
-//============================================================================
-// Standard headers
-#ifndef YAKE_BASE_PREREQUISITES_H
-# include "yakePrerequisites.h"
-#endif
-// Yake
-#include <yake/base/yakeOutputStream.h>
-#include <yake/base/templates/yakeSingleton.h>
-
-//============================================================================
-// INTERFACE STRUCTURES / UTILITY CLASSES
-//============================================================================
-namespace yake
-{
-namespace base
-{
-
-class YAKE_BASE_API DebugOutputStream : public IOutputStream
-{
-YAKE_DECLARE_CLASS( yake::base::DebugOutputStream )
-// Class
-public:
- DebugOutputStream();
-
-// Methods
-public:
- int seek( int offset, SeekBase base );
- int tell() const;
- bool isEos() const;
-
- IOutputStream& operator<<( bool b );
- IOutputStream& operator<<( signed char ch );
- IOutputStream& operator<<( unsigned char ch );
- IOutputStream& operator<<( signed short rNumber );
- IOutputStream& operator<<( unsigned short rNumber );
- IOutputStream& operator<<( signed int rNumber );
- IOutputStream& operator<<( unsigned int rNumber );
- IOutputStream& operator<<( signed long rNumber );
- IOutputStream& operator<<( unsigned long rNumber );
- IOutputStream& operator<<( float rNumber );
- IOutputStream& operator<<( double rNumber );
- IOutputStream& operator<<( const char* pString );
-
- int write( const bool* pBuffer, int count );
- int write( const signed char* pBuffer, int count );
- int write( const unsigned char* pBuffer, int count );
- int write( const signed short* pBuffer, int count );
- int write( const unsigned short* pBuffer, int count );
- int write( const signed int* pBuffer, int count );
- int write( const unsigned int* pBuffer, int count );
- int write( const signed long* pBuffer, int count );
- int write( const unsigned long* pBuffer, int count );
- int write( const float* pBuffer, int count );
- int write( const double* pBuffer, int count );
-
-YAKE_BUILD_SINGLETON( DebugOutputStream )
-};
-
-} // base
-} // yake
-
-#endif // YAKE_BASE_DEBUGOUTPUTSTREAM_H
Deleted: trunk/yake/yake/base/yakeInputStream.h
===================================================================
--- trunk/yake/yake/base/yakeInputStream.h 2007-09-10 21:31:51 UTC (rev 1844)
+++ trunk/yake/yake/base/yakeInputStream.h 2007-09-11 23:14:21 UTC (rev 1845)
@@ -1,92 +0,0 @@
-/*
- ------------------------------------------------------------------------------------
- This file is part of YAKE
- Copyright (c) 2004 - 2008 The YAKE Team
- For the latest information visit http://www.yake.org
- ------------------------------------------------------------------------------------
- This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU Lesser 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 Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser 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, or go to
- http://www.gnu.org/copyleft/lesser.txt.
- ------------------------------------------------------------------------------------
- If you are interested in another license model contact the Yake Team via
- E-Mail: te...@ya....
- For more information see the LICENSE file in the root directory of the
- source code distribution.
- ------------------------------------------------------------------------------------
-*/
-#ifndef YAKE_BASE_INPUTSTREAM_H
-#define YAKE_BASE_INPUTSTREAM_H
-
-//============================================================================
-// IMPLEMENTATION HEADERS
-//============================================================================
-// Standard headers
-#ifndef YAKE_BASE_PREREQUISITES_H
-# include "yakePrerequisites.h"
-#endif
-// Yake
-
-//============================================================================
-// INTERFACE STRUCTURES / UTILITY CLASSES
-//============================================================================
-namespace yake
-{
-namespace base
-{
-
-class YAKE_BASE_API IInputStream
-{
-// Types
-public:
- enum SeekBase
- { BEGIN, CURRENT, END };
-
-// Class
-public:
- virtual ~IInputStream();
-
-// Methods
-public:
- virtual int seek( int offset, SeekBase base ) = 0;
- virtual int tell() const = 0;
- virtual bool isEos() const = 0;
-
- virtual IInputStream& operator>>( bool& rB ) = 0;
- virtual IInputStream& operator>>( signed char& rCh ) = 0;
- virtual IInputStream& operator>>( unsigned char& rCh ) = 0;
- virtual IInputStream& operator>>( signed short& rNumber ) = 0;
- virtual IInputStream& operator>>( unsigned short& rNumber ) = 0;
- virtual IInputStream& operator>>( signed int& rNumber ) = 0;
- virtual IInputStream& operator>>( unsigned int& rNumber ) = 0;
- virtual IInputStream& operator>>( signed long& rNumber ) = 0;
- virtual IInputStream& operator>>( unsigned long& rNumber ) = 0;
- virtual IInputStream& operator>>( float& rNumber ) = 0;
- virtual IInputStream& operator>>( double& rNumber ) = 0;
-
- virtual int Read( bool* pBuffer, int count ) = 0;
- virtual int Read( signed char* pBuffer, int count ) = 0;
- virtual int Read( unsigned char* pBuffer, int count ) = 0;
- virtual int Read( signed short* pBuffer, int count ) = 0;
- virtual int Read( unsigned short* pBuffer, int count ) = 0;
- virtual int Read( signed int* pBuffer, int count ) = 0;
- virtual int Read( unsigned int* pBuffer, int count ) = 0;
- virtual int Read( signed long* pBuffer, int count ) = 0;
- virtual int Read( unsigned long* pBuffer, int count ) = 0;
- virtual int Read( float* pBuffer, int count ) = 0;
- virtual int Read( double* pBuffer, int count ) = 0;
-};
-
-} // base
-} // yake
-
-#endif // YAKE_BASE_INPUTSTREAM_H
Deleted: trunk/yake/yake/base/yakeInputStreamDecorator.h
===================================================================
--- trunk/yake/yake/base/yakeInputStreamDecorator.h 2007-09-10 21:31:51 UTC (rev 1844)
+++ trunk/yake/yake/base/yakeInputStreamDecorator.h 2007-09-11 23:14:21 UTC (rev 1845)
@@ -1,95 +0,0 @@
-/*
- ------------------------------------------------------------------------------------
- This file is part of YAKE
- Copyright (c) 2004 - 2008 The YAKE Team
- For the latest information visit http://www.yake.org
- ------------------------------------------------------------------------------------
- This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU Lesser 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 Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser 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, or go to
- http://www.gnu.org/copyleft/lesser.txt.
- ------------------------------------------------------------------------------------
- If you are interested in another license model contact the Yake Team via
- E-Mail: te...@ya....
- For more information see the LICENSE file in the root directory of the
- source code distribution.
- ------------------------------------------------------------------------------------
-*/
-#ifndef YAKE_BASE_INPUTSTREAMDECORATOR_H
-#define YAKE_BASE_INPUTSTREAMDECORATOR_H
-
-//============================================================================
-// IMPLEMENTATION HEADERS
-//============================================================================
-// Standard headers
-#ifndef YAKE_BASE_PREREQUISITES_H
-# include "yakePrerequisites.h"
-#endif
-// Yake
-#include <yake/base/yakeInputStream.h>
-#include <yake/base/Templates/yakePointer.h>
-
-//============================================================================
-// INTERFACE STRUCTURES / UTILITY CLASSES
-//============================================================================
-namespace yake
-{
-namespace base
-{
-
-class YAKE_BASE_API IInputStreamDecorator : public IInputStream
-{
-// Class
-public:
- IInputStreamDecorator( const SharedPtr< IInputStream >& pDecorated )
- : mpDecorated( pDecorated )
- {}
-
-// Methods
-public:
-
- const SharedPtr< IInputStream >& getDecorated() { return mpDecorated; }
-
- int Seek( int offset, SeekBase base ) { return mpDecorated->Seek( offset, base ); }
- int Tell() const { return mpDecorated->Tell(); }
- bool IsEos() const { return mpDecorated->IsEos(); }
-
- IInputStream& operator>>( bool& rB ) { return ( *mpDecorated ) >> rB; }
- IInputStream& operator>>( signed char& rChar ) { return ( *mpDecorated ) >> rChar; }
- IInputStream& operator>>( unsigned char& rChar ) { return ( *mpDecorated ) >> rChar; }
- IInputStream& operator>>( signed short& rNumber ) { return ( *mpDecorated ) >> rNumber; }
- IInputStream& operator>>( unsigned short& rNumber ) { return ( *mpDecorated ) >> rNumber; }
- IInputStream& operator>>( signed int& rNumber ) { return ( *mpDecorated ) >> rNumber; }
- IInputStream& operator>>( unsigned int& rNumber ) { return ( *mpDecorated ) >> rNumber; }
- IInputStream& operator>>( signed long& rNumber ) { return ( *mpDecorated ) >> rNumber; }
- IInputStream& operator>>( unsigned long& rNumber ) { return ( *mpDecorated ) >> rNumber; }
-
- int read( bool* ppBuffer, int icount ) { return mpDecorated->read( pBuffer, count ); }
- int read( signed char* pBuffer, int count ) { return mpDecorated->read( pBuffer, count ); }
- int read( unsigned char* pBuffer, int count ) { return mpDecorated->read( pBuffer, count ); }
- int read( signed short* pBuffer, int count ) { return mpDecorated->read( pBuffer, count ); }
- int read( unsigned short* pBuffer, int count ) { return mpDecorated->read( pBuffer, count ); }
- int read( signed int* pBuffer, int count ) { return mpDecorated->read( pBuffer, count ); }
- int read( unsigned int* pBuffer, int count ) { return mpDecorated->read( pBuffer, count ); }
- int read( signed long* pBuffer, int count ) { return mpDecorated->read( pBuffer, count ); }
- int read( unsigned long* pBuffer, int count ) { return mpDecorated->read( pBuffer, count ); }
- int read( float* pBuffer, int count ) { return mpDecorated->read( pBuffer, count ); }
- int read( double* pBuffer, int count ) { return mpDecorated->read( pBuffer, count ); }
-
-private:
- SharedPtr< IInputStream > mpDecorated;
-};
-
-} // base
-} // yake
-
-#endif // YAKE_BASE_INPUTSTREAMDECORATOR_H
Deleted: trunk/yake/yake/base/yakeOutputStream.h
===================================================================
--- trunk/yake/yake/base/yakeOutputStream.h 2007-09-10 21:31:51 UTC (rev 1844)
+++ trunk/yake/yake/base/yakeOutputStream.h 2007-09-11 23:14:21 UTC (rev 1845)
@@ -1,95 +0,0 @@
-/*
- ------------------------------------------------------------------------------------
- This file is part of YAKE
- Copyright (c) 2004 - 2008 The YAKE Team
- For the latest information visit http://www.yake.org
- ------------------------------------------------------------------------------------
- This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU Lesser 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 Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser 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, or go to
- http://www.gnu.org/copyleft/lesser.txt.
- ------------------------------------------------------------------------------------
- If you are interested in another license model contact the Yake Team via
- E-Mail: te...@ya....
- For more information see the LICENSE file in the root directory of the
- source code distribution.
- ------------------------------------------------------------------------------------
-*/
-#ifndef YAKE_BASE_OUTPUTSTREAM_H
-#define YAKE_BASE_OUTPUTSTREAM_H
-
-//============================================================================
-// IMPLEMENTATION HEADERS
-//============================================================================
-// Standard headers
-#ifndef YAKE_BASE_PREREQUISITES_H
-# include "yakePrerequisites.h"
-#endif
-// Yake
-#include <yake/base/yakeString.h>
-
-//============================================================================
-// INTERFACE STRUCTURES / UTILITY CLASSES
-//============================================================================
-namespace yake
-{
-namespace base
-{
-
-class YAKE_BASE_API IOutputStream
-{
-public:
- virtual ~IOutputStream();
-
- enum SeekBase
- { BEGIN, CURRENT, END };
-
- virtual int seek( int offset, SeekBase base ) = 0;
- virtual int tell() const = 0;
- virtual bool isEos() const = 0;
-
- virtual IOutputStream& operator<<( bool b ) = 0;
- virtual IOutputStream& operator<<( signed char ch ) = 0;
- virtual IOutputStream& operator<<( unsigned char ch ) = 0;
- virtual IOutputStream& operator<<( signed short rNumber ) = 0;
- virtual IOutputStream& operator<<( unsigned short rNumber ) = 0;
- virtual IOutputStream& operator<<( signed int rNumber ) = 0;
- virtual IOutputStream& operator<<( unsigned int rNumber ) = 0;
- virtual IOutputStream& operator<<( signed long rNumber ) = 0;
- virtual IOutputStream& operator<<( unsigned long rNumber ) = 0;
- virtual IOutputStream& operator<<( float rNumber ) = 0;
- virtual IOutputStream& operator<<( double rNumber ) = 0;
- virtual IOutputStream& operator<<( const char* pString ) = 0;
-
- virtual int write( const bool* pBuffer, int count ) = 0;
- virtual int write( const signed char* pBuffer, int count ) = 0;
- virtual int write( const unsigned char* pBuffer, int count ) = 0;
- virtual int write( const signed short* pBuffer, int count ) = 0;
- virtual int write( const unsigned short* pBuffer, int count ) = 0;
- virtual int write( const signed int* pBuffer, int count ) = 0;
- virtual int write( const unsigned int* pBuffer, int count ) = 0;
- virtual int write( const signed long* pBuffer, int count ) = 0;
- virtual int write( const unsigned long* pBuffer, int count ) = 0;
- virtual int write( const float* pBuffer, int count ) = 0;
- virtual int write( const double* pBuffer, int count ) = 0;
-};
-
-inline IOutputStream& operator<<( IOutputStream& rOut, const String& rString )
-{
- return rOut << rString.c_str();
-}
-
-
-} // base
-} // yake
-
-#endif // YAKE_BASE_OUTPUTSTREAM_H
Deleted: trunk/yake/yake/base/yakeOutputStreamDecorator.h
===================================================================
--- trunk/yake/yake/base/yakeOutputStreamDecorator.h 2007-09-10 21:31:51 UTC (rev 1844)
+++ trunk/yake/yake/base/yakeOutputStreamDecorator.h 2007-09-11 23:14:21 UTC (rev 1845)
@@ -1,95 +0,0 @@
-/*
- ------------------------------------------------------------------------------------
- This file is part of YAKE
- Copyright (c) 2004 - 2008 The YAKE Team
- For the latest information visit http://www.yake.org
- ------------------------------------------------------------------------------------
- This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU Lesser 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 Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser 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, or go to
- http://www.gnu.org/copyleft/lesser.txt.
- ------------------------------------------------------------------------------------
- If you are interested in another license model contact the Yake Team via
- E-Mail: te...@ya....
- For more information see the LICENSE file in the root directory of the
- source code distribution.
- ------------------------------------------------------------------------------------
-*/
-#ifndef YAKE_BASE_OUTPUTSTREAMDECORATOR_H
-#define YAKE_BASE_OUTPUTSTREAMDECORATOR_H
-
-//============================================================================
-// IMPLEMENTATION HEADERS
-//============================================================================
-// Standard headers
-#ifndef YAKE_BASE_PREREQUISITES_H
-# include "yakePrerequisites.h"
-#endif
-// Yake
-#include <yake/base/yakeOutputStre...
[truncated message content] |
|
From: <psy...@us...> - 2007-09-14 23:05:59
|
Revision: 1853
http://yake.svn.sourceforge.net/yake/?rev=1853&view=rev
Author: psyclonist
Date: 2007-09-14 16:06:01 -0700 (Fri, 14 Sep 2007)
Log Message:
-----------
* [demo] fixed some lua related demos
* [base] fixed prerequisites settings for MinGW
* [build] fixed premake scripts for dealing with CodeBlocks/MinGW
Modified Paths:
--------------
trunk/yake/samples/base/scripting/lua/yakeDemo.cpp
trunk/yake/samples/property/lua1/demo.cpp
trunk/yake/scripts/cb_gnu_win/patch_cbp.lua
trunk/yake/scripts/premake/deps.lua
trunk/yake/scripts/premake/tools.lua
trunk/yake/yake/base/prerequisites/yakePrerequisitesGCCWin.h
Modified: trunk/yake/samples/base/scripting/lua/yakeDemo.cpp
===================================================================
--- trunk/yake/samples/base/scripting/lua/yakeDemo.cpp 2007-09-12 19:59:48 UTC (rev 1852)
+++ trunk/yake/samples/base/scripting/lua/yakeDemo.cpp 2007-09-14 23:06:01 UTC (rev 1853)
@@ -8,6 +8,8 @@
#include <yake/base/yake.h>
#include <yake/scripting/yakeScriptingSystem.h>
#include <yake/bindings.lua/bindings.lua.h>
+#include <yake/plugins/scriptingLua/ScriptingSystemLua.h>
+#include <yake/res/res.h>
using namespace yake; // We don't expect collisions.
@@ -20,7 +22,7 @@
int main(int argc, char* argv[])
{
- try
+ try
{
SharedPtr<base::Library> lib = loadLib(YAKE_DYNLIB_NAME("scriptingLua"));
YAKE_ASSERT( lib ).debug("Cannot load Lua scripting plugin.");
@@ -34,15 +36,20 @@
scripting::VMPtr vm( scriptingSys->createVM() );
YAKE_ASSERT( vm );
- bind_all( vm.get() );
+ bind_base( vm.get() );
+ bind_math( vm.get() );
// This prints 'hello from lua scripting ;)' to stdout using
// the Lua function print().
vm->execute("print('hello from lua scripting ;)');");
+ // Setup resources
+ res::SourceFactory::global().reg<res::FileSource>("file");
+ res::SourceManager::global().addSource("file","../../common/media/samples/");
+
// Execute a script created from a file.
{
- scripting::ScriptPtr script( scriptingSys->createScriptFromFile("../../../common/media/samples/scriptingLua/test.lua") );
+ scripting::ScriptPtr script( scriptingSys->createScriptFromFile("scriptingLua/test.lua") );
YAKE_ASSERT( script );
vm->execute( script );
}
Modified: trunk/yake/samples/property/lua1/demo.cpp
===================================================================
--- trunk/yake/samples/property/lua1/demo.cpp 2007-09-12 19:59:48 UTC (rev 1852)
+++ trunk/yake/samples/property/lua1/demo.cpp 2007-09-14 23:06:01 UTC (rev 1853)
@@ -4,7 +4,7 @@
#include "yake/base/yakeLog.h"
#include "yake/base/yakeStderrLog.h"
-void main()
+int main()
{
using namespace yake;
@@ -34,12 +34,14 @@
// run Lua script
scripting::ScriptPtr demoScript( scriptingSys.createScriptFromFile("property/demo.lua") );
vm->execute( demoScript );
-
+
// clean up
vm.reset();
}
catch (Exception& ex)
{
std::cerr << "Exception: " << ex.what() << "\n";
+ return 1;
}
+ return 0;
}
Modified: trunk/yake/scripts/cb_gnu_win/patch_cbp.lua
===================================================================
--- trunk/yake/scripts/cb_gnu_win/patch_cbp.lua 2007-09-12 19:59:48 UTC (rev 1852)
+++ trunk/yake/scripts/cb_gnu_win/patch_cbp.lua 2007-09-14 23:06:01 UTC (rev 1853)
@@ -10,9 +10,26 @@
local s = string.gmatch(line,"%<Build%>")()
if s and #s > 0 then
cbp:write("\t\t<Linker>\n")
- cbp:write("\t\t\t<Add option=\"-s\"/>\n")
+ --cbp:write("\t\t\t<Add option=\"-s\"/>\n")
+ cbp:write("\t\t\t")
+ cbp:write([[<Add option="-Wl,--enable-auto-image-base" />]])
+ cbp:write("\n")
+ cbp:write("\t\t\t")
+ cbp:write([[<Add option="-Wl,--add-stdcall-alias" />]])
+ cbp:write("\n")
cbp:write("\t\t</Linker>\n")
+
+ cbp:write(line.."\n")
+ else
+ s = string.gmatch(line,"createStaticLib=\"0\"")()
+ if s and #s > 0 then
+ cbp:write("\t\t\t\t")
+ cbp:write([[<Option createStaticLib="1"/>]])
+ cbp:write("\n")
+ else
+ cbp:write(line.."\n")
+ end
end
- cbp:write(line.."\n")
end
cbp:close()
+os.remove(fname..".orig")
Modified: trunk/yake/scripts/premake/deps.lua
===================================================================
--- trunk/yake/scripts/premake/deps.lua 2007-09-12 19:59:48 UTC (rev 1852)
+++ trunk/yake/scripts/premake/deps.lua 2007-09-14 23:06:01 UTC (rev 1853)
@@ -10,8 +10,8 @@
defDepLibrary("boost","boost_signals")
defDepLibrary("boost","boost_thread")
elseif cb_gcc then
- defDepLibrary("boost","libboost_signals-mgw34-mt-d-1_34_1.a")
- defDepLibrary("boost","libboost_thread-mgw34-mt-d-1_34_1.a")
+ defDepLibrary("boost","boost_signals-mgw34-mt-d-1_34_1")
+ defDepLibrary("boost","boost_thread-mgw34-mt-d-1_34_1")
end
--------------------------------------
Modified: trunk/yake/scripts/premake/tools.lua
===================================================================
--- trunk/yake/scripts/premake/tools.lua 2007-09-12 19:59:48 UTC (rev 1852)
+++ trunk/yake/scripts/premake/tools.lua 2007-09-14 23:06:01 UTC (rev 1853)
@@ -2,6 +2,7 @@
-- Various utility functions for
-- the YAKE build file make script
--------------------------------------
+dofile("config.lua")
--------------------------------------
-- INTERNAL
@@ -172,15 +173,30 @@
package.buildoptions = {}
if (linux or cb_gcc) then --TODO should be 'if gcc'
- package.buildoptions = {"-s"}
+ --package.buildoptions = {"-s"} --< TODO release builds only
end
+ if (cb_gcc) then
+ --TODO some options only for dynamic targets:
+ --table.insert(package.buildoptions,"-Wall")
+ table.insert(package.buildoptions,"-mthreads")
+ table.insert(package.buildoptions,"-fmessage-length=0")
+ table.insert(package.buildoptions,"-fexceptions")
+ table.insert(package.buildoptions,"-fident")
+ table.insert(package.buildoptions,"-pipe")
+ end
package.includepaths = {rootdir}
package.defines = {}
if (windows) then
- addDefine("_CRT_SECURE_NO_DEPRECATE")
- addDefine("_CRT_NOFORCE_MANIFEST") -- No manifests for DLLs. Let the executable decide.
addDefine("WIN32")
+ addDefine("_WINDOWS")
+ if (not linux and not cb_gcc) then --MSVC:
+ addDefine("_CRT_SECURE_NO_DEPRECATE")
+ addDefine("_CRT_NOFORCE_MANIFEST") -- No manifests for DLLs. Let the executable decide.
+ end
+ if (cb_gcc) then
+ addDefine("_REENTRANT")
+ end
else
addDefine("_REENTRANT")
end
@@ -192,7 +208,7 @@
debug.target = (LIBFILE_PREFIX)..name..(DEBUG_DLL_SUFFIX)
debug.defines = {"_DEBUG"}
debug.buildflags = {"no-pch"}
- if windows then
+ if windows and not cb_gcc then
local targetfile = targetBaseDir .. debug.target .. "." .. DLL_EXTENSION
local args = targetfile.. " " .. rootdir .. "samples/bin/debug"
Modified: trunk/yake/yake/base/prerequisites/yakePrerequisitesGCCWin.h
===================================================================
--- trunk/yake/yake/base/prerequisites/yakePrerequisitesGCCWin.h 2007-09-12 19:59:48 UTC (rev 1852)
+++ trunk/yake/yake/base/prerequisites/yakePrerequisitesGCCWin.h 2007-09-14 23:06:01 UTC (rev 1853)
@@ -51,7 +51,7 @@
// we can just remove the following typedefs and add an #include <cstdint>.
// SK: put it into namespace because it collided with other libs:
-namespace yake
+namespace yake
{
typedef signed char int8;
typedef unsigned char uint8;
@@ -70,7 +70,7 @@
// #else
// # define HashMap ::stdext::hash_map
// #endif
-
+
#else
# error("Yake: GCC/Win32: No configuration file set for the selected platform/compiler!")
#endif
@@ -81,9 +81,9 @@
//============================================================================
#define YAKE_VSNPRINTF vsnprintf
-#define DLLEXPORT
-#define DLLIMPORT
-#define LIBRARY_EXTENSION ( "so" )
+#define DLLEXPORT __declspec(dllexport)
+#define DLLIMPORT __declspec(dllimport)
+#define LIBRARY_EXTENSION ( "dll" )
#ifdef _DEBUG
# define YAKE_DEBUG_BUILD
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <psy...@us...> - 2007-09-16 00:52:08
|
Revision: 1870
http://yake.svn.sourceforge.net/yake/?rev=1870&view=rev
Author: psyclonist
Date: 2007-09-15 17:52:12 -0700 (Sat, 15 Sep 2007)
Log Message:
-----------
* [res] FileDataStream uses C API
Modified Paths:
--------------
trunk/yake/src/res/datastream.cpp
trunk/yake/yake/res/datastream.h
Modified: trunk/yake/src/res/datastream.cpp
===================================================================
--- trunk/yake/src/res/datastream.cpp 2007-09-15 23:46:41 UTC (rev 1869)
+++ trunk/yake/src/res/datastream.cpp 2007-09-16 00:52:12 UTC (rev 1870)
@@ -36,29 +36,47 @@
DataStreamBase::~DataStreamBase() {}
- FileDataStream::FileDataStream(const std::string & fn) : in_(fn.c_str()), size_(0)
+ FileDataStream::FileDataStream(const std::string & fn) : in_(0), size_(0)
{
- assert( in_.is_open() );
+ //std::ifstream test(fn.c_str());
+ //YAKE_ASSERT( test.is_open() );
+ //test.close();
- struct stat s;
- const int code = ::stat(fn.c_str(), &s);
- YAKE_ASSERT(code == 0)(code); // @todo throw exception of ENOENT or ENOTDIR?
- size_ = s.st_size;
+ in_ = fopen(fn.c_str(),"r");
+ YAKE_ASSERT( in_ );
+
+ int succ = fseek(in_, 0, SEEK_END);
+ YAKE_ASSERT( succ == 0 ).debug("failed to seek to end");
+
+ size_ = ftell(in_);
+ std::cout << "file '" << fn << "' has length " << size_ << " byte(s) (ftell)\n";
+
+ succ = fseek(in_, 0, SEEK_SET);
+ YAKE_ASSERT( succ == 0 ).debug("failed to seek to begin");
}
+ FileDataStream::~FileDataStream()
+ {
+ close();
+ }
size_t FileDataStream::read(void * out, size_t size)
{
- YAKE_ASSERT( in_.is_open() );
- YAKE_ASSERT( !eof() );
- if (eof())
+ YAKE_ASSERT( in_ );
+ YAKE_ASSERT( !feof(in_) );
+ if (feof(in_))
return 0;
- // NB use readsome() for async
- std::streampos pre = in_.tellg();
- in_.read((char*)(out),std::streampos(size)); //@todo use boost safe numeric cast
- return size_t(in_.tellg() - pre);
+
+ size_t succ = fread(out,size,1,in_);
+ if ((succ != 1) && !feof(in_))
+ {
+ YAKE_ASSERT( succ == 1 )(succ)(size).debug("read not successful");
+ return 0;
+ }
+
+ return size;
}
bool FileDataStream::eof() const
{
- return const_cast<std::ifstream&>(in_).is_open() ? in_.eof() : false;
+ return in_ ? (feof(in_)!=0) : false;
}
size_t FileDataStream::size() const
{
@@ -66,8 +84,9 @@
}
void FileDataStream::close()
{
- if (!in_.is_open())
- in_.close();
+ if (in_)
+ fclose(in_);
+ in_ = 0;
}
} // namespace res
Modified: trunk/yake/yake/res/datastream.h
===================================================================
--- trunk/yake/yake/res/datastream.h 2007-09-15 23:46:41 UTC (rev 1869)
+++ trunk/yake/yake/res/datastream.h 2007-09-16 00:52:12 UTC (rev 1870)
@@ -28,7 +28,7 @@
#define YAKE_RES_DATASTREAM_H
#include "prerequisites.h"
-#include <fstream>
+#include <cstdio>
#include <boost/shared_ptr.hpp>
namespace yake {
@@ -47,20 +47,21 @@
virtual size_t size() const = 0;
virtual void close() = 0;
};
- typedef boost::shared_ptr<DataStreamBase> DataStreamPtr;
+ typedef boost::shared_ptr<DataStreamBase> DataStreamPtr;
/** Implements the data stream interface for files.
*/
struct YAKE_RES_API FileDataStream : public DataStreamBase
{
FileDataStream(const std::string&);
+ virtual ~FileDataStream();
virtual size_t read(void*,size_t);
virtual bool eof() const;
virtual size_t size() const;
virtual void close();
private:
- std::ifstream in_;
+ FILE* in_;
size_t size_; //@todo fails if file is modified during read!
};
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <psy...@us...> - 2007-09-18 00:26:38
|
Revision: 1873
http://yake.svn.sourceforge.net/yake/?rev=1873&view=rev
Author: psyclonist
Date: 2007-09-17 17:26:38 -0700 (Mon, 17 Sep 2007)
Log Message:
-----------
* [bindings.lua] fixed issue caused by Luabind in conjunction with GCC and any_converters: solution is the same as with the shared_ptr fix. -> task.lua.cpp for details.
Modified Paths:
--------------
trunk/yake/scripts/premake/config.lua
trunk/yake/src/bindings.lua/bindings.lua.cpp
trunk/yake/src/bindings.lua/detail/base.lua.cpp
trunk/yake/src/bindings.lua/detail/ent.listener.lua.cpp
trunk/yake/src/bindings.lua/detail/ent.registry.lua.cpp
trunk/yake/src/bindings.lua/detail/graphics.lua.cpp
trunk/yake/src/bindings.lua/detail/input.lua.cpp
trunk/yake/src/bindings.lua/detail/model.lua.cpp
trunk/yake/src/bindings.lua/detail/physics.lua.cpp
trunk/yake/src/bindings.lua/detail/property.lua.cpp
trunk/yake/src/bindings.lua/detail/raf.lua.cpp
trunk/yake/src/bindings.lua/detail/res.lua.cpp
trunk/yake/src/bindings.lua/detail/task.lua.cpp
trunk/yake/yake/bindings.lua/common/vminfo.lua.cpp
trunk/yake/yake/bindings.lua/common/yake.lua.any_converter.h
trunk/yake/yake/bindings.lua/detail/property.lua.h
Added Paths:
-----------
trunk/yake/yake/bindings.lua/common/yake.lua.any_converter.inl
Modified: trunk/yake/scripts/premake/config.lua
===================================================================
--- trunk/yake/scripts/premake/config.lua 2007-09-18 00:21:13 UTC (rev 1872)
+++ trunk/yake/scripts/premake/config.lua 2007-09-18 00:26:38 UTC (rev 1873)
@@ -28,7 +28,7 @@
-- Plugins
--------------------------------------
--- NB only some of these are implemented:
+-- NB only some of these options have effect
--PLUGIN_SCRIPTING_LUA = true
PLUGIN_AUDIO_OPENAL = true
PLUGIN_GRAPHICS_OGRE = true
Modified: trunk/yake/src/bindings.lua/bindings.lua.cpp
===================================================================
--- trunk/yake/src/bindings.lua/bindings.lua.cpp 2007-09-18 00:21:13 UTC (rev 1872)
+++ trunk/yake/src/bindings.lua/bindings.lua.cpp 2007-09-18 00:26:38 UTC (rev 1873)
@@ -28,15 +28,22 @@
#include <yake/scripting/yakeScriptingSystem.h>
#include <yake/plugins/scriptingLua/ScriptingSystemLua.h>
#include <yake/bindings.lua/bindings.lua.h>
+
+#define YAKE_EXPORT_LUA_ANY_CONVERTER
+// The order of the following 4 includes is very important!
+// -> see task.cpp for more information!
+#include <yake/bindings.lua/common/yake.lua.shared_ptr.h>
+#include <yake/bindings.lua/common/yake.lua.any_converter.h>
#include <yake/bindings.lua/common/yake.lua.common.h>
+#include <yake/bindings.lua/common/yake.lua.any_converter.inl>
+//
+#include <yake/bindings.lua/common/yake.lua.any_converter.cpp>
+
+//
#include <yake/bindings.lua/common/lua.helpers.h>
#include <yake/bindings.lua/common/lua.helpers.cpp> // define here
-#define YAKE_EXPORT_LUA_ANY_CONVERTER
-#include <yake/bindings.lua/common/yake.lua.any_converter.h>
-#include <yake/bindings.lua/common/yake.lua.any_converter.cpp>
-
namespace yake {
namespace {
struct RegisterDefaultAnyConverters
@@ -48,11 +55,11 @@
register_any_converter<double>();
register_any_converter<bool>();
register_any_converter<String>();
-
+
register_any_converter<luabind::object>();
}
} g_registerDefaultAnyConverters;
- } // namespace
+ } // namespace
void bind_all(lua_State* L)
{
Modified: trunk/yake/src/bindings.lua/detail/base.lua.cpp
===================================================================
--- trunk/yake/src/bindings.lua/detail/base.lua.cpp 2007-09-18 00:21:13 UTC (rev 1872)
+++ trunk/yake/src/bindings.lua/detail/base.lua.cpp 2007-09-18 00:26:38 UTC (rev 1873)
@@ -29,13 +29,16 @@
#include <yake/base/yake.h>
-#include <yake/bindings.lua/bindings.lua.h> // Don't forget to include this for proper dllexport!
+// The order of the following 4 includes is very important!
+// -> see task.cpp for more information!
+#include <yake/bindings.lua/common/yake.lua.shared_ptr.h>
+#include <yake/bindings.lua/common/yake.lua.any_converter.h>
+#include <yake/bindings.lua/common/yake.lua.common.h>
+#include <yake/bindings.lua/common/yake.lua.any_converter.inl>
#include <yake/bindings.lua/detail/private.h>
#include <yake/bindings.lua/common/lua.helpers.h>
#include <yake/bindings.lua/common/vminfo.lua.h>
-#include <yake/bindings.lua/common/yake.lua.shared_ptr.h>
-#include <yake/bindings.lua/common/yake.lua.any_converter.h>
#include <luabind/operator.hpp>
#include <luabind/adopt_policy.hpp>
Modified: trunk/yake/src/bindings.lua/detail/ent.listener.lua.cpp
===================================================================
--- trunk/yake/src/bindings.lua/detail/ent.listener.lua.cpp 2007-09-18 00:21:13 UTC (rev 1872)
+++ trunk/yake/src/bindings.lua/detail/ent.listener.lua.cpp 2007-09-18 00:26:38 UTC (rev 1873)
@@ -27,14 +27,18 @@
#include <yake/config.h>
#if YAKE_ENABLE_LUA_ENT == 1
-#include <yake/bindings.lua/bindings.lua.h> // Don't forget to include this for proper dllexport!
+// The order of the following 4 includes is very important!
+// -> see task.cpp for more information!
+#include <yake/bindings.lua/common/yake.lua.shared_ptr.h>
+#include <yake/bindings.lua/common/yake.lua.any_converter.h>
+#include <yake/bindings.lua/common/yake.lua.common.h>
+#include <yake/bindings.lua/common/yake.lua.any_converter.inl>
+//
#include <yake/base/templates/yakeSmartAssert.h>
#include <yake/bindings.lua/bindings.lua.ent.h>
#include <yake/bindings.lua/bindings.lua.ent.registry.h>
-#include <yake/bindings.lua/common/yake.lua.shared_ptr.h>
-#include <yake/bindings.lua/common/yake.lua.any_converter.h>
#include <yake/bindings.lua/detail/private.h>
#include <yake/bindings.lua/detail/property.lua.h>
Modified: trunk/yake/src/bindings.lua/detail/ent.registry.lua.cpp
===================================================================
--- trunk/yake/src/bindings.lua/detail/ent.registry.lua.cpp 2007-09-18 00:21:13 UTC (rev 1872)
+++ trunk/yake/src/bindings.lua/detail/ent.registry.lua.cpp 2007-09-18 00:26:38 UTC (rev 1873)
@@ -27,12 +27,13 @@
#include <yake/config.h>
#if YAKE_ENABLE_LUA_ENT == 1
+#include <yake/bindings.lua/common/yake.lua.shared_ptr.h> // Always before Luabind includes!
+
#include <yake/bindings.lua/bindings.lua.h> // Don't forget to include this for proper dllexport!
#include <yake/base/templates/yakeSmartAssert.h>
#include <yake/bindings.lua/bindings.lua.ent.registry.h>
-#include <yake/bindings.lua/common/yake.lua.shared_ptr.h>
#include <yake/bindings.lua/detail/private.h>
namespace yake {
Modified: trunk/yake/src/bindings.lua/detail/graphics.lua.cpp
===================================================================
--- trunk/yake/src/bindings.lua/detail/graphics.lua.cpp 2007-09-18 00:21:13 UTC (rev 1872)
+++ trunk/yake/src/bindings.lua/detail/graphics.lua.cpp 2007-09-18 00:26:38 UTC (rev 1873)
@@ -29,11 +29,17 @@
#define YAKE_ENABLE_LUA_GRAPHICS_OGRE 0
#if YAKE_ENABLE_LUA_GRAPHICS == 1
+#include <yake/bindings.lua/prerequisites.h> // Don't forget to include this for proper dllexport!
+
// See task.lua.cpp
+// The order of the following 4 includes is very important!
+// -> see task.cpp for more information!
#include <yake/bindings.lua/common/yake.lua.shared_ptr.h>
+#include <yake/bindings.lua/common/yake.lua.any_converter.h>
+#include <yake/bindings.lua/common/yake.lua.common.h>
+#include <yake/bindings.lua/common/yake.lua.any_converter.inl>
-#include <yake/bindings.lua/bindings.lua.h> // Don't forget to include this for proper dllexport!
-
+//
#include <yake/base/templates/yakeSmartAssert.h>
#include <yake/base/yake.h>
#include <yake/graphics/yakeGraphics.h>
@@ -49,7 +55,6 @@
#endif
#include <yake/bindings.lua/detail/private.h>
-#include <yake/bindings.lua/common/yake.lua.any_converter.h>
#include <luabind/discard_result_policy.hpp>
#include <luabind/iterator_policy.hpp>
Modified: trunk/yake/src/bindings.lua/detail/input.lua.cpp
===================================================================
--- trunk/yake/src/bindings.lua/detail/input.lua.cpp 2007-09-18 00:21:13 UTC (rev 1872)
+++ trunk/yake/src/bindings.lua/detail/input.lua.cpp 2007-09-18 00:26:38 UTC (rev 1873)
@@ -27,17 +27,20 @@
#include <yake/config.h>
#if YAKE_ENABLE_LUA_INPUT == 1
-// See task.lua.cpp
+// The order of the following 4 includes is very important!
+// -> see task.cpp for more information!
#include <yake/bindings.lua/common/yake.lua.shared_ptr.h>
+#include <yake/bindings.lua/common/yake.lua.any_converter.h>
+#include <yake/bindings.lua/common/yake.lua.common.h>
+#include <yake/bindings.lua/common/yake.lua.any_converter.inl>
-#include <yake/bindings.lua/bindings.lua.h> // Don't forget to include this for proper dllexport!
+//
#include <yake/base/templates/yakeSmartAssert.h>
#include <yake/base/yake.h>
#include <yake/input/yakeInput.h>
#include <yake/bindings.lua/detail/private.h>
-#include <yake/bindings.lua/common/yake.lua.any_converter.h>
#include <luabind/discard_result_policy.hpp>
#include <luabind/iterator_policy.hpp>
Modified: trunk/yake/src/bindings.lua/detail/model.lua.cpp
===================================================================
--- trunk/yake/src/bindings.lua/detail/model.lua.cpp 2007-09-18 00:21:13 UTC (rev 1872)
+++ trunk/yake/src/bindings.lua/detail/model.lua.cpp 2007-09-18 00:26:38 UTC (rev 1873)
@@ -27,13 +27,17 @@
#include <yake/config.h>
#if YAKE_ENABLE_LUA_MODEL == 1
-#include <yake/bindings.lua/bindings.lua.h> // Don't forget to include this for proper dllexport!
+// The order of the following 4 includes is very important!
+// -> see task.cpp for more information!
+#include <yake/bindings.lua/common/yake.lua.shared_ptr.h>
+#include <yake/bindings.lua/common/yake.lua.any_converter.h>
+#include <yake/bindings.lua/common/yake.lua.common.h>
+#include <yake/bindings.lua/common/yake.lua.any_converter.inl>
+//
#include <yake/base/templates/yakeSmartAssert.h>
#include <yake/base/yake.h>
#include <yake/model/model.h>
-#include <yake/bindings.lua/common/yake.lua.shared_ptr.h>
-#include <yake/bindings.lua/common/yake.lua.any_converter.h>
#include <yake/bindings.lua/detail/private.h>
#include <luabind/discard_result_policy.hpp>
Modified: trunk/yake/src/bindings.lua/detail/physics.lua.cpp
===================================================================
--- trunk/yake/src/bindings.lua/detail/physics.lua.cpp 2007-09-18 00:21:13 UTC (rev 1872)
+++ trunk/yake/src/bindings.lua/detail/physics.lua.cpp 2007-09-18 00:26:38 UTC (rev 1873)
@@ -29,17 +29,19 @@
#pragma warning(disable:4267) // VC8-32Bit: conversion from 'size_t' to 'unsigned int', possible loss of data
-// See task.lua.cpp
+// The order of the following 4 includes is very important!
+// -> see task.cpp for more information!
#include <yake/bindings.lua/common/yake.lua.shared_ptr.h>
+#include <yake/bindings.lua/common/yake.lua.any_converter.h>
+#include <yake/bindings.lua/common/yake.lua.common.h>
+#include <yake/bindings.lua/common/yake.lua.any_converter.inl>
-#include <yake/bindings.lua/bindings.lua.h> // Don't forget to include this for proper dllexport!
-
+//
#include <yake/base/templates/yakeSmartAssert.h>
#include <yake/base/yake.h>
#include <yake/physics/yakePhysics.h>
#include <yake/bindings.lua/detail/private.h>
-#include <yake/bindings.lua/common/yake.lua.any_converter.h>
#include <luabind/discard_result_policy.hpp>
#include <luabind/iterator_policy.hpp>
Modified: trunk/yake/src/bindings.lua/detail/property.lua.cpp
===================================================================
--- trunk/yake/src/bindings.lua/detail/property.lua.cpp 2007-09-18 00:21:13 UTC (rev 1872)
+++ trunk/yake/src/bindings.lua/detail/property.lua.cpp 2007-09-18 00:26:38 UTC (rev 1873)
@@ -27,15 +27,17 @@
#include <yake/config.h>
#if YAKE_ENABLE_LUA_PROPERTY == 1
+// The order of the following 4 includes is very important!
+// -> see task.cpp for more information!
#include <yake/bindings.lua/common/yake.lua.shared_ptr.h>
+#include <yake/bindings.lua/common/yake.lua.any_converter.h>
+#include <yake/bindings.lua/common/yake.lua.common.h>
+#include <yake/bindings.lua/common/yake.lua.any_converter.inl>
-#include <yake/bindings.lua/bindings.lua.h> // Don't forget to include this for proper dllexport!
-
#include <yake/base/templates/yakeSmartAssert.h>
#include <yake/base/yake.h>
#include <yake/property/property.h>
-#include <yake/bindings.lua/common/yake.lua.any_converter.h>
#include <yake/bindings.lua/detail/private.h>
#include <yake/bindings.lua/detail/property.lua.h>
Modified: trunk/yake/src/bindings.lua/detail/raf.lua.cpp
===================================================================
--- trunk/yake/src/bindings.lua/detail/raf.lua.cpp 2007-09-18 00:21:13 UTC (rev 1872)
+++ trunk/yake/src/bindings.lua/detail/raf.lua.cpp 2007-09-18 00:26:38 UTC (rev 1873)
@@ -30,13 +30,18 @@
#include <yake/base/yake.h>
#include <yake/raf/yakeRaf.h>
-#include <yake/bindings.lua/bindings.lua.h> // Don't forget to include this for proper dllexport!
+// The order of the following 4 includes is very important!
+// -> see task.cpp for more information!
+#include <yake/bindings.lua/common/yake.lua.shared_ptr.h>
+#include <yake/bindings.lua/common/yake.lua.any_converter.h>
+#include <yake/bindings.lua/common/yake.lua.common.h>
+#include <yake/bindings.lua/common/yake.lua.any_converter.inl>
+//
+
#include <yake/bindings.lua/detail/private.h>
#include <yake/bindings.lua/common/lua.helpers.h>
#include <yake/bindings.lua/common/vminfo.lua.h>
-#include <yake/bindings.lua/common/yake.lua.shared_ptr.h>
-#include <yake/bindings.lua/common/yake.lua.any_converter.h>
namespace yake {
namespace raf {
@@ -54,7 +59,7 @@
}
*/
} g_initer;
- } // namespace
+ } // namespace
input::KeyboardDevice* getAppKeyboard(raf::Application* app)
{
return app ? app->getKeyboard() : 0;
Modified: trunk/yake/src/bindings.lua/detail/res.lua.cpp
===================================================================
--- trunk/yake/src/bindings.lua/detail/res.lua.cpp 2007-09-18 00:21:13 UTC (rev 1872)
+++ trunk/yake/src/bindings.lua/detail/res.lua.cpp 2007-09-18 00:26:38 UTC (rev 1873)
@@ -28,16 +28,20 @@
#if YAKE_ENABLE_LUA_RES == 1
// See task.lua.cpp
+// The order of the following 4 includes is very important!
+// -> see task.cpp for more information!
#include <yake/bindings.lua/common/yake.lua.shared_ptr.h>
+#include <yake/bindings.lua/common/yake.lua.any_converter.h>
+#include <yake/bindings.lua/common/yake.lua.common.h>
+#include <yake/bindings.lua/common/yake.lua.any_converter.inl>
-#include <yake/bindings.lua/bindings.lua.h> // Don't forget to include this for proper dllexport!
+//
#include <yake/base/templates/yakeSmartAssert.h>
#include <yake/base/yake.h>
#include <yake/res/res.h>
#include <yake/bindings.lua/detail/private.h>
-#include <yake/bindings.lua/common/yake.lua.any_converter.h>
#include <luabind/discard_result_policy.hpp>
#include <luabind/iterator_policy.hpp>
Modified: trunk/yake/src/bindings.lua/detail/task.lua.cpp
===================================================================
--- trunk/yake/src/bindings.lua/detail/task.lua.cpp 2007-09-18 00:21:13 UTC (rev 1872)
+++ trunk/yake/src/bindings.lua/detail/task.lua.cpp 2007-09-18 00:26:38 UTC (rev 1873)
@@ -39,16 +39,20 @@
// luabind::get_const_holder(...) catch all handler.
// (Source: http://osdir.com/ml/lang.lua.bind.user/2006-02/msg00008.html)
// Solution: Include the overloads for our smart pointers PRIOR to any Luabind headers.
+//
+// Update: Also do the same for any_converters because of is_userdefined(...).
+//
#include <yake/bindings.lua/common/yake.lua.shared_ptr.h>
+#include <yake/bindings.lua/common/yake.lua.any_converter.h>
+#include <yake/bindings.lua/common/yake.lua.common.h>
+#include <yake/bindings.lua/common/yake.lua.any_converter.inl>
-#include <yake/bindings.lua/bindings.lua.h> // Don't forget to include this for proper dllexport!
-
+//
#include <yake/base/templates/yakeSmartAssert.h>
#include <yake/bindings.lua/detail/private.h>
#include <yake/bindings.lua/common/lua.helpers.h>
#include <yake/bindings.lua/common/vminfo.lua.h>
-#include <yake/bindings.lua/common/yake.lua.any_converter.h>
#include <yake/task/task.h>
Modified: trunk/yake/yake/bindings.lua/common/vminfo.lua.cpp
===================================================================
--- trunk/yake/yake/bindings.lua/common/vminfo.lua.cpp 2007-09-18 00:21:13 UTC (rev 1872)
+++ trunk/yake/yake/bindings.lua/common/vminfo.lua.cpp 2007-09-18 00:26:38 UTC (rev 1873)
@@ -28,19 +28,19 @@
#include "vminfo.lua.h"
// Lua and Luabind includes:
-extern "C" {
+//extern "C" {
#include "lua.h"
#include "lualib.h"
#include "lauxlib.h"
-}
+//}
#pragma warning(push)
#pragma warning(disable: 4251)
#include <luabind/luabind.hpp>
#pragma warning(pop)
// @todo autolink?
-#pragma comment(lib,"luad.lib")
-#pragma comment(lib,"luabindd.lib")
+//#pragma comment(lib,"luad.lib")
+//#pragma comment(lib,"luabindd.lib")
//
namespace yake {
Modified: trunk/yake/yake/bindings.lua/common/yake.lua.any_converter.h
===================================================================
--- trunk/yake/yake/bindings.lua/common/yake.lua.any_converter.h 2007-09-18 00:21:13 UTC (rev 1872)
+++ trunk/yake/yake/bindings.lua/common/yake.lua.any_converter.h 2007-09-18 00:26:38 UTC (rev 1873)
@@ -31,10 +31,23 @@
#include <yake/base/yakePrerequisites.h>
#include <yake/base/type_info.h>
#include <yake/bindings.lua/prerequisites.h>
-#include <yake/bindings.lua/common/yake.lua.common.h>
+//#include <yake/bindings.lua/common/yake.lua.common.h>
#include <map>
#include <boost/any.hpp>
+#include <luabind/detail/yes_no.hpp> // safe. doesn't include luabind/detail/policy.hpp
+#include <luabind/detail/primitives.hpp>
+struct lua_State;
+namespace luabind {
+ namespace adl { class object; }
+ using adl::object;
+}
+
+//================ FIXME =========================
+//#undef YAKE_ENABLE_LUA_PROPERTY
+//#define YAKE_ENABLE_LUA_PROPERTY 0
+//================ FIXME =========================
+
#define YAKE_LUA_ANY_CONVERTER_API YAKE_BINDINGS_LUA_API
#define YAKE_LUA_ANY_CONVERTER_POINTERS 0
@@ -53,28 +66,15 @@
typedef std::map<TypeInfo,PropertyFromObjectFn> PropertyFromObjectMap;
YAKE_LUA_ANY_CONVERTER_API PropertyFromObjectMap& object_property_creators();
- typedef luabind::class_<PropertyBase> LuabindClass_PropertyBase;
- //typedef luabind::class_<PropertyBase,PropertyPtr> LuabindClass_PropertyBase;
-
- typedef void(*BindSetPropertyFn)(LuabindClass_PropertyBase&);
+ //typedef luabind::class_<PropertyBase> LuabindClass_PropertyBase;
+ typedef void* LuabindClass_PropertyBasePtr;
+
+ typedef void(*BindSetPropertyFn)(LuabindClass_PropertyBasePtr);
typedef std::vector<BindSetPropertyFn> BindSetPropertyFnList;
YAKE_LUA_ANY_CONVERTER_API BindSetPropertyFnList& setPropertyValue_binders();
template<typename T>
- bool setPropertyValue_Generic(PropertyBase& prop, const T& value)
- {
- try {
- prop.setAny( value );
- return true;
- }
- catch (BadCastException&)
- {
- //@todo report error! throw exception?
- std::cerr << ">>> Warning: Type mismatch on setting of property value!\n";
- std::cerr << " value type=" << typeid(T).name() << " expected type=" << prop.type() << "\n";
- return false;
- }
- }
+ bool setPropertyValue_Generic(PropertyBase& prop, const T& value);
} // namespace property
} // namespace yake
#endif
@@ -91,91 +91,14 @@
template<class T>
struct convert_any
{
- static void convert(lua_State* L, const boost::any& a)
- {
- //typename luabind::detail::default_policy::template generate_converter<T, luabind::detail::cpp_to_lua>::type conv;
- //conv.apply(L, *boost::any_cast<T>(&a));
- luabind::detail::convert_to_lua(L, *boost::any_cast<T>(&a));
- }
+ static void convert(lua_State* L, const boost::any& a);
#if YAKE_ENABLE_LUA_PROPERTY == 1 // extension for yake::property:
- static yake::property::PropertyBase* yake_createValuePropertyFromAny(const boost::any& a)
- {
- try
- {
- yake::property::Property<T>* prop = yake::property::makeValueProperty<T>( boost::any_cast<T>(a) );
- YAKE_ASSERT( prop );
- return prop;
- }
- catch (boost::bad_any_cast&)
- {
- return 0;//@todo report error
- }
- }
- static yake::property::PropertyBase* yake_createValuePropertyFromObject(const luabind::object& a)
- {
- //int type = luabind::type(a);
- boost::optional<T> value = luabind::object_cast_nothrow<T>(a);
- if (value)
- {
- yake::property::Property<T>* prop = yake::property::makeValueProperty<T>( *value );
- YAKE_ASSERT( prop );
- return prop;
- }
-#if YAKE_LUA_ANY_CONVERTER_POINTERS == 1
- boost::optional<T*> valuePtr = luabind::object_cast_nothrow<T*>(a);
- if (valuePtr)
- {
- T* px = *valuePtr;
- if (px)
- {
- //yake::property::Property<T>* prop = yake::property::makeValueProperty<T>( *px );
- yake::property::Property<T>* prop = yake::property::makePointerProperty<T>( px );
- YAKE_ASSERT( prop );
- return prop;
- }
- }
+ static yake::property::PropertyBase* yake_createValuePropertyFromAny(const boost::any& a);
+ static yake::property::PropertyBase* yake_createValuePropertyFromObject(const luabind::object& a);
+ static void yake_bind_setPropertyValue(::yake::property::LuabindClass_PropertyBasePtr);
#endif
- return 0; //@todo report error
- }
- static void yake_bind_setPropertyValue(::yake::property::LuabindClass_PropertyBase& x)
- {
- x.def("set",&yake::property::setPropertyValue_Generic<T>);
- }
-#endif
- static bool yake_anyFromObject(const luabind::object& a, boost::any& out)
- {
- boost::optional<T> value = luabind::object_cast_nothrow<T>(a);
- if (value)
- {
- out = *value;
- return true;
- }
-#if YAKE_LUA_ANY_CONVERTER_POINTERS == 1
- boost::optional<T*> valuePtr = luabind::object_cast_nothrow<T*>(a);
- if (valuePtr)
- {
- T* px = *valuePtr;
- if (px)
- {
- out = *px;
- return true;
- }
- }
-#endif
- return false; //@todo report error ?
- }
- static bool yake_tryAnyFromObject(const luabind::object& a)
- {
- boost::optional<T> value = luabind::object_cast_nothrow<T>(a);
- if (value)
- return true;
-#if YAKE_LUA_ANY_CONVERTER_POINTERS == 1
- boost::optional<T*> valuePtr = luabind::object_cast_nothrow<T*>(a);
- if (value)
- return true;
-#endif
- return false; //@todo report error ?
- }
+ static bool yake_anyFromObject(const luabind::object& a, boost::any& out);
+ static bool yake_tryAnyFromObject(const luabind::object& a);
};
typedef std::map<yake::TypeInfo, void(*)(lua_State*, const boost::any&)> any_converter_map;
@@ -211,21 +134,18 @@
// This creator is to be used as a last resort only. If it is stored
// with all the other creators it may get called before a better option
// can be called.
- template<>
- inline void register_any_converter<luabind::object>()
- {
- const yake::TypeInfo ti = YAKE_TYPEID(luabind::object);
- any_converters()[ti] = convert_any<luabind::object>::convert;
-#if YAKE_ENABLE_LUA_PROPERTY == 1 // extension for yake::property:
- yake::property::any_property_creators()[ti] = convert_any<luabind::object>::yake_createValuePropertyFromAny;
- yake::property::setPropertyValue_binders().push_back( convert_any<luabind::object>::yake_bind_setPropertyValue );
-#endif
- }
+ //template<>
+ //inline void register_any_converter<luabind::object>();
namespace luabind
{
namespace converters
{
+ using luabind::detail::yes_t;
+ using luabind::detail::no_t;
+ using luabind::detail::by_value;
+ using luabind::detail::by_const_reference;
+
yes_t is_user_defined(by_value<boost::any>);
yes_t is_user_defined(by_const_reference<boost::any>);
Added: trunk/yake/yake/bindings.lua/common/yake.lua.any_converter.inl
===================================================================
--- trunk/yake/yake/bindings.lua/common/yake.lua.any_converter.inl (rev 0)
+++ trunk/yake/yake/bindings.lua/common/yake.lua.any_converter.inl 2007-09-18 00:26:38 UTC (rev 1873)
@@ -0,0 +1,164 @@
+/*
+ ------------------------------------------------------------------------------------
+ This file is part of YAKE
+ Copyright (c) 2004 - 2008 The YAKE Team
+ For the latest information visit http://www.yake.org
+ ------------------------------------------------------------------------------------
+ This program is free software; you can redistribute it and/or modify it under
+ the terms of the GNU Lesser 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 Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser 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, or go to
+ http://www.gnu.org/copyleft/lesser.txt.
+ ------------------------------------------------------------------------------------
+ If you are interested in another license model contact the Yake Team via
+ E-Mail: te...@ya....
+ For more information see the LICENSE file in the root directory of the
+ source code distribution.
+ ------------------------------------------------------------------------------------
+*/
+#ifndef YAKE_LUA_ANYCONVERTER_INL_H
+#define YAKE_LUA_ANYCONVERTER_INL_H
+
+#if YAKE_ENABLE_LUA_PROPERTY == 1 // extension for yake::property:
+ namespace yake {
+ namespace property {
+ typedef luabind::class_<PropertyBase> LuabindClass_PropertyBase;
+
+ template<typename T>
+ bool setPropertyValue_Generic(PropertyBase& prop, const T& value)
+ {
+ try {
+ prop.setAny( value );
+ return true;
+ }
+ catch (BadCastException&)
+ {
+ //@todo report error! throw exception?
+ std::cerr << ">>> Warning: Type mismatch on setting of property value!\n";
+ std::cerr << " value type=" << typeid(T).name() << " expected type=" << prop.type() << "\n";
+ return false;
+ }
+ }
+ } // namespace property
+ } // namespace yake
+#endif
+
+
+ // boost::any bindings
+ template<class T>
+ void convert_any<T>::convert(lua_State* L, const boost::any& a)
+ {
+ luabind::detail::convert_to_lua(L, *boost::any_cast<T>(&a));
+ }
+#if YAKE_ENABLE_LUA_PROPERTY == 1 // extension for yake::property:
+ template<class T>
+ yake::property::PropertyBase* convert_any<T>::yake_createValuePropertyFromAny(const boost::any& a)
+ {
+ try
+ {
+ yake::property::Property<T>* prop = yake::property::makeValueProperty<T>( boost::any_cast<T>(a) );
+ YAKE_ASSERT( prop );
+ return prop;
+ }
+ catch (boost::bad_any_cast&)
+ {
+ return 0;//@todo report error
+ }
+ }
+ template<class T>
+ yake::property::PropertyBase* convert_any<T>::yake_createValuePropertyFromObject(const luabind::object& a)
+ {
+ //int type = luabind::type(a);
+ boost::optional<T> value = luabind::object_cast_nothrow<T>(a);
+ if (value)
+ {
+ yake::property::Property<T>* prop = yake::property::makeValueProperty<T>( *value );
+ YAKE_ASSERT( prop );
+ return prop;
+ }
+#if YAKE_LUA_ANY_CONVERTER_POINTERS == 1
+ boost::optional<T*> valuePtr = luabind::object_cast_nothrow<T*>(a);
+ if (valuePtr)
+ {
+ T* px = *valuePtr;
+ if (px)
+ {
+ //yake::property::Property<T>* prop = yake::property::makeValueProperty<T>( *px );
+ yake::property::Property<T>* prop = yake::property::makePointerProperty<T>( px );
+ YAKE_ASSERT( prop );
+ return prop;
+ }
+ }
+#endif
+ return 0; //@todo report error
+ }
+ template<class T>
+ void convert_any<T>::yake_bind_setPropertyValue(::yake::property::LuabindClass_PropertyBasePtr xp)
+ {
+ yake::property::LuabindClass_PropertyBase& x = *reinterpret_cast<yake::property::LuabindClass_PropertyBase*>(xp);
+ x.def("set",&yake::property::setPropertyValue_Generic<T>);
+ }
+#endif
+ template<class T>
+ bool convert_any<T>::yake_anyFromObject(const luabind::object& a, boost::any& out)
+ {
+ boost::optional<T> value = luabind::object_cast_nothrow<T>(a);
+ if (value)
+ {
+ out = *value;
+ return true;
+ }
+#if YAKE_LUA_ANY_CONVERTER_POINTERS == 1
+ boost::optional<T*> valuePtr = luabind::object_cast_nothrow<T*>(a);
+ if (valuePtr)
+ {
+ T* px = *valuePtr;
+ if (px)
+ {
+ out = *px;
+ return true;
+ }
+ }
+#endif
+ return false; //@todo report error ?
+ }
+ template<class T>
+ bool convert_any<T>::yake_tryAnyFromObject(const luabind::object& a)
+ {
+ boost::optional<T> value = luabind::object_cast_nothrow<T>(a);
+ if (value)
+ return true;
+#if YAKE_LUA_ANY_CONVERTER_POINTERS == 1
+ boost::optional<T*> valuePtr = luabind::object_cast_nothrow<T*>(a);
+ if (value)
+ return true;
+#endif
+ return false; //@todo report error ?
+ }
+
+ // NB The specialization for luabind::object is required as for
+ // this type we do not store a creator in object_property_creators().
+ // This creator is to be used as a last resort only. If it is stored
+ // with all the other creators it may get called before a better option
+ // can be called.
+ template<>
+ inline void register_any_converter<luabind::object>()
+ {
+ const yake::TypeInfo ti = YAKE_TYPEID(luabind::object);
+ any_converters()[ti] = convert_any<luabind::object>::convert;
+#if YAKE_ENABLE_LUA_PROPERTY == 1 // extension for yake::property:
+ yake::property::any_property_creators()[ti] = convert_any<luabind::object>::yake_createValuePropertyFromAny;
+ yake::property::setPropertyValue_binders().push_back( convert_any<luabind::object>::yake_bind_setPropertyValue );
+#endif
+ }
+
+
+#endif
Modified: trunk/yake/yake/bindings.lua/detail/property.lua.h
===================================================================
--- trunk/yake/yake/bindings.lua/detail/property.lua.h 2007-09-18 00:21:13 UTC (rev 1872)
+++ trunk/yake/yake/bindings.lua/detail/property.lua.h 2007-09-18 00:26:38 UTC (rev 1873)
@@ -24,13 +24,13 @@
source code distribution.
------------------------------------------------------------------------------------
*/
-#ifndef YAKE_LUA_BINDINGS_PROPERTYLUA_H
-#define YAKE_LUA_BINDINGS_PROPERTYLUA_H
+#ifndef YAKE_LUA_BINDINGS_PROPERTYLUA__H
+#define YAKE_LUA_BINDINGS_PROPERTYLUA__H
#include <yake/config.h>
#if YAKE_ENABLE_LUA_PROPERTY == 1
-#include <yake/bindings.lua/bindings.lua.h> // Don't forget to include this for proper dllexport!
+#include <yake/bindings.lua/prerequisites.h> // Don't forget to include this for proper dllexport!
#include <yake/base/yake.h>
#include <yake/property/property.h>
#include <boost/any.hpp>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <psy...@us...> - 2007-09-22 21:19:38
|
Revision: 1876
http://yake.svn.sourceforge.net/yake/?rev=1876&view=rev
Author: psyclonist
Date: 2007-09-22 14:19:42 -0700 (Sat, 22 Sep 2007)
Log Message:
-----------
* [bindings.lua] fixed issue with binding of 'Entity.model' property (reported by BartoloB)
* [bindings.lua] fixed trigger script to handle more than one entity
Modified Paths:
--------------
trunk/yake/common/media/scripts/o_trigger2.lua
trunk/yake/src/bindings.lua/detail/model.lua.cpp
Modified: trunk/yake/common/media/scripts/o_trigger2.lua
===================================================================
--- trunk/yake/common/media/scripts/o_trigger2.lua 2007-09-18 00:53:17 UTC (rev 1875)
+++ trunk/yake/common/media/scripts/o_trigger2.lua 2007-09-22 21:19:42 UTC (rev 1876)
@@ -4,23 +4,49 @@
assert( sim.objMgr, "no obj mgr" )
local objs = sim.objMgr:getAllObjects()
+ -- For each object with a 'position' property we check
+ -- whether it intersects the trigger's volume(s).
+ -- Note: We suppose that 'position' always means the same
+ -- thing, namely a point in space (yake.Point3).
+ -- The script will stop/crash if a position property
+ -- has a different type!
+ -- TODO: Check whether the object is derived from 'Entity'
+ -- because the position property in this case always
+ -- is of type 'yake.Point3'.
+ local numIntersects = 0
+ local toggled = false
for id,ent in pairs(objs) do
- if ent and id ~= this.id then -- ignore self, and non-Entity objects
- local intersects = this.volumes:intersectsWith( ent.position )
+ --TODO: if .. and ent.isA()->isKindOf("Entity")
+ local pos = ent.position -- pos will be 'nil' if property 'position' does not exist.
+ if ent and id ~= this.id and pos ~= nil then -- ignore self, and non-positioned objects
+ local intersects = this.volumes:intersectsWith( pos )
+ if intersects then
+ numIntersects = numIntersects + 1
+ end
+ -- The trigger is switched to 'on' when at least
+ -- one entity is in its volume.
if not this.on and intersects then
this:processFsmEvent("toggle")
- elseif this.on and not intersects then
- this:processFsmEvent("toggle")
+ toggled = true
+ break
end
end
end
+ -- If no entity is in the trigger's volume(s) and the
+ -- trigger state is currently 'on' then we switch to
+ -- state 'off'.
+ -- Note: We check 'not toggled' to not undo the work of the
+ -- intersection loop above.
+ if not toggled and this.on and (numIntersects == 0) then
+ this:processFsmEvent("toggle")
+ end
- --if filter then
-- local filter = yake.ObjectFilter()
-- filter:add( filterByClass("Player") )
-- filter:add( filterByClass("Entity",IgnoreDerived) )
-- filter.byClass("Player")
- --end
+ -- local objs = objMgr:getAllObjects()
+ -- filter:apply(objs)
end
end
function main()
Modified: trunk/yake/src/bindings.lua/detail/model.lua.cpp
===================================================================
--- trunk/yake/src/bindings.lua/detail/model.lua.cpp 2007-09-18 00:53:17 UTC (rev 1875)
+++ trunk/yake/src/bindings.lua/detail/model.lua.cpp 2007-09-22 21:19:42 UTC (rev 1876)
@@ -46,6 +46,16 @@
namespace yake {
namespace model {
+ //-------------------------------------------------------------------------
+ namespace {
+ struct AnyConverterIniter
+ {
+ AnyConverterIniter()
+ {
+ register_any_converter<model::ModelPtr>();
+ }
+ } g_initer;
+ } // namespace
Graphical* Model_createGraphical(Model& m)
{
Graphical* c = new Graphical();
@@ -62,13 +72,13 @@
YAKE_ASSERT(g);
g->addSceneNode( node, path );
}
- Model* ModelManager_createModel(ModelManager* mgr, const String& modelName, const String& def)
+ ModelPtr ModelManager_createModel(ModelManager* mgr, const String& modelName, const String& def)
{
- return (mgr ? mgr->createModel(modelName,def).get() : 0);
+ return (mgr ? mgr->createModel(modelName,def) : ModelPtr());
}
- Model* ModelManager_createModelFromTemplate(ModelManager* mgr, const String& modelName, const String& tplName)
+ ModelPtr ModelManager_createModelFromTemplate(ModelManager* mgr, const String& modelName, const String& tplName)
{
- return (mgr ? mgr->createModelFromTemplate(modelName,tplName).get() : 0);
+ return (mgr ? mgr->createModelFromTemplate(modelName,tplName) : ModelPtr());
}
bool ModelMovableLink_subscribeToPositionChanged(ModelMovableLink* link, const luabind::object& o)
{
@@ -146,7 +156,7 @@
class_<ModelMovableLink,ModelLink>( "ModelMovableLink" )
.def( "subscribeToPositionChanged", &ModelMovableLink_subscribeToPositionChanged)
,
- class_<Model>( "Model" )
+ class_<Model,ModelPtr>( "Model" )
.def( constructor<>() )
.property( "name", &Model::getName, &Model::setName )
.def( "getName", &Model::getName )
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <psy...@us...> - 2007-09-22 21:23:17
|
Revision: 1877
http://yake.svn.sourceforge.net/yake/?rev=1877&view=rev
Author: psyclonist
Date: 2007-09-22 14:23:17 -0700 (Sat, 22 Sep 2007)
Log Message:
-----------
* [demo] raf/lua2: Corrected name to 'VolumeTrigger'. ('Trigger' is the base class.)
Modified Paths:
--------------
trunk/yake/common/media/scripts/raf2.lua
trunk/yake/samples/raf/lua2/demo.cpp
Modified: trunk/yake/common/media/scripts/raf2.lua
===================================================================
--- trunk/yake/common/media/scripts/raf2.lua 2007-09-22 21:19:42 UTC (rev 1876)
+++ trunk/yake/common/media/scripts/raf2.lua 2007-09-22 21:23:17 UTC (rev 1877)
@@ -19,7 +19,7 @@
-- demo methods which make creating various objects simpler
--------------------------------------
function makeProximityTrigger(radius)
- local trigger = objMgr:makeObject("Trigger")
+ local trigger = objMgr:makeObject("VolumeTrigger")
assert( trigger )
trigger.volumes:add( yake.Sphere(radius or 2) )
Modified: trunk/yake/samples/raf/lua2/demo.cpp
===================================================================
--- trunk/yake/samples/raf/lua2/demo.cpp 2007-09-22 21:19:42 UTC (rev 1876)
+++ trunk/yake/samples/raf/lua2/demo.cpp 2007-09-22 21:23:17 UTC (rev 1877)
@@ -131,10 +131,14 @@
ent::RegistrationResult ret = objMgr_.registerClass<ent::Entity>("Entity",params);
YAKE_ASSERT( ret.first == object::RC_OK );
- params.set("lua.startup",(MakeStringVector() << "o_trigger2.lua").get());
+ params.set("lua.startup",(MakeStringVector() << "o_entity.lua").get());
ret = objMgr_.registerClass<ent::Trigger>("Trigger",params);
YAKE_ASSERT( ret.first == object::RC_OK );
+ params.set("lua.startup",(MakeStringVector() << "o_trigger2.lua").get());
+ ret = objMgr_.registerClass<ent::Trigger>("VolumeTrigger",params);
+ YAKE_ASSERT( ret.first == object::RC_OK );
+
params.set("lua.startup",(MakeStringVector() << "o_ball.lua").get());
ret = objMgr_.registerClass<ent::Entity>("Ball",params);
YAKE_ASSERT( ret.first == object::RC_OK );
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <psy...@us...> - 2007-09-25 21:29:28
|
Revision: 1878
http://yake.svn.sourceforge.net/yake/?rev=1878&view=rev
Author: psyclonist
Date: 2007-09-25 14:29:30 -0700 (Tue, 25 Sep 2007)
Log Message:
-----------
* [vehicle] lib and demo updated to new API (Vector3 vs Point3 etc)
Modified Paths:
--------------
trunk/yake/samples/vehicle/yakeDemo.cpp
trunk/yake/src/vehicle/yakeDotVehicle.cpp
trunk/yake/src/vehicle/yakeMountPoint.cpp
trunk/yake/src/vehicle/yakeNativeOde.cpp
trunk/yake/yake/vehicle/yakeDotVehicle.h
trunk/yake/yake/vehicle/yakeInterfaces.h
trunk/yake/yake/vehicle/yakeMountPoint.h
trunk/yake/yake/vehicle/yakeNativeOde.h
trunk/yake/yake/vehicle/yakeTemplates.h
Added Paths:
-----------
trunk/yake/samples/bin/debug/sampleVehicle.cfg
Added: trunk/yake/samples/bin/debug/sampleVehicle.cfg
===================================================================
--- trunk/yake/samples/bin/debug/sampleVehicle.cfg (rev 0)
+++ trunk/yake/samples/bin/debug/sampleVehicle.cfg 2007-09-25 21:29:30 UTC (rev 1878)
@@ -0,0 +1,18 @@
+[resource.sources] # <- evaluated by RAF
+file=../../../common/media/scripts/ # <- do NOT forget trialing '/' !!
+
+#-----------------------------------
+[raf.startup.libraries]
+# Libraries to be loaded automatically at startup
+
+graphicsOgre
+inputOgreOIS
+physicsODE
+
+#-----------------------------------
+[raf.startup.systems]
+# System to be created & initialized automatically
+
+graphics=ogre3d
+input=ois
+physics=ode
Modified: trunk/yake/samples/vehicle/yakeDemo.cpp
===================================================================
--- trunk/yake/samples/vehicle/yakeDemo.cpp 2007-09-22 21:23:17 UTC (rev 1877)
+++ trunk/yake/samples/vehicle/yakeDemo.cpp 2007-09-25 21:29:30 UTC (rev 1878)
@@ -96,7 +96,7 @@
// set up camera
getDefaultCamera()->setNearClipDistance( 1 );
getDefaultCamera()->setFixedYawAxis(Vector3::kUnitY);
- getDefaultCamera()->setPosition(Vector3(7,4,-7));
+ getDefaultCamera()->setPosition(Point3(7,4,-7));
//
getPhysicalWorld()->setGlobalGravity(Vector3(0,real(-9.81),0));
@@ -113,7 +113,7 @@
pGroundE->setCastsShadow( false );
pGroundSN->attachEntity( pGroundE );
pGroundSN->setScale( Vector3(200,1,200) );
- pGroundSN->setPosition( Vector3(0,groundHeight,0) );
+ pGroundSN->setPosition( Point3(0,groundHeight,0) );
model::Graphical* pG = new model::Graphical();
pG->addSceneNode( pGroundSN, "groundSN" );
@@ -229,7 +229,7 @@
struct GoVehicleBase
{
virtual ~GoVehicleBase() {}
- virtual Vector3 getPosition() const = 0;
+ virtual Point3 getPosition() const = 0;
virtual void onEnter(input::ActionMap& actionMap, input::KeyboardDevice* keyboard) = 0;
virtual void onExit()
{
@@ -264,7 +264,7 @@
{
destroy();
}
- virtual Vector3 getPosition() const
+ virtual Point3 getPosition() const
{
YAKE_ASSERT( mVehicle );
return mVehicle->getChassisPosition();
@@ -456,7 +456,7 @@
{
destroy();
}
- virtual Vector3 getPosition() const
+ virtual Point3 getPosition() const
{
YAKE_ASSERT( mVehicle );
return mVehicle->getChassisPosition();
@@ -485,7 +485,7 @@
// - ship body
graphics::ISceneNode* pSN = gworld.createSceneNode();
pSN->attachEntity( gworld.createEntity("razor.mesh") );
- pSN->setScale( math::Vector3::kUnitScale * razorMeshScale );
+ pSN->setScale( Vector3::kUnitScale * razorMeshScale );
pG->addSceneNode(pSN,"root");
YAKE_LOG( "demo","Creating thruster visuals" );
@@ -645,7 +645,7 @@
graphics::ISceneNode* pSN = gworld.createSceneNode();
graphics::IEntity* pE = gworld.createEntity("sphere_d1.mesh");
pSN->attachEntity( pE );
- const math::Vector3 scale = math::Vector3::kUnitScale * 2.f * mVehicle->getWheelInterface(wheelId)->getRadius();
+ const Vector3 scale = Vector3::kUnitScale * 2.f * mVehicle->getWheelInterface(wheelId)->getRadius();
pSN->setScale( scale );
YAKE_ASSERT( mModel );
@@ -707,7 +707,10 @@
class TheApp : public raf::ExampleApplication<TheConfiguration>
{
public:
- TheApp() {}
+ TheApp()
+ {
+ getConfiguration().get().load("sampleVehicle.cfg");
+ }
protected:
virtual raf::MainState* createMainState()
{
Modified: trunk/yake/src/vehicle/yakeDotVehicle.cpp
===================================================================
--- trunk/yake/src/vehicle/yakeDotVehicle.cpp 2007-09-22 21:23:17 UTC (rev 1877)
+++ trunk/yake/src/vehicle/yakeDotVehicle.cpp 2007-09-25 21:29:30 UTC (rev 1878)
@@ -136,11 +136,11 @@
void DotVehicleParser::parseShapeBox( const data::dom::INode& n, const String& matId )
{
- math::Vector3 dim;
+ Vector3 dim;
dim.x = StringUtil::parseReal( n.getAttributeValueAs<String>("x") );
dim.y = StringUtil::parseReal( n.getAttributeValueAs<String>("y") );
dim.z = StringUtil::parseReal( n.getAttributeValueAs<String>("z") );
- math::Vector3 pos;
+ Point3 pos;
if (n.getNodeByName("position"))
parsePosition( *n.getNodeByName("position"), pos );
mpCurrVehTpl->mChassis.mChassisShapes.push_back(
@@ -150,7 +150,7 @@
void DotVehicleParser::parseShapeSphere( const data::dom::INode& n, const String& matId )
{
real radius = StringUtil::parseReal( n.getAttributeValueAs<String>("radius") );
- math::Vector3 pos;
+ Point3 pos;
if (n.getNodeByName("position"))
parsePosition( *n.getNodeByName("position"), pos );
mpCurrVehTpl->mChassis.mChassisShapes.push_back(
@@ -260,17 +260,17 @@
const String thisId = n.getAttributeValueAs<String>("name");
YAKE_ASSERT( !thisId.empty() );
- math::Vector3 position;
+ Point3 position;
SharedPtr<INode> pNode = n.getNodeByName("position");
if (pNode.get())
parsePosition( *pNode, position );
- math::Quaternion orientation;
+ Quaternion orientation;
pNode = n.getNodeByName("orientation");
if (pNode.get())
parseOrientation( *pNode, orientation );
- math::Vector3 direction;
+ Vector3 direction;
pNode = n.getNodeByName("direction");
if (pNode.get())
parseDirection( *pNode, direction );
@@ -321,12 +321,12 @@
return;
YAKE_ASSERT( mpCurrVehTpl->mWheels.find( name ) == mpCurrVehTpl->mWheels.end() )( name ).debug("duplicate wheel name. overriding values.");
- math::Vector3 position;
+ Point3 position;
SharedPtr<data::dom::INode> pN = n.getNodeByName("position");
if (pN.get())
parsePosition( *pN, position );
- math::Quaternion rotation( math::Quaternion::kIdentity );
+ Quaternion rotation( Quaternion::kIdentity );
pN = n.getNodeByName("orientation");
if (pN.get())
parseOrientation( *pN, rotation );
@@ -356,19 +356,19 @@
}
- void DotVehicleParser::parsePosition( const data::dom::INode& n, math::Vector3& ret )
+ void DotVehicleParser::parsePosition( const data::dom::INode& n, Point3& ret )
{
ret.x = StringUtil::parseReal( n.getAttributeValueAs<String>("x") );
ret.y = StringUtil::parseReal( n.getAttributeValueAs<String>("y") );
ret.z = StringUtil::parseReal( n.getAttributeValueAs<String>("z") );
}
- void DotVehicleParser::parseDirection( const data::dom::INode& n, math::Vector3& ret )
+ void DotVehicleParser::parseDirection( const data::dom::INode& n, Vector3& ret )
{
ret.x = StringUtil::parseReal( n.getAttributeValueAs<String>("x") );
ret.y = StringUtil::parseReal( n.getAttributeValueAs<String>("y") );
ret.z = StringUtil::parseReal( n.getAttributeValueAs<String>("z") );
}
- void DotVehicleParser::parseOrientation( const data::dom::INode& n, math::Quaternion& ret )
+ void DotVehicleParser::parseOrientation( const data::dom::INode& n, Quaternion& ret )
{
if ( n.getAttributeValueAs<String>("qx") != "" )
{
@@ -379,7 +379,7 @@
}
else if ( n.getAttributeValueAs<String>("axisX") != "" )
{
- math::Vector3 axis;
+ Vector3 axis;
axis.x = StringUtil::parseReal( n.getAttributeValueAs<String>("axisX") );
axis.y = StringUtil::parseReal( n.getAttributeValueAs<String>("axisY") );
axis.z = StringUtil::parseReal( n.getAttributeValueAs<String>("axisZ") );
@@ -387,7 +387,7 @@
}
else if ( n.getAttributeValueAs<String>("angleX") != "" )
{
- math::Vector3 axis;
+ Vector3 axis;
axis.x = StringUtil::parseReal( n.getAttributeValueAs<String>("angleX") );
axis.y = StringUtil::parseReal( n.getAttributeValueAs<String>("angleY") );
axis.z = StringUtil::parseReal( n.getAttributeValueAs<String>("angleZ") );
Modified: trunk/yake/src/vehicle/yakeMountPoint.cpp
===================================================================
--- trunk/yake/src/vehicle/yakeMountPoint.cpp 2007-09-22 21:23:17 UTC (rev 1877)
+++ trunk/yake/src/vehicle/yakeMountPoint.cpp 2007-09-25 21:29:30 UTC (rev 1878)
@@ -35,8 +35,8 @@
// Class: MountPoint
//-----------------------------------------------------
MountPoint::MountPoint() :
- mPosition(math::Vector3::kZero),
- mOrientation(math::Quaternion::kIdentity),
+ mPosition(Point3::kZero),
+ mOrientation(Quaternion::kIdentity),
mParent(0),
mOverrideParent(0)
{
@@ -91,29 +91,29 @@
mMountables.erase( itFind );
mountable->onDetached();
}
- math::Vector3 MountPoint::getDirection() const
+ Vector3 MountPoint::getDirection() const
{
// direction in local coordinates
//
- return mOrientation * math::Vector3::kUnitZ;
+ return mOrientation * Vector3::kUnitZ;
}
- void MountPoint::setDirection( const math::Vector3& dir)
+ void MountPoint::setDirection( const Vector3& dir)
{
const real tolerance = real(0.001);
- const math::Vector3 currDir = getDirection();
- const math::Vector3 newDir = dir.normalisedCopy();
+ const Vector3 currDir = getDirection();
+ const Vector3 newDir = dir.normalisedCopy();
if ( newDir == currDir )
return;
if ( newDir.dotProduct( currDir ) + 1 <= tolerance ) // tolerance check. TODO tolerance globally? for math
{
- real angle = 0.;
- math::Vector3 axis;
- mOrientation.ToAngleAxis( angle, axis );
+ real angle = 0.;
+ Vector3 axis;
+ mOrientation.ToAngleAxis( angle, axis );
// adding another 180 grads
- angle += math::Math::PI;
+ angle += Math::PI;
// setting new orientation
mOrientation.FromAngleAxis( angle, axis );
@@ -122,23 +122,23 @@
}
mOrientation = currDir.getRotationTo( newDir ) * mOrientation;
}
- void MountPoint::setPosition(const math::Vector3& rPosition)
+ void MountPoint::setPosition(const Point3& rPosition)
{
mPosition = rPosition;
}
- math::Vector3 MountPoint::getPosition() const
+ Point3 MountPoint::getPosition() const
{
return mPosition;
}
- void MountPoint::setOrientation( const math::Quaternion& q )
+ void MountPoint::setOrientation( const Quaternion& q )
{
mOrientation = q;
}
- math::Quaternion MountPoint::getOrientation() const
+ Quaternion MountPoint::getOrientation() const
{
return mOrientation;
}
- math::Vector3 MountPoint::getDerivedPosition() const
+ Point3 MountPoint::getDerivedPosition() const
{
if (mOverrideParent)
return mOverrideParent->getOrientation() * mPosition + mOverrideParent->getPosition();
@@ -146,7 +146,7 @@
return mParent->getDerivedOrientation() * mPosition + mParent->getDerivedPosition();
return mPosition;
}
- math::Quaternion MountPoint::getDerivedOrientation() const
+ Quaternion MountPoint::getDerivedOrientation() const
{
if (mOverrideParent)
return mOverrideParent->getOrientation() * mOrientation;
Modified: trunk/yake/src/vehicle/yakeNativeOde.cpp
===================================================================
--- trunk/yake/src/vehicle/yakeNativeOde.cpp 2007-09-22 21:23:17 UTC (rev 1877)
+++ trunk/yake/src/vehicle/yakeNativeOde.cpp 2007-09-25 21:29:30 UTC (rev 1878)
@@ -221,12 +221,12 @@
return 0;
return itFind->second;
}
- math::Vector3 GenericVehicle::getChassisPosition() const
+ Point3 GenericVehicle::getChassisPosition() const
{
YAKE_ASSERT( mpChassis );
return mpChassis->getPosition();
}
- math::Quaternion GenericVehicle::getChassisOrientation() const
+ Quaternion GenericVehicle::getChassisOrientation() const
{
YAKE_ASSERT( mpChassis );
return mpChassis->getOrientation();
@@ -463,7 +463,7 @@
{
pE = GWorld.createEntity("sphere_1d.mesh");
pSN->attachEntity( pE );
- pSN->setScale( math::Vector3::kUnitScale * pShape->getPropertyReal("radius") );
+ pSN->setScale( Vector3::kUnitScale * pShape->getPropertyReal("radius") );
}
break;
default:
@@ -498,7 +498,7 @@
{
YAKE_SAFE_DELETE( mDebugModel );
}
- void GenericVehicle::setPosition(const Vector3& position)
+ void GenericVehicle::setPosition(const Point3& position)
{
YAKE_ASSERT( mpChassis );
const Vector3 delta = position - this->getChassisPosition();
@@ -537,7 +537,7 @@
YAKE_ASSERT( chassisObj );
mpWheel = PWorld.createActor( physics::ACTOR_DYNAMIC );
- mpWheel->createShape( physics::IShape::SphereDesc( mRadius, Vector3::kZero, Quaternion::kIdentity, tpl.mMaterial ) );
+ mpWheel->createShape( physics::IShape::SphereDesc( mRadius, Point3::kZero, Quaternion::kIdentity, tpl.mMaterial ) );
real mass = tpl.mMassRelativeToChassis ?
(tpl.mMass * chassisObj->getBody().getMass()) : tpl.mMass;
mpWheel->setPosition( tpl.mPosition );
@@ -554,8 +554,8 @@
{
mpJoint = PWorld.createJoint( physics::IJoint::DescHinge2(
chassisObj, mpWheel,
- tpl.mOrientation * math::Vector3::kUnitY,
- tpl.mOrientation * math::Vector3::kUnitX,
+ tpl.mOrientation * Vector3::kUnitY,
+ tpl.mOrientation * Vector3::kUnitX,
tpl.mPosition ) );
mpJoint->setSpring( tpl.mSuspensionSpring );
@@ -633,10 +633,10 @@
{
YAKE_ASSERT( mpChassis );
YAKE_ASSERT( mpWheel );
- const math::Vector3 chassisDir = mpChassis->getOrientation() * math::Vector3::kUnitZ;
- const math::Vector3 linVel = mpWheel->getBody().getLinearVelocity();
+ const Vector3 chassisDir = mpChassis->getOrientation() * Vector3::kUnitZ;
+ const Vector3 linVel = mpWheel->getBody().getLinearVelocity();
const real linVelf = linVel.length();
- const math::Vector3 wheelMovementDir = linVel.normalisedCopy();
+ const Vector3 wheelMovementDir = linVel.normalisedCopy();
if (linVelf < 0.1) //@todo FIXME should be dependent size...
mSkid = 0.;
else
@@ -651,32 +651,32 @@
{
return mRadius;
}
- void OdeWheel::setPosition(const math::Vector3& pos)
+ void OdeWheel::setPosition(const Point3& pos)
{
YAKE_ASSERT( mpWheel );
mpWheel->setPosition( pos );
}
- void OdeWheel::setOrientation(const math::Quaternion& o)
+ void OdeWheel::setOrientation(const Quaternion& o)
{
YAKE_ASSERT( mpWheel );
mpWheel->setOrientation( o );
}
- math::Vector3 OdeWheel::getPosition() const
+ Point3 OdeWheel::getPosition() const
{
YAKE_ASSERT( mpWheel );
return mpWheel->getPosition();
}
- math::Vector3 OdeWheel::getDerivedPosition() const
+ Point3 OdeWheel::getDerivedPosition() const
{
YAKE_ASSERT( mpWheel );
return mpWheel->getDerivedPosition();
}
- math::Quaternion OdeWheel::getOrientation() const
+ Quaternion OdeWheel::getOrientation() const
{
YAKE_ASSERT( mpWheel );
return mpWheel->getOrientation();
}
- math::Quaternion OdeWheel::getDerivedOrientation() const
+ Quaternion OdeWheel::getDerivedOrientation() const
{
YAKE_ASSERT( mpWheel );
return mpWheel->getDerivedOrientation();
@@ -684,22 +684,22 @@
void OdeWheel::_applyDriveTq( const real tq )
{
//std::cout << "DTQ=" << tq << "\n";
- //_applyTq( math::Vector3::kUnitX * tq );
+ //_applyTq( Vector3::kUnitX * tq );
if (mBrakeRatio > 0.01)
- _applyBrakeTq( math::Vector3::kUnitX * mBrakeRatio * 1.5 );
+ _applyBrakeTq( Vector3::kUnitX * mBrakeRatio * 1.5 );
const real targetVel = tq < 0. ? -40. : 40.;
_applyMotor( targetVel, - tq * 0.01/*@todo this is "dt" dependent*/ );
}
- void OdeWheel::_applyTq( const math::Vector3& torque )
+ void OdeWheel::_applyTq( const Vector3& torque )
{
mpWheel->getBody().addTorque( mpWheel->getOrientation() * torque );
}
- void OdeWheel::_applyBrakeTq( const math::Vector3 & torque )
+ void OdeWheel::_applyBrakeTq( const Vector3 & torque )
{
- math::Vector3 linVel = mpWheel->getBody().getLinearVelocity();
- math::Vector3 dir = mpWheel->getOrientation() * math::Vector3::kUnitX;
+ Vector3 linVel = mpWheel->getBody().getLinearVelocity();
+ Vector3 dir = mpWheel->getOrientation() * Vector3::kUnitX;
if (dir.dotProduct(linVel) > 0)
{
std::cout << "BRK+\n";
@@ -774,12 +774,12 @@
}
void GenericLinearThruster::updateSimulation( real timeElapsed )
{
- real abs_force = getMinimumForce() + math::Math::Abs( mVoltage ) * ( getMaximumForce() - getMinimumForce() );
+ real abs_force = getMinimumForce() + Math::Abs( mVoltage ) * ( getMaximumForce() - getMinimumForce() );
if ( abs_force > getMaximumForce() )
abs_force = getMaximumForce();
- setForce( math::Math::Sign( mVoltage )*abs_force );
+ setForce( Math::Sign( mVoltage )*abs_force );
}
//-----------------------------------------------------
@@ -799,9 +799,9 @@
return;
const MountPoint* mp = getMountPoint();
- const math::Vector3 pos = mp ? mp->getDerivedPosition() : math::Vector3::kZero;
- const math::Quaternion rot = mp ? mp->getDerivedOrientation() : math::Quaternion::kIdentity;
- const math::Vector3 f = mThruster->getForce() * ( rot * -math::Vector3::kUnitZ );
+ const Point3 pos = mp ? mp->getDerivedPosition() : Point3::kZero;
+ const Quaternion rot = mp ? mp->getDerivedOrientation() : Quaternion::kIdentity;
+ const Vector3 f = mThruster->getForce() * ( rot * -Vector3::kUnitZ );
ConstDequeIterator< BodyPtrList > itBody( mTargets );
while (itBody.hasMoreElements())
Modified: trunk/yake/yake/vehicle/yakeDotVehicle.h
===================================================================
--- trunk/yake/yake/vehicle/yakeDotVehicle.h 2007-09-22 21:23:17 UTC (rev 1877)
+++ trunk/yake/yake/vehicle/yakeDotVehicle.h 2007-09-25 21:29:30 UTC (rev 1878)
@@ -66,9 +66,9 @@
void parseWheel( const data::dom::INode& n );
void parseEngineTpl( const data::dom::INode& n );
- void parsePosition( const data::dom::INode& n, math::Vector3& ret );
- void parseOrientation( const data::dom::INode& n, math::Quaternion& ret );
- void parseDirection( const data::dom::INode& n, math::Vector3& ret );
+ void parsePosition( const data::dom::INode& n, Point3& ret );
+ void parseOrientation( const data::dom::INode& n, Quaternion& ret );
+ void parseDirection( const data::dom::INode& n, Vector3& ret );
VehicleTemplate* mpCurrVehTpl;
};
Modified: trunk/yake/yake/vehicle/yakeInterfaces.h
===================================================================
--- trunk/yake/yake/vehicle/yakeInterfaces.h 2007-09-22 21:23:17 UTC (rev 1877)
+++ trunk/yake/yake/vehicle/yakeInterfaces.h 2007-09-25 21:29:30 UTC (rev 1878)
@@ -67,15 +67,15 @@
virtual void setSteering( const uint32 sg, const real ) = 0;
virtual real getSteering( const uint32 sg ) const = 0;
- virtual math::Vector3 getChassisPosition() const = 0;
- virtual math::Quaternion getChassisOrientation() const = 0;
+ virtual Point3 getChassisPosition() const = 0;
+ virtual Quaternion getChassisOrientation() const = 0;
virtual Movable* getChassisMovable() const = 0;
virtual physics::IActorPtr getPhysicalChassis() const = 0;
virtual void enableDebugGeometry(graphics::IWorld&) = 0;
virtual void disableDebugGeometry() = 0;
- virtual void setPosition(const Vector3&) = 0;
+ virtual void setPosition(const Point3&) = 0;
virtual void translate(const Vector3&) = 0;
};
Modified: trunk/yake/yake/vehicle/yakeMountPoint.h
===================================================================
--- trunk/yake/yake/vehicle/yakeMountPoint.h 2007-09-22 21:23:17 UTC (rev 1877)
+++ trunk/yake/yake/vehicle/yakeMountPoint.h 2007-09-25 21:29:30 UTC (rev 1878)
@@ -87,7 +87,7 @@
typedef Deque< Mountable* > MountablePtrList;
MountablePtrList mMountables;
Quaternion mOrientation;
- Vector3 mPosition;
+ Point3 mPosition;
typedef Deque< std::pair<MountPoint*,bool> > MountPointList;
MountPointList mChildren;
MountPoint* mParent;
Modified: trunk/yake/yake/vehicle/yakeNativeOde.h
===================================================================
--- trunk/yake/yake/vehicle/yakeNativeOde.h 2007-09-22 21:23:17 UTC (rev 1877)
+++ trunk/yake/yake/vehicle/yakeNativeOde.h 2007-09-25 21:29:30 UTC (rev 1878)
@@ -98,8 +98,8 @@
virtual IEnginePtrList getEngineInterfaces() const;
virtual IWheel* getWheelInterface(const String& id) const;
- virtual math::Vector3 getChassisPosition() const;
- virtual math::Quaternion getChassisOrientation() const;
+ virtual Point3 getChassisPosition() const;
+ virtual Quaternion getChassisOrientation() const;
virtual Movable* getChassisMovable() const;
virtual physics::IActorPtr getPhysicalChassis() const;
@@ -109,7 +109,7 @@
virtual void enableDebugGeometry(graphics::IWorld&);
virtual void disableDebugGeometry();
- virtual void setPosition(const Vector3&);
+ virtual void setPosition(const Point3&);
virtual void translate(const Vector3&);
void _create(const VehicleTemplate&, physics::IWorld& PWorld, model::Physical& physModel );
@@ -209,12 +209,12 @@
const VehicleTemplate::WheelTpl& tpl,
physics::IWorld& PWorld );
- virtual void setPosition(const math::Vector3&);
- virtual math::Vector3 getPosition() const;
- virtual math::Vector3 getDerivedPosition() const;
- virtual void setOrientation(const math::Quaternion&);
- virtual math::Quaternion getOrientation() const;
- virtual math::Quaternion getDerivedOrientation() const;
+ virtual void setPosition(const Point3&);
+ virtual Point3 getPosition() const;
+ virtual Point3 getDerivedPosition() const;
+ virtual void setOrientation(const Quaternion&);
+ virtual Quaternion getOrientation() const;
+ virtual Quaternion getDerivedOrientation() const;
virtual real getRadius() const;
@@ -226,8 +226,8 @@
void _applyDriveTq( const real tq );
private:
- void _applyTq( const math::Vector3 & torque );
- void _applyBrakeTq( const math::Vector3 & torque );
+ void _applyTq( const Vector3 & torque );
+ void _applyBrakeTq( const Vector3 & torque );
void _applyMotor( real velocity, real fmax );
void _onPreStepInternal( const real dt );
Modified: trunk/yake/yake/vehicle/yakeTemplates.h
===================================================================
--- trunk/yake/yake/vehicle/yakeTemplates.h 2007-09-22 21:23:17 UTC (rev 1877)
+++ trunk/yake/yake/vehicle/yakeTemplates.h 2007-09-25 21:29:30 UTC (rev 1878)
@@ -41,31 +41,31 @@
typedef AssocVector< String, MountPointTpl > MountPointTplList;
struct MountPointTpl
{
- math::Vector3 mPosition;
- math::Quaternion mOrientation;
- math::Vector3 mDirection;
- bool mUseDirection;
+ Point3 mPosition;
+ Quaternion mOrientation;
+ Vector3 mDirection;
+ bool mUseDirection;
MountPointTplList mChildren;
MountPointTpl(
- const math::Vector3& pos = math::Vector3::kZero,
- const math::Quaternion& rot = math::Quaternion::kIdentity) :
+ const Point3& pos = Point3::kZero,
+ const Quaternion& rot = Quaternion::kIdentity) :
mPosition(pos),
mOrientation(rot),
mUseDirection(false)
{}
MountPointTpl(
- const math::Vector3& pos,
- const math::Vector3& dir) :
+ const Point3& pos,
+ const Vector3& dir) :
mPosition(pos),
mDirection(dir),
mUseDirection(true)
{}
MountPointTpl& addMountPoint(
- const math::Vector3& pos = math::Vector3::kZero,
- const math::Quaternion& rot = math::Quaternion::kIdentity);
+ const Point3& pos = Point3::kZero,
+ const Quaternion& rot = Quaternion::kIdentity);
MountPointTpl& addMountPoint(
- const math::Vector3& pos,
- const math::Vector3& dir);
+ const Point3& pos,
+ const Vector3& dir);
};
enum GearMode
{
@@ -123,14 +123,14 @@
struct ChassisTpl
{
- math::Vector3 mPosition; // initial position
+ Point3 mPosition; // initial position
real mMass;
- ShapeTplList mChassisShapes;
+ ShapeTplList mChassisShapes;
String mGfxReference; // e.g. dotScene file
String mPhysicsBody; // e.g. physical body loaded from .xode file
ChassisTpl() :
- mPosition(math::Vector3::kZero),
+ mPosition(Point3::kZero),
mMass(real(1.6)) // @todo FIXME magic number
{}
};
@@ -138,8 +138,8 @@
struct WheelTpl
{
uint32 mAxle;
- math::Vector3 mPosition;
- math::Quaternion mOrientation;
+ Point3 mPosition;
+ Quaternion mOrientation;
uint32 mSteeringGroup;
real mRadius;
real mMass;
@@ -150,8 +150,8 @@
//String mGfxReferenceType; // e.g. "dotscene"
String mMaterial;
WheelTpl(
- const math::Vector3& position = math::Vector3::kZero,
- const math::Quaternion& orientation = math::Quaternion::kIdentity,
+ const Point3& position = Point3::kZero,
+ const Quaternion& orientation = Quaternion::kIdentity,
const real radius = real(0.2),
const real mass = real(0.018),
const bool massRelativeToChassis = true,
@@ -178,10 +178,10 @@
//
- ChassisTpl mChassis;
+ ChassisTpl mChassis;
MountPointTplList mMountPoints;
EngineTplList mEngines;
- uint32 mSteeringGroups;
+ uint32 mSteeringGroups;
WheelTplList mWheels;
VehicleTemplate() : mSteeringGroups(0)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <psy...@us...> - 2007-10-22 15:50:49
|
Revision: 1879
http://yake.svn.sourceforge.net/yake/?rev=1879&view=rev
Author: psyclonist
Date: 2007-10-22 08:50:52 -0700 (Mon, 22 Oct 2007)
Log Message:
-----------
* added demo net2/message2
* replaced custom serialization with boost::serialization for complex network messages
Modified Paths:
--------------
trunk/yake/scripts/premake/samples.lua
trunk/yake/yake/net2/async_send.h
trunk/yake/yake/net2/error.h
trunk/yake/yake/net2/message_decoder.h
trunk/yake/yake/net2/net.h
trunk/yake/yake/net2/packet_connection.h
trunk/yake/yake/net2/simple_serialization.h
Added Paths:
-----------
trunk/yake/samples/net2/message2/
trunk/yake/samples/net2/message2/demo.cpp
Added: trunk/yake/samples/net2/message2/demo.cpp
===================================================================
--- trunk/yake/samples/net2/message2/demo.cpp (rev 0)
+++ trunk/yake/samples/net2/message2/demo.cpp 2007-10-22 15:50:52 UTC (rev 1879)
@@ -0,0 +1,505 @@
+#include <yake/base/yakePrerequisites.h>
+#include <yake/base/yake.h> // for YAKE_ASSERT etc
+#include <yake/net2/net.h>
+#undef min
+#undef max
+#include <boost/bind.hpp>
+
+
+using namespace yake;
+
+struct c2sLoginReq
+{
+private:
+ friend class boost::serialization::access;
+ template<class Archive>
+ void serialize(Archive & ar, const unsigned int version)
+ {
+ ar & user & passhash;
+ }
+public:
+ enum { ID = 2 };
+ std::string user;
+ std::string passhash;
+};
+#define DEF_SIMPLE_MESSAGE_0(NAME,MSGID) \
+struct NAME \
+{ \
+private: \
+ friend class boost::serialization::access; \
+ template<class Archive> \
+ void serialize(Archive & ar, const unsigned int version) \
+ { \
+ } \
+public: \
+ enum { ID = MSGID }; \
+};
+#define DEF_SIMPLE_MESSAGE_1(NAME,MSGID,T1,NAME1) \
+struct NAME \
+{ \
+private: \
+ friend class boost::serialization::access; \
+ template<class Archive> \
+ void serialize(Archive & ar, const unsigned int version) \
+ { \
+ ar & NAME1; \
+ } \
+public: \
+ enum { ID = MSGID }; \
+ T1 NAME1; \
+ NAME() {} \
+ NAME(const T1& NAME1 ##_) : NAME1(NAME1 ##_) {} \
+};
+#define DEF_SIMPLE_MESSAGE_2(NAME,MSGID,T1,NAME1,T2,NAME2) \
+struct NAME \
+{ \
+private: \
+ friend class boost::serialization::access; \
+ template<class Archive> \
+ void serialize(Archive & ar, const unsigned int version) \
+ { \
+ ar & NAME1 & NAME2; \
+ } \
+public: \
+ enum { ID = MSGID }; \
+ T1 NAME1; \
+ T2 NAME2; \
+ NAME() {} \
+ NAME(const T1& NAME1 ##_, const T2& NAME2 ##_) : NAME1(NAME1 ##_), NAME2(NAME2 ##_) {} \
+};
+DEF_SIMPLE_MESSAGE_2(s2cLoginResult,3,bool,success,std::string,reason);
+
+DEF_SIMPLE_MESSAGE_1(c2sCommJoinChannel,10,std::string,channel);
+DEF_SIMPLE_MESSAGE_2(c2sCommSendMessage,11,std::string,channel,std::string,text);
+DEF_SIMPLE_MESSAGE_1(c2sCommCreateChannel,20,std::string,channel);
+DEF_SIMPLE_MESSAGE_1(c2sCommDestroyChannel,21,std::string,channel);
+DEF_SIMPLE_MESSAGE_2(s2cCommMessage,22,std::string,channel,std::string,text);
+namespace CommError {
+ enum Code
+ {
+ access_denied_or_channel_does_not_exist = 0, //<- We are vague here. And that's right!
+ access_denied = 1,
+ numCodes
+ };
+ const char* toString(const Code code)
+ {
+ static const char* s_text[numCodes+1] = {
+ "Access denied or channel does not exist.",
+ "Access denied.",
+ "(no text available)"
+ };
+ if (code < numCodes && int(code) >= 0)
+ return s_text[code];
+ else
+ return s_text[numCodes];
+ }
+} // namespace CommError
+DEF_SIMPLE_MESSAGE_2(s2cCommError,23,CommError::Code,code,std::string,text);
+
+DEF_SIMPLE_MESSAGE_2(s2cSimBegin,1100,std::string,name,std::vector<uint8>,initialData);
+typedef std::map<std::string,uint32> ClassIdMap;
+DEF_SIMPLE_MESSAGE_1(s2cSimClassMapData,1110,ClassIdMap,clsId);
+
+#include <yake/base/yakeStderrLog.h>
+#include <boost/thread/thread.hpp>
+
+namespace placeholders = net::placeholders;
+
+// required Host interface:
+// * ... Host::dispatcher(clientId)
+// * ... Host::
+/** Synchronized: No */
+template<class Host>
+struct CommServerService : public noncopyable
+{
+ typedef typename Host::connection_ptr connection_ptr;
+ typedef typename Host::connection_data connection_data;
+ typedef connection_data ClientId;
+ void onNewConnection(connection_data clientId, connection_ptr conn)
+ {
+ std::cout << "s:comm: connect\n";
+
+ net::setDecoder<c2sCommJoinChannel>( Host::dispatcher(clientId),
+ boost::bind(&CommServerService::onJoinRequest,this,clientId,conn,placeholders::error,placeholders::message) );
+
+ //should be done for when the client joins the first channel:
+ net::setDecoder<c2sCommSendMessage>( Host::dispatcher(clientId),
+ boost::bind(&CommServerService::onMessage,this,clientId,conn,placeholders::error,placeholders::message) );
+
+ YAKE_ASSERT( !users_[ clientId ] );
+ users_[ clientId ].reset( new UserEntry() );
+ }
+ void onDisconnect(connection_data clientId, connection_ptr conn)
+ {
+ std::cout << "s:comm: disconnect\n";
+ net::setDecoder<c2sCommSendMessage>( Host::dispatcher(clientId), 0 );
+ net::setDecoder<c2sCommJoinChannel>( Host::dispatcher(clientId), 0 );
+
+ UserMap::iterator it = users_.find( clientId );
+ if (it == users_.end())
+ ;
+ else
+ {
+ // remove user from channels
+ YAKE_FOR_EACH(ChannelIdList::const_iterator, itCid, it->second->channels_)
+ {
+ ChannelMap::iterator itC = channels_.find( *itCid );
+ if (itC == channels_.end())
+ continue; // should not happen, but to be safe...
+ UserList::iterator itU = itC->second->users_.find( clientId );
+ if (itU != itC->second->users_.end())
+ itC->second->users_.erase( itU );
+ }
+ //
+ users_.erase( it );
+ }
+ }
+ CommServerService()
+ {
+ channels_.insert(
+ std::make_pair("#lobby",
+ ChannelEntry::pointer(new ChannelEntry()) ));
+ channels_.insert(
+ std::make_pair("#team_a",
+ ChannelEntry::pointer(new ChannelEntry()) ));
+ channels_.insert(
+ std::make_pair("#team_b",
+ ChannelEntry::pointer(new ChannelEntry()) ));
+ }
+private:
+ void onJoinRequest(connection_data clientId, connection_ptr conn, const net::Error&, const c2sCommJoinChannel& msg)
+ {
+ std::cout << "s:comm: X wants to join '" << msg.channel << "'\n";
+
+ if (msg.channel.size() > 100)
+ return; //@todo log this
+
+ channel_iterator it = channels_.find( msg.channel );
+ if (it == channels_.end())
+ {
+ net::async_send( *conn, s2cCommError(CommError::access_denied_or_channel_does_not_exist,msg.channel) );
+ }
+ else
+ {
+ UserMap::iterator itUser = users_.find( clientId );
+ if (itUser == users_.end())
+ return; //@todo log this
+ if (!itUser->second)
+ return; //@todo log this - report failure to client?
+ UserEntry& userEntry = *itUser->second;
+ userEntry.channels_.push_back( msg.channel );
+
+ ChannelEntry& chan = *it->second;
+ chan.users_.insert( IdConnPair(clientId,conn) );
+
+ net::async_send( *conn, s2cCommMessage(msg.channel,"Welcome to "+msg.channel+"!") );
+
+ sendToAllExcept( chan.users_, clientId, s2cCommMessage(msg.channel,"X joined the channel") );
+ }
+ }
+ void onMessage(connection_data clientId, connection_ptr conn, const net::Error&, const c2sCommSendMessage& msg)
+ {
+ std::cout << "s:comm: in '" << msg.channel << "' '?' says '" << msg.text << "'\n";
+ const_channel_iterator it = channels_.find( msg.channel );
+ if (it == channels_.end())
+ net::async_send( *conn, s2cCommError(CommError::access_denied,msg.channel) );
+ else
+ {
+ const UserList& users = it->second->users_;
+ UserList::const_iterator itFindUser = users.find( clientId );
+ if (itFindUser == users.end())
+ ; //@todo report "not a member of channel" ?
+ else
+ sendToAllExcept( users, clientId, s2cCommMessage(msg.channel,msg.text) );
+ }
+ }
+ //helper:
+ typedef std::pair<ClientId,connection_ptr> IdConnPair;
+ typedef std::map<ClientId,connection_ptr> UserList;
+ template<class Mt>
+ void sendToAllExcept(const UserList& users, ClientId clientId, const Mt& msg)
+ {
+ net::ArchiveContext arCtx; //<- reuse for performance.
+ YAKE_FOR_EACH( UserList::const_iterator, itUser, users )
+ {
+ const IdConnPair& idconn = *itUser;
+ if (idconn.first == clientId) // Don't send to self.
+ continue;
+ net::async_send( *idconn.second, msg, arCtx );
+ }
+ }
+ template<class Mt>
+ void sendToAll(const UserList& users, const Mt& msg)
+ {
+ net::ArchiveContext arCtx; //<- reuse for performance.
+ YAKE_FOR_EACH( UserList::const_iterator, itUser, users )
+ {
+ const IdConnPair& idconn = *itUser;
+ net::async_send( *idconn.second, msg, arCtx );
+ }
+ }
+private:
+ net::io_service io_;
+ boost::mutex channelMtx_;
+ boost::mutex userMtx_;
+
+ struct ChannelEntry
+ {
+ typedef boost::shared_ptr<ChannelEntry> pointer;
+
+ UserList users_;
+ };
+ typedef std::map<std::string,typename ChannelEntry::pointer> ChannelMap;
+ typedef typename ChannelMap::const_iterator const_channel_iterator;
+ typedef typename ChannelMap::iterator channel_iterator;
+ ChannelMap channels_;
+
+ typedef std::deque<std::string> ChannelIdList;
+ struct UserEntry
+ {
+ typedef boost::shared_ptr<UserEntry> pointer;
+
+ ChannelIdList channels_;
+ };
+ typedef std::map<ClientId,typename UserEntry::pointer> UserMap;
+ UserMap users_;
+};
+
+//typedef net::TCPServer<> server_type;
+typedef net::TCPServer<net::TCPPacketConnection<>,net::ConnectionFilterByIP> server_type;
+struct ServerHandler
+{
+ typedef server_type::packet_type packet_type;
+
+ //
+ struct Client : public boost::noncopyable
+ {
+ //typedef yake::SharedPtr<Client> pointer;
+ typedef Client* pointer;
+ net::IncomingPacketDispatcher<>& dispatcher()
+ { return dispatcher_; }
+
+ Client()
+ {
+ std::cout << "app: new Client\n";
+ }
+ ~Client()
+ {
+ std::cout << "app: ~Client\n";
+ }
+ private:
+ net::IncomingPacketDispatcher<> dispatcher_;
+ };
+
+ // for services:
+ typedef server_type::connection_type* connection_ptr;
+ typedef Client* connection_data; // app data... could be anything.
+ static net::IncomingPacketDispatcher<>& dispatcher(Client* client)
+ {
+ YAKE_ASSERT(client);
+ return client->dispatcher();
+ }
+
+ //
+ typedef CommServerService<ServerHandler> CommSvc;
+ CommSvc commSvc;
+
+ //
+ void onConnection(Client::pointer client,server_type::connection_weakptr conn, const net::Error& e)
+ {
+ std::cout << "app:onConnection: " << e.code() << "=" << e.what() << "\n";
+ assert( client );
+ if (e == net::Error::connected)
+ {
+ net::setDecoder<c2sLoginReq>( client->dispatcher(),
+ boost::bind(&ServerHandler::onLoginReq,this,client,conn,placeholders::error,placeholders::message) );
+ }
+ else if (!e)
+ {
+ net::setDecoder<c2sLoginReq>( client->dispatcher(), 0 );
+ if (e.code() == net::Error::disconnected)
+ {
+ commSvc.onDisconnect( client, conn.lock().get() );
+ delete client; //!
+ }
+ }
+ }
+ void onPacket(Client::pointer client,server_type::connection_weakptr conn, const packet_type& pckt)
+ {
+ std::cout << "app: recv'd packet. payload: " << pckt.header().payloadSize << " byte(s)\n";
+ assert( client );
+
+ client->dispatcher().dispatch( pckt );
+ }
+ void onCreateConnection(server_type::ConnectionHandler& connHandler, server_type::PacketHandler& pcktHandler)
+ {
+ Client::pointer client = new Client();
+ connHandler = boost::bind(&ServerHandler::onConnection,this,client,_1,_2);
+ pcktHandler = boost::bind(&ServerHandler::onPacket,this,client,_1,_2);
+ }
+ //
+ void onLoginReq(Client::pointer client, server_type::connection_weakptr conn, const net::Error& e, const c2sLoginReq& request)
+ {
+ if (!e)
+ std::cerr << "app: recv'd but FAILED to decode LOGINREQ: " << e << "\n";
+ else
+ {
+ std::cout << "app: recv'd & decoded LOGINREQ: user=" << request.user << "\n";
+ if (conn.lock())
+ {
+ s2cLoginResult out;
+ out.success = true;
+ out.reason = "Welcome!";
+ net::async_send( *conn.lock(), out );
+
+ //
+ commSvc.onNewConnection( client, conn.lock().get() );
+ }
+ }
+ }
+};
+int main(int argc, char* argv[])
+{
+ SharedPtr<logging::log_listener> to_stderr( new logging::stderr_listener() );
+ logging::addListener( to_stderr.get() );
+
+ // server
+ try {
+ if (argc > 1)
+ {
+ YAKE_LOG("demo", "starting server...");
+
+ net::io_service io;
+
+ ServerHandler serverApp;
+
+ // Create a server object for listening at localhost's port 40000 and
+ // creating TCPPacketConnection<> objects for each incoming TCP connections.
+ server_type server(io,
+ "localhost", // <- throws exception if invalid
+ 40000,
+ boost::bind(&ServerHandler::onCreateConnection,&serverApp,_1,_2));
+
+ // Test access of policy-enriched interface:
+ net::TCPIncomingConnectionFilter::address_set blackList;
+ //blackList.insert( net::detail::makeIpAddress("localhost") );
+ server.ipFilter().setBlackList(blackList);
+
+ // Run the server processing in a different thread.
+ // Note that, by subsequently creating additional threads
+ // running the same io_service::run() method we can increase
+ // the number of threads for the TCP server.
+ boost::thread_group netThreads;
+
+ // NB At the moment, only 1 is safe for the current implementation of ServerHandler.
+ const size_t numThreads = 1;
+ for (size_t i=0; i<numThreads; ++i)
+ netThreads.create_thread( boost::bind(&net::io_service::run,&io) );
+
+ // Wait for the server process to finish.
+ // @todo At the moment, it only finishes if it fails.
+ netThreads.join_all();
+ }
+ else
+ {
+ YAKE_LOG("demo", "starting client...");
+ // The io_service manages the asynchronous operations
+ net::io_service netIo_;
+
+ // Create a TCPPacketConnection object for connecting to
+ // a server.
+ net::TCPPacketConnection<>::pointer c = net::TCPPacketConnection<>::createClientConnection(netIo_);
+
+ // Add compression filter (ZLib):
+ //c->filters().add( new StatefulZipCompressorFilter() );
+
+ // Create a dispatcher object for incoming packets.
+ net::IncomingPacketDispatcher<> pcktDispatcher;
+
+ struct ClientHandler
+ {
+ static void onLoginResult(const net::Error& e, const s2cLoginResult& result)
+ {
+ if (e)
+ std::cout << "app: recv'd LOGIN RESULT: ok=" << result.success << " msg=" << result.reason << "\n";
+ else
+ std::cerr << "app: recv'd LOGIN RESULT but something did go wrong...\n";
+ }
+ static void onConnection(const net::Error& e)
+ {
+ if (!e)
+ std::cout << "app: status = " << e << "\n";
+ }
+ static void onMessage(const net::Error& e, const s2cCommMessage& msg)
+ {
+ if (!e)
+ std::cout << "app: status = " << e << "\n";
+ else
+ std::cout << msg.channel << ": " << msg.text << "\n";
+ }
+ static void onCommError(const net::Error& e, const s2cCommError& err)
+ {
+ if (!e)
+ std::cout << "app: status = " << e << "\n";
+ else
+ std::cout << "comm-error: [" << int(err.code) << "]=" << CommError::toString(err.code) << " (" << err.text << ")\n";
+ }
+ };
+
+ // Subscribe to specific packet ids.
+ //pcktDispatcher.setHandler( 1, &onRecvPacket );
+ net::setDecoder<s2cLoginResult>( pcktDispatcher,
+ boost::bind(&ClientHandler::onLoginResult,placeholders::error,placeholders::message) );
+ net::setDecoder<s2cCommMessage>( pcktDispatcher,
+ boost::bind(&ClientHandler::onMessage,placeholders::error,placeholders::message) );
+ net::setDecoder<s2cCommError>( pcktDispatcher,
+ boost::bind(&ClientHandler::onCommError,placeholders::error,placeholders::message) );
+
+ // Start asynchronous connection attempt to server at port 40000.
+ // * onConnection receives connection related errors and status information.
+ // * onPacket is called when incoming packets have arrived.
+ // OR in this case we forward it to the IncomingPacketDispatcher
+ // * 5 is the maxmimum timeout (in seconds) for the connection attempt.
+ c->connect("localhost",40000,&ClientHandler::onConnection,
+ /*&onPacket OR*/ boost::bind(&net::IncomingPacketDispatcher<>::dispatch,&pcktDispatcher,_1),
+ 50);
+
+ // Start the io_service for the connection in a seperate thread.
+ // As soon as the connection is closed or in case it couldn't be
+ // established the thread will be terminated.
+ boost::thread netThread( boost::bind(&net::io_service::run,&netIo_) );
+
+ // Send some data (or enqueue, depending on connection state)
+ net::ArchiveContext arCtx; //<- reuse of context improves performance.
+ {
+ c2sLoginReq req;
+ req.user = "admin";
+ req.passhash = "letme";
+ net::async_send( *c, req, &ClientHandler::onConnection, arCtx );
+ }
+ // This one will get thrown away as we haven't yet joined the channel:
+ net::async_send( *c, c2sCommSendMessage("#lobby","Hi there! #1"), &ClientHandler::onConnection, arCtx );
+
+ net::async_send( *c, c2sCommJoinChannel("#lobby"), &ClientHandler::onConnection, arCtx );
+ net::async_send( *c, c2sCommSendMessage("#lobby","Hi there! #2"), &ClientHandler::onConnection, arCtx );
+
+ // This will result in an error message sent to us because
+ // this channel does not exist.
+ net::async_send( *c, c2sCommJoinChannel("#doesnotexist"), &ClientHandler::onConnection, arCtx );
+
+ // Wait for the connection thread to exit. (timeout or error ...)
+ netThread.join();
+ }
+ }
+ catch (boost::asio::error& ex)
+ {
+ YAKE_LOG_ERROR("demo",String("ASIO EXCEPTION: ") + ex.what());
+ }
+ catch (std::exception& ex)
+ {
+ YAKE_LOG_ERROR("demo",String("EXCEPTION: ") + ex.what());
+ }
+
+ return 0;
+}
+
Modified: trunk/yake/scripts/premake/samples.lua
===================================================================
--- trunk/yake/scripts/premake/samples.lua 2007-09-25 21:29:30 UTC (rev 1878)
+++ trunk/yake/scripts/premake/samples.lua 2007-10-22 15:50:52 UTC (rev 1879)
@@ -178,6 +178,12 @@
sampleUsesConsole()
useComponent("base")
--useComponent("net")
+
+ makeSample("sampleNetMessage2","samples/net2/message2")
+ sampleUsesConsole()
+ useComponent("base")
+ --useComponent("net")
+
end
--------------------------------------
Modified: trunk/yake/yake/net2/async_send.h
===================================================================
--- trunk/yake/yake/net2/async_send.h 2007-09-25 21:29:30 UTC (rev 1878)
+++ trunk/yake/yake/net2/async_send.h 2007-10-22 15:50:52 UTC (rev 1879)
@@ -4,6 +4,7 @@
#include "types.h"
#include "packet.h"
#include "packet_connection.h"
+#include "serialization.h"
namespace yake {
namespace net {
@@ -22,13 +23,12 @@
MessageDecoder<>.
*/
template<class Mt, class Pt, class Ct, typename Handler>
- void async_send(Ct& conn, Pt pckt, const Mt& msg, Handler handler)
+ void async_send(Ct& conn, Pt pckt, const Mt& msg, Handler handler, ArchiveContext& ctx = ArchiveContext())
{
assert( pckt );
- BinaryOutArchive ar( pckt->payload(), Pt::value_type::nMaxPayloadSize );
- ar & const_cast<Mt&>(msg);
- pckt->setId(Mt::ID);
- pckt->setPayloadSize(ar.curr());
+
+ detail::serialize_to_packet( *pckt, msg, ctx );
+
conn.async_send( pckt, handler );
}
/** Serialize and send message asynchronously over the
@@ -42,14 +42,13 @@
MessageDecoder<>.
*/
template<class Mt, class Ct, typename Handler>
- void async_send(Ct& conn, const Mt& msg, Handler handler)
+ void async_send(Ct& conn, const Mt& msg, Handler handler, ArchiveContext& ctx = ArchiveContext())
{
typedef typename Ct::packet_type packet_type;
typename packet_type::pointer pckt(new packet_type());
- BinaryOutArchive ar( pckt->payload(), packet_type::nMaxPayloadSize );
- ar & const_cast<Mt&>(msg);
- pckt->setId(Mt::ID);
- pckt->setPayloadSize(ar.curr());
+
+ detail::serialize_to_packet( *pckt, msg, ctx );
+
conn.async_send( pckt, handler );
}
/** Serialize and send message asynchronously over the
@@ -60,14 +59,13 @@
MessageDecoder<>.
*/
template<class Mt, class Ct>
- void async_send(Ct& conn, const Mt& msg)
+ void async_send(Ct& conn, const Mt& msg, ArchiveContext& ctx = ArchiveContext())
{
typedef typename Ct::packet_type packet_type;
typename packet_type::pointer pckt(new packet_type());
- BinaryOutArchive ar( pckt->payload(), packet_type::nMaxPayloadSize );
- ar & const_cast<Mt&>(msg);
- pckt->setId(Mt::ID);
- pckt->setPayloadSize(ar.curr());
+
+ detail::serialize_to_packet( *pckt, msg, ctx );
+
conn.async_send( pckt );
}
Modified: trunk/yake/yake/net2/error.h
===================================================================
--- trunk/yake/yake/net2/error.h 2007-09-25 21:29:30 UTC (rev 1878)
+++ trunk/yake/yake/net2/error.h 2007-10-22 15:50:52 UTC (rev 1879)
@@ -35,7 +35,7 @@
}
operator bool() const
{
- return (code_ == ok);
+ return (code_ == ok); //@todo shouldn't this be exactly the other way around? if (e) ...error-handling...
}
bool operator == (const Code code) const
{
@@ -64,6 +64,11 @@
private:
Code code_;
};
+ inline std::ostream& operator << (std::ostream& out, const Error& rhs)
+ {
+ out << "net::error(" << rhs.code() << "=" << rhs.what() << ")";
+ return out;
+ }
} // namespace net
} // namespace yake
Modified: trunk/yake/yake/net2/message_decoder.h
===================================================================
--- trunk/yake/yake/net2/message_decoder.h 2007-09-25 21:29:30 UTC (rev 1878)
+++ trunk/yake/yake/net2/message_decoder.h 2007-10-22 15:50:52 UTC (rev 1879)
@@ -3,7 +3,7 @@
#include "types.h"
#include "packet_dispatcher.h"
-#include "simple_serialization.h"
+#include "serialization.h"
namespace yake {
namespace net {
@@ -28,7 +28,8 @@
Furthermore, the the message type 'Mt' needs to have a default constructor.
- see @IncomingMessageDecoderDispatcher::setHandler()
+ @todo Make MessageDecoder<> use ArchiveContext for optimized deserialization.
+ @see IncomingMessageDecoderDispatcher::setHandler()
*/
template<typename Mt, class PacketType = net::Packet<net::DefaultPacketTraits> >
struct MessageDecoder : MessageDecoderBase<PacketType>
@@ -49,12 +50,25 @@
std::cout << "decoding '" << typeid(message_type).name() << "'\n";
message_type msg; //in try block?
- try {
- net::BinaryInArchive ar( pckt.payload(), pckt.payloadSize() );
- ::yake::net::serialize(ar,msg);
+ try
+ {
+ namespace archive = boost::archive;
+ namespace io = boost::iostreams;
+ const int archive_flags = archive::no_header | archive::no_codecvt | archive::no_tracking;
+
+ io::stream<io::array_source> str( (const char*)pckt.payload(), pckt.payloadSize() );
+ boost::archive::binary_iarchive ar(str,archive_flags);
+
+ ar >> msg;
+
handler_( net::Error::ok, msg );
}
+ catch (boost::archive::archive_exception& ex)
+ {
+ std::cerr << "ser: FAILED to INIT ARCHIVE: " << ex.what() << "\n";
+ handler_( net::Error::failed_to_decode, msg );
+ }
catch (std::exception& ex)
{
std::cerr << "ser: FAILED to DECODE: " << ex.what() << "\n";
@@ -65,6 +79,7 @@
}
private:
boost::function<void(const net::Error&,const Mt&)> handler_;
+ //net::ArchiveContext ctx_;
};
/** (Helper) function to create & register a message decoder
Modified: trunk/yake/yake/net2/net.h
===================================================================
--- trunk/yake/yake/net2/net.h 2007-09-25 21:29:30 UTC (rev 1878)
+++ trunk/yake/yake/net2/net.h 2007-10-22 15:50:52 UTC (rev 1879)
@@ -8,10 +8,10 @@
#include "packet.h"
#include "packet_connection.h"
#include "packet_dispatcher.h"
-#include "simple_serialization.h"
#include "message_decoder.h"
#include "utils.h"
#include "server.h"
+#include "serialization.h"
#include "async_send.h"
#endif
Modified: trunk/yake/yake/net2/packet_connection.h
===================================================================
--- trunk/yake/yake/net2/packet_connection.h 2007-09-25 21:29:30 UTC (rev 1878)
+++ trunk/yake/yake/net2/packet_connection.h 2007-10-22 15:50:52 UTC (rev 1879)
@@ -48,12 +48,12 @@
public:
~TCPPacketConnection()
{
- //std::cout << "tcp:conn:~dtor()\n";
+ std::cout << "tcp:conn:~dtor()\n";
}
/**
- @note Call blocks until connection is dead (disconnection, failure, ...).
- You can run this function in a thread if you need a threaded connection object.
- @note Do not run this function more than once before it returns! (For example, in different threads!)
+ @note Call blocks until connection is dead (disconnection, failure, ...).
+ You can run this function in a thread if you need a threaded connection object.
+ @note Do not run this function more than once before it returns! (For example, in different threads!)
*/
void connect(const std::string& remoteIp, const uint16 remotePort,
ErrorHandler handler, PacketHandler packetHandler, const long timeoutSec = 5)
@@ -76,7 +76,9 @@
//io_.run();
}
- /** @note Do not call directly! */
+ /** @note Do not call directly!
+ @todo refactor out?
+ */
void startAsServerConnection(ErrorHandler handler, PacketHandler packetHandler)
{
assert( handler && "need a valid connection handler" );
@@ -97,6 +99,7 @@
start();
}
+ /** Synchronized: yes */
void async_send(packet_pointer pckt)
{
/*
@@ -105,29 +108,30 @@
*/
io_.post( boost::bind(&TCPPacketConnection::doSend,shared_from_this(),pckt) );
}
- //template<typename Handler>
- //void async_send(packet_pointer pckt, Handler handler)
+ /** Synchronized: yes */
void async_send(packet_pointer pckt, const boost::function<void(const Error&)>& handler)
{
io_.post( boost::bind(&TCPPacketConnection::doSend,shared_from_this(),pckt,handler) );
}
+ /** Synchronized: yes */
void async_send(packet_type* pckt)
{
this->async_send( packet_pointer(pckt) );
}
- //template<typename Handler>
- //void async_send(packet_type* pckt, Handler handler)
+ /** Synchronized: yes */
void async_send(packet_type* pckt, const boost::function<void(const Error&)>& handler)
{
this->async_send( packet_pointer(pckt), handler );
}
+ /** Synchronized: yes */
void stop()
{
io_.post( boost::bind(&TCPPacketConnection::doStop,shared_from_this(),Error::operation_aborted) );
}
- //protocol for TcpServer<> only:
+ /** Synchronized: no */
+ //internal protocol for TcpServer<> only:
socket_type& socket()
{
if (!socket_)
Modified: trunk/yake/yake/net2/simple_serialization.h
===================================================================
--- trunk/yake/yake/net2/simple_serialization.h 2007-09-25 21:29:30 UTC (rev 1878)
+++ trunk/yake/yake/net2/simple_serialization.h 2007-10-22 15:50:52 UTC (rev 1879)
@@ -1,207 +0,0 @@
-#ifndef NET_SIMPLE_SERIALIZATION_H
-#define NET_SIMPLE_SERIALIZATION_H
-
-#include <boost/static_assert.hpp>
-#include "types.h"
-
-namespace yake {
-namespace net {
-
- struct BinaryOutArchive
- {
- static const int saving = 1;
- BinaryOutArchive(uint8* data, size_t size) :
- data_(data), size_(size), curr_(0)
- {
- assert( data_ );
- assert( size_ > 0 );
- }
- void write(const void* data, const size_t size)
- {
- if (curr_ + size > size_)
- throw std::out_of_range("write() out of range");
- memcpy(data_ + curr_, data, size);
- curr_ += size;
- }
- void write(uint8 rhs)
- {
- write(&rhs,sizeof(rhs));
- }
- void write(uint16 rhs)
- {
- write(&rhs,sizeof(rhs));
- }
- void write(uint32 rhs)
- {
- write(&rhs,sizeof(rhs));
- }
- void write(uint64 rhs)
- {
- write(&rhs,sizeof(rhs));
- }
-
- template<typename T>
- BinaryOutArchive& operator & (T& rhs)
- {
- ::yake::net::serialize(*this,rhs);
- return *this;
- }
-
- size_t curr() const
- {
- return curr_;
- }
- private:
- uint8* data_;
- size_t size_;
-
- size_t curr_;
- };
- struct BinaryInArchive
- {
- static const int saving = 0;
- BinaryInArchive(const uint8* data, size_t size) :
- data_(data), size_(size), curr_(0)
- {
- assert( data_ );
- }
- void read(void* data, const size_t size)
- {
- if (curr_ + size > size_)
- throw std::out_of_range("read() out of range");
- memcpy(data, data_ + curr_, size);
- curr_ += size;
- }
- void read(uint8& rhs)
- {
- read(&rhs,sizeof(rhs));
- }
- void read(uint16& rhs)
- {
- read(&rhs,sizeof(rhs));
- }
- void read(uint32& rhs)
- {
- read(&rhs,sizeof(rhs));
- }
- void read(uint64& rhs)
- {
- read(&rhs,sizeof(rhs));
- }
-
- template<typename T>
- BinaryInArchive& operator & (T& rhs)
- {
- ::yake::net::serialize(*this,rhs);
- return *this;
- }
- private:
- const uint8* data_;
- size_t size_;
-
- size_t curr_;
- };
-
- template<int n>
- struct Int2Type
- {
- static const int value = n;
- };
-
- template<class Ar, typename T>
- void serialize(Ar& ar, T& rhs)
- {
- do_serialize(ar,rhs,Int2Type<Ar::saving>());
- }
- template<class Ar, typename T>
- inline void do_serialize(Ar& ar, T& rhs, Int2Type<0>)
- {
- ar >> rhs;
- }
- template<class Ar, typename T>
- inline void do_serialize(Ar& ar, T& rhs, Int2Type<1>)
- {
- ar << rhs;
- }
-
- ///////////////////////////////////////////////////////////////////////////
- template<class Ar>
- Ar& operator << (Ar& ar, int rhs)
- {
- ar.write(&rhs,sizeof(int));
- return ar;
- }
- template<class Ar>
- Ar& operator >> (Ar& ar, int& rhs)
- {
- ar.read(&rhs,sizeof(int));
- return ar;
- }
- template<class Ar>
- Ar& operator << (Ar& ar, const std::string& rhs)
- {
- BOOST_STATIC_ASSERT( sizeof(size_t) == sizeof(uint32) );
- ar.write( uint32(rhs.size()) );
- ar.write( rhs.c_str(), rhs.size() );
- return ar;
- }
- template<class Ar>
- Ar& operator >> (Ar& ar, std::string& rhs)
- {
- rhs.clear();
- uint32 size = 0;
- ar.read(size);
- rhs.resize(size);
- ar.read((void*)rhs.data(),size);
- return ar;
- }
- template<class Ar, class _Ty, class _Ax>
- Ar& operator << (Ar& ar, const std::vector<_Ty,_Ax>& rhs)
- {
- typedef std::vector<_Ty,_Ax> ctr_type;
- BOOST_STATIC_ASSERT( sizeof(size_t) == sizeof(uint32) );
- ar.write( uint32(rhs.size()) );
- for (size_t i=0;i<rhs.size(); ++i)
- ar & rhs.at(i);
- return ar;
- }
- template<class Ar, class _Ty, class _Ax>
- Ar& operator >> (Ar& ar, std::vector<_Ty,_Ax>& rhs)
- {
- rhs.clear();
- uint32 size = 0;
- ar.read(size);
- rhs.resize(size);
- for (size_t i=0; i<size; ++i)
- ar & rhs.at(i);
- return ar;
- }
- // Enable for improved performance for containers with integral types.
- // Available: vector<int,...>
-#if 0
- template<class Ar, class _Ax>
- Ar& operator << (Ar& ar, const std::vector<int,_Ax>& rhs)
- {
- std::cout << "boosted\n";
- typedef std::vector<int,_Ax> ctr_type;
- BOOST_STATIC_ASSERT( sizeof(size_t) == sizeof(uint32) );
- ar.write( uint32(rhs.size()) );
- ar.write( &rhs[0], sizeof(int)*rhs.size() );
- return ar;
- }
- template<class Ar, class _Ax>
- Ar& operator >> (Ar& ar, std::vector<int,_Ax>& rhs)
- {
- rhs.clear();
- uint32 size = 0;
- ar.read(size);
- rhs.resize(size);
- ar.read(&rhs[0],sizeof(int)*size);
- return ar;
- }
-#endif
-
-} // namespace net
-} // namespace yake
-
-#endif
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <psy...@us...> - 2007-11-12 21:59:42
|
Revision: 1888
http://yake.svn.sourceforge.net/yake/?rev=1888&view=rev
Author: psyclonist
Date: 2007-11-12 13:59:44 -0800 (Mon, 12 Nov 2007)
Log Message:
-----------
* fixed demos due to API and resource changes
* [bindings.lua] fixed dll export issues
* various other little fixes
Modified Paths:
--------------
trunk/yake/common/media/scripts/o_fsm_test.lua
trunk/yake/common/media/scripts/raf1.lua
trunk/yake/samples/ent/sampleEntFsm/demo.cpp
trunk/yake/samples/gui/console/yakeConsoleDemo.cpp
trunk/yake/samples/property/demo1/demo.cpp
trunk/yake/samples/property/lua1/demo.cpp
trunk/yake/samples/raf/demo1/yakeDemo.cpp
trunk/yake/samples/raf/lua1/demo.cpp
trunk/yake/samples/task/lua1/demo.cpp
trunk/yake/scripts/msvc80/yake.suo
trunk/yake/src/bindings.lua/detail/base.lua.cpp
trunk/yake/src/bindings.lua/detail/ent.listener.lua.cpp
trunk/yake/src/bindings.lua/detail/property.lua.cpp
trunk/yake/src/bindings.lua/detail/res.lua.cpp
trunk/yake/src/bindings.lua/detail/task.lua.cpp
trunk/yake/src/raf/yakeApplication.cpp
trunk/yake/yake/plugins/ceguiOgreRendererAdapter/pch.h
Added Paths:
-----------
trunk/yake/common/media/scripts/o_entity_fsm.lua
trunk/yake/samples/bin/debug/sampleGuiConsole.cfg
trunk/yake/samples/bin/debug/sampleRaf1.cfg
trunk/yake/samples/bin/debug/sampleRafLua1.cfg
Added: trunk/yake/common/media/scripts/o_entity_fsm.lua
===================================================================
--- trunk/yake/common/media/scripts/o_entity_fsm.lua (rev 0)
+++ trunk/yake/common/media/scripts/o_entity_fsm.lua 2007-11-12 21:59:44 UTC (rev 1888)
@@ -0,0 +1,25 @@
+function onTick()
+ print("entity.onTick()")
+end
+function main()
+ this.events.tick:connect( onTick )
+end
+
+state = {
+ alive = {
+ on_enter = function()
+ print("entity: state.alive.on_enter()")
+ end,
+ on_tick = function()
+ print("entity: state.alive.on_tick()")
+ end,
+ on_exit = function()
+ print("entity: state.alive.on_exit()")
+ end,
+ },
+ awakening = {
+ on_enter = function()
+ print("entity: state.awakening.on_enter()")
+ end
+ },
+}
Modified: trunk/yake/common/media/scripts/o_fsm_test.lua
===================================================================
--- trunk/yake/common/media/scripts/o_fsm_test.lua 2007-11-08 18:40:55 UTC (rev 1887)
+++ trunk/yake/common/media/scripts/o_fsm_test.lua 2007-11-12 21:59:44 UTC (rev 1888)
@@ -1,10 +1,48 @@
print("> Starting object script...");
+function startup()
+ --this:fsm("main"):connectTo("alive",fn) -- connects to 'enter', 'tick', 'exit'
+ --this:fsm("main"):connectToEnter("dead",fn) -- connects to 'enter' only
+ --this:fsm("main"):connect("alive", fnEnter, fnTick, fnExit)
+
+ this:events("spawn"):connect(
+ function()
+
+ end
+ )
+end
+properties = {}
+properties_mt = {}
+
+properties_mt.__index = function(t,k)
+ print("INDEX",t,k)
+ --for u,v in pairs(t) do print(u,v) end
+ --return events[k]
+ return this:properties():get(k):get()
+end
+properties_mt.__newindex = function(t,k,v)
+ print("NEWINDEX",t,"'"..tostring(k).."'",v)
+ --rawset(t,k,v)
+ --for u,v in pairs(t) do print(u,v) end
+ local exists = this:properties():get(k)
+ if exists then
+ print("EXISTS")
+ exists:set(v)
+ return true
+ end
+ this:properties():create(k,v)
+ return true
+end
+
+setmetatable(properties, properties_mt)
+
+properties.s = 1
+properties["s"] = 2
+print(properties["s"])
+
event = {
on_spawn = function()
print(" script event.on_spawn")
- --ent:postCmd("go to","jack's bar")
- --OR: ev:postCmd(ent,"go to","jack's bar")
- --ent:postCmd("die")
+ this:properties():create("ticks",0)
end,
on_tick = function()
print(" script event.on_tick")
@@ -14,6 +52,10 @@
end,
-- various:
onArrived = function() --triggered as a result of "go to"
+ end,
+ -- Trigger
+ on_toggle = function()
+ print("event.on_toggle")
end
}
fsm = {
@@ -30,28 +72,47 @@
}
}
state = {
- alive = {
+ off = {
on_enter = function()
- print(" script state.alive.on_enter")
+ print("state.off.enter()")
+
+ this:setCondition(function() return (this:property("ticks"):get() >= 1 and this:property("ticks"):get() <= 3) end)
+ this:events():get("onTriggered"):connect( function(a) print("TRIGGER:onTriggered:",a) end )
end,
on_tick = function()
- print(" script state.alive.on_tick")
+ local ticks = this:property("ticks")
+ if ticks then
+ ticks:set( ticks:get() + 1 )
+ end
+ print("state.off.tick()") --,ticks:get()
+ --
+ --if (state.off.ticks == 1) then
+ -- this:processFsmEvent("trigger")
+ --end
+ --
+ --this:events():get("onTriggered"):fire(42)
end,
on_exit = function()
- print(" script state.alive.on_exit")
+ print("state.off.exit()")
end
- },
- awakening = {
+ }
+ ,
+ on = {
on_enter = function()
- print(" script state.awakening.on_enter")
+ print("state.on.enter()")
end,
on_tick = function()
- print(" script state.awakening.on_tick")
+ local ticks = this:property("ticks")
+ if ticks then
+ ticks:set( ticks:get() + 1 )
+ end
+ print("state.on.tick()") --,ticks:get()
end,
on_exit = function()
- print(" script state.awakening.on_exit")
+ print("state.on.exit()")
end
- },
+ }
+ ,
dead = {
on_enter = function()
print(" script state.dead.on_enter")
@@ -63,13 +124,10 @@
print(" script state.dead.on_exit")
end
}
-
}
print("> Object script up.");
function main()
- print("main() calling charGoTo()")
- charGoTo("blah")
- print("main() resuming from charGoTo()")
+ print("main()")
end
Modified: trunk/yake/common/media/scripts/raf1.lua
===================================================================
--- trunk/yake/common/media/scripts/raf1.lua 2007-11-08 18:40:55 UTC (rev 1887)
+++ trunk/yake/common/media/scripts/raf1.lua 2007-11-12 21:59:44 UTC (rev 1888)
@@ -2,7 +2,6 @@
local defaultCam = scene.activeCamera
local actionMap = app.actionMap
local input = yake.input
-local objMgr = sim.objMgr
--------------------------------------
-- Configure graphics
@@ -37,12 +36,6 @@
cam:lookAt( yake.Point3(0,100,0) ) -- look at our ninja!
--------------------------------------
--- Create objects
---------------------------------------
-
-local ninja = objMgr:makeObject("Entity")
-
---------------------------------------
-- Configure input
--------------------------------------
Added: trunk/yake/samples/bin/debug/sampleGuiConsole.cfg
===================================================================
--- trunk/yake/samples/bin/debug/sampleGuiConsole.cfg (rev 0)
+++ trunk/yake/samples/bin/debug/sampleGuiConsole.cfg 2007-11-12 21:59:44 UTC (rev 1888)
@@ -0,0 +1,20 @@
+[resource.sources] # <- evaluated by RAF
+file=../../../common/media/scripts/ # <- do NOT forget trialing '/' !!
+file=../../../common/media/
+
+[raf.options]
+useCEGUI=yes
+
+#-----------------------------------
+[raf.startup.libraries]
+# Libraries to be loaded automatically at startup
+
+graphicsOgre
+inputOgreOIS
+
+#-----------------------------------
+[raf.startup.systems]
+# System to be created & initialized automatically
+
+graphics=ogre3d
+input=ois
Added: trunk/yake/samples/bin/debug/sampleRaf1.cfg
===================================================================
--- trunk/yake/samples/bin/debug/sampleRaf1.cfg (rev 0)
+++ trunk/yake/samples/bin/debug/sampleRaf1.cfg 2007-11-12 21:59:44 UTC (rev 1888)
@@ -0,0 +1,16 @@
+[resource.sources] # <- evaluated by RAF
+file=../../../common/media/scripts/ # <- do NOT forget trialing '/' !!
+
+#-----------------------------------
+[raf.startup.libraries]
+# Libraries to be loaded automatically at startup
+
+graphicsOgre
+inputOgreOIS
+
+#-----------------------------------
+[raf.startup.systems]
+# System to be created & initialized automatically
+
+graphics=ogre3d
+input=ois
Added: trunk/yake/samples/bin/debug/sampleRafLua1.cfg
===================================================================
--- trunk/yake/samples/bin/debug/sampleRafLua1.cfg (rev 0)
+++ trunk/yake/samples/bin/debug/sampleRafLua1.cfg 2007-11-12 21:59:44 UTC (rev 1888)
@@ -0,0 +1,18 @@
+[resource.sources] # <- evaluated by RAF
+file=../../../common/media/scripts/ # <- do NOT forget trialing '/' !!
+
+#-----------------------------------
+[raf.startup.libraries]
+# Libraries to be loaded automatically at startup
+
+graphicsOgre
+inputOgreOIS
+scriptingLua
+
+#-----------------------------------
+[raf.startup.systems]
+# System to be created & initialized automatically
+
+graphics=ogre3d
+input=ois
+scripting=lua
Modified: trunk/yake/samples/ent/sampleEntFsm/demo.cpp
===================================================================
--- trunk/yake/samples/ent/sampleEntFsm/demo.cpp 2007-11-08 18:40:55 UTC (rev 1887)
+++ trunk/yake/samples/ent/sampleEntFsm/demo.cpp 2007-11-12 21:59:44 UTC (rev 1888)
@@ -6,212 +6,57 @@
#include "yake/plugins/scriptingLua/ScriptingSystemLua.h"
#include "yake/bindings.lua/bindings.lua.h"
#include "yake/bindings.lua/bindings.lua.ent.h"
+#include "yake/bindings.lua/bindings.lua.ent.registry.h"
#include "yake/res/res.h"
-using namespace yake;
+namespace yake {
namespace exapp {
- // Commonly used states for this application's objects.
- const std::string ksAwakening = "awakening";
- const std::string ksAlive = "alive";
- const std::string ksDead = "dead";
-
- /** Listens to object manager and initializes newly created objects by adding
- a Lua VM, adding default states and transitions to the state machine etc.
- */
- struct ExampleAppObjectMgrListener : public ent::ObjectManagerListener
- {
- ExampleAppObjectMgrListener(scripting::IScriptingSystem& scriptingSys) : scriptingSys_(scriptingSys)
- {}
- virtual void onObjectCreated(ent::Object* obj)
- {
- YAKE_LOG( "exappOML", "onObjectCreated: class is '" + obj->isA()->name() + "'" );
-
- scripting::VMPtr vm = scriptingSys_.createVM();
- YAKE_ASSERT( vm );
- bind_all( vm.get() );
-
- ent::Entity* ent = ent::Entity::cast(obj);
- YAKE_ASSERT( ent );
- ent->attachVM(vm,"main");
-
- if (ent::Trigger::cast(ent))
- luabind::globals( static_cast<scripting::LuaVM*>(vm.get())->getLuaState() )["this"] = ent::Trigger::cast(ent);
- else
- luabind::globals( static_cast<scripting::LuaVM*>(vm.get())->getLuaState() )["this"] = ent;
- }
- virtual void onDestroyObject(ent::Object* obj)
- {
- ent::Entity* ent = ent::Entity::cast(obj);
- YAKE_ASSERT( ent );
-
- scripting::VMPtr vm = ent->detachVM("main");
- YAKE_ASSERT( vm );
- // vm will destruct when scope is left.
- }
- virtual void onObjectInitialized(ent::Object* obj)
- {
- ent::Entity* ent = ent::Entity::cast(obj);
- YAKE_ASSERT( ent );
-
- ent->processFsmEvent("spawn");
- }
- private:
- scripting::IScriptingSystem& scriptingSys_;
- };
-
- struct SimpleGraphicsCo : public ent::Component
- {
- DECL_CO(SimpleGraphicsCo,"SimpleGraphicsCo")
- };
- IMPL_CO_1(SimpleGraphicsCo,"Component")
+ const yake::String ksAwakening = "awakening";
+ const yake::String ksAlive = "alive";
+ const yake::String ksDead = "dead";
} // namespace exapp
+} // namespace yake
-#ifdef OOSTATE
-struct oostate
-{
- virtual ~oostate() {}
- virtual void onEnter() {}
- virtual void onExit() {}
-};
-template<typename _state_class_type /*= oostate */, typename _event_type>
-struct oomachine
-{
- typedef _event_type event_type;
- typedef _state_class_type* state_type;
- oomachine() :
- fnEnter_( boost::bind(&oomachine::onEnter,this,_1,_2) ),
- fnExit_( boost::bind(&oomachine::onExit,this,_1,_2) )
- {
- }
-
- void addState(const state_type);
- void addTransition(const state_type, const event_type&, const state_type);
- void setState(const state_type);
- void processEvent(const event_type& evt);
- const state_type& getCurrentFsmState() const
- { return m_.current(); }
-private:
- typedef fsm::machine<state_type,event_type> machine_type;
- void onEnter(machine_type&,const state_type&);
- void onExit(machine_type&,const state_type&);
-private:
- machine_type machine_;
- typedef boost::function<void(machine_type&,const state_type&)> CbFn;
- CbFn fnEnter_;
- CbFn fnExit_;
-};
-template<typename _state_class_type, typename _event_type>
-void oomachine<_state_class_type,_event_type>::onEnter(machine_type&,const state_type& state)
-{
- YAKE_ASSERT( state );
- state->onEnter();
-}
-template<typename _state_class_type, typename _event_type>
-void oomachine<_state_class_type,_event_type>::onExit(machine_type&,const state_type& state)
-{
- YAKE_ASSERT( state );
- state->onExit();
-}
-template<typename _state_class_type, typename _event_type>
-void oomachine<_state_class_type,_event_type>::addState(const state_type s)
-{
- machine_.addState(s);
-}
-template<typename _state_class_type, typename _event_type>
-void oomachine<_state_class_type,_event_type>::addTransition(const state_type from, const event_type& ev, const state_type to)
-{
- machine_.addTransition( from, ev, to );
-}
-template<typename _state_class_type, typename _event_type>
-void oomachine<_state_class_type,_event_type>::setState(const state_type s)
-{
- machine_.setState( s );
-}
-template<typename _state_class_type, typename _event_type>
-void oomachine<_state_class_type,_event_type>::processEvent(const event_type& evt)
-{
- YAKE_ASSERT( !fnEnter_.empty() );
- machine_.processEventCb(evt, fnEnter_, fnExit_);
-}
-struct test_state_base
-{
- virtual ~test_state_base() {}
- virtual void onEnter() {}
- virtual void onExit() {}
-};
-typedef test_state_base* test_state_base_ptr;
-namespace fsm {
- template<>
- inline const test_state_base_ptr& get_null_state()
- {
- static test_state_base* ms_null = 0;
- return ms_null;
- }
-}
-struct test_state : public test_state_base
-{
- test_state(const std::string& name) : name_(name)
- {}
- virtual void onEnter()
- {
- std::cout << name_ << ".onEnter()\n";
- }
- virtual void onExit()
- {
- std::cout << name_ << ".onExit()\n";
- }
-private:
- std::string name_;
-};
-void test()
-{
- typedef oomachine<test_state_base,std::string> machine_t;
- test_state_base* first = new test_state("first");
- test_state_base* second = new test_state("second");
-
- machine_t machine;
- machine.addState( first );
- machine.addState( second );
- machine.setState( first );
- machine.addTransition( first, "go", second );
- machine.processEvent("go");
-}
-#endif
int main(int argc, char* argv[])
{
+ using namespace yake;
try
{
// create and attach log listeners
typedef SharedPtr<logging::log_listener> log_listener_ptr;
- log_listener_ptr toStdErr( new yake::logging::stderr_listener() );
+ log_listener_ptr toStdErr( new logging::stderr_listener() );
logging::addListener( toStdErr.get() );
// Setup resources
res::SourceFactory::global().reg<res::FileSource>("file");
- res::SourceManager::global().addSource("file","../../common/media/scripts/");
+ res::SourceManager::global().addSource("file","../../../common/media/scripts/");
// Create the scripting system we want to use (Lua).
SharedPtr<scripting::IScriptingSystem> luaSys = templates::create<scripting::IScriptingSystem>("lua");
YAKE_ASSERT( luaSys.get() );
+ typedef void(*FreeBinderFn)(scripting::IVM*);
+ luaSys->addDefaultBinder( (FreeBinderFn)&bind_all );
// Create an object manager which manages creation, initialization and destruction of objects.
ent::ObjectManager objMgr;
// Create & attach the listener which handles the connection to the Lua VM and the bindings.
- ent::LuaObjectManagerListener luaFmsObjListener(*luaSys);
+ ent::LuaObjectManagerListener luaFmsObjListener(*luaSys,"main");
objMgr.attachListener( &luaFmsObjListener, "luaFsm", ent::ObjectManager::kKeepOwnership );
- // Example listener which sets the objects up for our example application :)
- // The listener adds default states and transitions to the object's state machine, for example.
- SharedPtr<exapp::ExampleAppObjectMgrListener> exappObjInitializer( new exapp::ExampleAppObjectMgrListener(*luaSys) );
- objMgr.attachListener( exappObjInitializer.get(), "exapp_listener", ent::ObjectManager::kKeepOwnership );
+ // bind 'this binders' for Lua
+ ent::registerClass<ent::Object>();
+ ent::registerClass<ent::Entity>();
+ ent::registerClass<ent::Trigger>();
// Register object class(es)
- ent::RegistrationResult ret = objMgr.registerClass<ent::Entity>("Entity");
+ ent::ObjectCreationParameters params;
+ params.set("lua.startup",(MakeStringVector() << "o_entity_fsm.lua").get());
+ ent::RegistrationResult ret = objMgr.registerClass<ent::Entity>("Entity",params);
YAKE_ASSERT( ret.first == object::RC_OK );
- ret = objMgr.registerClass<ent::Trigger>("Trigger");
+ ret = objMgr.registerClass<ent::Trigger>("Trigger",params);
YAKE_ASSERT( ret.first == object::RC_OK );
// Create trigger
@@ -224,7 +69,7 @@
objMgr.tick();
// Let's create an object.
- if (false)
+ if (true)
{
//ent::Object* o = objMgr.makeObject(ret.second); // create by ClassId
ent::Object* o = objMgr.makeObject("Entity"); // create by class name
@@ -284,7 +129,6 @@
// clean up
objMgr.destroyAllObjects(); // <- may trigger Lua callbacks.
- exappObjInitializer.reset();
luaSys.reset();
}
catch (yake::Exception& ex)
Modified: trunk/yake/samples/gui/console/yakeConsoleDemo.cpp
===================================================================
--- trunk/yake/samples/gui/console/yakeConsoleDemo.cpp 2007-11-08 18:40:55 UTC (rev 1887)
+++ trunk/yake/samples/gui/console/yakeConsoleDemo.cpp 2007-11-12 21:59:44 UTC (rev 1888)
@@ -45,7 +45,8 @@
#include <yake/graphics/yakeGraphicsSystem.h>
#include <yake/data/yakeData.h>
-#include <samples/common/exapp/yakeExampleApplication.h>
+#include "yake/raf/yakeRaf.h"
+
#include <yake/common/yakeCEGUIRendererAdapter.h>
#include <yake/common/yakeCEGUIHelpers.h>
#include <yake/model/model.h>
@@ -85,11 +86,9 @@
/** Application class.
* Based on ExampleApplication which is often used in demos here.
*/
-class TheApp : public yake::exapp::ExampleApplication
+class TheMainState : public raf::RtMainState
{
- YAKE_DECLARE_CLASS( TheApp );
private:
-
/// Finally declare our console type
typedef yake::gui::Console< Msg,
yake::gui::CEGUIInputArea,
@@ -116,6 +115,8 @@
YAKE_BUILD_PHOENIX_SINGLETON( ConsoleHolder );
};
+ raf::Application& mApp;
+
/// Viewport/Camera pairs
Vector< std::pair<IViewport*,ICamera*> > mVPs;
/// Graphical world
@@ -133,50 +134,18 @@
LuaConsole& mConsole;
public:
- TheApp( ) :
- ExampleApplication( true /*graphics*/,
- false /*physics*/,
- true /*scripting*/,
- true /*input*/,
- false /*script bindings*/,
- false /*audio*/),
+ TheMainState(raf::Application& owner) :
+ raf::RtMainState(owner),
+ mApp(owner),
mGuiRendererAdapter( NULL ),
mConsole( ConsoleHolder::instance().getConsole() ),
mEditBox( 0 ),
mListBox( 0 )
- {}
-
- /**
- * Load CEGUI renderer adapter plugin.
- * @param file Plugin library file name
- * @return Plugin handle
- */
- ceguiadapter::RendererAdapterPlugin* loadPlugin( const String& file )
{
- yake::base::Library* pDynLib = new yake::base::Library( file );
- YAKE_ASSERT( pDynLib ).debug( "Out of memory" );
-
- YAKE_LOG("demo","Loading plugin " + file );
-
- yake::base::YakeDynLibStartPluginFn pfnStartPlugin = (yake::base::YakeDynLibStartPluginFn)pDynLib->getSymbol( "dynlibStartPlugin" );
- YAKE_ASSERT( pfnStartPlugin ).debug( "Cannot find export in dynamic library" );
-
- ceguiadapter::RendererAdapterPlugin* pPlugin = static_cast<ceguiadapter::RendererAdapterPlugin*>(pfnStartPlugin());
- YAKE_ASSERT( pPlugin ).debug( "Plugin startup function failed" );
-
- //
- bool bRet = pPlugin->initialise();
- YAKE_ASSERT( bRet ).debug( "Plugin initialization failed" );
-
- if (!bRet)
- {
- delete pPlugin;
- return 0;
- }
-
- return pPlugin;
+ enableInstantQuitByKey( input::KC_ESCAPE );
}
+#if 0
/**
* Keyboard key pressed event handler.
* Implements console key combinations processing. Feeds events to CEGUI.
@@ -263,35 +232,9 @@
CEGUI::System::getSingleton().injectMouseMove( rDelta.x*scale, rDelta.y*scale );
}
}
+#endif
/**
- * Create camera and viewport.
- * Camera is attached to viewport. Camera/Viewport pair is saved in mVPs map.
- * Origin is in top-left corner.
- * @param sx Starting x position of viewport in relative units [0..1]
- * @param sy Starting y position of viewport in relative units [0..1]
- * @param w Viewport width in relative units [0..1]
- * @param h Viewport height in relative units [0..1]
- * @param z Z-order of viewport
- * @return Index of creaed camera/viewport pair in mVPs map
- */
- int createCameraViewportPair( real sx, real sy, real w, real h, int z )
- {
- ICamera* pC = mGWorld->createCamera();
- YAKE_ASSERT( pC );
- pC->setNearClipDistance( 1. );
-
- pC->setFarClipDistance( 2000 );
-
- mVPs.push_back( std::pair<IViewport*,ICamera*>(mGWorld->createViewport( pC ), pC) );
- size_t idx = mVPs.size()-1;
- YAKE_ASSERT( mVPs[idx].first );
- mVPs[idx].first->setDimensions( sx, sy, w, h );
- mVPs[idx].first->setZ( z );
- return static_cast<int>(idx);
- }
-
- /**
* Helper method to add console message.
* Used from scripts.
* @param msg Message to add.
@@ -315,7 +258,7 @@
if (mListBox)
mConsole.setOutputWidget( mListBox );
- yake::scripting::VMPtr vm = getScriptingSystem().createVM();
+ yake::scripting::VMPtr vm = mApp.getScriptingSystem()->createVM();
YAKE_ASSERT( vm );
mConsole.setScriptingVirtualMachine( vm );
@@ -329,13 +272,13 @@
using namespace luabind;
module( pL->getLuaState() )
- [
- class_<TheApp>( "app" )
- .scope
- [
- def( "addConsoleMessage", &TheApp::addConsoleMessage )
- ]
- ];
+ [
+ class_<TheMainState>( "app" )
+ .scope
+ [
+ def( "addConsoleMessage", &TheMainState::addConsoleMessage )
+ ]
+ ];
}
catch (luabind::error& e)
{
@@ -347,7 +290,7 @@
// executing console initialisation script
//pL->execute( "dofile( '../../../media/gui.addons.scripts/console_redirect.lua' );" );
- scripting::ScriptPtr script( getScriptingSystem().createScriptFromFile("../../../common/media/gui.addons.scripts/console_redirect.lua"));
+ scripting::ScriptPtr script( mApp.getScriptingSystem()->createScriptFromFile("gui.addons.scripts/console_redirect.lua"));
pL->execute( script );
}
@@ -357,134 +300,83 @@
*/
void initGui()
{
- //mGuiRendererAdapter = loadPlugin( "CEGUIOgreAdapter" );
- mGuiRendererAdapter = loadPlugin( YAKE_DYNLIB_NAME("ceguiOgreRendererAdapter") );
- YAKE_ASSERT( mGuiRendererAdapter );
-
- YAKE_LOG("demo", "Starting adapter version " + mGuiRendererAdapter->getName() );
- YAKE_LOG("demo", "Initialising CEGUI..." );
-
+#if 1
try
{
- CEGUI::System* ceguiSys = new CEGUI::System( mGuiRendererAdapter->getRenderer() );
- ceguiSys = 0; // we don't use sys pointer but want to avoid unused variable warning
+ CEGUI::WindowManager& winMgr = CEGUI::WindowManager::getSingleton();
- using namespace CEGUI;
-
- YAKE_LOG("demo", "Setting CEGUI logging level..." );
-
- Logger::getSingleton().setLoggingLevel( Informative );
-
- YAKE_LOG("demo", "Loading scheme..." );
-
- SchemeManager::getSingleton().loadScheme("VanillaSkin.scheme");
- System::getSingleton().setDefaultMouseCursor("Vanilla-Images","MouseArrow");
- FontManager::getSingleton().createFont("Iconified-12.font");
- WindowManager& winMgr = WindowManager::getSingleton();
-
- Window* background = winMgr.createWindow("Vanilla/StaticImage");
+ /*
+ CEGUI::Window* background = winMgr.createWindow("Vanilla/StaticImage");
background->setArea(URect(cegui_reldim(0), cegui_reldim(0), cegui_reldim(1), cegui_reldim(1)));
background->setProperty("FrameEnabled", "false");
background->setProperty("BackgroundEnabled", "false");
//@todo background->setProperty("Image", "set:BackgroundImage image:full_image");
- System::getSingleton().setGUISheet(background);
- background->addChildWindow(winMgr.loadWindowLayout("VanillaConsole.layout"));
+ CEGUI::System::getSingleton().setGUISheet(background);
+ */
+ CEGUI::Window* consoleWindow = winMgr.loadWindowLayout("VanillaConsole.layout");
+ CEGUI::System::getSingleton().setGUISheet( consoleWindow );
+
+ /*
+ background->addChildWindow(consoleWindow);
background->activate();
+ */
#if 1
- mEditBox = static_cast<CEGUI::Editbox*>(CEGUI::WindowManager::getSingleton().getWindow("/Console/Wnd/Edit"));
- mListBox = static_cast<CEGUI::Listbox*>(CEGUI::WindowManager::getSingleton().getWindow("/Console/Wnd/History"));
+ if (winMgr.isWindowPresent("/Console/Wnd/Edit"))
+ mEditBox = static_cast<CEGUI::Editbox*>(winMgr.getWindow("/Console/Wnd/Edit"));
+ if (winMgr.isWindowPresent("/Console/Wnd/History"))
+ mListBox = static_cast<CEGUI::Listbox*>(winMgr.getWindow("/Console/Wnd/History"));
#endif
}
// catch to prevent exit (errors will be logged).
catch( CEGUI::Exception& e)
{
+ YAKE_LOG_ERROR( "demo", yake::String( "CEGUI Exception: " ) + e.getMessage().c_str() );
YAKE_EXCEPT( yake::String( "CEGUI Exception: " ) + e.getMessage().c_str() );
}
-
+#endif
setupConsole();
}
-
- /**
- * Cleanup GUI resources.
- * Executed on app shutdown.
- */
- void cleanupGui()
+private:
+ virtual void onEnter()
{
- if ( CEGUI::System::getSingletonPtr() )
- delete CEGUI::System::getSingletonPtr();
- if (mGuiRendererAdapter)
- mGuiRendererAdapter->shutdown();
- //YAKE_SAFE_DELETE( mGuiRendererAdapter ); // do NOT delete, the plugin is in the list of plugins ExampleApplication holds and will be destroyed later.
- }
+ mApp.enableInputForCEGUI();
- /**
- * Setup input events.
- * Subscribe to input subsystem signals.
- */
- void setupInputEvents()
- {
- mKeyboardEventGenerator.subscribeToKeyDown( Bind1( &TheApp::onKeyDown, this ) );
- mKeyboardEventGenerator.subscribeToKeyUp( Bind1( &TheApp::onKeyUp, this ) );
- mMouseEventGenerator.subscribeToMouseButtonDown( Bind1( &TheApp::onMBDown, this ) );
- mMouseEventGenerator.subscribeToMouseButtonUp( Bind1( &TheApp::onMBUp, this ) );
- mMouseEventGenerator.subscribeToMouseMoved( Bind1( &TheApp::onMouseMoved, this ) );
+ this->getGraphicalWorld();
+ // initialise gui
+ initGui();
}
-
- /**
- * Setup graphics.
- * Sets up graphical world and cameras/viewports.
- */
- void setupGraphics()
+ virtual void onExit()
{
- mGWorld = getGraphicsSystem().createWorld();
- YAKE_ASSERT( mGWorld );
-
- createCameraViewportPair( 0.0, 0.0, 1, 1, 10 );
+ // Shutting down
+ mGWorld.reset();
}
/**
* Run the application main cycle.
* Performs initialisation, then enters main program loop.
*/
- virtual void run()
+ virtual void onFrame(const real timeElapsed)
{
- // setup event input generators
- setupInputEvents();
-
- // graphics
- setupGraphics();
-
- // initialise gui
- initGui();
-
- // main loop
- real lastTime = native::getTime();
- while (!shutdownRequested())
- {
- // timing
- real time = native::getTime();
- real timeElapsed = time - lastTime;
- lastTime = time;
-
- // handle input
- getInputSystem().update();
- mMouseEventGenerator.update();
- mKeyboardEventGenerator.update();
-
- // render the scene
- if (!shutdownRequested())
- mGWorld->render( timeElapsed );
- }
-
- // Shutting down
- cleanupGui();
- mGWorld.reset();
}
};
+/** The mighty application itself! */
+class TheApp : public raf::ExampleApplication<>
+{
+public:
+ TheApp()
+ {
+ getConfiguration().get().load("sampleGuiConsole.cfg");
+ }
+private:
+ virtual raf::MainState* createMainState()
+ {
+ return new TheMainState(*this);
+ }
+};
/**
* Main program entry point.
@@ -496,15 +388,16 @@
{
try
{
- TheApp theApp;
- theApp.initialise();
- theApp.run();
+ // create and attach log listeners
+ typedef SharedPtr<logging::log_listener> log_listener_ptr;
+ log_listener_ptr toStdErr( new yake::logging::stderr_listener() );
+ logging::addListener( toStdErr.get() );
+
+ // Use default executor for convenience.
+ // It's always possible to manually execute TheApp::initialise() etc.
+ TheApp app;
+ return (raf::runApplication( app )) ? 0 : 1;
}
- catch ( yake::Exception& rException )
- {
- YAKE_LOG_ERROR( "demo", rException.what() );
- std::cin.get();
- }
catch ( ... )
{
YAKE_LOG_ERROR( "demo", "Caught unhandled exception." );
Modified: trunk/yake/samples/property/demo1/demo.cpp
===================================================================
--- trunk/yake/samples/property/demo1/demo.cpp 2007-11-08 18:40:55 UTC (rev 1887)
+++ trunk/yake/samples/property/demo1/demo.cpp 2007-11-12 21:59:44 UTC (rev 1888)
@@ -88,9 +88,9 @@
ASSERT_EXCEPTION(props.add("a",makeValueProperty<int>(33)),AlreadyExistsException);
ASSERT_EXCEPTION(props.get("noname"),NotFoundException);
std::cout << "'a' : " << props.get("a") << "\n";
- try_cast_set<int>(props.get("a"),44);
+ try_set<int>(props.get("a"),44);
try_cast<int>(props.get("a")).set(55);
- ASSERT_EXCEPTION( try_cast_set<String>(props.get("a"),"66"), BadCastException );
+ ASSERT_EXCEPTION( try_set<String>(props.get("a"),"66"), BadCastException );
std::cout << props << "\n";
}
}
Modified: trunk/yake/samples/property/lua1/demo.cpp
===================================================================
--- trunk/yake/samples/property/lua1/demo.cpp 2007-11-08 18:40:55 UTC (rev 1887)
+++ trunk/yake/samples/property/lua1/demo.cpp 2007-11-12 21:59:44 UTC (rev 1888)
@@ -16,7 +16,7 @@
// Setup resources
res::SourceFactory::global().reg<res::FileSource>("file");
- res::SourceManager::global().addSource("file","../../common/media/samples/");
+ res::SourceManager::global().addSource("file","../../../common/media/samples/");
// init scripting VM
typedef scripting::ScriptingSystemLua scripting_t;
Modified: trunk/yake/samples/raf/demo1/yakeDemo.cpp
===================================================================
--- trunk/yake/samples/raf/demo1/yakeDemo.cpp 2007-11-08 18:40:55 UTC (rev 1887)
+++ trunk/yake/samples/raf/demo1/yakeDemo.cpp 2007-11-12 21:59:44 UTC (rev 1888)
@@ -5,24 +5,6 @@
using namespace yake;
-/** Configuration of the application */
-struct TheConfiguration : public raf::ApplicationConfiguration
-{
- // Use "inputOgre" for Ogre 1.2/1.3, "inputOgreOIS" for Ogre 1.4+.
- virtual StringVector getLibraries()
- { return MakeStringVector() << YAKE_LIB("scriptingLua") << YAKE_LIB("graphicsOgre") << YAKE_LIB("inputOgreOIS"); }
-
- // Use "ogre" for Ogre 1.2/1.3, "ois" for Ogre 1.4+.
- virtual StringVector getInputSystems()
- { return MakeStringVector() << "ois"; }
-
- virtual StringVector getScriptingSystems()
- { return MakeStringVector() << "lua"; }
-
- virtual StringVector getGraphicsSystems()
- { return MakeStringVector() << "ogre3d"; }
-};
-
/** Main application state */
class TheMainState : public raf::RtMainState
{
@@ -47,8 +29,8 @@
// position camera and look at the ninja
getDefaultCamera()->setFixedYawAxis(Vector3::kUnitY);
- getDefaultCamera()->setPosition(Vector3(100,20,-400));
- getDefaultCamera()->lookAt(Vector3(0,100,0));
+ getDefaultCamera()->setPosition(Point3(100,20,-400));
+ getDefaultCamera()->lookAt(Point3(0,100,0));
}
virtual void onFrame(const real timeElapsed)
{
@@ -56,10 +38,13 @@
};
/** The mighty application itself! */
-class TheApp : public raf::ExampleApplication<TheConfiguration>
+class TheApp : public raf::ExampleApplication<>
{
public:
- TheApp() {}
+ TheApp()
+ {
+ getConfiguration().get().load("sampleRaf1.cfg");
+ }
protected:
virtual raf::MainState* createMainState()
{
@@ -71,6 +56,7 @@
{
// Use default executor for convenience.
// It's always possible to manually execute TheApp::initialise() etc.
- return (raf::runApplication( TheApp() )) ? 0 : 1;
+ TheApp app;
+ return (raf::runApplication( app )) ? 0 : 1;
}
Modified: trunk/yake/samples/raf/lua1/demo.cpp
===================================================================
--- trunk/yake/samples/raf/lua1/demo.cpp 2007-11-08 18:40:55 UTC (rev 1887)
+++ trunk/yake/samples/raf/lua1/demo.cpp 2007-11-12 21:59:44 UTC (rev 1888)
@@ -60,7 +60,7 @@
}
// Create ninja model, position camera and look at the ninja: All done in Lua script:
- scripting::ScriptPtr script = sys->createScriptFromFile("../../../common/media/scripts/raf1.lua");
+ scripting::ScriptPtr script = sys->createScriptFromFile("raf1.lua");
vm_->execute( script );
}
Modified: trunk/yake/samples/task/lua1/demo.cpp
===================================================================
--- trunk/yake/samples/task/lua1/demo.cpp 2007-11-08 18:40:55 UTC (rev 1887)
+++ trunk/yake/samples/task/lua1/demo.cpp 2007-11-12 21:59:44 UTC (rev 1888)
@@ -1,6 +1,7 @@
#include <yake/task/task.h>
#include <yake/plugins/scriptingLua/ScriptingSystemLua.h>
#include <yake/bindings.lua/bindings.lua.h>
+#include <yake/res/res.h>
#include <luabind/luabind.hpp>
@@ -9,6 +10,10 @@
using namespace yake;
try {
+ // Setup resources
+ res::SourceFactory::global().reg<res::FileSource>("file");
+ res::SourceManager::global().addSource("file","../../../common/media/samples/");
+
// init scripting VM
typedef scripting::ScriptingSystemLua scripting_t;
scripting_t scriptingSys;
@@ -28,8 +33,8 @@
luabind::globals(L)["sched"] = exec;
// run Lua script
- scripting::ScriptPtr setupScript( scriptingSys.createScriptFromFile("../../../common/media/samples/task/events.lua") );
- scripting::ScriptPtr demoScript( scriptingSys.createScriptFromFile("../../../common/media/samples/task/demo.lua") );
+ scripting::ScriptPtr setupScript( scriptingSys.createScriptFromFile("task/events.lua") );
+ scripting::ScriptPtr demoScript( scriptingSys.createScriptFromFile("task/demo.lua") );
vm->execute( setupScript );
vm->execute( demoScript );
Modified: trunk/yake/scripts/msvc80/yake.suo
===================================================================
(Binary files differ)
Modified: trunk/yake/src/bindings.lua/detail/base.lua.cpp
===================================================================
--- trunk/yake/src/bindings.lua/detail/base.lua.cpp 2007-11-08 18:40:55 UTC (rev 1887)
+++ trunk/yake/src/bindings.lua/detail/base.lua.cpp 2007-11-12 21:59:44 UTC (rev 1888)
@@ -40,6 +40,8 @@
#include <yake/bindings.lua/common/lua.helpers.h>
#include <yake/bindings.lua/common/vminfo.lua.h>
+#include <yake/bindings.lua/bindings.lua.h> // for API
+
#include <luabind/operator.hpp>
#include <luabind/adopt_policy.hpp>
Modified: trunk/yake/src/bindings.lua/detail/ent.listener.lua.cpp
===================================================================
--- trunk/yake/src/bindings.lua/detail/ent.listener.lua.cpp 2007-11-08 18:40:55 UTC (rev 1887)
+++ trunk/yake/src/bindings.lua/detail/ent.listener.lua.cpp 2007-11-12 21:59:44 UTC (rev 1888)
@@ -116,27 +116,47 @@
}
#endif
}
+ namespace detail {
+ void executeFsmStateHandler(scripting::VMPtr vm, const object_fsm::state_type& state, const std::string& handlerName)
+ {
+ YAKE_ASSERT( vm );
+ lua_State* L = static_cast<scripting::LuaVM*>(vm.get())->getLuaState();
+ luabind::object stateTbl = luabind::globals(L)["state"];
+ if (stateTbl && luabind::type(stateTbl) == LUA_TTABLE)
+ {
+ luabind::object currState = stateTbl[state];
+ if (currState && luabind::type(currState) == LUA_TTABLE)
+ {
+ luabind::object handler = currState[handlerName];
+ if (handler && luabind::type(handler) == LUA_TFUNCTION)
+ {
+ handler();
+ }
+ }
+ }
+ }
+ } // namespace detail
void LuaFsmObjectListener::onFsmEnterState(Object& obj,/*const std::string& fsmName, */const object_fsm&, const object_fsm::state_type& state)
{
-#if 0
+#if 1
Entity* ent = Entity::cast(&obj);
if (ent)
{
scripting::VMPtr vm = ent->getFsmVM();
YAKE_ASSERT( vm );
- detail::executeOfTable_2(*vm,"state",state,"on_enter");
+ detail::executeFsmStateHandler(vm, state, "on_enter");
}
#endif
}
void LuaFsmObjectListener::onFsmExitState(Object& obj,/*const std::string& fsmName, */const object_fsm&, const object_fsm::state_type& state)
{
-#if 0
+#if 1
Entity* ent = Entity::cast(&obj);
if (ent)
{
scripting::VMPtr vm = ent->getFsmVM();
YAKE_ASSERT( vm );
- detail::executeOfTable_2(*vm,"state",state,"on_exit");
+ detail::executeFsmStateHandler(vm, state, "on_exit");
}
#endif
}
Modified: trunk/yake/src/bindings.lua/detail/property.lua.cpp
===================================================================
--- trunk/yake/src/bindings.lua/detail/property.lua.cpp 2007-11-08 18:40:55 UTC (rev 1887)
+++ trunk/yake/src/bindings.lua/detail/property.lua.cpp 2007-11-12 21:59:44 UTC (rev 1888)
@@ -38,6 +38,7 @@
#include <yake/base/yake.h>
#include <yake/property/property.h>
+#include <yake/bindings.lua/bindings.lua.h> // for API
#include <yake/bindings.lua/detail/private.h>
#include <yake/bindings.lua/detail/property.lua.h>
Modified: trunk/yake/src/bindings.lua/detail/res.lua.cpp
===================================================================
--- trunk/yake/src/bindings.lua/detail/res.lua.cpp 2007-11-08 18:40:55 UTC (rev 1887)
+++ trunk/yake/src/bindings.lua/detail/res.lua.cpp 2007-11-12 21:59:44 UTC (rev 1888)
@@ -43,6 +43,8 @@
#include <yake/bindings.lua/detail/private.h>
+#include <yake/bindings.lua/bindings.lua.h> // for API
+
#include <luabind/discard_result_policy.hpp>
#include <luabind/iterator_policy.hpp>
#include <luabind/operator.hpp>
Modified: trunk/yake/src/bindings.lua/detail/task.lua.cpp
===================================================================
--- trunk/yake/src/bindings.lua/detail/task.lua.cpp 2007-11-08 18:40:55 UTC (rev 1887)
+++ trunk/yake/src/bindings.lua/detail/task.lua.cpp 2007-11-12 21:59:44 UTC (rev 1888)
@@ -50,6 +50,8 @@
//
#include <yake/base/templates/yakeSmartAssert.h>
+#include <yake/bindings.lua/bindings.lua.h> // for dll export to work
+
#include <yake/bindings.lua/detail/private.h>
#include <yake/bindings.lua/common/lua.helpers.h>
#include <yake/bindings.lua/common/vminfo.lua.h>
Modified: trunk/yake/src/raf/yakeApplication.cpp
===================================================================
--- trunk/yake/src/raf/yakeApplication.cpp 2007-11-08 18:40:55 UTC (rev 1887)
+++ trunk/yake/src/raf/yakeApplication.cpp 2007-11-12 21:59:44 UTC (rev 1888)
@@ -233,28 +233,22 @@
YAKE_LOG("raf", "Initialising CEGUI..." );
CEGUI::System* ceguiSys = new CEGUI::System( mCeguiRendererAdapter->getRenderer() );
- using namespace CEGUI;
YAKE_LOG( "raf", "Setting CEGUI logging level..." );
- Logger::getSingleton().setLoggingLevel( Informative );
+ CEGUI::Logger::getSingleton().setLoggingLevel( CEGUI::Informative );
try
{
YAKE_LOG( "raf", "Loading scheme..." );
// load scheme and set up defaults
- SchemeManager::getSingleton().loadScheme((utf8*)"TaharezLook.scheme");
- System::getSingleton().setDefaultMouseCursor((utf8*)"TaharezLook", (utf8*)"MouseArrow");
+ CEGUI::SchemeManager::getSingleton().loadScheme("VanillaSkin.scheme");
+ CEGUI::System::getSingleton().setDefaultMouseCursor("Vanilla-Images", "MouseArrow");
CEGUI::MouseCursor::getSingleton().setImage(CEGUI::System::getSingleton().getDefaultMouseCursor());
- System::getSingleton().setDefaultFont((utf8*)"Tahoma-12");
+ if (!CEGUI::FontManager::getSingleton().isFontPresent("Iconified-12"))
+ CEGUI::FontManager::getSingleton().createFont("Iconified-12.font");
+ CEGUI::System::getSingleton().setDefaultFont("Iconified-12");
- WindowManager& wmgr = WindowManager::getSingleton();
-
- //Window* sheet = wmgr.loadWindowLayout( "console.layout" );
- //System::getSingleton().setGUISheet(sheet);
-
- //CEGUI::Window* pEditBoxWnd = CEGUI::WindowManager::getSingleton().getWindow((CEGUI::utf8*)"/Console/Wnd/Edit");
- //mEditBox = static_cast<CEGUI::Editbox*>(CEGUI::WindowManager::getSingleton().getWindow("/Console/Wnd/Edit"));
- //mListBox = static_cast<CEGUI::Listbox*>(CEGUI::WindowManager::getSingleton().getWindow("/Console/Wnd/List"));
+ //WindowManager& wmgr = WindowManager::getSingleton();
}
// catch to prevent exit (errors will be logged).
catch( CEGUI::Exception& e)
Modified: trunk/yake/yake/plugins/ceguiOgreRendererAdapter/pch.h
===================================================================
--- trunk/yake/yake/plugins/ceguiOgreRendererAdapter/pch.h 2007-11-08 18:40:55 UTC (rev 1887)
+++ trunk/yake/yake/plugins/ceguiOgreRendererAdapter/pch.h 2007-11-12 21:59:44 UTC (rev 1888)
@@ -32,7 +32,5 @@
#include <yake/scripting/yakeScriptingSystem.h>
#include <yake/graphics/yakeGraphicsSystem.h>
-#include <samples/common/exapp/yakeExampleApplication.h>
-
#include "Ogre.h"
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <psy...@us...> - 2007-12-12 21:48:32
|
Revision: 1906
http://yake.svn.sourceforge.net/yake/?rev=1906&view=rev
Author: psyclonist
Date: 2007-12-12 13:48:34 -0800 (Wed, 12 Dec 2007)
Log Message:
-----------
merge 1890:HEAD branches/v0-7-0 trunk
Modified Paths:
--------------
trunk/yake/documentation/api/DoxySfile
trunk/yake/documentation/api/Doxyfile
trunk/yake/samples/audio/demo1/demo.cpp
trunk/yake/samples/bin/release/raf_common.cfg
trunk/yake/samples/cmdrmayhem/yakeDemo.cpp
trunk/yake/scripts/msvc80/yake.suo
trunk/yake/scripts/premake/plugins.lua
trunk/yake/scripts/premake/samples.lua
trunk/yake/src/base/native/win32/yakeTime.cpp
trunk/yake/src/bindings.lua/detail/property.lua.cpp
trunk/yake/src/plugins/audioOpenAL/yakeAudioWorldOpenAL.cpp
trunk/yake/yake/plugins/audioOpenAL/yakeAudioSystemOpenAL.h
Added Paths:
-----------
trunk/yake/common/media/graphics.materials/scripts/yake.material
trunk/yake/common/media/gui/imagesets/Imageset.xsd
trunk/yake/common/media/gui/imagesets/TaharezLook.imageset
trunk/yake/common/media/gui/imagesets/TaharezLook.tga
trunk/yake/common/media/gui/looknfeel/TaharezLook.looknfeel
trunk/yake/common/media/gui/schemes/GUIScheme.xsd
trunk/yake/common/media/gui/schemes/TaharezLookSkin.scheme
trunk/yake/common/media/gui/schemes/TaharezLookWidgetAliases.scheme
trunk/yake/samples/bin/debug/sampleCmdrMayhem.cfg
trunk/yake/samples/bin/release/commclient.cfg
trunk/yake/samples/bin/release/commserver.cfg
trunk/yake/samples/bin/release/roclient.cfg
trunk/yake/samples/bin/release/rodemo.cfg
trunk/yake/samples/bin/release/roserver.cfg
trunk/yake/samples/bin/release/sampleCmdrMayhem.cfg
trunk/yake/samples/bin/release/sampleGuiConsole.cfg
trunk/yake/samples/bin/release/sampleRaf1.cfg
trunk/yake/samples/bin/release/sampleRafLua1.cfg
trunk/yake/samples/bin/release/sampleRafLua2.cfg
trunk/yake/samples/bin/release/sampleVehicle.cfg
Copied: trunk/yake/common/media/graphics.materials/scripts/yake.material (from rev 1905, branches/v0-7-0/yake/common/media/graphics.materials/scripts/yake.material)
===================================================================
--- trunk/yake/common/media/graphics.materials/scripts/yake.material (rev 0)
+++ trunk/yake/common/media/graphics.materials/scripts/yake.material 2007-12-12 21:48:34 UTC (rev 1906)
@@ -0,0 +1,44 @@
+material blue_translucent
+{
+ receive_shadows off
+ technique
+ {
+ pass
+ {
+ //lighting off
+
+ // alpha=opacity (1.=opaque,0=transparent)
+ diffuse .2 .2 1 0.6
+ ambient 1 1 1
+ //specular 1 1 1
+ depth_write off
+ //depth_check off
+
+ //scene_blend modulate
+ scene_blend alpha_blend
+ //scene_blend modulate
+ }
+ }
+}
+material red_translucent
+{
+ receive_shadows off
+ technique
+ {
+ pass
+ {
+ //lighting off
+
+ // alpha=opacity (1.=opaque,0=transparent)
+ diffuse 1 0 0 0.6
+ ambient 1 1 1
+ //specular 1 1 1
+ depth_write off
+ //depth_check off
+
+ //scene_blend modulate
+ scene_blend alpha_blend
+ //scene_blend modulate
+ }
+ }
+}
Copied: trunk/yake/common/media/gui/imagesets/Imageset.xsd (from rev 1905, branches/v0-7-0/yake/common/media/gui/imagesets/Imageset.xsd)
===================================================================
--- trunk/yake/common/media/gui/imagesets/Imageset.xsd (rev 0)
+++ trunk/yake/common/media/gui/imagesets/Imageset.xsd 2007-12-12 21:48:34 UTC (rev 1906)
@@ -0,0 +1,28 @@
+<?xml version="1.0"?>
+<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
+
+ <xsd:element name="Imageset" type="ImagesetType"/>
+
+ <xsd:complexType name="ImagesetType">
+ <xsd:sequence>
+ <xsd:element name="Image" type="ImageType" maxOccurs="unbounded"/>
+ </xsd:sequence>
+ <xsd:attribute name="Imagefile" type="xsd:string" use="required"/>
+ <xsd:attribute name="ResourceGroup" type="xsd:string" use="optional" default="" />
+ <xsd:attribute name="Name" type="xsd:string" use="required"/>
+ <xsd:attribute name="NativeHorzRes" type="xsd:nonNegativeInteger" use="optional" default="640" />
+ <xsd:attribute name="NativeVertRes" type="xsd:nonNegativeInteger" use="optional" default="480" />
+ <xsd:attribute name="AutoScaled" type="xsd:boolean" use="optional" default="false" />
+ </xsd:complexType>
+
+ <xsd:complexType name="ImageType">
+ <xsd:attribute name="Name" type="xsd:string" use="required"/>
+ <xsd:attribute name="XPos" type="xsd:nonNegativeInteger" use="required"/>
+ <xsd:attribute name="YPos" type="xsd:nonNegativeInteger" use="required"/>
+ <xsd:attribute name="Width" type="xsd:nonNegativeInteger" use="required"/>
+ <xsd:attribute name="Height" type="xsd:nonNegativeInteger" use="required"/>
+ <xsd:attribute name="XOffset" type="xsd:integer" use="optional" default="0"/>
+ <xsd:attribute name="YOffset" type="xsd:integer" use="optional" default="0"/>
+ </xsd:complexType>
+
+</xsd:schema>
Copied: trunk/yake/common/media/gui/imagesets/TaharezLook.imageset (from rev 1905, branches/v0-7-0/yake/common/media/gui/imagesets/TaharezLook.imageset)
===================================================================
--- trunk/yake/common/media/gui/imagesets/TaharezLook.imageset (rev 0)
+++ trunk/yake/common/media/gui/imagesets/TaharezLook.imageset 2007-12-12 21:48:34 UTC (rev 1906)
@@ -0,0 +1,242 @@
+<?xml version="1.0" ?>
+<Imageset Name="TaharezLook" Imagefile="TaharezLook.tga" NativeHorzRes="800" NativeVertRes="600" AutoScaled="true">
+ <Image Name="ClientBrush" XPos="2" YPos="2" Width="64" Height="64" />
+ <Image Name="WindowLeftEdge" XPos="6" YPos="95" Width="1" Height="22" XOffset="4" />
+ <Image Name="WindowRightEdge" XPos="34" YPos="95" Width="1" Height="22" XOffset="-5" />
+ <Image Name="WindowTopEdge" XPos="9" YPos="68" Width="23" Height="1" />
+ <Image Name="WindowBottomEdge" XPos="9" YPos="143" Width="23" Height="1" />
+ <Image Name="WindowTopLeft" XPos="2" YPos="68" Width="5" Height="24" />
+ <Image Name="WindowTopRight" XPos="34" YPos="68" Width="5" Height="24" />
+ <Image Name="WindowBottomLeft" XPos="2" YPos="120" Width="5" Height="24" />
+ <Image Name="WindowBottomRight" XPos="34" YPos="120" Width="5" Height="24" />
+ <Image Name="ButtonLeftNormal" XPos="68" YPos="20" Width="12" Height="16" />
+ <Image Name="ButtonMiddleNormal" XPos="82" YPos="20" Width="12" Height="16" />
+ <Image Name="ButtonRightNormal" XPos="96" YPos="20" Width="12" Height="16" />
+ <Image Name="ButtonLeftPushed" XPos="68" YPos="38" Width="12" Height="16" />
+ <Image Name="ButtonMiddlePushed" XPos="82" YPos="38" Width="12" Height="16" />
+ <Image Name="ButtonRightPushed" XPos="96" YPos="38" Width="12" Height="16" />
+ <Image Name="ButtonLeftHighlight" XPos="68" YPos="56" Width="12" Height="16" />
+ <Image Name="ButtonMiddleHighlight" XPos="82" YPos="56" Width="12" Height="16" />
+ <Image Name="ButtonRightHighlight" XPos="96" YPos="56" Width="12" Height="16" />
+ <Image Name="CheckboxNormal" XPos="110" YPos="2" Width="12" Height="12" />
+ <Image Name="CheckboxHover" XPos="110" YPos="30" Width="12" Height="12" />
+ <Image Name="CheckboxMark" XPos="110" YPos="16" Width="12" Height="12" />
+ <Image Name="RadioButtonNormal" XPos="124" YPos="2" Width="12" Height="12" />
+ <Image Name="RadioButtonHover" XPos="124" YPos="30" Width="12" Height="12" />
+ <Image Name="RadioButtonMark" XPos="124" YPos="16" Width="12" Height="12" />
+ <Image Name="TitlebarLeft" XPos="68" YPos="2" Width="8" Height="16" />
+ <Image Name="TitlebarMiddle" XPos="78" YPos="2" Width="8" Height="16" />
+ <Image Name="TitlebarRight" XPos="88" YPos="2" Width="8" Height="16" />
+ <Image Name="NewTitlebarLeft" XPos="61" YPos="127" Width="13" Height="16" />
+ <Image Name="NewTitlebarMiddle" XPos="77" YPos="127" Width="12" Height="16" />
+ <Image Name="NewTitlebarRight" XPos="92" YPos="127" Width="12" Height="16" />
+ <Image Name="SysAreaMiddle" XPos="107" YPos="127" Width="12" Height="16" />
+ <Image Name="SysAreaRight" XPos="122" YPos="127" Width="13" Height="16" />
+ <Image Name="StaticLeft" XPos="41" YPos="89" Width="6" Height="6" />
+ <Image Name="StaticRight" XPos="63" YPos="89" Width="6" Height="6" />
+ <Image Name="StaticTop" XPos="52" YPos="78" Width="6" Height="6" />
+ <Image Name="StaticBottom" XPos="52" YPos="100" Width="6" Height="6" />
+ <Image Name="StaticTopLeft" XPos="41" YPos="78" Width="6" Height="6" />
+ <Image Name="StaticTopRight" XPos="63" YPos="78" Width="6" Height="6" />
+ <Image Name="StaticBottomLeft" XPos="41" YPos="100" Width="6" Height="6" />
+ <Image Name="StaticBottomRight" XPos="63" YPos="100" Width="6" Height="6" />
+ <Image Name="StaticBackdrop" XPos="52" YPos="89" Width="6" Height="6" />
+ <Image Name="ProgressBarLeft" XPos="71" YPos="74" Width="7" Height="12" />
+ <Image Name="ProgressBarMiddle" XPos="80" YPos="74" Width="6" Height="12" />
+ <Image Name="ProgressBarRight" XPos="88" YPos="74" Width="6" Height="12" />
+ <Image Name="ProgressBarDimSegment" XPos="96" YPos="74" Width="8" Height="12" />
+ <Image Name="ProgressBarLitSegment" XPos="106" YPos="74" Width="8" Height="12" />
+ <Image Name="EditBoxLeft" XPos="41" YPos="108" Width="4" Height="18" />
+ <Image Name="EditBoxMiddle" XPos="47" YPos="108" Width="4" Height="18" />
+ <Image Name="EditBoxRight" XPos="53" YPos="108" Width="4" Height="18" />
+ <Image Name="EditBoxCarat" XPos="60" YPos="108" Width="4" Height="18" />
+ <Image Name="SpinnerUpNormal" XPos="68" YPos="110" Width="10" Height="6" />
+ <Image Name="SpinnerDownNormal" XPos="68" YPos="118" Width="10" Height="6" />
+ <Image Name="SpinnerUpHover" XPos="82" YPos="110" Width="10" Height="6" />
+ <Image Name="SpinnerDownHover" XPos="82" YPos="118" Width="10" Height="6" />
+ <Image Name="TextSelectionBrush" XPos="8" YPos="70" Width="16" Height="16" />
+ <Image Name="VertScrollTop" XPos="182" YPos="2" Width="20" Height="8" />
+ <Image Name="VertScrollMiddle" XPos="182" YPos="12" Width="20" Height="8" />
+ <Image Name="VertScrollBottom" XPos="182" YPos="22" Width="20" Height="8" />
+ <Image Name="VertScrollBarSegment" XPos="206" YPos="2" Width="4" Height="10" />
+ <Image Name="VertScrollThumbNormal" XPos="214" YPos="2" Width="8" Height="24" />
+ <Image Name="VertScrollThumbHover" XPos="224" YPos="2" Width="8" Height="24" />
+ <Image Name="VertScrollUpNormal" XPos="196" YPos="32" Width="12" Height="12" />
+ <Image Name="VertScrollDownNormal" XPos="182" YPos="32" Width="12" Height="12" />
+ <Image Name="VertScrollUpHover" XPos="196" YPos="46" Width="12" Height="12" />
+ <Image Name="VertScrollDownHover" XPos="182" YPos="46" Width="12" Height="12" />
+ <Image Name="MiniVertScrollBarSegment" XPos="207" YPos="60" Width="4" Height="10" />
+ <Image Name="MiniVertScrollThumbNormal" XPos="214" YPos="59" Width="7" Height="22" />
+ <Image Name="MiniVertScrollThumbTopNormal" XPos="214" YPos="59" Width="7" Height="5" />
+ <Image Name="MiniVertScrollThumbMiddleNormal" XPos="214" YPos="65" Width="7" Height="5" />
+ <Image Name="MiniVertScrollThumbBottomNormal" XPos="214" YPos="76" Width="7" Height="5" />
+ <Image Name="MiniVertScrollThumbTopHover" XPos="223" YPos="59" Width="7" Height="5" />
+ <Image Name="MiniVertScrollThumbMiddleHover" XPos="223" YPos="65" Width="7" Height="5" />
+ <Image Name="MiniVertScrollThumbBottomHover" XPos="223" YPos="76" Width="7" Height="5" />
+ <Image Name="MiniVertScrollThumbHover" XPos="223" YPos="59" Width="7" Height="22" />
+ <Image Name="MiniVertScrollUpNormal" XPos="194" YPos="60" Width="10" Height="9" />
+ <Image Name="MiniVertScrollDownNormal" XPos="182" YPos="59" Width="10" Height="9" />
+ <Image Name="MiniVertScrollUpHover" XPos="194" YPos="70" Width="10" Height="9" />
+ <Image Name="MiniVertScrollDownHover" XPos="182" YPos="69" Width="10" Height="9" />
+ <Image Name="VertSliderBody" XPos="234" YPos="2" Width="9" Height="48" />
+ <Image Name="VertSliderThumbNormal" XPos="217" YPos="28" Width="15" Height="6" />
+ <Image Name="VertSliderThumbHover" XPos="217" YPos="36" Width="15" Height="6" />
+ <Image Name="MiniHorzScrollBarSegment" XPos="244" YPos="80" Width="10" Height="4" />
+ <Image Name="MiniHorzScrollThumbNormal" XPos="233" YPos="87" Width="22" Height="7" />
+ <Image Name="MiniHorzScrollThumbLeftNormal" XPos="233" YPos="87" Width="5" Height="7" />
+ <Image Name="MiniHorzScrollThumbMiddleNormal" XPos="239" YPos="87" Width="5" Height="7" />
+ <Image Name="MiniHorzScrollThumbRightNormal" XPos="250" YPos="87" Width="5" Height="7" />
+ <Image Name="MiniHorzScrollThumbHover" XPos="233" YPos="96" Width="22" Height="7" />
+ <Image Name="MiniHorzScrollThumbLeftHover" XPos="233" YPos="96" Width="5" Height="7" />
+ <Image Name="MiniHorzScrollThumbMiddleHover" XPos="239" YPos="96" Width="5" Height="7" />
+ <Image Name="MiniHorzScrollThumbRightHover" XPos="250" YPos="96" Width="5" Height="7" />
+ <Image Name="MiniHorzScrollLeftNormal" XPos="246" YPos="55" Width="9" Height="10" />
+ <Image Name="MiniHorzScrollRightNormal" XPos="245" YPos="67" Width="9" Height="10" />
+ <Image Name="MiniHorzScrollLeftHover" XPos="236" YPos="55" Width="9" Height="10" />
+ <Image Name="MiniHorzScrollRightHover" XPos="235" YPos="67" Width="9" Height="10" />
+ <Image Name="ListboxLeft" XPos="41" YPos="89" Width="7" Height="6" />
+ <Image Name="ListboxRight" XPos="62" YPos="89" Width="7" Height="6" />
+ <Image Name="ListboxTop" XPos="52" YPos="78" Width="6" Height="7" />
+ <Image Name="ListboxBottom" XPos="52" YPos="99" Width="6" Height="7" />
+ <Image Name="ListboxTopLeft" XPos="41" YPos="78" Width="7" Height="7" />
+ <Image Name="ListboxTopRight" XPos="62" YPos="78" Width="7" Height="7" />
+ <Image Name="ListboxBottomLeft" XPos="41" YPos="99" Width="7" Height="7" />
+ <Image Name="ListboxBottomRight" XPos="62" YPos="99" Width="7" Height="7" />
+ <Image Name="ListboxBackdrop" XPos="52" YPos="89" Width="6" Height="6" />
+ <Image Name="ListboxSelectionBrush" XPos="8" YPos="70" Width="16" Height="16" />
+ <Image Name="ComboboxEditLeft" XPos="138" YPos="2" Width="8" Height="16" />
+ <Image Name="ComboboxEditMiddle" XPos="148" YPos="2" Width="8" Height="16" />
+ <Image Name="ComboboxListButtonNormal" XPos="158" YPos="2" Width="16" Height="16" />
+ <Image Name="ComboboxListButtonHover" XPos="158" YPos="20" Width="16" Height="16" />
+ <Image Name="ComboboxListLeft" XPos="138" YPos="48" Width="8" Height="8" />
+ <Image Name="ComboboxListRight" XPos="158" YPos="48" Width="8" Height="8" />
+ <Image Name="ComboboxListTop" XPos="148" YPos="48" Width="8" Height="8" />
+ <Image Name="ComboboxListBottom" XPos="148" YPos="58" Width="8" Height="8" />
+ <Image Name="ComboboxListTopLeft" XPos="138" YPos="38" Width="8" Height="8" />
+ <Image Name="ComboboxListTopRight" XPos="158" YPos="38" Width="8" Height="8" />
+ <Image Name="ComboboxListBottomLeft" XPos="138" YPos="58" Width="8" Height="8" />
+ <Image Name="ComboboxListBottomRight" XPos="158" YPos="58" Width="8" Height="8" />
+ <Image Name="ComboboxListBackdrop" XPos="148" YPos="48" Width="8" Height="8" />
+ <Image Name="ComboboxSelectionBrush" XPos="8" YPos="70" Width="16" Height="16" />
+ <Image Name="ComboboxDividerLeft" XPos="138" YPos="68" Width="14" Height="1" />
+ <Image Name="ComboboxDividerMiddle" XPos="154" YPos="68" Width="8" Height="1" />
+ <Image Name="ComboboxDividerRight" XPos="164" YPos="68" Width="14" Height="1" />
+ <Image Name="HeaderBarBackdropNormal" XPos="230" YPos="163" Width="10" Height="12" />
+ <Image Name="HeaderBarBackdropHover" XPos="230" YPos="163" Width="10" Height="12" />
+ <Image Name="HeaderBarSplitterNormal" XPos="225" YPos="92" Width="3" Height="16" />
+ <Image Name="HeaderBarSplitterHover" XPos="200" YPos="92" Width="3" Height="16" />
+ <Image Name="HeaderBarSortUp" XPos="233" YPos="178" Width="8" Height="8" />
+ <Image Name="HeaderBarSortDown" XPos="244" YPos="178" Width="8" Height="8" />
+ <Image Name="MultiListLeft" XPos="170" YPos="92" Width="7" Height="6" />
+ <Image Name="MultiListRight" XPos="191" YPos="92" Width="7" Height="6" />
+ <Image Name="MultiListTop" XPos="181" YPos="81" Width="6" Height="7" />
+ <Image Name="MultiListBottom" XPos="181" YPos="102" Width="6" Height="7" />
+ <Image Name="MultiListTopLeft" XPos="170" YPos="81" Width="7" Height="7" />
+ <Image Name="MultiListTopRight" XPos="191" YPos="81" Width="7" Height="7" />
+ <Image Name="MultiListBottomLeft" XPos="170" YPos="102" Width="7" Height="7" />
+ <Image Name="MultiListBottomRight" XPos="191" YPos="102" Width="7" Height="7" />
+ <Image Name="MultiListBackdrop" XPos="181" YPos="92" Width="6" Height="6" />
+ <Image Name="MultiListSelectionBrush" XPos="9" YPos="71" Width="14" Height="14" />
+ <Image Name="AltProgressLeft" XPos="71" YPos="88" Width="8" Height="12" />
+ <Image Name="AltProgressMiddle" XPos="81" YPos="88" Width="8" Height="12" />
+ <Image Name="AltProgressRight" XPos="91" YPos="88" Width="8" Height="12" />
+ <Image Name="AltProgressQuarter" XPos="102" YPos="89" Width="3" Height="4" />
+ <Image Name="AltProgressHalf" XPos="109" YPos="89" Width="4" Height="5" />
+ <Image Name="AltProgressLight1" XPos="100" YPos="97" Width="4" Height="8" />
+ <Image Name="AltProgressLight2" XPos="106" YPos="97" Width="4" Height="8" />
+ <Image Name="AltProgressLight3" XPos="112" YPos="97" Width="4" Height="8" />
+ <Image Name="AltProgressLight4" XPos="118" YPos="97" Width="4" Height="8" />
+ <Image Name="AltProgressLight5" XPos="124" YPos="97" Width="4" Height="8" />
+ <Image Name="AltProgressLight6" XPos="130" YPos="97" Width="4" Height="8" />
+ <Image Name="AltProgressLight7" XPos="136" YPos="97" Width="4" Height="8" />
+ <Image Name="AltProgressLight8" XPos="142" YPos="97" Width="4" Height="8" />
+ <Image Name="AltProgressLight9" XPos="148" YPos="97" Width="4" Height="8" />
+ <Image Name="AltProgressLight10" XPos="154" YPos="97" Width="4" Height="8" />
+ <Image Name="CloseButtonNormal" XPos="41" YPos="128" Width="16" Height="16" />
+ <Image Name="CloseButtonHover" XPos="41" YPos="146" Width="16" Height="16" />
+ <Image Name="CloseButtonPressed" XPos="41" YPos="164" Width="16" Height="16" />
+ <Image Name="NewCloseButtonNormal" XPos="90" YPos="146" Width="10" Height="10" />
+ <Image Name="NewCloseButtonHover" XPos="90" YPos="146" Width="10" Height="10" />
+ <Image Name="NewCloseButtonPressed" XPos="90" YPos="146" Width="10" Height="10" />
+ <Image Name="MultiLineEditboxLeft" XPos="41" YPos="89" Width="6" Height="6" />
+ <Image Name="MultiLineEditboxRight" XPos="63" YPos="89" Width="6" Height="6" />
+ <Image Name="MultiLineEditboxTop" XPos="52" YPos="78" Width="6" Height="6" />
+ <Image Name="MultiLineEditboxBottom" XPos="52" YPos="100" Width="6" Height="6" />
+ <Image Name="MultiLineEditboxTopLeft" XPos="41" YPos="78" Width="6" Height="6" />
+ <Image Name="MultiLineEditboxTopRight" XPos="63" YPos="78" Width="6" Height="6" />
+ <Image Name="MultiLineEditboxBottomLeft" XPos="41" YPos="100" Width="6" Height="6" />
+ <Image Name="MultiLineEditboxBottomRight" XPos="63" YPos="100" Width="6" Height="6" />
+ <Image Name="MultiLineEditboxBackdrop" XPos="52" YPos="89" Width="6" Height="6" />
+ <Image Name="MultiLineEditboxSelectionBrush" XPos="9" YPos="71" Width="14" Height="14" />
+ <Image Name="MouseTarget" XPos="182" YPos="127" Width="17" Height="17" XOffset="-8" YOffset="-8" />
+ <Image Name="MouseArrow" XPos="138" YPos="127" Width="31" Height="25" XOffset="0" YOffset="0" />
+ <Image Name="MouseMoveCursor" XPos="201" YPos="127" Width="18" Height="18" XOffset="-8" YOffset="-8" />
+ <Image Name="MouseNoSoCursor" XPos="221" YPos="127" Width="8" Height="18" XOffset="-3" YOffset="-8" />
+ <Image Name="MouseEsWeCursor" XPos="182" YPos="150" Width="18" Height="8" XOffset="-8" YOffset="-3" />
+ <Image Name="MouseNeSwCursor" XPos="201" YPos="147" Width="14" Height="14" XOffset="-7" YOffset="-7" />
+ <Image Name="MouseNwSeCursor" XPos="230" YPos="126" Width="14" Height="14" XOffset="-7" YOffset="-7" />
+ <Image Name="MouseTextBar" XPos="173" YPos="127" Width="7" Height="18" XOffset="-2" YOffset="-9" />
+ <Image Name="TabHorizontalFiller" XPos="197" YPos="201" Width="7" Height="1" />
+ <Image Name="TabContentPaneUpperLeft" XPos="41" YPos="78" Width="7" Height="7" />
+ <Image Name="TabContentPaneUpper" XPos="52" YPos="78" Width="6" Height="7" />
+ <Image Name="TabContentPaneUpperRight" XPos="62" YPos="78" Width="7" Height="7" />
+ <Image Name="TabContentPaneLeft" XPos="41" YPos="89" Width="7" Height="6" />
+ <Image Name="TabContentPaneRight" XPos="62" YPos="89" Width="7" Height="6" />
+ <Image Name="TabContentPaneLower" XPos="52" YPos="99" Width="6" Height="7" />
+ <Image Name="TabContentPaneLowerLeft" XPos="41" YPos="99" Width="7" Height="7" />
+ <Image Name="TabContentPaneLowerRight" XPos="62" YPos="99" Width="7" Height="7" />
+ <Image Name="TabContentPaneMiddle" XPos="52" YPos="89" Width="6" Height="6" />
+ <Image Name="TabButtonScrollLeftNormal" XPos="97" YPos="108" Width="16" Height="17" />
+ <Image Name="TabButtonScrollRightNormal" XPos="112" YPos="108" Width="16" Height="17" />
+ <Image Name="TabButtonScrollLeftHover" XPos="127" YPos="108" Width="16" Height="17" />
+ <Image Name="TabButtonScrollRightHover" XPos="142" YPos="108" Width="16" Height="17" />
+ <Image Name="TabButtonLeftNormal" XPos="41" YPos="89" Width="7" Height="6" />
+ <Image Name="TabButtonRightNormal" XPos="62" YPos="89" Width="7" Height="6" />
+ <Image Name="TabButtonUpperNormal" XPos="52" YPos="78" Width="6" Height="7" />
+ <Image Name="TabButtonLowerNormal" XPos="52" YPos="99" Width="6" Height="7" />
+ <Image Name="TabButtonUpperLeftNormal" XPos="41" YPos="78" Width="7" Height="7" />
+ <Image Name="TabButtonUpperLeft2Normal" XPos="186" YPos="164" Width="7" Height="7" />
+ <Image Name="TabButtonUpperRightNormal" XPos="62" YPos="78" Width="7" Height="7" />
+ <Image Name="TabButtonLowerLeftNormal" XPos="41" YPos="99" Width="7" Height="7" />
+ <Image Name="TabButtonLowerRightNormal" XPos="62" YPos="99" Width="7" Height="7" />
+ <Image Name="TabButtonLowerRight2Normal" XPos="187" YPos="195" Width="7" Height="7" />
+ <Image Name="TabButtonMiddleNormal" XPos="52" YPos="89" Width="6" Height="6" />
+ <Image Name="TabButtonLeftSelected" XPos="41" YPos="89" Width="7" Height="6" />
+ <Image Name="TabButtonRightSelected" XPos="62" YPos="89" Width="7" Height="6" />
+ <Image Name="TabButtonUpperSelected" XPos="52" YPos="78" Width="6" Height="7" />
+ <Image Name="TabButtonLowerSelected" XPos="52" YPos="89" Width="6" Height="6" />
+ <Image Name="TabButtonUpperLeftSelected" XPos="41" YPos="78" Width="7" Height="7" />
+ <Image Name="TabButtonUpperRightSelected" XPos="62" YPos="78" Width="7" Height="7" />
+ <Image Name="TabButtonLowerLeftSelected" XPos="41" YPos="99" Width="7" Height="7" />
+ <Image Name="TabButtonLowerRightSelected" XPos="62" YPos="99" Width="7" Height="7" />
+ <Image Name="TabButtonMiddleSelected" XPos="52" YPos="89" Width="6" Height="6" />
+ <Image Name="TooltipTopLeft" XPos="61" YPos="160" Width="4" Height="4" />
+ <Image Name="TooltipTopRight" XPos="85" YPos="160" Width="5" Height="4" />
+ <Image Name="TooltipBottomLeft" XPos="61" YPos="184" Width="4" Height="5" />
+ <Image Name="TooltipBottomRight" XPos="85" YPos="184" Width="5" Height="5" />
+ <Image Name="TooltipLeftEdge" XPos="61" YPos="171" Width="4" Height="6" />
+ <Image Name="TooltipRightEdge" XPos="85" YPos="171" Width="5" Height="6" />
+ <Image Name="TooltipTopEdge" XPos="72" YPos="160" Width="6" Height="4" />
+ <Image Name="TooltipBottomEdge" XPos="72" YPos="184" Width="6" Height="5" />
+ <Image Name="TooltipMiddle" XPos="72" YPos="171" Width="6" Height="6" />
+ <Image Name="MenuTopLeft" XPos="166" YPos="204" Width="2" Height="2" />
+ <Image Name="MenuTopRight" XPos="175" YPos="204" Width="3" Height="2" />
+ <Image Name="MenuBottomLeft" XPos="166" YPos="213" Width="2" Height="3" />
+ <Image Name="MenuBottomRight" XPos="175" YPos="213" Width="3" Height="3" />
+ <Image Name="MenuLeft" XPos="166" YPos="209" Width="2" Height="1" />
+ <Image Name="MenuRight" XPos="175" YPos="209" Width="3" Height="1" />
+ <Image Name="MenuTop" XPos="171" YPos="204" Width="1" Height="2" />
+ <Image Name="MenuBottom" XPos="171" YPos="213" Width="1" Height="3" />
+ <Image Name="MenuMiddle" XPos="171" YPos="209" Width="1" Height="1" />
+ <Image Name="PopupMenuFrameTopLeft" XPos="186" YPos="204" Width="2" Height="2" />
+ <Image Name="PopupMenuFrameTopRight" XPos="195" YPos="204" Width="4" Height="2" />
+ <Image Name="PopupMenuFrameBottomLeft" XPos="186" YPos="213" Width="2" Height="4" />
+ <Image Name="PopupMenuFrameBottomRight" XPos="195" YPos="213" Width="4" Height="4" />
+ <Image Name="PopupMenuFrameLeft" XPos="186" YPos="209" Width="2" Height="1" />
+ <Image Name="PopupMenuFrameRight" XPos="195" YPos="209" Width="4" Height="1" />
+ <Image Name="PopupMenuFrameTop" XPos="191" YPos="204" Width="1" Height="2" />
+ <Image Name="PopupMenuFrameBottom" XPos="191" YPos="213" Width="1" Height="4" />
+ <Image Name="PopupMenuMiddle" XPos="191" YPos="209" Width="1" Height="1" />
+ <Image Name="PopupMenuArrowRight" XPos="179" YPos="204" Width="5" Height="5" />
+ <Image Name="PopupMenuArrowLeft" XPos="179" YPos="210" Width="5" Height="5" />
+</Imageset>
Copied: trunk/yake/common/media/gui/imagesets/TaharezLook.tga (from rev 1905, branches/v0-7-0/yake/common/media/gui/imagesets/TaharezLook.tga)
===================================================================
(Binary files differ)
Copied: trunk/yake/common/media/gui/looknfeel/TaharezLook.looknfeel (from rev 1905, branches/v0-7-0/yake/common/media/gui/looknfeel/TaharezLook.looknfeel)
===================================================================
--- trunk/yake/common/media/gui/looknfeel/TaharezLook.looknfeel (rev 0)
+++ trunk/yake/common/media/gui/looknfeel/TaharezLook.looknfeel 2007-12-12 21:48:34 UTC (rev 1906)
@@ -0,0 +1,4315 @@
+<?xml version="1.0" ?>
+<Falagard>
+ <!--
+ ***************************************************
+ TaharezLook/Button
+ ***************************************************
+ -->
+ <WidgetLook name="TaharezLook/Button">
+ <PropertyDefinition name="NormalTextColour" initialValue="FFFFFFFF" redrawOnWrite="true" />
+ <PropertyDefinition name="HoverTextColour" initialValue="FFFFFFFF" redrawOnWrite="true" />
+ <PropertyDefinition name="PushedTextColour" initialValue="FFFFFFFF" redrawOnWrite="true" />
+ <PropertyDefinition name="DisabledTextColour" initialValue="FF7F7F7F" redrawOnWrite="true" />
+ <PropertyDefinition name="VertLabelFormatting" initialValue="CentreAligned" />
+ <PropertyDefinition name="HorzLabelFormatting" initialValue="CentreAligned" />
+ <PropertyDefinition name="NormalImage" initialValue="" redrawOnWrite="true" />
+ <PropertyDefinition name="HoverImage" initialValue="" redrawOnWrite="true" />
+ <PropertyDefinition name="PushedImage" initialValue="" redrawOnWrite="true" />
+ <PropertyDefinition name="DisabledImage" initialValue="" redrawOnWrite="true" />
+ <PropertyDefinition name="VertImageFormatting" initialValue="Stretched" redrawOnWrite="true" />
+ <PropertyDefinition name="HorzImageFormatting" initialValue="Stretched" redrawOnWrite="true" />
+ <ImagerySection name="label">
+ <TextComponent>
+ <Area>
+ <Dim type="LeftEdge"><AbsoluteDim value="0" /></Dim>
+ <Dim type="TopEdge"><AbsoluteDim value="0" /></Dim>
+ <Dim type="Width"><UnifiedDim scale="1" type="Width" /></Dim>
+ <Dim type="Height"><UnifiedDim scale="1" type="Height" /></Dim>
+ </Area>
+ <VertFormatProperty name="VertLabelFormatting" />
+ <HorzFormatProperty name="HorzLabelFormatting" />
+ </TextComponent>
+ </ImagerySection>
+ <ImagerySection name="normal">
+ <FrameComponent>
+ <Area>
+ <Dim type="LeftEdge"><AbsoluteDim value="0" /></Dim>
+ <Dim type="TopEdge"><AbsoluteDim value="0" /></Dim>
+ <Dim type="Width"><UnifiedDim scale="1" type="Width" /></Dim>
+ <Dim type="Height"><UnifiedDim scale="1" type="Height" /></Dim>
+ </Area>
+ <Image type="LeftEdge" imageset="TaharezLook" image="ButtonLeftNormal" />
+ <Image type="RightEdge" imageset="TaharezLook" image="ButtonRightNormal" />
+ <Image type="Background" imageset="TaharezLook" image="ButtonMiddleNormal" />
+ </FrameComponent>
+ <ImageryComponent>
+ <Area>
+ <Dim type="LeftEdge" ><AbsoluteDim value="0" /></Dim>
+ <Dim type="TopEdge" ><AbsoluteDim value="0" /></Dim>
+ <Dim type="Width" ><UnifiedDim scale="1" type="Width" /></Dim>
+ <Dim type="Height" ><UnifiedDim scale="1" type="Height" /></Dim>
+ </Area>
+ <ImageProperty name="NormalImage" />
+ <VertFormatProperty name="VertImageFormatting" />
+ <HorzFormatProperty name="HorzImageFormatting" />
+ </ImageryComponent>
+ </ImagerySection>
+ <ImagerySection name="hover">
+ <FrameComponent>
+ <Area>
+ <Dim type="LeftEdge" ><AbsoluteDim value="0" /></Dim>
+ <Dim type="TopEdge" ><AbsoluteDim value="0" /></Dim>
+ <Dim type="Width" ><UnifiedDim scale="1" type="Width" /></Dim>
+ <Dim type="Height" ><UnifiedDim scale="1" type="Height" /></Dim>
+ </Area>
+ <Image type="LeftEdge" imageset="TaharezLook" image="ButtonLeftHighlight" />
+ <Image type="RightEdge" imageset="TaharezLook" image="ButtonRightHighlight" />
+ <Image type="Background" imageset="TaharezLook" image="ButtonMiddleHighlight" />
+ </FrameComponent>
+ <ImageryComponent>
+ <Area>
+ <Dim type="LeftEdge" ><AbsoluteDim value="0" /></Dim>
+ <Dim type="TopEdge" ><AbsoluteDim value="0" /></Dim>
+ <Dim type="Width" ><UnifiedDim scale="1" type="Width" /></Dim>
+ <Dim type="Height" ><UnifiedDim scale="1" type="Height" /></Dim>
+ </Area>
+ <ImageProperty name="HoverImage" />
+ <VertFormatProperty name="VertImageFormatting" />
+ <HorzFormatProperty name="HorzImageFormatting" />
+ </ImageryComponent>
+ </ImagerySection>
+ <ImagerySection name="pushed">
+ <FrameComponent>
+ <Area>
+ <Dim type="LeftEdge" ><AbsoluteDim value="0" /></Dim>
+ <Dim type="TopEdge" ><AbsoluteDim value="0" /></Dim>
+ <Dim type="Width" ><UnifiedDim scale="1" type="Width" /></Dim>
+ <Dim type="Height" ><UnifiedDim scale="1" type="Height" /></Dim>
+ </Area>
+ <Image type="LeftEdge" imageset="TaharezLook" image="ButtonLeftPushed" />
+ <Image type="RightEdge" imageset="TaharezLook" image="ButtonRightPushed" />
+ <Image type="Background" imageset="TaharezLook" image="ButtonMiddlePushed" />
+ </FrameComponent>
+ <ImageryComponent>
+ <Area>
+ <Dim type="LeftEdge" ><AbsoluteDim value="0" /></Dim>
+ <Dim type="TopEdge" ><AbsoluteDim value="0" /></Dim>
+ <Dim type="Width" ><UnifiedDim scale="1" type="Width" /></Dim>
+ <Dim type="Height" ><UnifiedDim scale="1" type="Height" /></Dim>
+ </Area>
+ <ImageProperty name="PushedImage" />
+ <VertFormatProperty name="VertImageFormatting" />
+ <HorzFormatProperty name="HorzImageFormatting" />
+ </ImageryComponent>
+ </ImagerySection>
+ <StateImagery name="Normal">
+ <Layer>
+ <Section section="normal" />
+ <Section section="label">
+ <ColourProperty name="NormalTextColour" />
+ </Section>
+ </Layer>
+ </StateImagery>
+ <StateImagery name="Hover">
+ <Layer>
+ <Section section="hover" />
+ <Section section="label">
+ <ColourProperty name="HoverTextColour" />
+ </Section>
+ </Layer>
+ </StateImagery>
+ <StateImagery name="Pushed">
+ <Layer>
+ <Section section="pushed" />
+ <Section section="label">
+ <ColourProperty name="PushedTextColour" />
+ </Section>
+ </Layer>
+ </StateImagery>
+ <StateImagery name="PushedOff">
+ <Layer>
+ <Section section="hover" />
+ <Section section="label">
+ <ColourProperty name="HoverTextColour" />
+ </Section>
+ </Layer>
+ </StateImagery>
+ <StateImagery name="Disabled">
+ <Layer>
+ <Section section="normal">
+ <Colours topLeft="FF7F7F7F" topRight="FF7F7F7F" bottomLeft="FF7F7F7F" bottomRight="FF7F7F7F" />
+ </Section>
+ <Section section="label">
+ <ColourProperty name="DisabledTextColour" />
+ </Section>
+ </Layer>
+ </StateImagery>
+ </WidgetLook>
+
+ <!--
+ ***************************************************
+ TaharezLook/RadioButton
+ ***************************************************
+ -->
+ <WidgetLook name="TaharezLook/RadioButton">
+ <PropertyDefinition name="NormalTextColour" initialValue="FFFFFFFF" redrawOnWrite="true" />
+ <PropertyDefinition name="HoverTextColour" initialValue="FFFFFFFF" redrawOnWrite="true" />
+ <PropertyDefinition name="PushedTextColour" initialValue="FFFFFFFF" redrawOnWrite="true" />
+ <PropertyDefinition name="DisabledTextColour" initialValue="FF7F7F7F" redrawOnWrite="true" />
+ <ImagerySection name="label">
+ <TextComponent>
+ <Area>
+ <Dim type="LeftEdge" >
+ <ImageDim imageset="TaharezLook" image="RadioButtonNormal" dimension="Width">
+ <DimOperator op="Add">
+ <AbsoluteDim value="3" />
+ </DimOperator>
+ </ImageDim>
+ </Dim>
+ <Dim type="TopEdge" ><AbsoluteDim value="0" /></Dim>
+ <Dim type="RightEdge" ><UnifiedDim scale="1" type="Width" /></Dim>
+ <Dim type="Height" ><UnifiedDim scale="1" type="Height" /></Dim>
+ </Area>
+ <VertFormat type="CentreAligned" />
+ <HorzFormat type="LeftAligned" />
+ </TextComponent>
+ </ImagerySection>
+ <ImagerySection name="normal">
+ <ImageryComponent>
+ <Area>
+ <Dim type="LeftEdge" ><AbsoluteDim value="0" /></Dim>
+ <Dim type="TopEdge" ><AbsoluteDim value="0" /></Dim>
+ <Dim type="Width" ><UnifiedDim scale="1" type="Width" /></Dim>
+ <Dim type="Height" ><UnifiedDim scale="1" type="Height" /></Dim>
+ </Area>
+ <Image imageset="TaharezLook" image="RadioButtonNormal" />
+ <VertFormat type="CentreAligned" />
+ <HorzFormat type="LeftAligned" />
+ </ImageryComponent>
+ </ImagerySection>
+ <ImagerySection name="hover">
+ <ImageryComponent>
+ <Area>
+ <Dim type="LeftEdge" ><AbsoluteDim value="0" /></Dim>
+ <Dim type="TopEdge" ><AbsoluteDim value="0" /></Dim>
+ <Dim type="Width" ><UnifiedDim scale="1" type="Width" /></Dim>
+ <Dim type="Height" ><UnifiedDim scale="1" type="Height" /></Dim>
+ </Area>
+ <Image imageset="TaharezLook" image="RadioButtonHover" />
+ <VertFormat type="CentreAligned" />
+ <HorzFormat type="LeftAligned" />
+ </ImageryComponent>
+ </ImagerySection>
+ <ImagerySection name="select_mark">
+ <ImageryComponent>
+ <Area>
+ <Dim type="LeftEdge" ><AbsoluteDim value="0" /></Dim>
+ <Dim type="TopEdge" ><AbsoluteDim value="0" /></Dim>
+ <Dim type="Width" ><UnifiedDim scale="1" type="Width" /></Dim>
+ <Dim type="Height" ><UnifiedDim scale="1" type="Height" /></Dim>
+ </Area>
+ <Image imageset="TaharezLook" image="RadioButtonMark" />
+ <VertFormat type="CentreAligned" />
+ <HorzFormat type="LeftAligned" />
+ </ImageryComponent>
+ </ImagerySection>
+ <StateImagery name="Normal">
+ <Layer>
+ <Section section="normal" />
+ <Section section="label">
+ <ColourProperty name="NormalTextColour" />
+ </Section>
+ </Layer>
+ </StateImagery>
+ <StateImagery name="Hover">
+ <Layer>
+ <Section section="hover" />
+ <Section section="label">
+ <ColourProperty name="HoverTextColour" />
+ </Section>
+ </Layer>
+ </StateImagery>
+ <StateImagery name="Disabled">
+ <Layer>
+ <Section section="normal">
+ <Colours topLeft="FF7F7F7F" topRight="FF7F7F7F" bottomLeft="FF7F7F7F" bottomRight="FF7F7F7F" />
+ </Section>
+ <Section section="label">
+ <ColourProperty name="DisabledTextColour" />
+ </Section>
+ </Layer>
+ </StateImagery>
+ <StateImagery name="SelectedNormal">
+ <Layer>
+ <Section section="normal" />
+ <Section section="select_mark" />
+ <Section section="label">
+ <ColourProperty name="NormalTextColour" />
+ </Section>
+ </Layer>
+ </StateImagery>
+ <StateImagery name="SelectedHover">
+ <Layer>
+ <Section section="hover" />
+ <Section section="select_mark" />
+ <Section section="label">
+ <ColourProperty name="HoverTextColour" />
+ </Section>
+ </Layer>
+ </StateImagery>
+ <StateImagery name="SelectedDisabled">
+ <Layer>
+ <Section section="normal">
+ <Colours topLeft="FF7F7F7F" topRight="FF7F7F7F" bottomLeft="FF7F7F7F" bottomRight="FF7F7F7F" />
+ </Section>
+ <Section section="select_mark">
+ <Colours topLeft="FF7F7F7F" topRight="FF7F7F7F" bottomLeft="FF7F7F7F" bottomRight="FF7F7F7F" />
+ </Section>
+ <Section section="label">
+ <ColourProperty name="DisabledTextColour" />
+ </Section>
+ </Layer>
+ </StateImagery>
+ </WidgetLook>
+
+ <!--
+ ***************************************************
+ TaharezLook/Checkbox
+ ***************************************************
+ -->
+ <WidgetLook name="TaharezLook/Checkbox">
+ <PropertyDefinition name="NormalTextColour" initialValue="FFFFFFFF" redrawOnWrite="true" />
+ <PropertyDefinition name="HoverTextColour" initialValue="FFFFFFFF" redrawOnWrite="true" />
+ <PropertyDefinition name="PushedTextColour" initialValue="FFFFFFFF" redrawOnWrite="true" />
+ <PropertyDefinition name="DisabledTextColour" initialValue="FF7F7F7F" redrawOnWrite="true" />
+ <ImagerySection name="label">
+ <TextComponent>
+ <Area>
+ <Dim type="LeftEdge" >
+ <ImageDim imageset="TaharezLook" image="CheckboxNormal" dimension="Width">
+ <DimOperator op="Add">
+ <AbsoluteDim value="3" />
+ </DimOperator>
+ </ImageDim>
+ </Dim>
+ <Dim type="TopEdge" ><AbsoluteDim value="0" /></Dim>
+ <Dim type="RightEdge" ><UnifiedDim scale="1" type="Width" /></Dim>
+ <Dim type="Height" ><UnifiedDim scale="1" type="Height" /></Dim>
+ </Area>
+ <VertFormat type="CentreAligned" />
+ <HorzFormat type="LeftAligned" />
+ </TextComponent>
+ </ImagerySection>
+ <ImagerySection name="normal">
+ <ImageryComponent>
+ <Area>
+ <Dim type="LeftEdge" ><AbsoluteDim value="0" /></Dim>
+ <Dim type="TopEdge" ><AbsoluteDim value="0" /></Dim>
+ <Dim type="Width" ><UnifiedDim scale="1" type="Width" /></Dim>
+ <Dim type="Height" ><UnifiedDim scale="1" type="Height" /></Dim>
+ </Area>
+ <Image imageset="TaharezLook" image="CheckboxNormal" />
+ <VertFormat type="CentreAligned" />
+ <HorzFormat type="LeftAligned" />
+ </ImageryComponent>
+ </ImagerySection>
+ <ImagerySection name="hover">
+ <ImageryComponent>
+ <Area>
+ <Dim type="LeftEdge" ><AbsoluteDim value="0" /></Dim>
+ <Dim type="TopEdge" ><AbsoluteDim value="0" /></Dim>
+ <Dim type="Width" ><UnifiedDim scale="1" type="Width" /></Dim>
+ <Dim type="Height" ><UnifiedDim scale="1" type="Height" /></Dim>
+ </Area>
+ <Image imageset="TaharezLook" image="CheckboxHover" />
+ <VertFormat type="CentreAligned" />
+ <HorzFormat type="LeftAligned" />
+ </ImageryComponent>
+ </ImagerySection>
+ <ImagerySection name="select_mark">
+ <ImageryComponent>
+ <Area>
+ <Dim type="LeftEdge" ><AbsoluteDim value="0" /></Dim>
+ <Dim type="TopEdge" ><AbsoluteDim value="0" /></Dim>
+ <Dim type="Width" ><UnifiedDim scale="1" type="Width" /></Dim>
+ <Dim type="Height" ><UnifiedDim scale="1" type="Height" /></Dim>
+ </Area>
+ <Image imageset="TaharezLook" image="CheckboxMark" />
+ <VertFormat type="CentreAligned" />
+ <HorzFormat type="LeftAligned" />
+ </ImageryComponent>
+ </ImagerySection>
+ <StateImagery name="Normal">
+ <Layer>
+ <Section section="normal" />
+ <Section section="label">
+ <ColourProperty name="NormalTextColour" />
+ </Section>
+ </Layer>
+ </StateImagery>
+ <StateImagery name="Hover">
+ <Layer>
+ <Section section="hover" />
+ <Section section="label">
+ <ColourProperty name="HoverTextColour" />
+ </Section>
+ </Layer>
+ </StateImagery>
+ <StateImagery name="Disabled">
+ <Layer>
+ <Section section="normal">
+ <Colours topLeft="FF7F7F7F" topRight="FF7F7F7F" bottomLeft="FF7F7F7F" bottomRight="FF7F7F7F" />
+ </Section>
+ <Section section="label">
+ <ColourProperty name="DisabledTextColour" />
+ </Section>
+ </Layer>
+ </StateImagery>
+ <StateImagery name="SelectedNormal">
+ <Layer>
+ <Section section="normal" />
+ <Section section="select_mark" />
+ <Section section="label">
+ <ColourProperty name="NormalTextColour" />
+ </Section>
+ </Layer>
+ </StateImagery>
+ <StateImagery name="SelectedHover">
+ <Layer>
+ <Section section="hover" />
+ <Section section="select_mark" />
+ <Section section="label">
+ <ColourProperty name="HoverTextColour" />
+ </Section>
+ </Layer>
+ </StateImagery>
+ <StateImagery name="SelectedDisabled">
+ <Layer>
+ <Section section="normal">
+ <Colours topLeft="FF7F7F7F" topRight="FF7F7F7F" bottomLeft="FF7F7F7F" bottomRight="FF7F7F7F" />
+ </Section>
+ <Section section="select_mark">
+ <Colours topLeft="FF7F7F7F" topRight="FF7F7F7F" bottomLeft="FF7F7F7F" bottomRight="FF7F7F7F" />
+ </Section>
+ <Section section="label">
+ <ColourProperty name="DisabledTextColour" />
+ </Section>
+ </Layer>
+ </StateImagery>
+ </WidgetLook>
+
+ <!--
+ ***************************************************
+ TaharezLook/Editbox
+ ***************************************************
+ -->
+ <WidgetLook name="TaharezLook/Editbox">
+ <PropertyDefinition name="NormalTextColour" initialValue="FFFFFFFF" redrawOnWrite="true" />
+ <PropertyDefinition name="SelectedTextColour" initialValue="FF000000" redrawOnWrite="true" />
+ <PropertyDefinition name="ActiveSelectionColour" initialValue="FF607FFF" redrawOnWrite="true" />
+ <PropertyDefinition name="InactiveSelectionColour" initialValue="FF808080" redrawOnWrite="true" />
+ <Property name="MouseCursorImage" value="set:TaharezLook image:MouseTextBar" />
+ <NamedArea name="TextArea">
+ <Area>
+ <Dim type="LeftEdge" ><AbsoluteDim value="5" /></Dim>
+ <Dim type="TopEdge" ><AbsoluteDim value="5" /></Dim>
+ <Dim type="RightEdge" ><UnifiedDim scale="1.0" offset="-5" type="RightEdge" /></Dim>
+ <Dim type="BottomEdge" ><UnifiedDim scale="1.0" offset="-5" type="BottomEdge" /></Dim>
+ </Area>
+ </NamedArea>
+ <ImagerySection name="container_normal">
+ <FrameComponent>
+ <Area>
+ <Dim type="LeftEdge" ><AbsoluteDim value="0" /></Dim>
+ <Dim type="TopEdge" ><AbsoluteDim value="0" /></Dim>
+ <Dim type="Width" ><UnifiedDim scale="1" type="Width" /></Dim>
+ <Dim type="Height" ><UnifiedDim scale="1" type="Height" /></Dim>
+ </Area>
+ <Image type="LeftEdge" imageset="TaharezLook" image="EditBoxLeft" />
+ <Image type="RightEdge" imageset="TaharezLook" image="EditBoxRight" />
+ <Image type="Background" imageset="TaharezLook" image="EditBoxMiddle" />
+ </FrameComponent>
+ </ImagerySection>
+ <ImagerySection name="selection">
+ <ImageryComponent>
+ <Area>
+ <Dim type="LeftEdge" ><AbsoluteDim value="0" /></Dim>
+ <Dim type="TopEdge" ><AbsoluteDim value="0" /></Dim>
+ <Dim type="RightEdge" ><UnifiedDim scale="1.0" type="RightEdge" /></Dim>
+ <Dim type="BottomEdge" ><UnifiedDim scale="1.0" type="BottomEdge" /></Dim>
+ </Area>
+ <Image imageset="TaharezLook" image="TextSelectionBrush" />
+ <VertFormat type="Stretched" />
+ <HorzFormat type="Stretched" />
+ </ImageryComponent>
+ </ImagerySection>
+ <ImagerySection name="Carat">
+ <ImageryComponent>
+ <Area>
+ <Dim type="LeftEdge" ><AbsoluteDim value="0" /></Dim>
+ <Dim type="TopEdge" ><AbsoluteDim value="0" /></Dim>
+ <Dim type="Width" ><ImageDim imageset="TaharezLook" image="EditBoxCarat" dimension="Width" /></Dim>
+ <Dim type="BottomEdge" ><UnifiedDim scale="1.0" type="BottomEdge" /></Dim>
+ </Area>
+ <Image imageset="TaharezLook" image="EditBoxCarat" />
+ <VertFormat type="Stretched" />
+ <HorzFormat type="Stretched" />
+ </ImageryComponent>
+ </ImagerySection>
+ <StateImagery name="Enabled">
+ <Layer>
+ <Section section="container_normal" />
+ </Layer>
+ </StateImagery>
+ <StateImagery name="ReadOnly">
+ <Layer>
+ <Section section="container_normal" />
+ </Layer>
+ </StateImagery>
+ <StateImagery name="Disabled">
+ <Layer>
+ <Section section="container_normal">
+ <Colours topLeft="FF7F7F7F" topRight="FF7F7F7F" bottomLeft="FF7F7F7F" bottomRight="FF7F7F7F" />
+ </Section>
+ </Layer>
+ </StateImagery>
+ <StateImagery name="ActiveSelection">
+ <Layer>
+ <Section section="selection">
+ <ColourProperty name="ActiveSelectionColour" />
+ </Section>
+ </Layer>
+ </StateImagery>
+ <StateImagery name="InactiveSelection">
+ <Layer>
+ <Section section="selection">
+ <ColourProperty name="InactiveSelectionColour" />
+ </Section>
+ </Layer>
+ </StateImagery>
+ </WidgetLook>
+
+ <!--
+ ***************************************************
+ TaharezLook/Titlebar
+ ***************************************************
+ -->
+ <WidgetLook name="TaharezLook/Titlebar">
+ <PropertyDefinition name="CaptionColour" initialValue="FFFFFFFF" redrawOnWrite="true" />
+ <ImagerySection name="main">
+ <ImageryComponent>
+ <Area>
+ <Dim type="LeftEdge" ><AbsoluteDim value="0" /></Dim>
+ <Dim type="TopEdge" ><AbsoluteDim value="0" /></Dim>
+ <Dim type="Width" ><UnifiedDim scale="1.0" type="Width" /></Dim>
+ <Dim type="Height" ><UnifiedDim scale="1.0" type="Height" /></Dim>
+ </Area>
+ <Image imageset="TaharezLook" image="NewTitlebarLeft" />
+ <VertFormat type="Stretched" />
+ </ImageryComponent>
+ <ImageryComponent>
+ <Area>
+ <Dim type="LeftEdge" ><AbsoluteDim value="0" /></Dim>
+ <Dim type="TopEdge" ><AbsoluteDim value="0" /></Dim>
+ <Dim type="RightEdge" >
+ <UnifiedDim scale="1" type="RightEdge">
+ <DimOperator op="Subtract">
+ <ImageDim imageset="TaharezLook" image="SysAreaRight" dimension="Width">
+ <DimOperator op="Add">
+ <ImageDim imageset="TaharezLook" image="SysAreaMiddle" dimension="Width" />
+ </DimOperator>
+ </ImageDim>
+ </DimOperator>
+ </UnifiedDim>
+ </Dim>
+ <Dim type="Height" ><UnifiedDim scale="1.0" type="Height" /></Dim>
+ </Area>
+ <Image imageset="TaharezLook" image="NewTitlebarRight" />
+ <VertFormat type="Stretched" />
+ <HorzFormat type="RightAligned" />
+ </ImageryComponent>
+ <ImageryComponent>
+ <Area>
+ <Dim type="LeftEdge" ><AbsoluteDim value="0" /></Dim>
+ <Dim type="TopEdge" ><AbsoluteDim value="0" /></Dim>
+ <Dim type="RightEdge" >
+ <UnifiedDim scale="1" type="RightEdge">
+ <DimOperator op="Subtract">
+ <ImageDim imageset="TaharezLook" image="SysAreaRight" dimension="Width" />
+ </DimOperator>
+ </UnifiedDim>
+ </Dim>
+ <Dim type="Height" ><UnifiedDim scale="1.0" type="Height" /></Dim>
+ </Area>
+ <Image imageset="TaharezLook" image="SysAreaMiddle" />
+ <VertFormat type="Stretched" />
+ <HorzFormat type="RightAligned" />
+ </ImageryComponent>
+ <ImageryComponent>
+ <Area>
+ <Dim type="LeftEdge" ><AbsoluteDim value="0" /></Dim>
+ <Dim type="TopEdge" ><AbsoluteDim value="0" /></Dim>
+ <Dim type="Width" ><UnifiedDim scale="1.0" type="Width" /></Dim>
+ <Dim type="Height" ><UnifiedDim scale="1.0" type="Height" /></Dim>
+ </Area>
+ <Image imageset="TaharezLook" image="SysAreaRight" />
+ <VertFormat type="Stretched" />
+ <HorzFormat type="RightAligned" />
+ </ImageryComponent>
+ <ImageryComponent>
+ <Area>
+ <Dim type="LeftEdge" ><ImageDim imageset="TaharezLook" image="NewTitlebarLeft" dimension="Width" /></Dim>
+ <Dim type="TopEdge" ><AbsoluteDim value="0" /></Dim>
+ <Dim type="RightEdge" >
+ <UnifiedDim scale="1" type="RightEdge">
+ <DimOperator op="Subtract">
+ <ImageDim imageset="TaharezLook" image="SysAreaRight" dimension="Width">
+ <DimOperator op="Add">
+ <ImageDim imageset="TaharezLook" image="SysAreaMiddle" dimension="Width">
+ <DimOperator op="Add">
+ <ImageDim imageset="TaharezLook" image="NewTitlebarRight" dimension="Width" />
+ </DimOperator>
+ </ImageDim>
+ </DimOperator>
+ </ImageDim>
+ </DimOperator>
+ </UnifiedDim>
+ </Dim>
+ <Dim type="Height" ><UnifiedDim scale="1.0" type="Height" /></Dim>
+ </Area>
+ <Image imageset="TaharezLook" image="NewTitlebarMiddle" />
+ <VertFormat type="Stretched" />
+ <HorzFormat type="Stretched" />
+ </ImageryComponent>
+ </ImagerySection>
+ <ImagerySection name="caption">
+ <TextComponent>
+ <Area>
+ <Dim type="LeftEdge" ><ImageDim imageset="TaharezLook" image="NewTitlebarLeft" dimension="Width" /></Dim>
+ <Dim type="TopEdge" ><AbsoluteDim value="0" /></Dim>
+ <Dim type="Width" ><UnifiedDim scale="1" offset="-75" type="Width" /></Dim>
+ <Dim type="Height" ><UnifiedDim scale="1" type="Height" /></Dim>
+ </Area>
+ <ColourProperty name="CaptionColour" />
+ <VertFormat type="CentreAligned" />
+ </TextComponent>
+ </ImagerySection>
+ <StateImagery name="Active">
+ <Layer>
+ <Section section="main" />
+ <Section section="caption" />
+ </Layer>
+ </StateImagery>
+ <StateImagery name="Inactive">
+ <Layer>
+ <Section section="main" />
+ <Section section="caption" />
+ </Layer>
+ </StateImagery>
+ <StateImagery name="Disabled">
+ <Layer>
+ <Section section="main">
+ <Colours topLeft="FF7F7F7F" topRight="FF7F7F7F" bottomLeft="FF7F7F7F" bottomRight="FF7F7F7F" />
+ </Section>
+ <Section section="caption">
+ <Colours topLeft="FF7F7F7F" topRight="FF7F7F7F" bottomLeft="FF7F7F7F" bottomRight="FF7F7F7F" />
+ </Section>
+ </Layer>
+ </StateImagery>
+ </WidgetLook>
+
+ <!--
+ ***************************************************
+ TaharezLook/FrameWindow
+ ***************************************************
+ -->
+ <WidgetLook name="TaharezLook/FrameWindow">
+ <PropertyLinkDefinition name="CaptionColour" widget="__auto_titlebar__" targetProperty="CaptionColour" initialValue="FFFFFFFF" />
+ <PropertyLinkDefinition name="TitlebarFont" widget="__auto_titlebar__" targetProperty="Font" />
+ <Property name="NSSizingCursorImage" value="set:TaharezLook image:MouseNoSoCursor" />
+ <Property name="EWSizingCursorImage" value="set:TaharezLook image:MouseEsWeCursor" />
+ <Property name="NWSESizingCursorImage" value="set:TaharezLook image:MouseNwSeCursor" />
+ <Property name="NESWSizingCursorImage" value="set:TaharezLook image:MouseNeSwCursor" />
+ <NamedArea name="ClientWithTitleWithFrame">
+ <Area>
+ <Dim type="LeftEdge" ><ImageDim imageset="TaharezLook" image="WindowTopLeft" dimension="Width" /></Dim>
+ <Dim type="TopEdge" ><WidgetDim widget="__auto_titlebar__" dimension="BottomEdge" /></Dim>
+ <Dim type="RightEdge" >
+ <UnifiedDim scale="1" type="RightEdge">
+ <DimOperator op="Subtract">
+ <ImageDim imageset="TaharezLook" image="WindowTopRight" dimension="Width" />
+ </DimOperator>
+ </UnifiedDim>
+ </Dim>
+ <Dim type="BottomEdge" >
+ <UnifiedDim scale="1" type="BottomEdge">
+ <DimOperator op="Subtract">
+ <ImageDim imageset="TaharezLook" image="WindowBottomEdge" dimension="Height" />
+ </DimOperator>
+ </UnifiedDim>
+ </Dim>
+ </Area>
+ </NamedArea>
+ <NamedArea name="ClientWithTitleNoFrame">
+ <Area>
+ <Dim type="LeftEdge" ><AbsoluteDim value="0" /></Dim>
+ <Dim type="TopEdge" ><WidgetDim widget="__auto_titlebar__" dimension="BottomEdge" /></Dim>
+ <Dim type="Width" ><UnifiedDim scale="1" type="Width" /></Dim>
+ <Dim type="BottomEdge" ><WidgetDim dimension="BottomEdge" /></Dim>
+ </Area>
+ </NamedArea>
+ <NamedArea name="ClientNoTitleWithFrame">
+ <Area>
+ <Dim type="LeftEdge" ><ImageDim imageset="TaharezLook" image="WindowTopLeft" dimension="Width" /></Dim>
+ <Dim type="TopEdge" ><ImageDim imageset="TaharezLook" image="WindowTopEdge" dimension="Height" /></Dim>
+ <Dim type="RightEdge" >
+ <UnifiedDim scale="1" type="RightEdge">
+ <DimOperator op="Subtract">
+ <ImageDim imageset="TaharezLook" image="WindowTopRight" dimension="Width" />
+ </DimOperator>
+ </UnifiedDim>
+ </Dim>
+ <Dim type="BottomEdge" >
+ <UnifiedDim scale="1" type="BottomEdge">
+ <DimOperator op="Subtract">
+ <ImageDim imageset="TaharezLook" image="WindowBottomEdge" dimension="Height" />
+ </DimOperator>
+ </UnifiedDim>
+ </Dim>
+ </Area>
+ </NamedArea>
+ <NamedArea name="ClientNoTitleNoFrame">
+ <Area>
+ <Dim type="LeftEdge" ><AbsoluteDim value="0" /></Dim>
+ <Dim type="TopEdge" ><AbsoluteDim value="0" /></Dim>
+ <Dim type="Width" ><UnifiedDim scale="1" type="Width" /></Dim>
+ <Dim type="Height" ><UnifiedDim scale="1" type="Height" /></Dim>
+ </Area>
+ </NamedArea>
+ <Child type="TaharezLook/Titlebar" nameSuffix="__auto_titlebar__">
+ <Area>
+ <...
[truncated message content] |
|
From: <psy...@us...> - 2008-03-24 21:30:47
|
Revision: 1909
http://yake.svn.sourceforge.net/yake/?rev=1909&view=rev
Author: psyclonist
Date: 2008-03-24 14:30:20 -0700 (Mon, 24 Mar 2008)
Log Message:
-----------
* added yake::factory template library
* [base] replaced macro "mess" in yakeRegistry.h with yake::factory base implementation
Modified Paths:
--------------
trunk/yake/src/graphics/yakeGraphicsSystem.cpp
trunk/yake/yake/audio/yakeAudioSystem.h
trunk/yake/yake/base/templates/yakeRegistry.h
trunk/yake/yake/graphics/yakeGraphicalWorld.h
trunk/yake/yake/graphics/yakeGraphicsSystem.h
Added Paths:
-----------
trunk/yake/yake/factory/
trunk/yake/yake/factory/config.h
trunk/yake/yake/factory/dynamic_factory.h
trunk/yake/yake/factory/global_dynamic_factory.h
trunk/yake/yake/factory/policies.h
Modified: trunk/yake/src/graphics/yakeGraphicsSystem.cpp
===================================================================
--- trunk/yake/src/graphics/yakeGraphicsSystem.cpp 2008-01-20 21:50:46 UTC (rev 1908)
+++ trunk/yake/src/graphics/yakeGraphicsSystem.cpp 2008-03-24 21:30:20 UTC (rev 1909)
@@ -33,13 +33,10 @@
#include <yake/graphics/yakeEntity.h>
#include <yake/graphics/yakeGeometryAccess.h>
-//============================================================================
-// INTERFACE STRUCTURES / UTILITY CLASSES
-//============================================================================
namespace yake {
namespace graphics {
- YAKE_IMPLEMENT_REGISTRY( IGraphicsSystem );
+ YAKE_IMPLEMENT_REGISTRY(IGraphicsSystem)
/// GraphicsEntity
GraphicsEntity::GraphicsEntity() : mName( uniqueName::create( "graphics" ) )
Modified: trunk/yake/yake/audio/yakeAudioSystem.h
===================================================================
--- trunk/yake/yake/audio/yakeAudioSystem.h 2008-01-20 21:50:46 UTC (rev 1908)
+++ trunk/yake/yake/audio/yakeAudioSystem.h 2008-03-24 21:30:20 UTC (rev 1909)
@@ -153,11 +153,10 @@
*/
class YAKE_AUDIO_API IAudioSystem
{
+ YAKE_DECLARE_REGISTRY_0(IAudioSystem,String)
public:
virtual ~IAudioSystem();
virtual WorldPtr createWorld() = 0;
-
- YAKE_DECLARE_REGISTRY_0( IAudioSystem, yake::String )
};
}
Modified: trunk/yake/yake/base/templates/yakeRegistry.h
===================================================================
--- trunk/yake/yake/base/templates/yakeRegistry.h 2008-01-20 21:50:46 UTC (rev 1908)
+++ trunk/yake/yake/base/templates/yakeRegistry.h 2008-03-24 21:30:20 UTC (rev 1909)
@@ -27,9 +27,6 @@
#ifndef YAKE_BASE_TEMPLATES_REGISTRY_H
#define YAKE_BASE_TEMPLATES_REGISTRY_H
-//============================================================================
-// IMPLEMENTATION HEADERS
-//============================================================================
// Standard headers
#ifndef YAKE_BASEPREREQUISITES_H
#include "yake/base/yakePrerequisites.h"
@@ -38,190 +35,94 @@
#include <yake/base/yakeException.h>
#include <yake/base/templates/yakeSmartAssert.h>
#include <yake/base/templates/yakePointer.h>
-#include <yake/base/templates/yakeManager.h>
-#include <yake/base/mpl/yakeBuildArguments.h>
+#include <yake/factory/global_dynamic_factory.h>
-//============================================================================
-// INTERFACE STRUCTURES / UTILITY CLASSES
-//============================================================================
-namespace yake
-{
-namespace templates
-{
+namespace yake {
+namespace templates {
-/* Helpers */
-#define FUNCTION(number) \
- YAKE_TYPES_ONE_FREE(number) \
- SharedPtr<T> create(typename T::RegistryType::Id id, YAKE_ARGUMENTS_ONE_FREE(number)) \
- { return T::getRegistry().getObject(id)->create(YAKE_USE_ARGUMENTS(number)); }
-YAKE_IMPLEMENT_FUNCTION(FUNCTION)
-#undef FUNCTION
-
-#define FUNCTION(number) \
- YAKE_TYPES_ONE_FREE(number) \
- SharedPtr<T> create_default(YAKE_ARGUMENTS_ONE_FREE(number)) \
- { return T::getRegistry().getDefaultCreator()->create(YAKE_USE_ARGUMENTS(number)); }
-YAKE_IMPLEMENT_FUNCTION(FUNCTION)
-#undef FUNCTION
-
-/* Registry */
-// todo: functors instead of creators
-// todo: if we cannot simplify manager template, remove it
-template <class ConfigClass>
-class Registry : public Manager< typename ConfigClass::Id, SharedPtr< typename ConfigClass::ICreator >, RegisterFunctionsNames >
-{
-YAKE_DECLARE_CLASS( yake::templates::Registry )
-public: // types
- typedef ConfigClass Config;
- typedef typename Config::Base Base;
- typedef typename Config::Id Id;
- typedef typename Config::ICreator ICreator;
-
-public: // constructors
- Registry() : m_pDefaultCreator() {}
-
-private: // no copy
- Registry( const Registry & );
- Registry & operator=( const Registry & );
-
-public: // methods
-#define FUNCTION( number ) \
- YAKE_TYPES( number ) \
- SharedPtr< Base > create( Id id, YAKE_ARGUMENTS_ONE_FREE( number ) ) \
- { return getObject( id )->create( YAKE_USE_ARGUMENTS( number ) ); }
-YAKE_IMPLEMENT_FUNCTION( FUNCTION )
-#undef FUNCTION
-
- SharedPtr< ICreator > getDefaultCreator()
- {
- YAKE_ASSERT( ( Manager< typename ConfigClass::Id, SharedPtr< typename ConfigClass::ICreator>,RegisterFunctionsNames >::getIdentifiers().size() ) > 0 ).debug( "No default creator available." ); // todo: does not work in release mode, should throw exception
- if( !m_pDefaultCreator ) m_pDefaultCreator = getObject( *Manager< typename ConfigClass::Id, SharedPtr< typename ConfigClass::ICreator >, RegisterFunctionsNames >::getIdentifiers().begin() ); // todo: (if(!m_pDefaultCreator) m_pDefaultCreator = front();
- return m_pDefaultCreator;
- }
-
- void setDefaultCreator( const SharedPtr< ICreator > pCreator )
- { m_pDefaultCreator = pCreator; }
-
-private: // data
- SharedPtr< ICreator > m_pDefaultCreator;
-};
-
-
// Note: there already has to be a registry configuration class called RegistryConfig.
// Note: this macro has to be used inside the class declaration.
-#define YAKE_DECLARE_REGISTRY() \
+#define YAKE_DECLARE_REGISTRY_EX(INTERFACE,IDTYPE,PARAMS) \
public: \
- typedef yake::templates::Registry< RegistryConfig > RegistryType; \
- static RegistryType& getRegistry();
+ typedef YAKE_FACTORY_NS::factory<IDTYPE,INTERFACE,SharedPtr<INTERFACE> PARAMS,YAKE_FACTORY_NS::ThrowErrorPolicy,YAKE_FACTORY_NS::SingletonPolicy> factory_t; \
+ typedef factory_t::key_type id_type; \
+ static factory_t& getRegistry();
// Note: you have to use DECLARE_REGISTRY() before.
#define YAKE_IMPLEMENT_REGISTRY( Class ) \
- Class::RegistryType& Class::getRegistry() \
+ Class::factory_t& Class::getRegistry() \
{ \
- static RegistryType* registry_s = 0; \
- if( !registry_s ) registry_s = new RegistryType; \
- return *registry_s; \
+ static factory_t* s_instance = new factory_t(); \
+ return factory_t::instance(); \
}
// Note: this macro has to be used inside the class declaration.
-#define YAKE_DECLARE_CONCRETE( Concrete, id ) \
+#define YAKE_DECLARE_CONCRETE( Concrete, ID ) \
public: \
- static RegistryType::Id getId() \
+ static factory_t::key_type getId() \
{ \
- return id; \
- } \
- static void Register() \
- { \
- getRegistry().doRegister( getId(), yake::SharedPtr< RegistryConfig::ConcreteCreator< Concrete > >( new RegistryConfig::ConcreteCreator< Concrete > ) ); \
+ return ID; \
}
-// getRegistry().doAdd( getId(), yake::SharedPtr< RegistryConfig::ConcreteCreator< Concrete > >::create() ); \ todo
-
// Registers a concrete implementation which has been declared before.
#define YAKE_REGISTER_CONCRETE( Concrete ) \
namespace \
{ \
static struct Concrete##Initor \
{ \
+ typedef Concrete::factory_t factory_t; \
Concrete##Initor() \
{ \
static int counter = 0; \
if( counter++ > 0 ) return; \
- typedef Concrete ConcreteT; \
- ConcreteT::Register(); \
+ Concrete::getRegistry().reg_ctor_smartptr<Concrete>(Concrete::getId()); \
} \
+ ~Concrete##Initor() \
+ { \
+ Concrete::getRegistry().remove(Concrete::getId()); \
+ } \
} g_##Concrete##Initor; \
} // nameless
+ template<typename Interface, typename Kt>
+ inline SharedPtr<Interface> create(const Kt& id)
+ {
+ return SharedPtr<Interface>(Interface::getRegistry().create(id));
+ }
+ template<typename Interface, typename Kt, typename A0>
+ inline SharedPtr<Interface> create(const Kt& id, const A0& a0)
+ {
+ return SharedPtr<Interface>(Interface::getRegistry().create(id,a0));
+ }
+ template<typename Interface>
+ inline SharedPtr<Interface> create_default()
+ {
+ return SharedPtr<Interface>(Interface::getRegistry().create_default());
+ }
+ template<typename Interface, typename A0>
+ inline SharedPtr<Interface> create_default(const A0& a0)
+ {
+ return SharedPtr<Interface>(Interface::getRegistry().create_default(a0));
+ }
+
} // templates
+using templates::create;
+using templates::create_default;
} // yake
// Declares a registry for types with an empty constructor.
#define YAKE_DECLARE_REGISTRY_0(BaseClass, IdClass) \
public: \
- struct RegistryConfig \
- { \
- typedef BaseClass Base; \
- typedef IdClass Id; \
- struct ICreator \
- { \
- virtual yake::SharedPtr< Base > create() = 0; \
- }; \
- template <typename T> \
- struct ConcreteCreator : public ICreator \
- { \
- yake::SharedPtr<Base> create() \
- { return yake::SharedPtr<T>(new T); } \
- }; \
- }; \
- YAKE_DECLARE_REGISTRY()
+ YAKE_DECLARE_REGISTRY_EX(BaseClass, IdClass, ())
- // return yake::SharedPtr< T >::create(); \ Todo
-
-
// Declares a registry for types with a constructor that takes one parameter.
#define YAKE_DECLARE_REGISTRY_1(BaseClass, IdClass, Param1) \
public: \
- struct RegistryConfig \
- { \
- typedef BaseClass Base; \
- typedef IdClass Id; \
- struct ICreator \
- { \
- virtual yake::SharedPtr<Base> create(Param1 p1) = 0; \
- }; \
- template <typename T> \
- struct ConcreteCreator : public ICreator \
- { \
- yake::SharedPtr<Base> create(Param1 p1) \
- { return yake::SharedPtr<T>(new T(p1)); } \
- }; \
- }; \
- YAKE_DECLARE_REGISTRY()
+ YAKE_DECLARE_REGISTRY_EX(BaseClass, IdClass, (Param1))
-// Declares a registry for types with a constructor that takes one parameter.
-#define YAKE_DECLARE_REGISTRY_01(BaseClass, IdClass, Param1) \
+#define YAKE_DECLARE_REGISTRY_2(BaseClass, IdClass, Param1, Param2) \
public: \
- struct RegistryConfig \
- { \
- typedef BaseClass Base; \
- typedef IdClass Id; \
- struct ICreator \
- { \
- virtual yake::SharedPtr<Base> create() = 0; \
- virtual yake::SharedPtr<Base> create(Param1 p1) = 0; \
- }; \
- template <typename T> \
- struct ConcreteCreator : public ICreator \
- { \
- yake::SharedPtr<Base> create() \
- { return yake::SharedPtr<T>(new T()); } \
- \
- yake::SharedPtr<Base> create(Param1 p1) \
- { return yake::SharedPtr<T>(new T(p1)); } \
- }; \
- }; \
- YAKE_DECLARE_REGISTRY()
+ YAKE_DECLARE_REGISTRY_EX(BaseClass, IdClass, (Param1,Param2))
#endif // YAKE_BASE_TEMPLATES_REGISTRY_H
Added: trunk/yake/yake/factory/config.h
===================================================================
--- trunk/yake/yake/factory/config.h (rev 0)
+++ trunk/yake/yake/factory/config.h 2008-03-24 21:30:20 UTC (rev 1909)
@@ -0,0 +1,9 @@
+#ifndef YAKE_FACTORY_CONFIG_H
+#define YAKE_FACTORY_CONFIG_H
+
+#define YAKE_FACTORY_EXCEPTION_BASE std::exception
+#define YAKE_FACTORY_NS ::yake::factory
+#define YAKE_FACTORY_NS_BEGIN() namespace yake { namespace factory {
+#define YAKE_FACTORY_NS_END() }}
+
+#endif
Added: trunk/yake/yake/factory/dynamic_factory.h
===================================================================
--- trunk/yake/yake/factory/dynamic_factory.h (rev 0)
+++ trunk/yake/yake/factory/dynamic_factory.h 2008-03-24 21:30:20 UTC (rev 1909)
@@ -0,0 +1,216 @@
+#ifndef YAKE_FACTORY_DYNAMIC_FACTORY_H
+#define YAKE_FACTORY_DYNAMIC_FACTORY_H
+
+#include "config.h"
+#include "policies.h"
+
+YAKE_FACTORY_NS_BEGIN()
+
+namespace detail {
+
+ template<
+ class X,
+ typename Kt,
+ typename Signature>
+ struct creator;
+
+ template<
+ class X,
+ typename Kt,
+ typename R>
+ struct creator<X,Kt,R()>
+ {
+ typedef boost::function<R()> function_t;
+ typedef R return_t;
+ R create(const Kt& id)
+ {
+ std::cout << "attempt create '" << typeid(X::return_t).name() << "' id='" << id << "' sig='" << typeid(X::signature_t).name() << "'\n";
+ typedef X::Id2Class::const_iterator it_t;
+ const X& x = static_cast<X&>(*this);
+ it_t it = x.id2class_.find(id);
+ if (it == x.id2class_.end())
+ {
+ X::error_t::onError(NotFoundException("creator not registered for id '"+id+"'"));
+ return R();
+ }
+ return (it->second)();
+ }
+ R create_default()
+ {
+ std::cout << "attempt create default sig='" << typeid(X::signature_t).name() << "'\n";
+ typedef X::Id2Class::const_iterator it_t;
+ const X& x = static_cast<X&>(*this);
+ it_t it = x.id2class_.begin();
+ if (it == x.id2class_.end())
+ {
+ X::error_t::onError(NotFoundException("default creator not registered"));
+ return R();
+ }
+ return (it->second)();
+ }
+ };
+
+
+ template<
+ class X,
+ typename Kt,
+ typename R, typename A0>
+ struct creator<X,Kt,R(A0)>
+ {
+ typedef boost::function<R(A0)> function_t;
+ typedef R return_t;
+ R create(const Kt& id, const A0& a0 = A0())
+ {
+ std::cout << "attempt create '" << typeid(X::return_t).name() << "' id='" << id << "' sig='" << typeid(X::signature_t).name() << "'\n";
+ typedef X::Id2Class::const_iterator it_t;
+ const X& x = static_cast<X&>(*this);
+ it_t it = x.id2class_.find(id);
+ if (it == x.id2class_.end())
+ {
+ X::error_t::onError(NotFoundException("creator not registered for id '"+id+"'"));
+ return R();
+ }
+ return (it->second)(a0);
+ }
+ R create_default(const A0& a0 = A0())
+ {
+ std::cout << "attempt create default sig='" << typeid(X::signature_t).name() << "'\n";
+ typedef X::Id2Class::const_iterator it_t;
+ const X& x = static_cast<X&>(*this);
+ it_t it = x.id2class_.begin();
+ if (it == x.id2class_.end())
+ {
+ X::error_t::onError(NotFoundException("default creator not registered"));
+ return R();
+ }
+ return (it->second)(a0);
+ }
+ };
+
+ template<
+ class T,
+ typename Signature>
+ struct new_fn;
+
+ template<
+ class T,
+ typename R>
+ struct new_fn<T,R()>
+ {
+ R* operator()()
+ {
+ return Holder(new T());
+ }
+ };
+
+ template<
+ class T,
+ typename R,
+ typename A0>
+ struct new_fn<T,R(A0)>
+ {
+ R* operator()(const A0& a0)
+ {
+ return Holder(new T(a0));
+ }
+ };
+
+
+ template<
+ class T,
+ typename Holder,
+ typename Signature>
+ struct new_fn_h;
+
+ template<
+ class T,
+ typename Holder,
+ typename R>
+ struct new_fn_h<T,Holder,R()>
+ {
+ Holder operator()()
+ {
+ return Holder(new T());
+ }
+ };
+
+ template<
+ class T,
+ typename Holder,
+ typename R,
+ typename A0>
+ struct new_fn_h<T,Holder,R(A0)>
+ {
+ Holder operator()(const A0& a0)
+ {
+ return Holder(new T(a0));
+ }
+ };
+} // namespace detail
+
+
+/**
+ @note No virtual destructors use, so do not delete via pointer-to-base!
+ @param Kt key type aka ids for registered creators/products
+ @param Interface product base interface/class
+ @param Signature Signature of the creator objects/functions (e.g. MyInterface*(int,const string&))
+ @param ErrorPolicy Error handling can be configured (default: NoThrowErrorPolicy).
+ @param InstancePolicy Factory instance policy can be configured (default: NoInstancePolicy).
+*/
+template<
+ typename Kt,
+ class Interface,
+ typename Signature,
+ class ErrorPolicy = NoThrowErrorPolicy,
+ template<class> class InstancePolicy = NoInstancePolicy
+ /*,template<class,typename,typename> class CreatorType = detail::creator*/>
+struct factory :
+ public InstancePolicy<factory<Kt,Interface,Signature,ErrorPolicy,InstancePolicy> >,
+ public detail::creator<factory<Kt,Interface,Signature,ErrorPolicy,InstancePolicy>,Kt,Signature >
+{
+ typedef Kt key_type;
+ typedef Interface interface_t;
+ typedef ErrorPolicy error_t;
+ typedef Signature signature_t;
+
+ typedef detail::creator<factory<Kt,Interface,Signature,ErrorPolicy,InstancePolicy>,Kt,Signature > creator_t;
+ friend struct creator_t;
+ typedef typename creator_t::function_t function_t;
+ typedef typename creator_t::return_t return_t;
+ //using creator_t::create;
+
+ template<typename Handler0>
+ void reg(const key_type& id, Handler0 h0)
+ {
+ std::cout << "reg '" << id << "'\n";
+ id2class_[ id ] = function_t(h0);
+ }
+
+ template<typename ProductT>
+ void reg_ctor(const key_type& id)
+ {
+ detail::new_fn<ProductT,,Signature> c_t;
+ reg(id,c_t);
+ }
+
+ template<typename ProductT>
+ void reg_ctor_smartptr(const key_type& id)
+ {
+ detail::new_fn_h<ProductT,return_t,Signature> c_t;
+ reg(id,c_t);
+ }
+
+ void remove(const key_type& id)
+ {
+ Id2Class::iterator it = id2class_.find(id);
+ if (it != id2class_.end())
+ id2class_.erase(it);
+ }
+private:
+ typedef std::map<key_type,function_t> Id2Class;
+ Id2Class id2class_;
+};
+
+YAKE_FACTORY_NS_END()
+
+#endif
Added: trunk/yake/yake/factory/global_dynamic_factory.h
===================================================================
--- trunk/yake/yake/factory/global_dynamic_factory.h (rev 0)
+++ trunk/yake/yake/factory/global_dynamic_factory.h 2008-03-24 21:30:20 UTC (rev 1909)
@@ -0,0 +1,134 @@
+#ifndef YAKE_FACTORY_GLOBAL_DYNAMIC_FACTORY_H
+#define YAKE_FACTORY_GLOBAL_DYNAMIC_FACTORY_H
+
+#include "config.h"
+#include "policies.h"
+#include "dynamic_factory.h"
+
+YAKE_FACTORY_NS_BEGIN()
+
+
+template<typename Interface>
+struct global_interface_traits
+{
+ typedef Interface*(signature_t)();
+ typedef boost::shared_ptr<Interface> holder_t;
+};
+
+/** Do NOT directly use this interface... */
+template<class Interface>
+struct global_factory
+{
+ typedef std::string key_type;
+ typedef typename global_interface_traits<Interface>::signature_t signature_t;
+ typedef yake::factory::factory<key_type,Interface,signature_t,NoThrowErrorPolicy,SingletonPolicy> factory_t;
+
+ //typedef typename factory_t::holder_t holder_t;
+ typedef typename global_interface_traits<Interface>::holder_t holder_t;
+
+ static factory_t& instance()
+ {
+ return factory_t::instance();
+ }
+ template<class Interface, class ConcreteT, typename CreatorFn>
+ void reg_product(const key_type& id, CreatorFn fn)
+ {
+ instance().reg(id,fn);
+ }
+
+ template<typename Interface, typename Kt>
+ holder_t create(const Kt& id)
+ {
+ return instance().create(id);
+ }
+ template<typename Interface, typename Kt, typename A0>
+ holder_t create(const Kt& id, const A0& a0)
+ {
+ return instance().create(id,a0);
+ }
+};
+
+template<class Interface, class Kt>
+typename global_interface_traits<Interface>::holder_t create(const Kt& id)
+{
+ typedef typename global_interface_traits<Interface>::holder_t holder_t;
+ return holder_t(global_factory<Interface>::instance().create(id));
+}
+template<class Interface, class Kt, typename A0>
+typename global_interface_traits<Interface>::holder_t create(const Kt& id, const A0& a0)
+{
+ typedef typename global_interface_traits<Interface>::holder_t holder_t;
+ return holder_t(global_factory<Interface>::instance().create(id,a0));
+}
+
+////////////////////////////////////////////////////////////////
+// Found in Dr.Dobb's: http://www.ddj.com/cpp/184401206 //
+// Modifications: //
+// added YAKE_ prefix //
+// //
+// //
+//////////////////// UtilityMacros.h ///////////////// rado ////
+// //
+// Copyright (c) 1999 Radoslav Getov //
+// //
+// Permission to use, copy, modify and distribute this //
+// software is granted without fee, provided that the above //
+// copyright notice and this permission notice appear in the //
+// modified source and the source files that #include it. //
+// //
+////////////////////////////////////////////////////////////////
+// //
+#define YAKE_UNIQUE_NAME_1(prefix, x) prefix##x
+#define YAKE_UNIQUE_NAME_2(prefix, x) YAKE_UNIQUE_NAME_1 (prefix, x)
+#define YAKE_UNIQUE_NAME_WP(prefix) YAKE_UNIQUE_NAME_2 (prefix, __LINE__)
+#define YAKE_UNIQUE_NAME YAKE_UNIQUE_NAME_WP(uniqueNameOnLine_)
+#define YAKE_UNIQUE_NAME2 YAKE_UNIQUE_NAME_WP(uniqueNameOnLine2_)
+// //
+////////////////////////////////////////////////////////////////
+
+// Shortcuts for registering global products:
+// YAKE_REGISTER_GLOBAL_PRODUCT
+// YAKE_REGISTER_GLOBAL_PRODUCT1
+
+#define YAKE_REGISTER_GLOBAL_PRODUCT(INTERFACE,PRODUCT,ID,CREATORFN) \
+namespace { \
+struct YAKE_UNIQUE_NAME \
+{ \
+ YAKE_UNIQUE_NAME() \
+ { \
+ YAKE_FACTORY_NS::global_factory<INTERFACE>::instance().reg(ID,boost::bind(CREATORFN)); \
+ } \
+} YAKE_UNIQUE_NAME2; \
+}
+#define YAKE_REGISTER_GLOBAL_PRODUCT1(INTERFACE,PRODUCT,ID,CREATORFN) \
+namespace { \
+struct YAKE_UNIQUE_NAME \
+{ \
+ YAKE_UNIQUE_NAME() \
+ { \
+ YAKE_FACTORY_NS::global_factory<INTERFACE>::instance().reg(ID,boost::bind(CREATORFN,_1)); \
+ } \
+} YAKE_UNIQUE_NAME2; \
+}
+
+// Shortcuts for registering global factories:
+// YAKE_REGISTER_GLOBAL_FACTORY_EX
+// YAKE_REGISTER_GLOBAL_FACTORY
+
+#define YAKE_REGISTER_GLOBAL_FACTORY_EX(INTERFACE,RETURNTYPE,PARAMS,HOLDER) \
+ YAKE_FACTORY_NS_BEGIN() \
+ template<> \
+ struct global_interface_traits<INTERFACE> \
+ { \
+ typedef RETURNTYPE(signature_t)PARAMS; \
+ typedef HOLDER holder_t; \
+ }; \
+ YAKE_FACTORY_NS_END()
+
+#define YAKE_REGISTER_GLOBAL_FACTORY(INTERFACE,PARAMS) \
+ YAKE_REGISTER_GLOBAL_FACTORY_EX(INTERFACE,INTERFACE *,PARAMS,boost::shared_ptr<INTERFACE>)
+
+
+YAKE_FACTORY_NS_END()
+
+#endif
Added: trunk/yake/yake/factory/policies.h
===================================================================
--- trunk/yake/yake/factory/policies.h (rev 0)
+++ trunk/yake/yake/factory/policies.h 2008-03-24 21:30:20 UTC (rev 1909)
@@ -0,0 +1,70 @@
+#ifndef YAKE_FACTORY_POLICIES_H
+#define YAKE_FACTORY_POLICIES_H
+
+#include "config.h"
+#include <string>
+#include <iostream> // for the std::cerr (used in error policies)
+#include <map>
+#include <exception>
+#include <boost/shared_ptr.hpp>
+#include <boost/function.hpp>
+#include <boost/bind.hpp>
+
+YAKE_FACTORY_NS_BEGIN()
+
+
+// Exceptions
+
+struct Exception : public std::exception
+{
+ Exception(const std::string& msg) : msg_(msg)
+ {}
+ virtual const char* what() const
+ {
+ return msg_.c_str();
+ }
+private:
+ std::string msg_;
+};
+typedef Exception NotFoundException;
+
+// Error Policies
+
+struct NoThrowErrorPolicy
+{
+ template<typename Et>
+ static void onError(const Et& ex)
+ {
+ std::cerr << "ERROR: " << ex.what() << "\n";
+ }
+};
+struct ThrowErrorPolicy
+{
+ template<typename Et>
+ static void onError(const Et& ex)
+ {
+ std::cerr << "ERROR: " << ex.what() << "\n";
+ throw ex;
+ }
+};
+
+// Instance Policies
+
+template<class X>
+struct NoInstancePolicy
+{
+};
+
+template<class X>
+struct SingletonPolicy
+{
+ static X& instance()
+ {
+ static X s_instance;
+ return s_instance;
+ }
+};
+
+YAKE_FACTORY_NS_END()
+
+#endif
Modified: trunk/yake/yake/graphics/yakeGraphicalWorld.h
===================================================================
--- trunk/yake/yake/graphics/yakeGraphicalWorld.h 2008-01-20 21:50:46 UTC (rev 1908)
+++ trunk/yake/yake/graphics/yakeGraphicalWorld.h 2008-03-24 21:30:20 UTC (rev 1909)
@@ -470,7 +470,6 @@
class YAKE_GRAPHICS_INTERFACE_API IFx
{
- YAKE_DECLARE_REGISTRY_01(IFx, String, IWorld&);
public:
virtual ~IFx() {}
};
@@ -478,5 +477,7 @@
} // graphics
} // yake
+YAKE_REGISTER_GLOBAL_FACTORY( yake::graphics::IFx, (yake::graphics::IWorld&) )
+
#endif // YAKE_GRAPHICALWORLD_H
Modified: trunk/yake/yake/graphics/yakeGraphicsSystem.h
===================================================================
--- trunk/yake/yake/graphics/yakeGraphicsSystem.h 2008-01-20 21:50:46 UTC (rev 1908)
+++ trunk/yake/yake/graphics/yakeGraphicsSystem.h 2008-03-24 21:30:20 UTC (rev 1909)
@@ -76,7 +76,7 @@
{
typedef AssocVector<String, String> ParamMap;
- YAKE_DECLARE_REGISTRY_01(IGraphicsSystem, String, ParamMap);
+ YAKE_DECLARE_REGISTRY_1(IGraphicsSystem, String, ParamMap);
virtual ~IGraphicsSystem();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <psy...@us...> - 2008-03-24 21:31:34
|
Revision: 1910
http://yake.svn.sourceforge.net/yake/?rev=1910&view=rev
Author: psyclonist
Date: 2008-03-24 14:31:15 -0700 (Mon, 24 Mar 2008)
Log Message:
-----------
* [vehicle] fixed GenericVehicle::setSteering()
Modified Paths:
--------------
trunk/yake/src/vehicle/yakeNativeOde.cpp
trunk/yake/yake/vehicle/yakeNativeOde.h
Modified: trunk/yake/src/vehicle/yakeNativeOde.cpp
===================================================================
--- trunk/yake/src/vehicle/yakeNativeOde.cpp 2008-03-24 21:30:20 UTC (rev 1909)
+++ trunk/yake/src/vehicle/yakeNativeOde.cpp 2008-03-24 21:31:15 UTC (rev 1910)
@@ -424,12 +424,16 @@
newVal = -1.;
else if (newVal > 1.)
newVal = 1.;
- ConstVectorIterator< Deque<OdeWheel*> > itWheel( mSteeringGroups[ sg ] );
- while (itWheel.hasMoreElements())
+ SteeringGroupList::const_iterator itSG = mSteeringGroups.find(sg);
+ YAKE_ASSERT( itSG != mSteeringGroups.end() )(sg).debug("steering group not found");
+ if ( itSG != mSteeringGroups.end() )
{
- OdeWheel* pW = itWheel.getNext();
- YAKE_ASSERT( pW );
- pW->setSteering( newVal );
+ YAKE_FOR_EACH(Deque<OdeWheel*>::const_iterator, itWheel, itSG->second)
+ {
+ OdeWheel* pW = *itWheel;
+ YAKE_ASSERT( pW );
+ pW->setSteering( newVal );
+ }
}
}
real GenericVehicle::getSteering( const uint32 sg ) const
Modified: trunk/yake/yake/vehicle/yakeNativeOde.h
===================================================================
--- trunk/yake/yake/vehicle/yakeNativeOde.h 2008-03-24 21:30:20 UTC (rev 1909)
+++ trunk/yake/yake/vehicle/yakeNativeOde.h 2008-03-24 21:31:15 UTC (rev 1910)
@@ -126,7 +126,7 @@
physics::IActorPtr mpChassis;
- typedef AssocVector<uint32,Deque<OdeWheel*> > SteeringGroupList;
+ typedef std::map<uint32,Deque<OdeWheel*> > SteeringGroupList;
SteeringGroupList mSteeringGroups;
typedef std::pair<ICarEngine*,Deque<OdeWheel*> > CarEngineWheelsPair;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <psy...@us...> - 2008-03-30 22:43:05
|
Revision: 1911
http://yake.svn.sourceforge.net/yake/?rev=1911&view=rev
Author: psyclonist
Date: 2008-03-30 15:43:07 -0700 (Sun, 30 Mar 2008)
Log Message:
-----------
* [base] fixed registry for 2 parameters
* [gui2] added experimental gui library (Yake license / LGPL)
Modified Paths:
--------------
trunk/yake/yake/base/templates/yakeRegistry.h
trunk/yake/yake/factory/dynamic_factory.h
Added Paths:
-----------
trunk/yake/src/gui2/
trunk/yake/src/gui2/layout/
trunk/yake/src/gui2/mutator.cpp
trunk/yake/src/gui2/plugins/
trunk/yake/src/gui2/plugins/renderer.ogre/
trunk/yake/src/gui2/plugins/renderer.ogre/renderer.ogre.cpp
trunk/yake/src/gui2/plugins/renderer.ogre/renderer.ogre.h
trunk/yake/src/gui2/plugins/renderer.opengl/
trunk/yake/src/gui2/plugins/style.lua/
trunk/yake/src/gui2/plugins/style.lua/style.lua.cpp
trunk/yake/src/gui2/plugins/style.lua/style.lua.h
trunk/yake/src/gui2/plugins/system.ogreois/
trunk/yake/src/gui2/plugins/system.ogreois/ogre_ois.cpp
trunk/yake/src/gui2/plugins/system.ogreois/ogre_ois.h
trunk/yake/src/gui2/plugins/window_manager.2d/
trunk/yake/src/gui2/plugins/window_manager.2d/window_manager.2d.cpp
trunk/yake/src/gui2/renderer.cpp
trunk/yake/src/gui2/system.cpp
trunk/yake/src/gui2/widget/
trunk/yake/src/gui2/widget/button.cpp
trunk/yake/src/gui2/widget/dialog.cpp
trunk/yake/src/gui2/widget/panel.cpp
trunk/yake/src/gui2/widget/static_text.cpp
trunk/yake/src/gui2/widget/text_edit.cpp
trunk/yake/src/gui2/widget/titlebar.cpp
trunk/yake/src/gui2/widget.cpp
trunk/yake/src/gui2/window_manager.cpp
trunk/yake/yake/gui2/
trunk/yake/yake/gui2/font.h
trunk/yake/yake/gui2/gui.h
trunk/yake/yake/gui2/input_provider.h
trunk/yake/yake/gui2/layout/
trunk/yake/yake/gui2/layout/hbox.h
trunk/yake/yake/gui2/layout/vbox.h
trunk/yake/yake/gui2/layout.h
trunk/yake/yake/gui2/mutator.cpp
trunk/yake/yake/gui2/mutator.h
trunk/yake/yake/gui2/plugins/
trunk/yake/yake/gui2/plugins/renderer.ogre/
trunk/yake/yake/gui2/plugins/renderer.ogre/renderer.ogre.cpp
trunk/yake/yake/gui2/plugins/renderer.ogre/renderer.ogre.h
trunk/yake/yake/gui2/plugins/renderer.opengl/
trunk/yake/yake/gui2/plugins/style.lua/
trunk/yake/yake/gui2/plugins/style.lua/style.lua.cpp
trunk/yake/yake/gui2/plugins/style.lua/style.lua.h
trunk/yake/yake/gui2/plugins/system.ogreois/
trunk/yake/yake/gui2/plugins/system.ogreois/ogre_ois.cpp
trunk/yake/yake/gui2/plugins/system.ogreois/ogre_ois.h
trunk/yake/yake/gui2/prerequisites.h
trunk/yake/yake/gui2/renderer.cpp
trunk/yake/yake/gui2/renderer.h
trunk/yake/yake/gui2/style.h
trunk/yake/yake/gui2/system.cpp
trunk/yake/yake/gui2/system.h
trunk/yake/yake/gui2/types.h
trunk/yake/yake/gui2/widget/
trunk/yake/yake/gui2/widget/button.cpp
trunk/yake/yake/gui2/widget/button.h
trunk/yake/yake/gui2/widget/dialog.cpp
trunk/yake/yake/gui2/widget/dialog.h
trunk/yake/yake/gui2/widget/panel.cpp
trunk/yake/yake/gui2/widget/panel.h
trunk/yake/yake/gui2/widget/static_text.cpp
trunk/yake/yake/gui2/widget/static_text.h
trunk/yake/yake/gui2/widget/text_edit.cpp
trunk/yake/yake/gui2/widget/text_edit.h
trunk/yake/yake/gui2/widget/titlebar.cpp
trunk/yake/yake/gui2/widget/titlebar.h
trunk/yake/yake/gui2/widget.cpp
trunk/yake/yake/gui2/widget.h
trunk/yake/yake/gui2/window_manager.cpp
trunk/yake/yake/gui2/window_manager.h
Added: trunk/yake/src/gui2/mutator.cpp
===================================================================
--- trunk/yake/src/gui2/mutator.cpp (rev 0)
+++ trunk/yake/src/gui2/mutator.cpp 2008-03-30 22:43:07 UTC (rev 1911)
@@ -0,0 +1,85 @@
+#include "yake/gui2/mutator.h"
+#include "yake/gui2/widget.h"
+
+namespace yake {
+namespace ui {
+ //-----------------------------------------------------
+ YAKE_IMPLEMENT_REGISTRY(MutatorBase)
+ //-----------------------------------------------------
+ void MutatorBase::_setOwner(Widget* owner)
+ {
+ owner_ = owner;
+ }
+ void MutatorBase::update(const real dt)
+ {
+ this->onUpdate(dt);
+ }
+ void MutatorBase::destroy()
+ {
+ assert( !dead_ );
+ if (!dead_)
+ {
+ dead_ = true;
+ if (getOwner())
+ getOwner()->_remove(this);
+ // If the "_remove" operation was successful then this mutator is dead!
+ // That is, it has been destroyed!
+ // Reason: The owner has ownership of this mutator (via shared_ptr).
+ }
+ }
+ //-----------------------------------------------------
+ struct MutatorMove : public MutatorBase
+ {
+ YAKE_DECLARE_CONCRETE(MutatorMove,"move")
+ public:
+ MutatorMove(const vector2& velocity) : vel_(velocity)
+ {}
+ private:
+ virtual void onUpdate(const real dt)
+ {
+ assert( getOwner() );
+ getOwner()->setPosition( getOwner()->getPosition() + vel_ * dt );
+ }
+ private:
+ vector2 vel_;
+ };
+ //-----------------------------------------------------
+ struct MutatorMoveTo : public MutatorBase
+ {
+ YAKE_DECLARE_CONCRETE(MutatorMoveTo,"moveTo")
+ public:
+ MutatorMoveTo(const Position& targetPos, const real minSpeed = 0.05, const real factor = 0.99) :
+ targetPos_(targetPos),
+ minSpeed_(minSpeed),
+ factor_(factor)
+ {}
+ private:
+ virtual void onUpdate(const real dt)
+ {
+ assert( getOwner() );
+ vector2 diff = targetPos_ - getOwner()->getPosition();
+ if (diff.length() < 1.)
+ {
+ getOwner()->setPosition( targetPos_ );
+
+ // self-destruct!
+ this->destroy();
+
+ return;
+ }
+ vector2 delta = factor_ * diff * dt;
+ if (delta.length() < minSpeed_ && !delta.isNull())
+ {
+ //std::cout << "min speed\n";
+ delta /= delta.length();
+ delta *= minSpeed_;
+ }
+ getOwner()->setPosition( getOwner()->getPosition() + delta );
+ }
+ private:
+ Position targetPos_;
+ real minSpeed_;
+ real factor_;
+ };
+} // namespace ui
+} // namespace yake
Added: trunk/yake/src/gui2/plugins/renderer.ogre/renderer.ogre.cpp
===================================================================
--- trunk/yake/src/gui2/plugins/renderer.ogre/renderer.ogre.cpp (rev 0)
+++ trunk/yake/src/gui2/plugins/renderer.ogre/renderer.ogre.cpp 2008-03-30 22:43:07 UTC (rev 1911)
@@ -0,0 +1,1044 @@
+
+// UI core
+#include "yake/gui2/system.h"
+#include "yake/gui2/window_manager.h"
+#include "yake/gui2/renderer.h"
+#include "yake/gui2/font.h"
+
+// UI Ogre Renderer
+#include "yake/gui2/plugins/renderer.ogre/renderer.ogre.h"
+#include <boost/array.hpp>
+
+// Boost
+#include <boost/algorithm/string.hpp>
+#include <boost/lexical_cast.hpp>
+
+// OGRE
+#include "Ogre.h"
+#include "OgreFontManager.h"
+
+namespace yake {
+namespace ui {
+ struct FaceVertex {
+ float x, y, z; //!< The position for the vertex.
+ Ogre::uint32 diffuse; //!< colour of the vertex
+ float tu0, tv0; //!< texture coordinates
+ };
+ struct Face
+ {
+ Ogre::TexturePtr pTex0;
+ FaceVertex vtx[4];
+ };
+
+#define FACELIST_MULTISET 1
+#define FACELIST_DEQUE 2
+#define FACELIST_TYPE FACELIST_DEQUE
+
+#if FACELIST_TYPE == FACELIST_DEQUE
+ typedef std::vector<Face> FaceList;
+ void addFace(FaceList& faces, const Face& f)
+ {
+ faces.push_back(f);
+ }
+#elif FACELIST_TYPE == FACELIST_MULTISET
+ typedef std::multiset<Face> FaceList;
+ void addFace(FaceList& faces, const Face& f)
+ {
+ faces.insert(f);
+ }
+#endif
+
+ /** Wraps initialisation and shutdown of OGRE. */
+ struct GraphicsCore : public boost::noncopyable
+ {
+ GraphicsCore();
+ ~GraphicsCore();
+
+ void start();
+ void stop();
+ void frame();
+
+ Ogre::SceneManager* _getSceneMgr() const
+ { return sceneMgr_; }
+ Ogre::RenderWindow* _getWindow() const
+ { return window_; }
+ private:
+ vector2 scrSize_;
+ Ogre::Root* root_;
+ Ogre::Camera* cam_;
+ Ogre::SceneManager* sceneMgr_;
+ Ogre::RenderWindow* window_;
+
+ void _setupResources();
+ };
+
+ struct WidgetRenderable : public IRenderableGeometry
+ {
+ FaceList faces;
+
+ typedef boost::shared_ptr<WidgetRenderable> pointer;
+ typedef boost::weak_ptr<WidgetRenderable> weak_ptr;
+
+ virtual void clear()
+ {
+ faces.clear();
+ }
+ };
+
+ struct OgreSystem : public ISystem
+ {
+ YAKE_DECLARE_CONCRETE(OgreSystem,"yake.ogre")
+ public:
+ OgreSystem();
+ ~OgreSystem() {}
+ virtual void start();
+ virtual void stop();
+ virtual FontPtr createFont(const string& id, const string& name, const real size);
+ //FontPtr getOrCreateFont(const string& id, const string& name, const real size);
+ virtual FontPtr getFont(const string& id) const;
+ virtual WindowRendererPtr getRenderer() const;
+ private:
+ typedef std::map<string,FontPtr> NamedFonts;
+ NamedFonts fonts_;
+
+ WindowRendererPtr renderer_;
+ std::auto_ptr<GraphicsCore> core_;
+ };
+ YAKE_REGISTER_CONCRETE(OgreSystem);
+
+ /** @todo Provide IFont and move impl out AND use IWindowRenderer interface!! */
+ struct Font : public IFont
+ {
+ public:
+ /** @exception NotFoundException Thrown if font file/definition cannot be found.
+ @exception IOException Thrown if setup of font fails.
+ @exception InvalidInputException Thrown if renderer passed is not valid.
+ */
+ Font(const string& name, WindowRendererPtr, const real size);
+
+ real getHeight() const;
+
+ real getLineSpacing() const;
+
+ AbsSize getTextSize(const string&) const;
+
+ // positions and dimensions of all rendered characters.
+ //typedef std::deque<std::pair<Position,AbsSize> > RenderInfo;
+ /**
+ @param text
+ May contain additional colouring formatting!
+ @param pos
+ Position in screen coordinates (top left border of the clip to draw).
+ */
+ //void render(const string& text, const Position&, const AbsSize& clipRect, const AbsSize& fmtRect, const TextFormatting, const WordWrapping);
+ //void render(const string& text, const Position&, const AbsSize& clipRect, const AbsSize& fmtRect, const TextFormatting, const WordWrapping, RenderInfo& outInfo);
+ void render(const string& text, const Position&, const Rectangle& clipRect,const colour& clr, const real z);
+ private:
+
+ WindowRendererPtr renderer_;
+ string name_;
+ real size_;
+ //boost::shared_ptr<FTGLPixmapFont> font_;
+ Ogre::Font* font_;
+ string materialName_;
+ };
+
+
+
+ Font::Font(const string& name, WindowRendererPtr renderer, const real size) : name_(name), renderer_(renderer), size_(size), font_(0)
+ {
+ Ogre::FontManager::ResourceCreateOrRetrieveResult succ = Ogre::FontManager::getSingleton().createOrRetrieve("BlueHighway","Default");
+ Ogre::FontPtr font = succ.first;
+ font->load();
+ assert( (font.get()!=0) && "failed to create or retrieve font" );
+ const Ogre::MaterialPtr& material = font->getMaterial();
+ assert( material.get() && "font material not (yet?) loaded" );
+ //materialName_ = material->getName();
+ //materialName_ = "BlueHighwayTexture";
+ materialName_ = font->getName() + "Texture";
+ font_ = font.get();
+ //material->setSceneBlending( Ogre::SBF_SOURCE_ALPHA, Ogre::SBF_ONE_MINUS_SOURCE_ALPHA );
+ //material->setSceneBlending( Ogre::SBF_SOURCE_COLOUR, Ogre::SBF_ZERO );
+ }
+ typedef boost::array<Position,4> Quadrangle;
+ /*
+ void clip(const Rectangle& clip, const Quadrangle& inV, Quadrangle& outV)
+ {
+ for (size_t i=0; i<4; ++i)
+ {
+ const Position& thisPos = inV[i];
+ const size_t nextI = (i == 3) ? 0 : (i+1);
+ const Position& nextPos = inV[nextI];
+
+ const bool thisIn = clip.containsPoint(thisPos);
+ const bool nextIn = clip.containsPoint(nextPos);
+ if (!
+ }
+ }
+ */
+ real Font::getHeight() const
+ {
+ return size_;
+ }
+ real Font::getLineSpacing() const
+ {
+ return 1.1 * size_;
+ }
+ AbsSize Font::getTextSize(const string& text) const
+ {
+ assert( font_ );
+
+ vector2 maxSize(0,0);
+
+ const vector2 scale(size_,size_);
+
+ // split text into lines
+ StringVector lines;
+ StringUtil::split(lines, text, "\n");
+
+ // for each line:
+ Position currLineStartPos(0,0);
+ for (StringVector::const_iterator it = lines.begin(); it != lines.end(); ++it)
+ {
+ const string& line = *it;
+ Position currPos(currLineStartPos);
+
+ // for each character:
+ for (string::const_iterator itC = line.begin(); itC != line.end(); ++itC)
+ {
+ const char c = *itC;
+
+ //@todo test for 32 ' '
+ Ogre::Font::GlyphInfo gi(c,Ogre::Font::UVRect(0,0,0,0),1.);
+ if (c == ' ')
+ gi.aspectRatio = .5; //@todo hack - replace with correct 'space' rendering
+ else
+ {
+ try {
+ gi = font_->getGlyphInfo(c);
+ }
+ catch (Ogre::Exception&)
+ {
+ assert( false && "failed to acquire glyph information for this character/code point" );
+ }
+ }
+
+ const Position topLeft(currPos.x,currPos.y);
+ //const vector2 size(scale.x*gi.aspectRatio, scale.y);
+ const vector2 size(scale.y*gi.aspectRatio, scale.y);
+
+ // next character
+ //currPos.x += size.x;
+ currPos.x += real(int(size.x)+1); // round to full pixels, then convert
+ }
+
+ //
+ if (currPos.x > maxSize.x)
+ maxSize.x = currPos.x;
+
+ // prepare for next line:
+ currLineStartPos.y += scale.y/* * 1.5*/;
+ }
+ maxSize.y = currLineStartPos.y;
+
+ return maxSize;
+ }
+ void Font::render(const string &text, const Position& pos, const Rectangle &clipRect,const colour& clr, const real z)
+ {
+ assert( font_ );
+ assert( renderer_ );
+
+ colour currClr(clr);
+
+ //const vector2 scale(12. * 4./3.,12.); //@todo original ".font" aspect ratio is not always 4/3 tsk tsk
+ const vector2 scale(size_,size_);
+
+ renderer_->pushMaterial(materialName_);
+
+ // split text into lines
+ StringVector lines;
+ StringUtil::split(lines, text, "\n");
+
+ // for each line:
+ Position currLineStartPos(pos);
+ for (StringVector::const_iterator it = lines.begin(); it != lines.end(); ++it)
+ {
+ const string& line = *it;
+ Position currPos(currLineStartPos);
+
+ // for each character:
+ for (string::const_iterator itC = line.begin(); itC != line.end(); ++itC)
+ {
+ const char c = *itC;
+
+ if (c == '\\')
+ {
+ if (itC == line.end()-1)
+ ; // just continue - the last character is really a '\'
+ else // more characters follow. let's see whether it's a control character:
+ {
+ const char cmd = *(itC + 1);
+ switch (cmd)
+ {
+ case 'c': // colour:
+ {
+ itC += 2;
+ assert( itC != line.end() && "unexpected end of command 'c'" );
+ if (itC == line.end())
+ continue;
+ assert( (*itC == '{') && "expected begin of parameters '{'" );
+ ++itC;
+ const std::string::size_type from = itC - line.begin();
+ std::string::size_type pos = line.find('}', from);
+ assert( (pos != std::string::npos) && "no parameter end marker '}' found" );
+ std::string paramString = line.substr( from, (pos-from) );
+ itC += (pos-from); // do not forget!
+
+ std::vector<std::string> params;
+ split(params,paramString,boost::is_any_of(",;"),boost::token_compress_on);
+ if (params.size() == 1)
+ {
+ // named colours:
+ static std::map<std::string,colour> s_namedColours;
+ if (s_namedColours.empty())
+ {
+ s_namedColours["white"] = colour(1,1,1);
+ s_namedColours["black"] = colour(0,0,0);
+ s_namedColours["gray"] = colour(.7,.7,.7);
+ s_namedColours["red"] = colour(1,0,0);
+ s_namedColours["blue"] = colour(0,0,1);
+ s_namedColours["green"] = colour(0,1,0);
+ }
+ std::map<std::string,colour>::const_iterator itColour = s_namedColours.find(params.at(0));
+ assert( (itColour != s_namedColours.end()) && "unknown named colour" );
+ if (itColour != s_namedColours.end())
+ currClr = itColour->second;
+ }
+ //
+ continue; // go to next valid (printable) character or start of control character.
+ }
+ break;
+ default:
+ break; // just continue - treat as a '\', it's not a known command. @todo print error?
+ };
+ }
+ }
+
+ //@todo test for 32 ' '
+ Ogre::Font::GlyphInfo gi(c,Ogre::Font::UVRect(0,0,0,0),1.);
+ if (c == ' ')
+ gi.aspectRatio = .5; //@todo hack - replace with correct 'space' rendering
+ else
+ {
+ try {
+ gi = font_->getGlyphInfo(c);
+ }
+ catch (Ogre::Exception&)
+ {
+ assert( false && "failed to acquire glyph information for this character/code point" );
+ }
+ }
+
+ const Position topLeft(currPos.x,currPos.y);
+ //const vector2 size(scale.x*gi.aspectRatio, scale.y);
+ const vector2 size(scale.y*gi.aspectRatio, scale.y);
+
+ /*
+ Quadrangle verts;
+ verts[0] = topLeft;
+ verts[1] = topLeft + vector2(0,size.y);
+ verts[2] = topLeft + size;
+ verts[3] = topLeft + vector2(size.x,0);
+ Quadrangle clipped;
+ clip(clipRect,verts,clipped);
+ */
+ Quadrangle clipped;
+ clipped[0] = topLeft;
+ clipped[1] = topLeft + vector2(0,size.y);
+ clipped[2] = topLeft + size;
+ clipped[3] = topLeft + vector2(size.x,0);
+
+ renderer_->quad2duv(clipped[0], clipped[1], clipped[2], clipped[3],
+ vector2(gi.uvRect.left,gi.uvRect.top), // top left
+ vector2(gi.uvRect.left,gi.uvRect.bottom),
+ vector2(gi.uvRect.right,gi.uvRect.bottom),
+ vector2(gi.uvRect.right,gi.uvRect.top),
+ currClr,
+ z
+ );
+
+ // next character
+ //currPos.x += size.x;
+ currPos.x += real(int(size.x)+1); // round to full pixels, then convert
+ }
+
+ // prepare for next line:
+ currLineStartPos.y += scale.y/* * 1.5*/;
+ }
+
+ renderer_->popMaterial();
+ }
+ //--------------------------------------
+ GraphicsCore::GraphicsCore() : root_(0), cam_(0)
+ {
+ }
+ GraphicsCore::~GraphicsCore()
+ {
+ stop();
+ }
+ /// Method which will define the source of resources (other than current folder)
+ void GraphicsCore::_setupResources()
+ {
+ using namespace Ogre;
+
+ // Load resource paths from config file
+ ConfigFile cf;
+ cf.load("resources.cfg");
+
+ // Go through all sections & settings in the file
+ ConfigFile::SectionIterator seci = cf.getSectionIterator();
+
+ String secName, typeName, archName;
+ while (seci.hasMoreElements())
+ {
+ secName = seci.peekNextKey();
+ ConfigFile::SettingsMultiMap *settings = seci.getNext();
+ ConfigFile::SettingsMultiMap::iterator i;
+ for (i = settings->begin(); i != settings->end(); ++i)
+ {
+ typeName = i->first;
+ archName = i->second;
+#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE
+ // OS X does not set the working directory relative to the app,
+ // In order to make things portable on OS X we need to provide
+ // the loading with it's own bundle path location
+ ResourceGroupManager::getSingleton().addResourceLocation(
+ String(macBundlePath() + "/" + archName), typeName, secName);
+#else
+ ResourceGroupManager::getSingleton().addResourceLocation(
+ archName, typeName, secName);
+#endif
+ }
+ }
+ }
+ void GraphicsCore::start()
+ {
+ root_ = new Ogre::Root("plugins.cfg","ogre.cfg","ogre.log");
+
+ //@todo setup resource paths
+
+ if (!root_->showConfigDialog())
+ throw std::logic_error("ui.GraphicsCore:start(): User aborted."); //@todo convert to regular exit
+
+ this->_setupResources();
+
+ window_ = root_->initialise(true/*=create default rendering system*/);
+
+ sceneMgr_ = root_->createSceneManager(Ogre::ST_GENERIC, "GUIT_SMInstance");
+
+ {
+ cam_ = sceneMgr_->createCamera("PlayerCam");
+ // Position it at 50 in Z direction
+ cam_->setPosition(Ogre::Vector3(0,0,50));
+ // Look back along -Z
+ cam_->lookAt(Ogre::Vector3(0,0,-30));
+ cam_->setNearClipDistance(1.);
+ }
+
+ {
+ // Create one viewport, entire window
+ Ogre::Viewport* vp = window_->addViewport(cam_);
+ vp->setBackgroundColour(Ogre::ColourValue(0.1,0.1,0.15));
+
+ // Alter the camera aspect ratio to match the viewport
+ cam_->setAspectRatio(
+ Ogre::Real(vp->getActualWidth()) / Ogre::Real(vp->getActualHeight()));
+
+ //
+ scrSize_.x = vp->getActualWidth();
+ scrSize_.y = vp->getActualHeight();
+ }
+
+ Ogre::TextureManager::getSingleton().setDefaultNumMipmaps(5);
+
+ //
+ Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
+
+ {
+ Ogre::Entity* e = sceneMgr_->createEntity("n1","ninja.mesh");
+ sceneMgr_->getRootSceneNode()->createChildSceneNode()->attachObject(e);
+ }
+ /*
+ {
+ // Create a manual object for 2D
+ Ogre::ManualObject* manual = sceneMgr_->createManualObject("manual");
+ manual->setUseIdentityProjection(true);
+ manual->setUseIdentityView(true);
+ manual->begin("BaseWhiteNoLighting", Ogre::RenderOperation::OT_LINE_STRIP);
+ manual->position(-0.2, -0.2, 0.0);
+ manual->position( 0.2, -0.2, 0.0);
+ manual->position( 0.2, 0.2, 0.0);
+ manual->position(-0.2, 0.2, 0.0);
+ manual->index(0);
+ manual->index(1);
+ manual->index(2);
+ manual->index(3);
+ manual->index(0);
+ manual->end();
+ Ogre::AxisAlignedBox aabInf; aabInf.setInfinite();
+ manual->setBoundingBox(aabInf); // Use infinite aab to always stay visible
+ manual->setRenderQueueGroup(Ogre::RENDER_QUEUE_OVERLAY - 1);
+ sceneMgr_->getRootSceneNode()->createChildSceneNode()->attachObject(manual);
+ }
+ */
+ }
+ void GraphicsCore::stop()
+ {
+ if (root_)
+ {
+ root_->shutdown();
+ delete root_;
+ root_ = 0;
+ }
+ }
+ void GraphicsCore::frame()
+ {
+ root_->renderOneFrame();
+
+ // Pump events on Win32
+ MSG msg;
+ while( PeekMessage( &msg, NULL, 0U, 0U, PM_REMOVE ) )
+ //if( PeekMessage( &msg, NULL, 0U, 0U, PM_REMOVE ) )
+ {
+ TranslateMessage( &msg );
+ DispatchMessage( &msg );
+ }
+ ::Sleep(0);
+ }
+ //--------------------------------------
+ /*************************************************************************
+ Utility function to create a render operation and vertex buffer to render quads
+ *************************************************************************/
+ static void createQuadRenderOp(Ogre::RenderOperation &d_render_op,
+ Ogre::HardwareVertexBufferSharedPtr &d_buffer, size_t nquads)
+ {
+ using namespace Ogre;
+ // Create and initialise the Ogre specific parts required for use in rendering later.
+ d_render_op.vertexData = new VertexData;
+ d_render_op.vertexData->vertexStart = 0;
+
+ // setup vertex declaration for the vertex format we use
+ VertexDeclaration* vd = d_render_op.vertexData->vertexDeclaration;
+ size_t vd_offset = 0;
+ vd->addElement(0, vd_offset, VET_FLOAT3, VES_POSITION);
+ vd_offset += VertexElement::getTypeSize(VET_FLOAT3);
+ vd->addElement(0, vd_offset, VET_COLOUR, VES_DIFFUSE);
+ vd_offset += VertexElement::getTypeSize(VET_COLOUR);
+ vd->addElement(0, vd_offset, VET_FLOAT2, VES_TEXTURE_COORDINATES);
+
+ // create hardware vertex buffer
+ d_buffer = HardwareBufferManager::getSingleton().createVertexBuffer(vd->getVertexSize(0), nquads,
+ HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY_DISCARDABLE, false);
+
+ // bind vertex buffer
+ d_render_op.vertexData->vertexBufferBinding->setBinding(0, d_buffer);
+
+ // complete render operation basic initialisation
+ d_render_op.operationType = RenderOperation::OT_TRIANGLE_LIST;
+ d_render_op.useIndexes = false;
+ }
+
+ static void destroyQuadRenderOp(Ogre::RenderOperation &d_render_op,
+ Ogre::HardwareVertexBufferSharedPtr &d_buffer)
+ {
+ delete d_render_op.vertexData;
+ d_render_op.vertexData = 0;
+ d_buffer.setNull();
+ }
+ //--------------------------------------
+ //--------------------------------------
+ const size_t VERTEXBUFFER_INITIAL_CAPACITY = 512;
+ const size_t VERTEX_PER_QUAD = 6;
+ struct OgreWindowRenderer : public IWindowRenderer
+ {
+ //protected:
+ OgreWindowRenderer(GraphicsCore&);
+ virtual ~OgreWindowRenderer();
+ public:
+ virtual void frame();
+
+ virtual void begin();
+ virtual void beginWidget(Widget&);
+ virtual void endWidget(Widget&);
+ virtual void end();
+
+ virtual void getFrameStatistics(Statistics&) const;
+
+ virtual void quad2duv(const Position& v0, const Position& v1, const Position& v2, const Position& v3,
+ const vector2& uv00, const vector2& uv01, const vector2& uv02, const vector2& uv03,
+ const colour& c0, const colour& c1, const colour& c2, const colour& c3,
+ const real z);
+ virtual void pushMaterial(const string& name);
+ virtual void popMaterial();
+ private:
+ void _render();
+ void _initRenderStates();
+
+ struct FrameStats
+ {
+ size_t numWidgets;
+ //size_t numMaterialChanges;
+ size_t numNewFaces;
+ FrameStats()
+ {
+ reset();
+ }
+ void reset()
+ {
+ memset(this,0,sizeof(FrameStats));
+ }
+ } frameStats_;
+
+ std::deque<Ogre::TexturePtr> curMaterialStack_;
+
+ struct RQListener : public Ogre::RenderQueueListener
+ {
+ RQListener(OgreWindowRenderer& owner, Ogre::uint8 qId);
+ private:
+ OgreWindowRenderer& owner_;
+ Ogre::uint8 qId_;
+
+ private:
+ virtual void renderQueueStarted(Ogre::uint8 id, const Ogre::String& invocation, bool& skipThisQueue);
+ virtual void renderQueueEnded(Ogre::uint8 id, const Ogre::String& invocation, bool& repeatThisQueue);
+ };
+ boost::shared_ptr<RQListener> listener_;
+
+ FaceList faces_;
+ bool dirty_;
+
+ WidgetRenderable::pointer currWidgetData_;
+
+ Ogre::Root* oRoot_;
+ Ogre::RenderSystem* oSystem_;
+ Ogre::RenderOperation renderOp_;
+ Ogre::HardwareVertexBufferSharedPtr vertexBuffer_;
+ size_t bufferPos_;
+ Ogre::SceneManager* sceneMgr_;
+ Ogre::LayerBlendModeEx colourBlend_;
+ Ogre::LayerBlendModeEx alphaBlend_;
+ Ogre::TextureUnitState::UVWAddressingMode uvwAddressingMode_;
+
+ vector2 texelOffset_;
+ GraphicsCore& core_;
+
+ inline void toScreen(const Position& in, float& x, float& y, float& z) const
+ {
+ x = in.x / (scrSize_.x * .5);
+ y = in.y / (scrSize_.y * .5);
+ x -= 1.;
+ y -= 1.;
+ y *= -1.;
+ z = 0;
+ }
+ Position toScreen(const Position&) const;
+ real toScreenX(const real) const;
+ real toScreenY(const real) const;
+ };
+ OgreWindowRenderer::OgreWindowRenderer(GraphicsCore& core) : IWindowRenderer(),
+ dirty_(false),
+ sceneMgr_(core._getSceneMgr()),
+ bufferPos_(0),
+ oRoot_(Ogre::Root::getSingletonPtr()),
+ oSystem_(0),
+ core_(core)
+ {
+ assert( core_._getWindow() );
+ this->setScreenSize( core_._getWindow()->getWidth(), core_._getWindow()->getHeight() );
+
+ assert( oRoot_ );
+ oSystem_ = oRoot_->getRenderSystem();
+
+ // Create and initialise the Ogre specific parts required for use in rendering later.
+ // Main GUI
+ createQuadRenderOp(renderOp_, vertexBuffer_, VERTEXBUFFER_INITIAL_CAPACITY);
+
+ // initialise required texel offset
+ texelOffset_ = vector2(oSystem_->getHorizontalTexelOffset(), -oSystem_->getVerticalTexelOffset());
+
+ // create listener which will handler the rendering side of things for us.
+ //@todo d_ourlistener = new CEGUIRQListener(this, queue_id, post_queue);
+
+ // Initialise blending modes to be used.
+ colourBlend_.blendType = Ogre::LBT_COLOUR;
+ /*
+ colourBlend_.source1 = Ogre::LBS_DIFFUSE;
+ colourBlend_.source2 = Ogre::LBS_CURRENT;
+ colourBlend_.operation = Ogre::LBX_BLEND_DIFFUSE_ALPHA;
+ */
+ colourBlend_.source1 = Ogre::LBS_TEXTURE;
+ colourBlend_.source2 = Ogre::LBS_DIFFUSE;
+ colourBlend_.operation = Ogre::LBX_MODULATE;
+
+ alphaBlend_.blendType = Ogre::LBT_ALPHA;
+ alphaBlend_.source1 = Ogre::LBS_TEXTURE;
+ alphaBlend_.source2 = Ogre::LBS_DIFFUSE;
+ alphaBlend_.operation = Ogre::LBX_MODULATE;
+
+ uvwAddressingMode_.u = Ogre::TextureUnitState::TAM_CLAMP;
+ uvwAddressingMode_.v = Ogre::TextureUnitState::TAM_CLAMP;
+ uvwAddressingMode_.w = Ogre::TextureUnitState::TAM_CLAMP;
+
+ listener_.reset( new RQListener(*this,Ogre::RENDER_QUEUE_OVERLAY-1) );
+ assert( sceneMgr_ );
+ sceneMgr_->addRenderQueueListener( listener_.get() );
+
+ faces_.reserve(2000);
+ }
+ OgreWindowRenderer::~OgreWindowRenderer()
+ {
+ if (sceneMgr_ && listener_)
+ sceneMgr_->removeRenderQueueListener( listener_.get() );
+ listener_.reset();
+ destroyQuadRenderOp( renderOp_, vertexBuffer_ );
+ }
+ void OgreWindowRenderer::getFrameStatistics(Statistics& stats) const
+ {
+ stats["frame.numFaces"] = boost::lexical_cast<string>(faces_.size());
+ stats["frame.newFaces"] = boost::lexical_cast<string>(frameStats_.numNewFaces);
+ }
+ void OgreWindowRenderer::pushMaterial(const string& name)
+ {
+ Ogre::ResourceManager::ResourceCreateOrRetrieveResult succ =
+ Ogre::TextureManager::getSingleton().createOrRetrieve(name,"General");
+ Ogre::TexturePtr tex = succ.first;
+
+ assert( tex.get() && "requested texture not available/loaded" );
+ curMaterialStack_.push_back(tex);
+
+ /*
+ Ogre::MaterialPtr mat = Ogre::MaterialManager::getSingleton().getByName(name);
+ curMaterialStack_.push_back(mat);
+ Ogre::Technique* tech = mat->getBestTechnique(0);
+ if (tech)
+ {
+ Ogre::Pass* pass = tech->getPass(0);
+ if (pass)
+ pass->getT
+ }
+ */
+ }
+ void OgreWindowRenderer::popMaterial()
+ {
+ if (!curMaterialStack_.empty())
+ curMaterialStack_.pop_back();
+ }
+ void OgreWindowRenderer::beginWidget(Widget& w)
+ {
+ currWidgetData_ = boost::dynamic_pointer_cast<WidgetRenderable>(w._getCachedGeometry());
+ if (currWidgetData_)
+ {
+ if (w.needsRepaint())
+ {
+ currWidgetData_->clear();
+ }
+ else
+ {
+ for (FaceList::const_iterator it = currWidgetData_->faces.begin();
+ it != currWidgetData_->faces.end(); ++it)
+ {
+ addFace(faces_,*it);
+ }
+ }
+ }
+ else
+ currWidgetData_.reset(new WidgetRenderable());
+ }
+ void OgreWindowRenderer::endWidget(Widget& w)
+ {
+ w._setCachedGeometry(currWidgetData_);
+ currWidgetData_.reset();
+ }
+ OgreWindowRenderer::RQListener::RQListener(OgreWindowRenderer& owner, Ogre::uint8 qId) : qId_(qId), owner_(owner)
+ {
+ }
+ void OgreWindowRenderer::RQListener::renderQueueStarted(Ogre::uint8 id, const Ogre::String& invocation, bool& skipThisQueue)
+ {
+ if (qId_ <= id)
+ owner_._render();
+ }
+ void OgreWindowRenderer::RQListener::renderQueueEnded(Ogre::uint8 id, const Ogre::String& invocation, bool& skipThisQueue)
+ {
+ }
+ void OgreWindowRenderer::frame()
+ {
+ core_.frame();
+ }
+ void OgreWindowRenderer::begin()
+ {
+ frameStats_.reset();
+
+ // NB vector<>::clear() will not modify the capacity of the container, so there are no reallocations triggered.
+ faces_.clear(); //@todo optimize by reuse...
+ }
+ void OgreWindowRenderer::end()
+ {
+ }
+ void OgreWindowRenderer::_initRenderStates()
+ {
+ assert( oSystem_ );
+ using namespace Ogre;
+
+ // set-up matrices
+ oSystem_->_setWorldMatrix(Ogre::Matrix4::IDENTITY);
+ oSystem_->_setViewMatrix(Ogre::Matrix4::IDENTITY);
+ oSystem_->_setProjectionMatrix(Ogre::Matrix4::IDENTITY);
+
+ // initialise render settings
+ oSystem_->setLightingEnabled(false);
+ oSystem_->_setDepthBufferParams(false, false);
+ oSystem_->_setDepthBias(0, 0);
+ oSystem_->_setCullingMode(CULL_NONE);
+ oSystem_->_setFog(FOG_NONE);
+ oSystem_->_setColourBufferWriteEnabled(true, true, true, true);
+ oSystem_->unbindGpuProgram(GPT_FRAGMENT_PROGRAM);
+ oSystem_->unbindGpuProgram(GPT_VERTEX_PROGRAM);
+ oSystem_->setShadingType(SO_GOURAUD);
+ oSystem_->_setPolygonMode(PM_SOLID);
+
+ // initialise texture settings
+ oSystem_->_setTextureCoordCalculation(0, TEXCALC_NONE);
+ oSystem_->_setTextureCoordSet(0, 0);
+ oSystem_->_setTextureUnitFiltering(0, FO_LINEAR, FO_LINEAR, FO_POINT);
+ oSystem_->_setTextureAddressingMode(0, uvwAddressingMode_);
+ oSystem_->_setTextureMatrix(0, Ogre::Matrix4::IDENTITY);
+ oSystem_->_setAlphaRejectSettings(CMPF_ALWAYS_PASS, 0);
+ oSystem_->_setTextureBlendMode(0, colourBlend_);
+ oSystem_->_setTextureBlendMode(0, alphaBlend_);
+ oSystem_->_disableTextureUnitsFrom(1);
+
+ // enable alpha blending
+ //oSystem_->_setSceneBlending(SBF_SOURCE_ALPHA, SBF_ONE_MINUS_SOURCE_ALPHA);
+ oSystem_->_setSceneBlending(SBF_SOURCE_ALPHA, SBF_ONE_MINUS_SOURCE_ALPHA);
+ }
+ void OgreWindowRenderer::_render()
+ {
+ if (dirty_)
+ {
+ //@todo sort by texture ...
+
+ // adjust vertex buffer size (if necessary)
+ size_t size = vertexBuffer_->getNumVertices();
+ size_t required = faces_.size() * VERTEX_PER_QUAD;
+ if (required > size)
+ {
+ while (required > size)
+ size *= 2;
+ destroyQuadRenderOp(renderOp_, vertexBuffer_);
+ createQuadRenderOp(renderOp_, vertexBuffer_, size);
+ }
+ //@todo adjust vertex buffer size after some time of "under-use"
+
+ // fill
+ FaceVertex* vtx = reinterpret_cast<FaceVertex*>(vertexBuffer_->lock(Ogre::HardwareVertexBuffer::HBL_DISCARD));
+ for (FaceList::const_iterator it = faces_.begin(); it != faces_.end(); ++it)
+ {
+ const Face& f = *it;
+#if 1
+ /*
+ memcpy(vtx,&f.vtx[0],sizeof(FaceVertex)); ++vtx;
+ memcpy(vtx,&f.vtx[1],sizeof(FaceVertex)); ++vtx;
+ memcpy(vtx,&f.vtx[2],sizeof(FaceVertex)); ++vtx;
+ */
+ *vtx = f.vtx[0]; ++vtx;
+ *vtx = f.vtx[1]; ++vtx;
+ *vtx = f.vtx[2]; ++vtx;
+
+ /*
+ memcpy(vtx,&f.vtx[0],sizeof(FaceVertex)); ++vtx;
+ memcpy(vtx,&f.vtx[2],sizeof(FaceVertex)); ++vtx;
+ memcpy(vtx,&f.vtx[3],sizeof(FaceVertex)); ++vtx;
+ */
+ *vtx = f.vtx[0]; ++vtx;
+ *vtx = f.vtx[2]; ++vtx;
+ *vtx = f.vtx[3]; ++vtx;
+#else
+ // 0,1,2
+ memcpy(vtx,&f.vtx[0],sizeof(FaceVertex)*3); vtx += 3;
+
+ // 0,2,3
+ *vtx = f.vtx[0]; ++vtx;
+ memcpy(vtx,&f.vtx[2],sizeof(FaceVertex)*2); vtx += 2;
+#endif
+ }
+ vertexBuffer_->unlock();
+ }
+ // render:
+ bool first = true;
+ bufferPos_ = 0;
+ FaceList::const_iterator it = faces_.begin();
+ while (it != faces_.end())
+ {
+ renderOp_.vertexData->vertexStart = bufferPos_;
+ Ogre::TexturePtr tex = it->pTex0;
+ for (; it != faces_.end(); ++it)
+ {
+ const Face& f = *it;
+ if (f.pTex0 != tex)
+ break;
+ bufferPos_ += VERTEX_PER_QUAD;
+ }
+ renderOp_.vertexData->vertexCount = bufferPos_ - renderOp_.vertexData->vertexStart;
+
+ if (first)
+ {
+ first = false;
+ _initRenderStates();
+ }
+
+ if (tex.get())
+ oSystem_->_setTexture(0,true,tex);
+ else
+ oSystem_->_disableTextureUnit(0);
+
+ oSystem_->_render(renderOp_);
+ }
+ }
+ Position OgreWindowRenderer::toScreen(const Position& in) const
+ {
+ Position out(in);
+ out.x /= (scrSize_.x * .5);
+ out.y /= (scrSize_.y * .5);
+ out.x -= 1.;
+ out.y -= 1.;
+ out.y *= -1.;
+ return out;
+ }
+ real OgreWindowRenderer::toScreenX(const real in) const
+ {
+ // xform to [-1,1]
+ real out = in / (scrSize_.x * .5);
+ out -= 1.;
+ return out;
+ }
+ real OgreWindowRenderer::toScreenY(const real in) const
+ {
+ // xform to [-1,1] (also flip Y)
+ real out = in / (scrSize_.y * .5);
+ out -= 1.;
+ out *= -1.; // flip Y
+ return out;
+ }
+ void OgreWindowRenderer::quad2duv(const Position& v0, const Position& v1, const Position& v2, const Position& v3,
+ const vector2& uv00, const vector2& uv01, const vector2& uv02, const vector2& uv03,
+ const colour& c0, const colour& c1, const colour& c2, const colour& c3,
+ const real z)
+ {
+ dirty_ = true;
+ ++frameStats_.numNewFaces;
+
+ Face f;
+ //f.z = 0; //@todo FIXME z handling
+ oSystem_->convertColourValue(Ogre::ColourValue( c0.r, c0.g, c0.b, c0.a ), &f.vtx[0].diffuse);
+ oSystem_->convertColourValue(Ogre::ColourValue( c1.r, c1.g, c1.b, c1.a ), &f.vtx[1].diffuse);
+ oSystem_->convertColourValue(Ogre::ColourValue( c2.r, c2.g, c2.b, c2.a ), &f.vtx[2].diffuse);
+ oSystem_->convertColourValue(Ogre::ColourValue( c3.r, c3.g, c3.b, c3.a ), &f.vtx[3].diffuse);
+ toScreen(v0,f.vtx[0].x,f.vtx[0].y,f.vtx[0].z);
+ toScreen(v1,f.vtx[1].x,f.vtx[1].y,f.vtx[1].z);
+ toScreen(v2,f.vtx[2].x,f.vtx[2].y,f.vtx[2].z);
+ toScreen(v3,f.vtx[3].x,f.vtx[3].y,f.vtx[3].z);
+ f.vtx[0].tu0 = uv00.x + texelOffset_.x;
+ f.vtx[0].tv0 = uv00.y + texelOffset_.y;
+ f.vtx[1].tu0 = uv01.x + texelOffset_.x;
+ f.vtx[1].tv0 = uv01.y + texelOffset_.y;
+ f.vtx[2].tu0 = uv02.x + texelOffset_.x;
+ f.vtx[2].tv0 = uv02.y + texelOffset_.y;
+ f.vtx[3].tu0 = uv03.x + texelOffset_.x;
+ f.vtx[3].tv0 = uv03.y + texelOffset_.y;
+
+ if (!curMaterialStack_.empty())
+ f.pTex0 = curMaterialStack_.back();
+
+ addFace(faces_,f);
+ if (currWidgetData_)
+ addFace(currWidgetData_->faces,f);
+
+ /*
+ // Input points (v0-v4) are counter-clockwise in space x=[0,abs_width],y=[0,abs_height]
+
+ mesh->position( toScreenX(v0.x), toScreenY(v0.y), z );
+ mesh->textureCoord( uv00.x, uv00.y );
+ mesh->colour( c0.r, c0.g, c0.b, c0.a );
+ mesh->position( toScreenX(v1.x), toScreenY(v1.y), z );
+ mesh->textureCoord( uv01.x, uv01.y );
+ mesh->colour( c1.r, c1.g, c1.b, c1.a );
+ mesh->position( toScreenX(v2.x), toScreenY(v2.y), z );
+ mesh->textureCoord( uv02.x, uv02.y );
+ mesh->colour( c2.r, c2.g, c2.b, c2.a );
+ mesh->position( toScreenX(v3.x), toScreenY(v3.y), z );
+ mesh->textureCoord( uv03.x, uv03.y );
+ mesh->colour( c3.r, c3.g, c3.b, c3.a );
+ */
+ }
+
+ //-----------------------------------------------------
+
+ //-----------------------------------------------------
+ OgreSystem::OgreSystem()
+ {
+ }
+ FontPtr OgreSystem::createFont(const string& id, const string& name, const real size)
+ {
+ NamedFonts::const_iterator it = fonts_.find(id);
+ if (it != fonts_.end())
+ return it->second;
+
+ try {
+ FontPtr fnt(new Font(name,getRenderer(),size));
+ fonts_[id] = fnt;
+ return fnt;
+ }
+ catch (Exception&)
+ {
+ assert( false && "CAUGHT EXCEPTION during FONT CREATION" ); //@todo <- replace with logging?
+ throw;
+ }
+ }
+ FontPtr OgreSystem::getFont(const string& id) const
+ {
+ NamedFonts::const_iterator it = fonts_.find(id);
+ return (it == fonts_.end()) ? FontPtr() : it->second;
+ }
+ void OgreSystem::start()
+ {
+ assert( !core_.get() );
+ if (core_.get())
+ return;
+ core_.reset( new GraphicsCore() );
+ core_->start();
+ renderer_.reset( new OgreWindowRenderer(*core_) );
+ }
+ void OgreSystem::stop()
+ {
+ renderer_.reset();
+ fonts_.clear(); // !!!
+ if (core_.get())
+ core_->stop();
+ core_.reset();
+ }
+ WindowRendererPtr OgreSystem::getRenderer() const
+ {
+ assert( renderer_ );
+ return renderer_;
+ }
+ //-----------------------------------------------------
+ SystemPtr createOgreSystem()
+ {
+ static SystemPtr s_sys;
+ assert(!s_sys && "you can only create a single Ogre system!");
+ if (!s_sys)
+ s_sys.reset( new OgreSystem() );
+ return s_sys;
+ }
+} // namespace ui
+} // namespace yake
Added: trunk/yake/src/gui2/plugins/renderer.ogre/renderer.ogre.h
===================================================================
--- trunk/yake/src/gui2/plugins/renderer.ogre/renderer.ogre.h (rev 0)
+++ trunk/yake/src/gui2/plugins/renderer.ogre/renderer.ogre.h 2008-03-30 22:43:07 UTC (rev 1911)
@@ -0,0 +1,12 @@
+#ifndef UI_OGRE_RENDERER_H
+#define UI_OGRE_RENDERER_H
+
+#include "../system.h"
+
+namespace ui {
+
+ SystemPtr createOgreSystem();
+
+} // namespace ui
+
+#endif
Added: trunk/yake/src/gui2/plugins/style.lua/style.lua.cpp
===================================================================
--- trunk/yake/src/gui2/plugins/style.lua/style.lua.cpp (rev 0)
+++ trunk/yake/src/gui2/plugins/style.lua/style.lua.cpp 2008-03-30 22:43:07 UTC (rev 1911)
@@ -0,0 +1,531 @@
+#include "yake/bindings.lua/common/yake.lua.shared_ptr.h"
+#include "yake/bindings.lua/common/yake.lua.any_converter.h"
+
+extern "C" {
+ #include "lua.h"
+ #include "lualib.h"
+ #include "lauxlib.h"
+}
+#pragma warning(disable: 4996) // deprecated
+#pragma warning(disable: 4251)
+#include "luabind/luabind.hpp"
+#include "luabind/operator.hpp"
+
+#include "yake/gui2/style.h"
+#include "yake/gui2/widget.h"
+#include "yake/gui2/renderer.h"
+#include "yake/gui2/system.h"
+#include "yake/gui2/font.h"
+#include "yake/gui2/plugins/style.lua/style.lua.h"
+
+namespace yake {
+namespace ui {
+ YAKE_REGISTER_CONCRETE(LuaStyle)
+ struct LuaStyleWidgetEntry
+ {
+ VMPtr vm;
+ typedef std::map<string,luabind::object> NamedFnMap;
+ NamedFnMap renderFns;
+ NamedFnMap methods;
+ };
+ struct LuaStyleBatcher
+ {
+ void setRenderer(WindowRendererPtr r)
+ { renderer_ = r; }
+ void setSystem(SystemPtr sys)
+ { sys_ = sys; }
+ struct vertex
+ {
+ dim2 pos;
+ colour clr;
+ vector2 uv;
+ vertex(const dim2& p, const colour& c = colour()) : pos(p), clr(c)
+ {}
+ vertex(const dim2& p, const colour& c, const vector2& uv0) : pos(p), clr(c), uv(uv0)
+ {}
+ vertex(const dim2& p, const vector2& uv0) : pos(p), clr(1,1,1,1), uv(uv0)
+ {}
+ };
+
+ LuaStyleBatcher() : curr_(0), currZ_(0)
+ {}
+ void setCurrentWidget(Widget& w, real z)
+ {
+ curr_ = &w;
+ currZ_ = z;
+ //if (curr_)
+ // std::cout << "W " << curr_->id() << "\n";
+ }
+ void pushMaterial(const string& name)
+ {
+ renderer_->pushMaterial(name);
+ }
+ void popMaterial()
+ {
+ renderer_->popMaterial();
+ }
+ void quad(const dim2& v0, const dim2& v1, const dim2& v2, const dim2& v3)
+ {
+ this->quad(vertex(v0,clr_),vertex(v1,clr_),vertex(v2,clr_),vertex(v3,clr_));
+ }
+ void quad(const dim2& v0, const dim2& v1, const dim2& v2, const dim2& v3,
+ const vector2& uv00, const vector2& uv01, const vector2& uv02, const vector2& uv03)
+ {
+ this->quad(vertex(v0,clr_,uv00),vertex(v1,clr_,uv01),vertex(v2,clr_,uv02),vertex(v3,clr_,uv03));
+ }
+ void quad(const vertex& v0, const vertex& v1, const vertex& v2, const vertex& v3)
+ {
+ //assert( curr_ );
+ const Position absPos = curr_ ? curr_->getDerivedPosition() : Position();
+ const AbsSize size = curr_ ? curr_->getSize() : AbsSize();
+
+ //std::cout << "quad(" << v0 << v1 << v2 << v3 << ")\n";
+ Position abs0 = absPos + toAbsolute(v0);
+ Position abs1 = absPos + toAbsolute(v1);
+ Position abs2 = absPos + toAbsolute(v2);
+ Position abs3 = absPos + toAbsolute(v3);
+ //std::cout << "quad(" << abs0 << abs1 << abs2 << abs3 << ")\n";
+ if ((v0.clr.a <= 0.001) && (v1.clr.a <= 0.001) && (v2.clr.a <= 0.001) && (v3.clr.a <= 0.001))
+ {
+ std::cout << "=> hidden quad\n";
+ }
+ else if (renderer_)
+ {
+ renderer_->quad2duv(abs0,abs1,abs2,abs3,
+ v0.uv, v1.uv, v2.uv, v3.uv,
+ v0.clr, v1.clr, v2.clr, v3.clr, .01*currZ_+(curr_?curr_->getZBias():0.));
+ }
+ }
+ void setColour(const colour& clr)
+ {
+ clr_ = clr;
+ //std::cout << "brush colour set to " << clr_ << "\n";
+ }
+ void setColour(const real r, const real g, const real b, const real a)
+ {
+ this->setColour(colour(r,g,b,a));
+ }
+ void setColour(const real r, const real g, const real b)
+ {
+ this->setColour(colour(r,g,b,1.));
+ }
+ void text(const dim2& pos, const string& text, const string& font, const real size)
+ {
+ FontPtr fnt = sys_->getFont(font);
+ assert( fnt && "could not retrieve font" );
+ if (fnt)
+ {
+ const Rectangle clip(curr_->getDerivedPosition(),curr_->getSize());
+ fnt->render( text, curr_->getDerivedPosition() + toAbsolute(pos), clip, clr_, currZ_+curr_->getZBias() );
+ }
+ }
+ void clearCurrentWidget()
+ {
+ curr_ = 0;
+ }
+ private:
+ Widget* curr_;
+ real currZ_;
+ colour clr_;
+ WindowRendererPtr renderer_;
+ SystemPtr sys_;
+
+ Position toAbsolute(const dim2& pos)
+ {
+ return this->toAbsolute(pos.x,pos.y);
+ }
+ Position toAbsolute(const vertex& vtx)
+ {
+ return this->toAbsolute(vtx.pos.x,vtx.pos.y);
+ }
+ Position toAbsolute(const dim& x, const dim& y)
+ {
+ Position out;
+ if (curr_)
+ {
+ out.x = x.abs + curr_->getSize().x * x.rel;
+ out.y = y.abs + curr_->getSize().y * y.rel;
+ }
+ else
+ out = Position(x.abs, y.abs);
+ return out;
+ }
+ };
+} // namespace ui
+} // namespace yake
+
+/*
+any_converter_map& any_converters()
+{
+ std::auto_ptr<any_converter_map> s_map( new any_converter_map() );
+ return *s_map;
+}
+*/
+/*
+namespace {
+struct RegisterCommonAnyConverters
+{
+ RegisterCommonAnyConverters()
+ {
+ register_any_converter<bool>();
+ register_any_converter<int>();
+ register_any_converter<float>();
+ register_any_converter<yake::real>();
+ register_any_converter<const char*>();
+ register_any_converter<std::string>();
+ }
+} gs_register;
+}
+*/
+
+// UI
+namespace yake {
+namespace ui {
+ int pcall_handler(lua_State* L)
+ {
+ return 1;
+ }
+ struct LuaVM
+ {
+ LuaVM() : L(0)
+ {
+ L = lua_open();
+
+ luaopen_base( L );
+ //lua_baselibopen(L);
+
+ luaopen_table( L );
+
+ //luaopen_io( L ); // see linit.c
+ lua_pushcfunction(L, luaopen_io);
+ lua_pushstring(L, "io");
+ lua_call(L, 1, 0);
+
+
+ luaopen_string( L );
+ luaopen_math( L );
+ luaopen_debug( L );
+
+ luabind::open( L );
+ }
+ ~LuaVM()
+ {
+ if (L)
+ lua_close( L );
+ L = 0;
+ }
+ void doFile(const string& fn)
+ {
+ lua_pushcclosure(L, &pcall_handler, 0);
+
+ if (luaL_loadfile(L, fn.c_str()))
+ {
+ std::string err(lua_tostring(L, -1));
+ lua_pop(L, 2);
+ throw std::exception( err.c_str() );
+ }
+
+ if (lua_pcall(L, 0, 0, -2))
+ {
+ std::string err(lua_tostring(L, -1));
+ lua_pop(L, 2);
+ throw std::exception( err.c_str() );
+ }
+
+ lua_pop(L, 1);
+ }
+ lua_State* state() const
+ {
+ return L;
+ }
+ private:
+ lua_State* L;
+ };
+ LuaStyle::LuaStyle(SystemPtr sys, WindowRendererPtr w) : sys_(sys), renderer_(w), batcher_( new LuaStyleBatcher() )
+ {
+ batcher_->setRenderer( renderer_ );
+ batcher_->setSystem( sys_ );
+
+ {
+ VMPtr init = this->createVM();
+ init->doFile("lua.init.lua");
+ {
+ lua_State* L = init->state();
+ using namespace luabind;
+ object o = globals(L)["widgets"];
+ if (o && (type(o) == LUA_TTABLE))
+ {
+ for (iterator it(o), end; it != end; ++it)
+ {
+ boost::optional<std::string> key = object_cast_nothrow<std::string>(it.key());
+ boost::optional<std::string> value = object_cast_nothrow<std::string>(*it);
+ if (key && value)
+ {
+ this->createVM(*key,*value);
+ }
+ }
+ }
+ /*
+ object o = globals(L)["images"];
+ if (o && (type(o) == LUA_TTABLE))
+ {
+ for (iterator it(o), end; it != end; ++it)
+ {
+ boost::optional<std::string> key = object_cast_nothrow<std::string>(it.key());
+ boost::optional<std::string> value = object_cast_nothrow<std::string>(*it);
+ if (key && value)
+ {
+ this->images_[ *key ] = *value;
+ }
+ }
+ }
+ */
+ }
+ } // startup VM
+//
+// this->createVM("Cursor","lua.cursor.lua");
+//
+// this->createVM("Widget","lua.panel.lua");
+// this->createVM("Panel","lua.panel.lua");
+// this->createVM("Button","lua.button.lua");
+// this->createVM("StaticText","lua.statictext.lua");
+// this->createVM("Titlebar","lua.titlebar.lua");
+// this->createVM("TextEdit","lua.textedit.lua");
+//
+// this->createVM("Dialog","lua.dialogpanel.lua");
+// this->createVM("DialogPanel","lua.dialogpanel.lua");
+ }
+
+ bool widget_hasMutator(Widget* w,const string& tag)
+ {
+ return (w ? (w->getMutator(tag).get()!=0) : false);
+ }
+
+ void LuaStyle::bind(VMPtr vm)
+ {
+ lua_State* L = vm ? vm->state() : 0;
+ assert(L && "null state");
+ if (!L)
+ return;
+
+ using namespace luabind;
+ //module( L, "ui" )
+ module( L )
+ [
+ class_<dim>("dim")
+ .def(constructor<real,real>())
+ .def(self + other<dim>())
+ .def(self * double())
+ .def_readwrite("abs", &dim::abs),
+
+ class_<dim2>("pos")
+ .def(constructor<dim,dim>())
+ .def(constructor<real,real>())
+ .def(constructor<dim,real>())
+ .def(constructor<real,dim>())
+ .def(self + other<dim2>())
+ .def(self - other<dim2>())
+ .def_readwrite("x", &dim2::x)
+ .def_readwrite("y", &dim2::y),
+
+ class_<colour>("colour")
+ .def(constructor<real,real,real,real>())
+ .def(constructor<real,real,real>())
+ //.def(self + other<colour>())
+ //.def(self - other<colour>())
+ .def_readwrite("r", &colour::r)
+ .def_readwrite("g", &colour::g)
+ .def_readwrite("b", &colour::b)
+ .def_readwrite("a", &colour::a),
+
+ class_<vector2>("vector2")
+ .def(constructor<real,real>())
+ .def(self * real())
+ .def(self + other<AbsSize>())
+ .def(self - other<vector2>())
+ .def_readwrite("x", &vector2::x)
+ .def_readwrite("y", &vector2::y)
+ ,
+
+ class_<MutatorBase, boost::shared_ptr<MutatorBase> >("mutator")
+ .def("update",&MutatorBase::update),
+
+ class_<Widget>("widget")
+ .def("id", &Widget::id)
+ .def("add", (void(Widget::*)(MutatorBasePtr,const string&))&Widget::add)
+ .def("hasMutator",&widget_hasMutator)
+ .def("getMutator", &Widget::getMutator)
+ .def("numChildren", &Widget::numChildren)
+ //.def("setProperty", (void(Widget::*)(const string&,const boost::any&))&Widget::property)
+ //.def("getProperty", (const boost::any&(Widget::*)(const string&)const)&Widget::property)
+ //.def("property", (Widget::PropertyAccessor(Widget::*)(const string&))&Widget::property)
+ .def("property", (void(Widget::*)(const string&,const boost::any&))&Widget::property)
+ .def("property", (const boost::any&(Widget::*)(const string&)const)&Widget::property)
+ ,
+
+ // special "LuaStyle" stuff:
+ class_<LuaStyleBatcher::vertex>("vertex")
+ .def(constructor<dim2>())
+ .def(constructor<dim2,colour>())
+ .def(constructor<dim2,vector2>()),
+
+ class_<LuaStyleBatcher, boost::shared_ptr<LuaStyleBatcher> >("LuaStyleBatcher")
+ .def("doquad",(void(LuaStyleBatcher::*)(const LuaStyleBatcher::vertex&,const LuaStyleBatcher::vertex&,const LuaStyleBatcher::vertex&,const LuaStyleBatcher::vertex&))&LuaStyleBatcher::quad)
+ .def("doquad",(void(LuaStyleBatcher::*)(const dim2&,const dim2&,const dim2&,const dim2&))&LuaStyleBatcher::quad)
+ .def("doquad",(void(LuaStyleBatcher::*)(const dim2&,const dim2&,const dim2&,const dim2&,const vector2&,const vector2&,const vector2&,const vector2&))&LuaStyleBatcher::quad)
+ .def("colour",(void(LuaStyleBatcher::*)(const colour&))&LuaStyleBatcher::setColour)
+ .def("colour",(void(LuaStyleBatcher::*)(real,real,real))&LuaStyleBatcher::setColour)
+ .def("colour",(void(LuaStyleBatcher::*)(real,real,real,real))&LuaStyleBatcher::setColour)
+ .def("text",&LuaStyleBatcher::text)
+ .def("pushMaterial",&LuaStyleBatcher::pushMaterial)
+ .def("popMaterial",&LuaStyleBatcher::popMaterial)
+ ,
+ class_<IFont, FontPtr>("Font")
+ .def("getTextSize",&IFont::getTextSize)
+ .def("getHeight",&IFont::getHeight)
+ ,
+ class_<ISystem, SystemPtr>("System")
+ .def("getFont",&ISystem::getFont)
+ ];
+
+ globals(L)["uv"] = globals(L)["vector2"];
+ globals(L)["size"] = globals(L)["vector2"];
+
+ globals(L)["property"] = luabind::newtable(L);
+ globals(L)["geometry"] = luabind::newtable(L);
+
+ globals(L)["render"] = batcher_;
+ batcher_->setRenderer( renderer_ );
+ globals(L)["ui"] = sys_;
+
+ globals(L)["methods"] = luabind::newtable(L);
+
+ }
+ VMPtr LuaStyle::createVM()
+ {
+ VMPtr vm(new LuaVM());
+ this->bind(vm);
+ return vm;
+ }
+ void LuaStyle::createVM(const string& widgetType,const string& fn)
+ {
+ vm_[ widgetType ].reset( new LuaStyleWidgetEntry() );
+ LuaStyleWidgetEntryPtr widgetEntry = vm_[ widgetType ];
+
+ //
+ widgetEntry->vm = this->createVM();
+ lua_State* L = widgetEntry->vm->state();
+ widgetEntry->vm->doFile( fn.c_str() );
+
+ //
+ for (luabind::iterator it(luabind::globals(L)["property"]), end; it != end; ++it)
+ {
+ //std::cout << "(found property '" << luabind::object_cast<std::string>(*it) << "')\n";
+ std::cout << "(found property '" << it.key() << "')\n";
+ }
+ for (luabind::iterator it(luabind::globals(L)["geometry"]), end; it != end; ++it)
+ {
+ std::cout << "(found geometry for '" << it.key() << "')\n";
+ luabind::object o = *it;
+ if (!o || luabind::type(o) != LUA_TFUNCTION)
+ throw std::exception("geometry value is NIL or not a function!");
+
+ widgetEntry->renderFns[ luabind::object_cast<std::string>(it.key()) ] = o;
+ }
+ for (luabind::iterator it(luabind::globals(L)["methods"]), end; it != end; ++it)
+ {
+ std::cout << "(found method '" << it.key() << "')\n";
+ luabind::object o = *it;
+ if (!o || luabind::type(o) != LUA_TFUNCTION)
+ throw std::exception("method value is NIL or not a function!");
+
+ widgetEntry->methods[ luabind::object_cast<std::string>(it.key()) ] = o;
+ }
+ }
+ AbsSize LuaStyle::determineMinimumSize(ui::Widget& w)
+ {
+ try
+ {
+ VmMap::iterator itVM = this->vm_.find( w.getStyleWidgetType() );
+ assert( itVM != this->vm_.end() );
+ LuaStyleWidgetEntry& entry = *(itVM->second);
+
+ luabind::object o = entry.methods.find("minimumSize")->second;
+
+ luabind::globals(entry.vm->state())["this"] = &w;
+
+ AbsSize value = luabind::call_function<AbsSize>( o );
+ return value;
+ }
+ catch (luabind::error& e)
+ {
+ std::string code = lua_tostring( e.state(), -1 );
+ throw Exception(code);
+ }
+ }
+ void LuaStyle::renderCursor(const Position& pos, const int zLevel)
+ {
+ assert( renderer_ );
+ assert( batcher_ );
+ batcher_->clearCurrentWidget();
+ renderer_->setZLevel( zLevel );
+ VmMap::iterator itVM = this->vm_.find("Cursor");
+ if (itVM != this->vm_.end())
+ {
+ try {
+ luabind::object o = luabind::globals(itVM->second->vm->state())["renderCursor"];
+ assert( luabind::type(o) == LUA_TFUNCTION );
+ //luabind::call_function();
+ o( pos.x, pos.y );
+ }
+ catch (luabind::error& e)
+ {
+ std::string code = lua_tostring( e.state(), -1 );
+ throw Exception(code);
+ }
+ }
+ else
+ {
+ renderer_->pushMaterial("cursor2-glass1.png");
+ const AbsSize size(16,16);
+ renderer_->quad2duv(pos,pos+AbsSize(0,16),pos+size,pos+AbsSize(16,0),
+ vector2(0,0),vector2(0,1),vector2(1,1),vector2(1,0),zLevel);
+ renderer_->popMaterial();
+ }
+ }
+ void LuaStyle::renderSingleWidget(Widget& w, const int zLevel)
+ {
+ assert( renderer_ );
+ renderer_->setZLevel( zLevel );
+ renderer_->beginWidget( w );
+ if (w.needsRepaint())
+ {
+ VmMap::iterator itVM = this->vm_.find( w.getStyleWidgetType() );
+ //assert( itVM != this->vm_.end() ); //@todo report error
+ if (itVM == this->vm_.end())
+ itVM = this->vm_.find("Widget"); //fallback
+ assert( itVM != this->vm_.end() );
+ LuaStyleWidgetEntry& entry = *(itVM->second);
+
+ const string stateId = (w.getState() == Widget::S_HOVER) ? "hover" : "normal";
+ LuaStyleWidgetEntry::NamedFnMap::const_iterator itFn = entry.renderFns.find(stateId);
+ if (itFn == entry.renderFns.end())
+ {
+ // not defined -- try "normal"
+ if (w.getState() != Widget::S_NORMAL)
+ itFn = entry.renderFns.find("normal");
+ assert( (itFn != entry.renderFns.end()) && "no fallback 'normal' render function defined" );
+ }
+ luabind::object o = itFn->second;
+ assert( luabind::type(o) == LUA_TFUNCTION );
+
+ assert( batcher_ );
+ batcher_->setCurrentWidget( w, zLevel );
+ luabind::globals(entry.vm->state())["this"] = &w;
+
+ o();
+ }
+ renderer_->endWidget( w );
+ }
+} // namespace ui
+} // namespace yake
Added: trunk/yake/src/gui2/plugins/style.lua/style.lua.h
===================================================================
--- trunk/yake/src/gui2/plugins/style.lua/style.lua.h (rev 0)
+++ trunk/yake/src/gui2/plugins/style.lua/style.lua.h 2008-03-30 22:43:07 UTC (rev 1911)
@@ -0,0 +1,37 @@
+#ifndef UI_LUASTYLE_H
+#define UI_LUASTYLE_H
+
+namespace ui {
+ struct LuaVM;
+ typedef boost::shared_ptr<LuaVM> VMPtr;
+ struct LuaStyleWidgetEntry;
+ typedef boost::shared_ptr<LuaStyleWidgetEntry> LuaStyleWidgetEntryPtr;
+ struct LuaStyleBatcher;
+ struct LuaStyle : public IStyle
+ {
+ LuaStyle(SystemPtr,WindowRendererPtr);
+ virtual AbsSize determineMinimumSize(Widget&);
+ virtual void renderSingleWidget(Widget&, const int zLevel);
+ virtual void renderCursor(const Position&, const int zLevel);
+
+ //void loadWidgetStyle(const string& scriptFile, const string& widgetType = "");
+ private:
+ typedef std::map<string,LuaStyleWidgetEntryPtr> VmMap;
+ VmMap vm_;
+ //typedef std::map<string,string> ScriptMap;
+ //ScriptMap widgetScripts_;
+
+ //typedef std::map<string,string> NamedImagesMap;
+ //NamedImagesMap images_;
+
+ boost::shared_ptr<LuaStyleBatcher> batcher_;
+ WindowRendererPtr renderer_;
+ SystemPtr sys_;
+
+ void bind(VMPtr);
+ VMPtr createVM();
+ void createVM(const string&,const string&);
+ };
+} // namespace ui
+
+#endif
Added: trunk/yake/src/gui2/plugins/system.ogreois/ogre_ois.cpp
===================================================================
--- trunk/yake/src/gui2/plugins/system.ogreois/ogre_ois.cpp (rev 0)
+++ trunk/yake/src/gui2/plugins/system.ogreois/ogre_ois.cpp 2008-03-30 22:43:07 UTC (rev 1911)
@@ -0,0 +1,220 @@
+#include "yake/gui2/plugins/system.ogreois/ogre_ois.h"
+
+#include "Ogre.h"
+//Use this define to signify OIS will be used as a DLL
+//(so that dll import/export macros are in effect)
+#define OIS_DYNAMIC_LIB
+#include <OIS/OIS.h>
+
+namespace yake {
+namespace ui {
+ YAKE_REGISTER_CONCRETE(OgreOIS_InputProvider);
+ namespace detail {
+ struct OgreOIS_FrameListener : public Ogre::FrameListener, public Ogre::WindowEventListener,
+ public OIS::KeyListener
+ {
+ private:
+ //OIS::KeyListener
+ std::string keys_;
+ virtual bool keyPressed( const OIS::KeyEvent &arg )
+ {
+ return true;
+ }
+ virtual bool keyReleased( const OIS::KeyEvent &arg )
+ {
+ if (arg.key == OIS::KC_BACK)
+ {
+ ;
+ }
+ else if (
+ (arg.key >= OIS::KC_1 && arg.key <= OIS::KC_RBRACKET) ||
+ (arg.key >= OIS::KC_A && arg.key <= OIS::KC_GRAVE) ||
+ (arg.key >= OIS::KC_Z && arg.key <= OIS::KC_SLASH) ||
+ (arg.key == OIS::KC_SPACE))
+ keys_ += mKeyboard->getAsString(arg.key);
+ return true;
+ }
+ public:
+ const std::string& keys() const
+ { return keys_; }
+ void clearKeys()
+ { keys_.clear(); }
+ public:
+ //
+ OgreOIS_FrameListener():
+ inputManager_(0)
+ {
+ YAKE_ASSERT( Ogre::LogManager::getSingletonPtr() ).debug("Ogre doesn't seem to have been initialized!");
+ Ogre::LogManager::getSingletonPtr()->logMessage("*** Initializing OIS ***");
+ OIS::ParamList pl;
+ size_t windowHnd = 0;
+ std::ostringstream windowHndStr;
+
+ window_ = Ogre::Root::getSingleton().getAutoCreatedWindow();
+ YAKE_ASSERT( window_ ).debug("only auto created window supported, at the moment" );
+ window_->getCustomAttribute("WINDOW", &windowHnd);
+ windowHndStr << windowHnd;
+ pl.insert(std::make_pair(std::string("WINDOW"), windowHndStr.str()));
+
+ inputManager_ = OIS::InputManager::createInputSystem( pl );
+
+ //Create all devices (We only catch joystick exceptions here, as, most people have Key/Mouse)
+ mKeyboard = static_cast<OIS::Keyboard*>(inputManager_->createInputObject( OIS::OISKeyboard, true/*buffered*/ ));
+ mKeyboard->setEventCallback(this);
+ mMouse = static_cast<OIS::Mouse*>(inputManager_->createInputObject( OIS::OISMouse, false/*buffered*/ ));
+ try {
+ mJoy = static_cast<OIS::JoyStick*>(inputManager_->createInputObject( OIS::OISJoyStick, false/*buffered*/ ));
+ }
+ catch(...) {
+ mJoy = 0;
+ }
+
+ //Set initial mouse clipping size
+ this->windowResized(window_);
+
+ //Register as a Window listener
+ Ogre::WindowEventUtilities::addWindowEventListener(window_, this);
+
+ Ogre::Root::getSingleton().addFrameListener(this);
+ }
+ virtual ~OgreOIS_FrameListener()
+ {
+ Ogre::Root::getSingleton().removeFrameListener(this);
+ //Remove ourself as a Window listener
+ Ogre::WindowEventUtilities::removeWindowEventListener(window_, this);
+ this->windowClosed(window_);
+ }
+ //Adjust mouse clipping area
+ virtual void windowResized(Ogre::RenderWindow* rw)
+ {
+ unsigned int width, height, depth;
+ int left, top;
+ rw->getMetrics(width, height, depth, left, top);
+
+ const OIS::MouseState &ms = mMouse->getMouseState();
+ ms.width = width;
+ ms.height = height;
+ }
+ //Unattach OIS before window shutdown (very important under Linux)
+ virtual void windowClosed(Ogre::RenderWindow* rw)
+ {
+ //Only close for window that created OIS (the main window in these demos)
+ if( rw == window_ )
+ {
+ if( inputManager_ )
+ {
+ inputManager_->destroyInputObject( mMouse );
+ inputManager_->destroyInputObject( mKeyboard );
+ inputManager_->destroyInputObject( mJoy );
+
+ OIS::InputManager::destroyInpu...
[truncated message content] |
|
From: <psy...@us...> - 2008-03-31 18:00:22
|
Revision: 1912
http://yake.svn.sourceforge.net/yake/?rev=1912&view=rev
Author: psyclonist
Date: 2008-03-31 11:00:28 -0700 (Mon, 31 Mar 2008)
Log Message:
-----------
* [gui2] added media files
* [gui2] fixed possible crash during shutdown of ogre when exceptions are thrown
* [gui2] attempt to make use of yake's resource system
* added 'gui2' and 'sampleUi1' projects
Modified Paths:
--------------
trunk/yake/scripts/premake/samples.lua
trunk/yake/scripts/premake/yake.lua
trunk/yake/src/gui2/plugins/renderer.ogre/renderer.ogre.cpp
trunk/yake/src/gui2/plugins/style.lua/style.lua.cpp
trunk/yake/src/res/source.cpp
Added Paths:
-----------
trunk/yake/common/media/gui2/
trunk/yake/common/media/gui2/styles/
trunk/yake/common/media/gui2/styles/lua1/
trunk/yake/common/media/gui2/styles/lua1/lua.button.lua
trunk/yake/common/media/gui2/styles/lua1/lua.colours.inc.lua
trunk/yake/common/media/gui2/styles/lua1/lua.cursor.lua
trunk/yake/common/media/gui2/styles/lua1/lua.dialogpanel.lua
trunk/yake/common/media/gui2/styles/lua1/lua.init.lua
trunk/yake/common/media/gui2/styles/lua1/lua.panel.lua
trunk/yake/common/media/gui2/styles/lua1/lua.statictext.lua
trunk/yake/common/media/gui2/styles/lua1/lua.textedit.lua
trunk/yake/common/media/gui2/styles/lua1/lua.titlebar.lua
Added: trunk/yake/common/media/gui2/styles/lua1/lua.button.lua
===================================================================
--- trunk/yake/common/media/gui2/styles/lua1/lua.button.lua (rev 0)
+++ trunk/yake/common/media/gui2/styles/lua1/lua.button.lua 2008-03-31 18:00:28 UTC (rev 1912)
@@ -0,0 +1,90 @@
+----------------------
+-- BUTTON
+----------------------
+dofile "lua.colours.inc.lua"
+
+property["normal.colour"] = theme.colours.control_normal
+property["hover.colour"] = theme.colours.control_hover
+property["text.colour"] = theme.colours.control_text
+property["padding"] = 2
+
+----------------------
+-- Name "normal", "hover" etc is defined by the style/widget!
+-- Name "forall" is defined by us for easy reuse in "normal", "hover" etc.
+
+function text2dim(text)
+ -- "2px" -> absolute
+ -- "1" -> relative
+ -- "1,2" -> 1 rel, 2 px
+ -- "1.2" -> 1.2 rel
+end
+
+geometry.forall_inner = function()
+ local px = property["padding"]
+ if (this:id() == "x") then
+ px = px - 1
+ end
+ render:quad(
+ {{0,px},{0,px}},
+ {{0,px},{1,-px}},
+ {{1,-px},{1,-px}},
+ {{1,-px},{0,px}})
+
+ if (this:id() == "x") then
+ px = px + 2
+ render:colour(property["hover.colour"])
+ render:quad(
+ {{0,px},{0,px}},
+ {{0,px},{1,-px}},
+ {{1,-px},{1,-px}},
+ {{1,-px},{0,px}})
+ end
+
+ if (this:id() ~= "x") then
+ local off = property["padding"] + 1
+ render:colour(property["text.colour"])
+ render:text(pos(dim(0,off),dim(0,off)), this:property("text"), theme.font, theme.text_size)
+ end
+end
+
+geometry.normal = function()
+ if (this:id() == "x") then
+ render:colour(property["hover.colour"])
+ render:quad({0,0},{0,1},{1,1},{1,0})
+
+ render:colour(property["normal.colour"])
+ geometry.forall_inner() -- Reuse!
+ else
+ render:colour(property["normal.colour"])
+ render:quad({0,0},{0,1},{1,1},{1,0})
+
+ render:colour(property["hover.colour"])
+ geometry.forall_inner() -- Reuse!
+ end
+end
+geometry.hover = function()
+ render:colour(property["hover.colour"])
+ render:quad({0,0},{0,1},{1,1},{1,0})
+
+ --render:colour(property["normal.colour"])
+ geometry.forall_inner() -- Reuse!
+end
+
+----------------------
+methods["minimumSize"] = function()
+ if (this:id() == "x") then
+ return size(6,6) + size(property["padding"],property["padding"]) * 2
+ else
+ local fnt = ui:getFont(theme.font)
+ return fnt:getTextSize( this:property("text") ) + size(property["padding"],property["padding"]) * 2
+ end
+end
+
+----------------------
+methods["onStateChanged"] = function(from,to)
+ if to == "hover" then
+ if this:getMutator("hoverFadeOut") == nil then
+ this:add( ColourFader(property["normal.colour"], property["hover.colour"]) )
+ end
+ end
+end
\ No newline at end of file
Added: trunk/yake/common/media/gui2/styles/lua1/lua.colours.inc.lua
===================================================================
--- trunk/yake/common/media/gui2/styles/lua1/lua.colours.inc.lua (rev 0)
+++ trunk/yake/common/media/gui2/styles/lua1/lua.colours.inc.lua 2008-03-31 18:00:28 UTC (rev 1912)
@@ -0,0 +1,65 @@
+
+theme = {
+ colours = {
+ background = colour(.1,.2,.2,1),
+ panel_hover = background,
+ control_normal = colour(.2,.4,.4,1),
+ control_hover = colour(.3,.6,.6,1),
+ control_text = colour(1,1,1,1),
+ edit_text = colour(.8,.8,.5,1)
+ },
+ text_size = 14,
+ font = "BlueHighway-10",
+ images = {
+ cursor = "cursor2-glass1.png",
+ }
+}
+
+
+
+function toPos(v)
+ if (type(v) == "table") then
+ local out = pos(0,0)
+ if v[1] then
+ if type(v[1]) == "table" then
+ out.x = dim(v[1][1] or 0, v[1][2] or 0)
+ elseif type(v[1]) == "number" then
+ out.x = dim(v[1],0)
+ end
+ end
+ if v[2] then
+ if type(v[2]) == "table" then
+ out.y = dim(v[2][1] or 0, v[2][2] or 0)
+ elseif type(v[2]) == "number" then
+ out.y = dim(v[2],0)
+ end
+ end
+ return out
+ end
+ return pos(0,0)
+end
+
+render.quad = function(self,v0,v1,v2,v3,uv0,uv1,uv2,uv3)
+ local v = {}
+ if (type(v0) == "table") then
+ v[1] = toPos(v0)
+ else
+ v[1] = v0
+ end
+ if (type(v1) == "table") then
+ v[2] = toPos(v1)
+ else
+ v[2] = v1
+ end
+ if (type(v2) == "table") then
+ v[3] = toPos(v2)
+ else
+ v[3] = v2
+ end
+ if (type(v3) == "table") then
+ v[4] = toPos(v3)
+ else
+ v[4] = v3
+ end
+ render:doquad(v[1],v[2],v[3],v[4],uv0 or uv(0,0),uv1 or uv(1,0),uv2 or uv(1,1),uv3 or uv(0,1))
+end
Added: trunk/yake/common/media/gui2/styles/lua1/lua.cursor.lua
===================================================================
--- trunk/yake/common/media/gui2/styles/lua1/lua.cursor.lua (rev 0)
+++ trunk/yake/common/media/gui2/styles/lua1/lua.cursor.lua 2008-03-31 18:00:28 UTC (rev 1912)
@@ -0,0 +1,21 @@
+----------------------
+-- Cursor
+----------------------
+dofile "lua.colours.inc.lua"
+
+renderCursor = function(x,y)
+ render:pushMaterial(theme.images.cursor)
+ local w = 16
+ local h = 16
+ render:quad({{0,x},{0,y}},
+ {{0,x},{0,y+h}},
+ {{0,x+w},{0,y+h}},
+ {{0,x+w},{0,y}},
+ uv(0,0),uv(0,1),uv(1,1),uv(1,0));
+ --render:quad(pos(dim(0,x),dim(0,y)),
+ -- pos(dim(0,x),dim(0,y+h)),
+ -- pos(dim(0,x+w),dim(0,y+h)),
+ -- pos(dim(0,x+w),dim(0,y)),
+ -- uv(0,0),uv(0,1),uv(1,1),uv(1,0));
+ render:popMaterial()
+end
Added: trunk/yake/common/media/gui2/styles/lua1/lua.dialogpanel.lua
===================================================================
--- trunk/yake/common/media/gui2/styles/lua1/lua.dialogpanel.lua (rev 0)
+++ trunk/yake/common/media/gui2/styles/lua1/lua.dialogpanel.lua 2008-03-31 18:00:28 UTC (rev 1912)
@@ -0,0 +1,53 @@
+----------------------
+-- PANEL
+----------------------
+dofile "lua.colours.inc.lua"
+
+property["margin"] = size(5,5) --5px (on all sides)
+
+----------------------
+-- Name "normal" is defined by the style!
+-- Name "forall" is defined by us for easy reuse.
+
+geometry.forall = function()
+ local off = 5;
+ render:quad( {{0,off},0}, {0,{0,off}}, {1,{0,off}}, {{1,-off},0} )
+ render:quad( {0,{0,off-1}}, {0,1}, {1,1}, {1,{0,off-1}})
+
+ -- horiz line at the bottom
+ --render:colour(theme.colours.control_normal)
+ --render:quad( pos(0,dim(1,-2)), pos(0,1), pos(1,1), pos(1,dim(1,-2)))
+
+ --render:quad( pos(0,dim(0,off)), pos(0,1), pos(dim(0,2),1), pos(dim(0,2),dim(0,off)))
+end
+
+geometry.normal = function()
+ if this:hasMutator("move") then
+ render:colour(1,0,0,1)
+ else
+ render:colour(theme.colours.background)
+ end
+ geometry.forall() -- Reuse!
+end
+geometry.hover = function()
+ --render:colour(theme.colours.panel_hover)
+ render:colour(theme.colours.background)
+ geometry.forall() -- Reuse!
+end
+
+----------------------
+-- If the pane has no child widgets then size(0,0) is returned.
+-- Otherwise the minimum is set to 2*margin.
+methods["minimumSize"] = function()
+ if this:numChildren() == 0 then
+ return size(0,0)
+ else
+ return size(0,0) --return property["margin"] * 2
+ end
+end
+
+--events["frame"] = function()
+--end
+
+--events["clicked"] = function()
+--end
Added: trunk/yake/common/media/gui2/styles/lua1/lua.init.lua
===================================================================
--- trunk/yake/common/media/gui2/styles/lua1/lua.init.lua (rev 0)
+++ trunk/yake/common/media/gui2/styles/lua1/lua.init.lua 2008-03-31 18:00:28 UTC (rev 1912)
@@ -0,0 +1,15 @@
+
+widgets = {
+ Cursor = "lua.cursor.lua",
+
+ Widget = "lua.panel.lua",
+ Panel = "lua.panel.lua",
+ Button = "lua.button.lua",
+ StaticText = "lua.statictext.lua",
+ Titlebar = "lua.titlebar.lua",
+ TextEdit = "lua.textedit.lua",
+
+ Dialog = "lua.dialogpanel.lua",
+ DialogPanel = "lua.dialogpanel.lua",
+}
+
Added: trunk/yake/common/media/gui2/styles/lua1/lua.panel.lua
===================================================================
--- trunk/yake/common/media/gui2/styles/lua1/lua.panel.lua (rev 0)
+++ trunk/yake/common/media/gui2/styles/lua1/lua.panel.lua 2008-03-31 18:00:28 UTC (rev 1912)
@@ -0,0 +1,40 @@
+----------------------
+-- PANEL
+----------------------
+dofile "lua.colours.inc.lua"
+
+property["margin"] = size(5,5) --5px (on all sides)
+
+----------------------
+-- Name "normal" is defined by the style!
+-- Name "forall" is defined by us for easy reuse.
+
+geometry.forall = function()
+ --render:quad(pos(0,0),pos(0,1),pos(1,1),pos(1,0))
+end
+
+geometry.normal = function()
+ render:colour(theme.colours.background)
+ geometry.forall() -- Reuse!
+end
+geometry.hover = function()
+ render:colour(theme.colours.background)
+ geometry.forall() -- Reuse!
+end
+
+----------------------
+-- If the pane has no child widgets then size(0,0) is returned.
+-- Otherwise the minimum is set to 2*margin.
+methods["minimumSize"] = function()
+ if this:numChildren() == 0 then
+ return size(0,0)
+ else
+ return size(0,0) --return property["margin"] * 2
+ end
+end
+
+--events["frame"] = function()
+--end
+
+--events["clicked"] = function()
+--end
Added: trunk/yake/common/media/gui2/styles/lua1/lua.statictext.lua
===================================================================
--- trunk/yake/common/media/gui2/styles/lua1/lua.statictext.lua (rev 0)
+++ trunk/yake/common/media/gui2/styles/lua1/lua.statictext.lua 2008-03-31 18:00:28 UTC (rev 1912)
@@ -0,0 +1,27 @@
+----------------------
+-- BUTTON
+----------------------
+dofile "lua.colours.inc.lua"
+
+property["normal.colour"] = theme.colours.control_normal
+property["text.colour"] = theme.colours.control_text
+property["padding"] = 2
+
+----------------------
+-- Name "normal", "hover" etc is defined by the style/widget!
+-- Name "forall" is defined by us for easy reuse in "normal", "hover" etc.
+
+geometry.normal = function()
+ --render:colour(property["normal.colour"])
+ --render:quad(pos(0,0),pos(0,1),pos(1,1),pos(1,0))
+
+ local pxOff = property["padding"] --pixel offset
+ render:colour(property["text.colour"])
+ render:text(pos(dim(0,pxOff),dim(0,pxOff)), this:property("text"), theme.font, theme.text_size)
+end
+
+----------------------
+methods["minimumSize"] = function()
+ local fnt = ui:getFont(theme.font)
+ return fnt:getTextSize( this:property("text") ) + size(property["padding"],property["padding"]) * 2
+end
Added: trunk/yake/common/media/gui2/styles/lua1/lua.textedit.lua
===================================================================
--- trunk/yake/common/media/gui2/styles/lua1/lua.textedit.lua (rev 0)
+++ trunk/yake/common/media/gui2/styles/lua1/lua.textedit.lua 2008-03-31 18:00:28 UTC (rev 1912)
@@ -0,0 +1,70 @@
+----------------------
+-- TextEdit
+----------------------
+dofile "lua.colours.inc.lua"
+
+property["normal.colour"] = theme.colours.control_normal
+property["text.colour"] = theme.colours.control_text
+property["padding"] = 2
+
+----------------------
+-- Name "normal", "hover" etc is defined by the style/widget!
+-- Name "forall" is defined by us for easy reuse in "normal", "hover" etc.
+
+geometry.normal = function()
+ local hasFocus = this:property("hasFocus")
+
+ render:colour(theme.colours.control_hover)
+ render:quad({0,0},{0,1},{1,1},{1,0})
+
+ local px = 1
+ if hasFocus then px = 2 end
+ render:colour(theme.colours.control_normal)
+ render:quad(
+ {{0,px},{0,px}},
+ {{0,px},{1,-px}},
+ {{1,-px},{1,-px}},
+ {{1,-px},{0,px}})
+
+ local pxOff = property["padding"] --pixel offset
+ if (hasFocus) then
+ render:colour(theme.colours.edit_text)
+ else
+ render:colour(property["text.colour"])
+ end
+ render:text(pos(dim(0,pxOff),dim(0,pxOff)), this:property("text"), theme.font, theme.text_size)
+end
+geometry.hover = function()
+ local hasFocus = this:property("hasFocus")
+ if hasFocus then
+ geometry.normal()
+ return
+ end
+
+ render:colour(theme.colours.control_hover)
+ render:colour(1,1,1,1)
+ render:quad({0,0},{0,1},{1,1},{1,0})
+
+ local px = 2
+ render:colour(theme.colours.control_normal)
+ render:quad(
+ {{0,px},{0,px}},
+ {{0,px},{1,-px}},
+ {{1,-px},{1,-px}},
+ {{1,-px},{0,px}})
+
+ local pxOff = property["padding"] --pixel offset
+ if (hasFocus) then
+ render:colour(theme.colours.edit_text)
+ else
+ render:colour(property["text.colour"])
+ end
+ render:text(pos(dim(0,pxOff),dim(0,pxOff)), this:property("text"), theme.font, theme.text_size)
+end
+
+----------------------
+methods["minimumSize"] = function()
+ local fnt = ui:getFont(theme.font)
+ return fnt:getTextSize( "EnterYourCred" ) + size(property["padding"],property["padding"]) * 2
+ --return size(50,20)
+end
Added: trunk/yake/common/media/gui2/styles/lua1/lua.titlebar.lua
===================================================================
--- trunk/yake/common/media/gui2/styles/lua1/lua.titlebar.lua (rev 0)
+++ trunk/yake/common/media/gui2/styles/lua1/lua.titlebar.lua 2008-03-31 18:00:28 UTC (rev 1912)
@@ -0,0 +1,45 @@
+----------------------
+-- Titlebar
+----------------------
+dofile "lua.colours.inc.lua"
+
+--property["margin"] = size(5,5) --5px (on all sides)
+property["padding"] = size(2,2)
+
+----------------------
+geometry.forall = function()
+ local off = 5;
+ render:quad( pos(dim(0,off),0), pos(0,dim(0,off)), pos(1,dim(0,off)), pos(dim(1,-off),0) )
+ render:quad( pos(0,dim(0,off)), pos(0,1), pos(1,1), pos(1,dim(0,off)))
+
+ render:colour(theme.colours.control_text);
+ --render:text(pos(dim(0,2),dim(0,2)), "("..this:id()..")", theme.font, theme.text_size)
+ --render:text(pos(dim(0,2),dim(0,2)), "("..this:id()..")"..this:property("text"), theme.font, theme.text_size)
+ local caption = this:property("text")
+ if caption and string.len(caption)>0 then
+ render:text(pos(dim(0,4),dim(0,1)), caption, theme.font, theme.text_size)
+ else
+ render:text(pos(dim(0,4),dim(0,1)), "("..this:id()..")", theme.font, theme.text_size)
+ end
+end
+
+geometry.normal = function()
+ render:colour(theme.colours.control_normal)
+ geometry.forall() -- Reuse!
+end
+geometry.hover = function()
+ render:colour(theme.colours.control_hover)
+ geometry.forall() -- Reuse!
+end
+
+----------------------
+methods["minimumSize"] = function()
+ local fnt = ui:getFont(theme.font)
+ return fnt:getTextSize( this:property("text") ) + property["padding"] * 2 + size(dim(0,2),0)
+end
+
+--events["frame"] = function()
+--end
+
+--events["clicked"] = function()
+--end
Modified: trunk/yake/scripts/premake/samples.lua
===================================================================
--- trunk/yake/scripts/premake/samples.lua 2008-03-30 22:43:07 UTC (rev 1911)
+++ trunk/yake/scripts/premake/samples.lua 2008-03-31 18:00:28 UTC (rev 1912)
@@ -278,5 +278,18 @@
end
end
+--------------------------------------
+if LUA_BINDINGS then
+ makeSample("sampleUi1","samples/gui/ui1")
+ sampleUsesConsole()
+ useComponent("base")
+ useComponent("scripting")
+ useComponent("res")
+ useComponent("bindings.lua")
+ useComponent("gui2")
+end
+--------------------------------------
+-- This has to be the last call:
+--------------------------------------
priv_finishSample()
Modified: trunk/yake/scripts/premake/yake.lua
===================================================================
--- trunk/yake/scripts/premake/yake.lua 2008-03-30 22:43:07 UTC (rev 1911)
+++ trunk/yake/scripts/premake/yake.lua 2008-03-31 18:00:28 UTC (rev 1912)
@@ -206,6 +206,19 @@
addDependency("netsvc")
--------------------------------------
+makeComponent("gui2","YAKE_GUI_EXPORTS")
+addDependency("base")
+addDependency("res")
+addDependency("scripting")
+addDependency("scriptingLua")
+addDependency("bindings.lua")
+
+useDep("lua")
+useDep("luabind")
+useDep("ogre")
+useDep("ois")
+
+--------------------------------------
makeComponent("vehicle","YAKE_VEHICLE_EXPORTS")
addDependency("base")
addDependency("data")
Modified: trunk/yake/src/gui2/plugins/renderer.ogre/renderer.ogre.cpp
===================================================================
--- trunk/yake/src/gui2/plugins/renderer.ogre/renderer.ogre.cpp 2008-03-30 22:43:07 UTC (rev 1911)
+++ trunk/yake/src/gui2/plugins/renderer.ogre/renderer.ogre.cpp 2008-03-31 18:00:28 UTC (rev 1912)
@@ -90,7 +90,10 @@
YAKE_DECLARE_CONCRETE(OgreSystem,"yake.ogre")
public:
OgreSystem();
- ~OgreSystem() {}
+ ~OgreSystem()
+ {
+ stop();
+ }
virtual void start();
virtual void stop();
virtual FontPtr createFont(const string& id, const string& name, const real size);
@@ -379,7 +382,7 @@
renderer_->popMaterial();
}
//--------------------------------------
- GraphicsCore::GraphicsCore() : root_(0), cam_(0)
+ GraphicsCore::GraphicsCore() : root_(0), cam_(0), sceneMgr_(0)
{
}
GraphicsCore::~GraphicsCore()
Modified: trunk/yake/src/gui2/plugins/style.lua/style.lua.cpp
===================================================================
--- trunk/yake/src/gui2/plugins/style.lua/style.lua.cpp 2008-03-30 22:43:07 UTC (rev 1911)
+++ trunk/yake/src/gui2/plugins/style.lua/style.lua.cpp 2008-03-31 18:00:28 UTC (rev 1912)
@@ -18,6 +18,8 @@
#include "yake/gui2/font.h"
#include "yake/gui2/plugins/style.lua/style.lua.h"
+#include "yake/res/res.h"
+
namespace yake {
namespace ui {
YAKE_REGISTER_CONCRETE(LuaStyle)
@@ -216,9 +218,13 @@
}
void doFile(const string& fn)
{
+ res::FindResult find = res::SourceManager::global().find(fn);
+ if (!find)
+ throw std::exception(std::string("could not find file: "+fn).c_str());
+
lua_pushcclosure(L, &pcall_handler, 0);
- if (luaL_loadfile(L, fn.c_str()))
+ if (luaL_loadfile(L, find.location().c_str()))
{
std::string err(lua_tostring(L, -1));
lua_pop(L, 2);
Modified: trunk/yake/src/res/source.cpp
===================================================================
--- trunk/yake/src/res/source.cpp 2008-03-30 22:43:07 UTC (rev 1911)
+++ trunk/yake/src/res/source.cpp 2008-03-31 18:00:28 UTC (rev 1912)
@@ -46,7 +46,7 @@
bool FileSource::exists(const Location& loc) const
{
struct stat s;
- const int code = ::stat(loc.c_str(), &s);
+ const int code = ::stat(loc.c_str(), &s);
//debugging only: std::cout << "FileSource.exists(" << loc << "): " << code << "\n";
return (code == 0);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <psy...@us...> - 2008-04-22 18:20:39
|
Revision: 1916
http://yake.svn.sourceforge.net/yake/?rev=1916&view=rev
Author: psyclonist
Date: 2008-04-22 11:19:42 -0700 (Tue, 22 Apr 2008)
Log Message:
-----------
* [gui2] "lua style" now uses Yake's Lua scripting
* [gui2] "lua style" now uses Yake's resource management
* [gui2] improved exception safety
* [gui2] added missing export declarations
Modified Paths:
--------------
trunk/yake/src/gui2/plugins/renderer.ogre/renderer.ogre.cpp
trunk/yake/src/gui2/plugins/style.lua/style.lua.cpp
trunk/yake/yake/gui2/plugins/style.lua/style.lua.h
trunk/yake/yake/gui2/widget/button.h
trunk/yake/yake/gui2/widget/dialog.h
trunk/yake/yake/gui2/widget/panel.h
trunk/yake/yake/gui2/widget/static_text.h
trunk/yake/yake/gui2/widget/text_edit.h
trunk/yake/yake/gui2/widget/titlebar.h
Modified: trunk/yake/src/gui2/plugins/renderer.ogre/renderer.ogre.cpp
===================================================================
--- trunk/yake/src/gui2/plugins/renderer.ogre/renderer.ogre.cpp 2008-04-22 18:17:42 UTC (rev 1915)
+++ trunk/yake/src/gui2/plugins/renderer.ogre/renderer.ogre.cpp 2008-04-22 18:19:42 UTC (rev 1916)
@@ -150,18 +150,25 @@
Font::Font(const string& name, WindowRendererPtr renderer, const real size) : name_(name), renderer_(renderer), size_(size), font_(0)
{
- Ogre::FontManager::ResourceCreateOrRetrieveResult succ = Ogre::FontManager::getSingleton().createOrRetrieve("BlueHighway","Default");
- Ogre::FontPtr font = succ.first;
- font->load();
- assert( (font.get()!=0) && "failed to create or retrieve font" );
- const Ogre::MaterialPtr& material = font->getMaterial();
- assert( material.get() && "font material not (yet?) loaded" );
- //materialName_ = material->getName();
- //materialName_ = "BlueHighwayTexture";
- materialName_ = font->getName() + "Texture";
- font_ = font.get();
- //material->setSceneBlending( Ogre::SBF_SOURCE_ALPHA, Ogre::SBF_ONE_MINUS_SOURCE_ALPHA );
- //material->setSceneBlending( Ogre::SBF_SOURCE_COLOUR, Ogre::SBF_ZERO );
+ try {
+ Ogre::FontManager::ResourceCreateOrRetrieveResult succ = Ogre::FontManager::getSingleton().createOrRetrieve(name.c_str(),"Default");
+ Ogre::FontPtr font = succ.first;
+ if (!font->isLoaded())
+ font->load();
+ assert( (font.get()!=0) && "failed to create or retrieve font" );
+ const Ogre::MaterialPtr& material = font->getMaterial();
+ assert( material.get() && "font material not (yet?) loaded" );
+ //materialName_ = material->getName();
+ //materialName_ = "BlueHighwayTexture";
+ materialName_ = font->getName() + "Texture";
+ font_ = font.get();
+ //material->setSceneBlending( Ogre::SBF_SOURCE_ALPHA, Ogre::SBF_ONE_MINUS_SOURCE_ALPHA );
+ //material->setSceneBlending( Ogre::SBF_SOURCE_COLOUR, Ogre::SBF_ZERO );
+ }
+ catch (Ogre::Exception& ex)
+ {
+ YAKE_EXCEPT(string("OGRE Exception: ")+ex.what());
+ }
}
typedef boost::array<Position,4> Quadrangle;
/*
@@ -677,16 +684,19 @@
/*
colourBlend_.source1 = Ogre::LBS_DIFFUSE;
colourBlend_.source2 = Ogre::LBS_CURRENT;
- colourBlend_.operation = Ogre::LBX_BLEND_DIFFUSE_ALPHA;
*/
colourBlend_.source1 = Ogre::LBS_TEXTURE;
colourBlend_.source2 = Ogre::LBS_DIFFUSE;
colourBlend_.operation = Ogre::LBX_MODULATE;
+ //colourBlend_.operation = Ogre::LBX_BLEND_DIFFUSE_ALPHA;
+ //colourBlend_.operation = Ogre::LBX_BLEND_TEXTURE_ALPHA;
alphaBlend_.blendType = Ogre::LBT_ALPHA;
alphaBlend_.source1 = Ogre::LBS_TEXTURE;
alphaBlend_.source2 = Ogre::LBS_DIFFUSE;
alphaBlend_.operation = Ogre::LBX_MODULATE;
+ //alphaBlend_.operation = Ogre::LBX_BLEND_DIFFUSE_ALPHA;
+ //alphaBlend_.operation = Ogre::LBX_BLEND_TEXTURE_ALPHA;
uvwAddressingMode_.u = Ogre::TextureUnitState::TAM_CLAMP;
uvwAddressingMode_.v = Ogre::TextureUnitState::TAM_CLAMP;
@@ -884,6 +894,8 @@
{
renderOp_.vertexData->vertexStart = bufferPos_;
Ogre::TexturePtr tex = it->pTex0;
+ //if (tex.get() && !tex->isLoaded())
+ // tex->load();
for (; it != faces_.end(); ++it)
{
const Face& f = *it;
@@ -996,16 +1008,17 @@
if (it != fonts_.end())
return it->second;
- try {
+ //try
+ {
FontPtr fnt(new Font(name,getRenderer(),size));
fonts_[id] = fnt;
return fnt;
}
- catch (Exception&)
- {
- assert( false && "CAUGHT EXCEPTION during FONT CREATION" ); //@todo <- replace with logging?
- throw;
- }
+// catch (Exception&)
+// {
+// //assert( false && "CAUGHT EXCEPTION during FONT CREATION" ); //@todo <- replace with logging?
+// throw;
+// }
}
FontPtr OgreSystem::getFont(const string& id) const
{
Modified: trunk/yake/src/gui2/plugins/style.lua/style.lua.cpp
===================================================================
--- trunk/yake/src/gui2/plugins/style.lua/style.lua.cpp 2008-04-22 18:17:42 UTC (rev 1915)
+++ trunk/yake/src/gui2/plugins/style.lua/style.lua.cpp 2008-04-22 18:19:42 UTC (rev 1916)
@@ -18,6 +18,9 @@
#include "yake/gui2/font.h"
#include "yake/gui2/plugins/style.lua/style.lua.h"
+#include "yake/scripting/scripting.h"
+#include "yake/plugins/scriptingLua/ScriptingSystemLua.h"
+#include "yake/bindings.lua/bindings.lua.h"
#include "yake/res/res.h"
namespace yake {
@@ -32,7 +35,7 @@
};
struct LuaStyleBatcher
{
- void setRenderer(WindowRendererPtr r)
+ void setRenderer(IWindowRenderer* r)
{ renderer_ = r; }
void setSystem(SystemPtr sys)
{ sys_ = sys; }
@@ -49,7 +52,7 @@
{}
};
- LuaStyleBatcher() : curr_(0), currZ_(0)
+ LuaStyleBatcher() : curr_(0), currZ_(0), renderer_(0)
{}
void setCurrentWidget(Widget& w, real z)
{
@@ -129,7 +132,7 @@
Widget* curr_;
real currZ_;
colour clr_;
- WindowRendererPtr renderer_;
+ IWindowRenderer* renderer_;
SystemPtr sys_;
Position toAbsolute(const dim2& pos)
@@ -183,6 +186,7 @@
// UI
namespace yake {
namespace ui {
+#if 0
int pcall_handler(lua_State* L)
{
return 1;
@@ -247,16 +251,26 @@
private:
lua_State* L;
};
+#endif
+ lua_State* state(VMPtr vm)
+ {
+ if (!vm)
+ return 0;
+ return static_cast<scripting::LuaVM*>(vm.get())->getLuaState();
+ }
LuaStyle::LuaStyle(SystemPtr sys, WindowRendererPtr w) : sys_(sys), renderer_(w), batcher_( new LuaStyleBatcher() )
{
- batcher_->setRenderer( renderer_ );
+ batcher_->setRenderer( renderer_.get() );
batcher_->setSystem( sys_ );
+ scriptingSys_ = create<scripting::IScriptingSystem>("lua");
+ YAKE_ASSERT( scriptingSys_ ).error("could init scripting system");;
+
{
VMPtr init = this->createVM();
- init->doFile("lua.init.lua");
+ init->execute(getOrLoadScript("lua.init.lua"));
{
- lua_State* L = init->state();
+ lua_State* L = state(init);
using namespace luabind;
object o = globals(L)["widgets"];
if (o && (type(o) == LUA_TTABLE))
@@ -301,6 +315,15 @@
// this->createVM("Dialog","lua.dialogpanel.lua");
// this->createVM("DialogPanel","lua.dialogpanel.lua");
}
+ LuaStyle::~LuaStyle()
+ {
+ scripts_.clear();
+ vm_.clear();
+ scriptingSys_.reset();
+ batcher_.reset();
+ renderer_.reset();
+ sys_.reset();
+ }
bool widget_hasMutator(Widget* w,const string& tag)
{
@@ -309,8 +332,8 @@
void LuaStyle::bind(VMPtr vm)
{
- lua_State* L = vm ? vm->state() : 0;
- assert(L && "null state");
+ lua_State* L = vm ? state(vm) : 0;
+ YAKE_ASSERT(L).error("null state");
if (!L)
return;
@@ -401,7 +424,7 @@
globals(L)["geometry"] = luabind::newtable(L);
globals(L)["render"] = batcher_;
- batcher_->setRenderer( renderer_ );
+ batcher_->setRenderer( renderer_.get() );
globals(L)["ui"] = sys_;
globals(L)["methods"] = luabind::newtable(L);
@@ -409,10 +432,25 @@
}
VMPtr LuaStyle::createVM()
{
- VMPtr vm(new LuaVM());
+ YAKE_ASSERT(scriptingSys_);
+ VMPtr vm = scriptingSys_->createVM();
+ bind_all(vm.get());
+ vm->execute(getOrLoadScript("bind_resource_loaders.lua"));
this->bind(vm);
return vm;
}
+ scripting::ScriptPtr LuaStyle::getOrLoadScript(const string& filename)
+ {
+ YAKE_ASSERT(scriptingSys_);
+ ScriptMap::const_iterator it = scripts_.find(filename);
+ if (it != scripts_.end())
+ return it->second;
+
+ scripting::ScriptPtr script = scriptingSys_->createScriptFromFile(filename);
+ if (script)
+ scripts_[filename] = script;
+ return script;
+ }
void LuaStyle::createVM(const string& widgetType,const string& fn)
{
vm_[ widgetType ].reset( new LuaStyleWidgetEntry() );
@@ -420,8 +458,8 @@
//
widgetEntry->vm = this->createVM();
- lua_State* L = widgetEntry->vm->state();
- widgetEntry->vm->doFile( fn.c_str() );
+ lua_State* L = state(widgetEntry->vm);
+ widgetEntry->vm->execute( getOrLoadScript(fn) );
//
for (luabind::iterator it(luabind::globals(L)["property"]), end; it != end; ++it)
@@ -458,7 +496,7 @@
luabind::object o = entry.methods.find("minimumSize")->second;
- luabind::globals(entry.vm->state())["this"] = &w;
+ luabind::globals(state(entry.vm))["this"] = &w;
AbsSize value = luabind::call_function<AbsSize>( o );
return value;
@@ -479,7 +517,7 @@
if (itVM != this->vm_.end())
{
try {
- luabind::object o = luabind::globals(itVM->second->vm->state())["renderCursor"];
+ luabind::object o = luabind::globals(state(itVM->second->vm))["renderCursor"];
assert( luabind::type(o) == LUA_TFUNCTION );
//luabind::call_function();
o( pos.x, pos.y );
@@ -527,7 +565,7 @@
assert( batcher_ );
batcher_->setCurrentWidget( w, zLevel );
- luabind::globals(entry.vm->state())["this"] = &w;
+ luabind::globals(state(entry.vm))["this"] = &w;
o();
}
Modified: trunk/yake/yake/gui2/plugins/style.lua/style.lua.h
===================================================================
--- trunk/yake/yake/gui2/plugins/style.lua/style.lua.h 2008-04-22 18:17:42 UTC (rev 1915)
+++ trunk/yake/yake/gui2/plugins/style.lua/style.lua.h 2008-04-22 18:19:42 UTC (rev 1916)
@@ -2,11 +2,11 @@
#define UI_LUASTYLE_H
#include "yake/gui2/style.h"
+#include "yake/scripting/scripting.h"
namespace yake {
namespace ui {
- struct LuaVM;
- typedef boost::shared_ptr<LuaVM> VMPtr;
+ typedef scripting::VMPtr VMPtr;
struct LuaStyleWidgetEntry;
typedef boost::shared_ptr<LuaStyleWidgetEntry> LuaStyleWidgetEntryPtr;
struct LuaStyleBatcher;
@@ -15,6 +15,7 @@
YAKE_DECLARE_CONCRETE(LuaStyle,"yake.lua")
public:
LuaStyle(SystemPtr,WindowRendererPtr);
+ virtual ~LuaStyle();
virtual AbsSize determineMinimumSize(Widget&);
virtual void renderSingleWidget(Widget&, const int zLevel);
virtual void renderCursor(const Position&, const int zLevel);
@@ -22,9 +23,10 @@
//void loadWidgetStyle(const string& scriptFile, const string& widgetType = "");
private:
typedef std::map<string,LuaStyleWidgetEntryPtr> VmMap;
- VmMap vm_;
- //typedef std::map<string,string> ScriptMap;
- //ScriptMap widgetScripts_;
+ VmMap vm_;
+ typedef std::map<string,scripting::ScriptPtr> ScriptMap;
+ ScriptMap scripts_;
+ SharedPtr<scripting::IScriptingSystem> scriptingSys_;
//typedef std::map<string,string> NamedImagesMap;
//NamedImagesMap images_;
@@ -36,6 +38,7 @@
void bind(VMPtr);
VMPtr createVM();
void createVM(const string&,const string&);
+ scripting::ScriptPtr getOrLoadScript(const string& filename);
};
} // namespace ui
} // namespace yake
Modified: trunk/yake/yake/gui2/widget/button.h
===================================================================
--- trunk/yake/yake/gui2/widget/button.h 2008-04-22 18:17:42 UTC (rev 1915)
+++ trunk/yake/yake/gui2/widget/button.h 2008-04-22 18:19:42 UTC (rev 1916)
@@ -6,7 +6,7 @@
namespace yake {
namespace ui {
- struct Button : public Widget
+ struct YAKE_GUI_API Button : public Widget
{
YAKE_WIDGET(Button);
Modified: trunk/yake/yake/gui2/widget/dialog.h
===================================================================
--- trunk/yake/yake/gui2/widget/dialog.h 2008-04-22 18:17:42 UTC (rev 1915)
+++ trunk/yake/yake/gui2/widget/dialog.h 2008-04-22 18:19:42 UTC (rev 1916)
@@ -7,7 +7,7 @@
namespace yake {
namespace ui {
- struct Dialog : public Widget
+ struct YAKE_GUI_API Dialog : public Widget
{
YAKE_WIDGET(Dialog);
Modified: trunk/yake/yake/gui2/widget/panel.h
===================================================================
--- trunk/yake/yake/gui2/widget/panel.h 2008-04-22 18:17:42 UTC (rev 1915)
+++ trunk/yake/yake/gui2/widget/panel.h 2008-04-22 18:19:42 UTC (rev 1916)
@@ -6,7 +6,7 @@
namespace yake {
namespace ui {
- struct Panel : public Widget
+ struct YAKE_GUI_API Panel : public Widget
{
YAKE_WIDGET(Panel);
Panel(const string& id) : Widget(id)
Modified: trunk/yake/yake/gui2/widget/static_text.h
===================================================================
--- trunk/yake/yake/gui2/widget/static_text.h 2008-04-22 18:17:42 UTC (rev 1915)
+++ trunk/yake/yake/gui2/widget/static_text.h 2008-04-22 18:19:42 UTC (rev 1916)
@@ -10,7 +10,7 @@
@property text string
@property fontsize real
*/
- struct StaticText : public Widget
+ struct YAKE_GUI_API StaticText : public Widget
{
YAKE_WIDGET(StaticText);
StaticText(const string& id);
Modified: trunk/yake/yake/gui2/widget/text_edit.h
===================================================================
--- trunk/yake/yake/gui2/widget/text_edit.h 2008-04-22 18:17:42 UTC (rev 1915)
+++ trunk/yake/yake/gui2/widget/text_edit.h 2008-04-22 18:19:42 UTC (rev 1916)
@@ -7,7 +7,7 @@
namespace yake {
namespace ui {
- struct TextEdit : public Panel
+ struct YAKE_GUI_API TextEdit : public Panel
{
YAKE_WIDGET(TextEdit);
Modified: trunk/yake/yake/gui2/widget/titlebar.h
===================================================================
--- trunk/yake/yake/gui2/widget/titlebar.h 2008-04-22 18:17:42 UTC (rev 1915)
+++ trunk/yake/yake/gui2/widget/titlebar.h 2008-04-22 18:19:42 UTC (rev 1916)
@@ -9,7 +9,7 @@
namespace yake {
namespace ui {
/** @todo convert into Behaviour !? */
- struct Titlebar : public Panel
+ struct YAKE_GUI_API Titlebar : public Panel
{
YAKE_WIDGET(Titlebar);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <psy...@us...> - 2008-05-20 21:30:29
|
Revision: 1918
http://yake.svn.sourceforge.net/yake/?rev=1918&view=rev
Author: psyclonist
Date: 2008-05-20 14:30:00 -0700 (Tue, 20 May 2008)
Log Message:
-----------
* feature: added support for Visual C++ 9.0 (incl. Express Edition!)
* bug: fixed a few namespace and include issues for PC/Windows
Modified Paths:
--------------
trunk/yake/src/base/native/win32/yakeApplication.cpp
trunk/yake/src/base/native/win32/yakeTime.cpp
trunk/yake/src/data/yakeXMLSerializer.cpp
trunk/yake/yake/base/math/yakeQuaternion.h
trunk/yake/yake/base/native/win32/win32.rc
trunk/yake/yake/base/prerequisites/yakePrerequisitesVC.h
trunk/yake/yake/base/yakePlatform.h
Modified: trunk/yake/src/base/native/win32/yakeApplication.cpp
===================================================================
--- trunk/yake/src/base/native/win32/yakeApplication.cpp 2008-05-02 11:34:55 UTC (rev 1917)
+++ trunk/yake/src/base/native/win32/yakeApplication.cpp 2008-05-20 21:30:00 UTC (rev 1918)
@@ -25,27 +25,17 @@
------------------------------------------------------------------------------------
*/
-//============================================================================
-// IMPLEMENTATION HEADERS
-//============================================================================
-// Yake
#include <yake/base/yakePCH.h>
#include <yake/base/native/yakeNative.h>
-namespace Win32
-{
+#ifndef STRICT
# define STRICT
-# define WIN32_LEAN_AND_MEAN
-# include <windows.h>
-}
+#endif
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
-//============================================================================
-// INTERFACE STRUCTURES / UTILITY CLASSES
-//============================================================================
-namespace yake
-{
-namespace native
-{
+namespace yake {
+namespace native {
const char* getApplicationDir()
{
@@ -53,7 +43,7 @@
if( !*szBuffer )
{
- Win32::GetModuleFileName( NULL, szBuffer, MAX_PATH );
+ GetModuleFileName( NULL, szBuffer, MAX_PATH );
*strrchr( szBuffer, '\\' ) = '\0';
}
Modified: trunk/yake/src/base/native/win32/yakeTime.cpp
===================================================================
--- trunk/yake/src/base/native/win32/yakeTime.cpp 2008-05-02 11:34:55 UTC (rev 1917)
+++ trunk/yake/src/base/native/win32/yakeTime.cpp 2008-05-20 21:30:00 UTC (rev 1918)
@@ -32,41 +32,35 @@
#include <yake/base/yakePCH.h>
#include <yake/base/native/yakeNative.h>
-namespace Win32
-{
+#ifndef STRICT
# define STRICT
-# define WIN32_LEAN_AND_MEAN
-# include <windows.h>
-# include <mmsystem.h>
-}
+#endif
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+#include <mmsystem.h>
-//============================================================================
-// INTERFACE STRUCTURES / UTILITY CLASSES
-//============================================================================
-namespace yake
-{
-namespace native
-{
+namespace yake {
+namespace native {
static class TimerInit
{
public:
// Public member for a gain of speed.
- Win32::LARGE_INTEGER mTimerFrequency;
+ ::LARGE_INTEGER mTimerFrequency;
double mStart;
// Constructor.
TimerInit()
{
- if( !Win32::QueryPerformanceFrequency( &mTimerFrequency ) )
+ if( !::QueryPerformanceFrequency( &mTimerFrequency ) )
{
mTimerFrequency.QuadPart = 0;
- mStart = Win32::timeGetTime() / 1000.0f;
+ mStart = ::timeGetTime() / 1000.0f;
}
else
{
- Win32::LARGE_INTEGER largeCount;
- Win32::QueryPerformanceCounter( &largeCount );
+ ::LARGE_INTEGER largeCount;
+ ::QueryPerformanceCounter( &largeCount );
double count = double( largeCount.QuadPart );
double frequency = double( mTimerFrequency.QuadPart );
@@ -81,10 +75,10 @@
{
// No performance timer available.
if( TimerInit_g.mTimerFrequency.QuadPart == 0 )
- return real( Win32::timeGetTime() / 1000.0f - TimerInit_g.mStart );
+ return real( ::timeGetTime() / 1000.0f - TimerInit_g.mStart );
- Win32::LARGE_INTEGER largeCount;
- Win32::QueryPerformanceCounter( &largeCount );
+ ::LARGE_INTEGER largeCount;
+ ::QueryPerformanceCounter( &largeCount );
double count = double( largeCount.QuadPart );
double frequency = double( TimerInit_g.mTimerFrequency.QuadPart );
Modified: trunk/yake/src/data/yakeXMLSerializer.cpp
===================================================================
--- trunk/yake/src/data/yakeXMLSerializer.cpp 2008-05-02 11:34:55 UTC (rev 1917)
+++ trunk/yake/src/data/yakeXMLSerializer.cpp 2008-05-20 21:30:00 UTC (rev 1918)
@@ -27,7 +27,9 @@
#include <yake/data/yakePCH.h>
#include <yake/data/yakeXMLSerializer.h>
-#define STRICT
+#ifndef STRICT
+# define STRICT
+#endif
#define WIN32_LEAN_AND_MEAN
#include <dependencies/tinyxml/tinyxml.h>
Modified: trunk/yake/yake/base/math/yakeQuaternion.h
===================================================================
--- trunk/yake/yake/base/math/yakeQuaternion.h 2008-05-02 11:34:55 UTC (rev 1917)
+++ trunk/yake/yake/base/math/yakeQuaternion.h 2008-05-20 21:30:00 UTC (rev 1918)
@@ -36,7 +36,6 @@
#endif
// Yake
#include "yake/base/math/yakeMath.h"
-#include <iostream>
//============================================================================
// INTERFACE STRUCTURES / UTILITY CLASSES
Modified: trunk/yake/yake/base/native/win32/win32.rc
===================================================================
--- trunk/yake/yake/base/native/win32/win32.rc 2008-05-02 11:34:55 UTC (rev 1917)
+++ trunk/yake/yake/base/native/win32/win32.rc 2008-05-20 21:30:00 UTC (rev 1918)
@@ -1,5 +1,9 @@
// Microsoft Visual C++ generated resource script.
//
+// NB We're including windows.h instead of afxres.h so that the resources
+// can be compiled on VC++Express2008(9.0), too. The Express Edition
+// does not ship with support for MFC/ATL, so afxres.h is missing there.
+//
#include "yakeResource.h"
#define APSTUDIO_READONLY_SYMBOLS
@@ -7,7 +11,7 @@
//
// Generated from the TEXTINCLUDE 2 resource.
//
-#include "afxres.h"
+#include "windows.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
@@ -34,7 +38,7 @@
2 TEXTINCLUDE
BEGIN
- "#include ""afxres.h""\r\n"
+ "#include ""windows.h""\r\n"
"\0"
END
Modified: trunk/yake/yake/base/prerequisites/yakePrerequisitesVC.h
===================================================================
--- trunk/yake/yake/base/prerequisites/yakePrerequisitesVC.h 2008-05-02 11:34:55 UTC (rev 1917)
+++ trunk/yake/yake/base/prerequisites/yakePrerequisitesVC.h 2008-05-20 21:30:00 UTC (rev 1918)
@@ -41,12 +41,19 @@
# include <xhash>
# include "yakePrerequisitesVC71Types.h"
# elif(YAKE_COMP_VER == 1400)
-# //pragma message("Yake platform/compiler config: yake.prerequisites.vc8")
+# //pragma message("Yake platform/compiler config: yake.prerequisites.vc80")
# include "yakePrerequisitesVC8Warnings.h"
# include <wchar.h>
# include <hash_map>
# include <xhash>
# include "yakePrerequisitesVC8Types.h"
+# elif(YAKE_COMP_VER == 1500)
+# //pragma message("Yake platform/compiler config: yake.prerequisites.vc90")
+# include "yakePrerequisitesVC8Warnings.h"
+# include <wchar.h>
+# include <hash_map>
+# include <xhash>
+# include "yakePrerequisitesVC8Types.h"
# else
# error("Yake platform/compiler error: no configuration file for this compiler!")
# endif
Modified: trunk/yake/yake/base/yakePlatform.h
===================================================================
--- trunk/yake/yake/base/yakePlatform.h 2008-05-02 11:34:55 UTC (rev 1917)
+++ trunk/yake/yake/base/yakePlatform.h 2008-05-20 21:30:00 UTC (rev 1918)
@@ -49,6 +49,7 @@
// 1300 for vc7.0 (2002)
// 1310 for vc7.1 (2003)
// 1400 for vc8.0 (2005)
+ // 1500 for vc9.0 (2008)
# define YAKE_COMP_VER _MSC_VER
#elif defined( __GNUC__ )
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <psy...@us...> - 2008-06-23 22:22:33
|
Revision: 1922
http://yake.svn.sourceforge.net/yake/?rev=1922&view=rev
Author: psyclonist
Date: 2008-06-23 15:22:28 -0700 (Mon, 23 Jun 2008)
Log Message:
-----------
* bindings.lua: provided registerClass<> for binding 'this' of parent classes
* sampleEntFsm: provided MyEntity to demonstrate how to create custom entities
* ent: fixed namespace reference in macro
Modified Paths:
--------------
trunk/yake/samples/ent/sampleEntFsm/demo.cpp
trunk/yake/yake/bindings.lua/bindings.lua.ent.registry.h
trunk/yake/yake/ent/object.h
Modified: trunk/yake/samples/ent/sampleEntFsm/demo.cpp
===================================================================
--- trunk/yake/samples/ent/sampleEntFsm/demo.cpp 2008-05-20 21:32:17 UTC (rev 1921)
+++ trunk/yake/samples/ent/sampleEntFsm/demo.cpp 2008-06-23 22:22:28 UTC (rev 1922)
@@ -11,13 +11,22 @@
namespace yake {
namespace exapp {
+ // Some states for the entity state machine:
const yake::String ksAwakening = "awakening";
const yake::String ksAlive = "alive";
const yake::String ksDead = "dead";
+
+ // A custom entity for our demo application:
+ struct MyEntity : public ent::Entity
+ {
+ DECL_OBJECT(MyEntity,"MyEntity")
+
+ MyEntity() {}
+ };
+ IMPL_OBJECT(MyEntity);
} // namespace exapp
} // namespace yake
-
int main(int argc, char* argv[])
{
using namespace yake;
@@ -49,6 +58,10 @@
ent::registerClass<ent::Object>();
ent::registerClass<ent::Entity>();
ent::registerClass<ent::Trigger>();
+ // Note, that we specify Entity as the parent class, as there've been Lua bindings defined for it
+ // while exapp::MyEntity has no Lua bindings. So, from Lua a MyEntity instance
+ // will look like an Entity instance.
+ ent::registerClass<exapp::MyEntity,ent::Entity>();
// Register object class(es)
ent::ObjectCreationParameters params;
@@ -59,12 +72,22 @@
ret = objMgr.registerClass<ent::Trigger>("Trigger",params);
YAKE_ASSERT( ret.first == object::RC_OK );
+ ret = objMgr.registerClass<exapp::MyEntity>("MyEntity",params);
+ YAKE_ASSERT( ret.first == object::RC_OK );
+
// Create trigger
{
ent::Trigger* trigger = ent::Trigger::cast(objMgr.makeObject("Trigger"));
YAKE_ASSERT( trigger );
}
+ // Create instance of MyEntity
+ {
+ exapp::MyEntity* myEnt = exapp::MyEntity::cast(objMgr.makeObject("MyEntity"));
+ YAKE_ASSERT( myEnt );
+ }
+
+ // run the sim for 10 ticks
for (size_t i=0; i<10; ++i)
objMgr.tick();
Modified: trunk/yake/yake/bindings.lua/bindings.lua.ent.registry.h
===================================================================
--- trunk/yake/yake/bindings.lua/bindings.lua.ent.registry.h 2008-05-20 21:32:17 UTC (rev 1921)
+++ trunk/yake/yake/bindings.lua/bindings.lua.ent.registry.h 2008-06-23 22:22:28 UTC (rev 1922)
@@ -239,6 +239,11 @@
{
classRegistry().registerClass<T>( boost::bind(&detail::do_register_bindThis<T>,_1,_2) );
}
+ template<class T, class ParentT>
+ inline void registerClass()
+ {
+ classRegistry().registerClass<T>( boost::bind(&detail::do_register_bindThis<ParentT>,_1,_2) );
+ }
} // namespace ent
} // namespace yake
Modified: trunk/yake/yake/ent/object.h
===================================================================
--- trunk/yake/yake/ent/object.h 2008-05-20 21:32:17 UTC (rev 1921)
+++ trunk/yake/yake/ent/object.h 2008-06-23 22:22:28 UTC (rev 1922)
@@ -45,7 +45,7 @@
#define DECL_OBJECT(CLASS,DESC) \
DECL_CLASS_RTTI(CLASS,DESC) \
public: \
- static ::yake::ent::Object* create(const ObjectId& id) \
+ static ::yake::ent::Object* create(const ::yake::ent::ObjectId& id) \
{ \
::yake::ent::Object* obj = new CLASS(); \
obj->setId(id); \
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <psy...@us...> - 2008-06-28 19:54:33
|
Revision: 1925
http://yake.svn.sourceforge.net/yake/?rev=1925&view=rev
Author: psyclonist
Date: 2008-06-28 12:54:36 -0700 (Sat, 28 Jun 2008)
Log Message:
-----------
* fixed due to /W4 warnings
Modified Paths:
--------------
trunk/yake/src/base/yakeConfigFile.cpp
trunk/yake/yake/base/templates/yakeSmartAssert.h
trunk/yake/yake/factory/dynamic_factory.h
trunk/yake/yake/factory/policies.h
Modified: trunk/yake/src/base/yakeConfigFile.cpp
===================================================================
--- trunk/yake/src/base/yakeConfigFile.cpp 2008-06-23 22:24:25 UTC (rev 1924)
+++ trunk/yake/src/base/yakeConfigFile.cpp 2008-06-28 19:54:36 UTC (rev 1925)
@@ -109,7 +109,7 @@
}
void Configuration::readFromFile(const String& fn, const String& insertAt)
{
- YAKE_ASSERT( insertAt.empty() && "not yet supported" );
+ YAKE_ASSERT( insertAt.empty() ).debug("not yet supported" );
std::ifstream in(fn.c_str());
if (!in.is_open())
return; //@todo
@@ -117,7 +117,7 @@
}
void Configuration::readFromXML(const String& fn, const String& insertAt)
{
- YAKE_ASSERT( insertAt.empty() && "not yet supported" );
+ YAKE_ASSERT( insertAt.empty() ).debug("not yet supported" );
std::ifstream in(fn.c_str());
if (!in.is_open())
return; //@todo
@@ -125,7 +125,7 @@
}
void Configuration::writeToFile(const String& fn, const String& startAt)
{
- YAKE_ASSERT( startAt.empty() && "not yet supported" );
+ YAKE_ASSERT( startAt.empty() ).debug("not yet supported" );
//boost::property_tree::write_info(cout,*tree_);
std::ofstream out(fn.c_str());
Modified: trunk/yake/yake/base/templates/yakeSmartAssert.h
===================================================================
--- trunk/yake/yake/base/templates/yakeSmartAssert.h 2008-06-23 22:24:25 UTC (rev 1924)
+++ trunk/yake/yake/base/templates/yakeSmartAssert.h 2008-06-28 19:54:36 UTC (rev 1925)
@@ -133,6 +133,16 @@
#pragma warning(push)
#pragma warning(disable: 4355) // 'this': used in base member initializer list
SmartAssert( const char * strExpr ) : YAKE_ASSERT_A(*this), YAKE_ASSERT_B(*this), mCtx(strExpr) {}
+ SmartAssert(const SmartAssert& other) : YAKE_ASSERT_A(*this), YAKE_ASSERT_B(*this), mCtx(other.mCtx)
+ {
+ }
+ const SmartAssert& operator = (const SmartAssert& rhs)
+ {
+ if (this == &rhs)
+ return *this;
+ mCtx = rhs.mCtx;
+ return *this;
+ }
#pragma warning(pop)
~SmartAssert();
Modified: trunk/yake/yake/factory/dynamic_factory.h
===================================================================
--- trunk/yake/yake/factory/dynamic_factory.h 2008-06-23 22:24:25 UTC (rev 1924)
+++ trunk/yake/yake/factory/dynamic_factory.h 2008-06-28 19:54:36 UTC (rev 1925)
@@ -25,7 +25,7 @@
R create(const Kt& id)
{
std::cout << "attempt create '" << typeid(X::return_t).name() << "' id='" << id << "' sig='" << typeid(X::signature_t).name() << "'\n";
- typedef X::Id2Class::const_iterator it_t;
+ typedef typename X::Id2Class::const_iterator it_t;
const X& x = static_cast<X&>(*this);
it_t it = x.id2class_.find(id);
if (it == x.id2class_.end())
@@ -38,7 +38,7 @@
R create_default()
{
std::cout << "attempt create default sig='" << typeid(X::signature_t).name() << "'\n";
- typedef X::Id2Class::const_iterator it_t;
+ typedef typename X::Id2Class::const_iterator it_t;
const X& x = static_cast<X&>(*this);
it_t it = x.id2class_.begin();
if (it == x.id2class_.end())
@@ -62,7 +62,7 @@
R create(const Kt& id, const A0& a0 = A0())
{
std::cout << "attempt create '" << typeid(X::return_t).name() << "' id='" << id << "' sig='" << typeid(X::signature_t).name() << "'\n";
- typedef X::Id2Class::const_iterator it_t;
+ typedef typename X::Id2Class::const_iterator it_t;
const X& x = static_cast<X&>(*this);
it_t it = x.id2class_.find(id);
if (it == x.id2class_.end())
@@ -75,7 +75,7 @@
R create_default(const A0& a0 = A0())
{
std::cout << "attempt create default sig='" << typeid(X::signature_t).name() << "'\n";
- typedef X::Id2Class::const_iterator it_t;
+ typedef typename X::Id2Class::const_iterator it_t;
const X& x = static_cast<X&>(*this);
it_t it = x.id2class_.begin();
if (it == x.id2class_.end())
@@ -98,7 +98,7 @@
R create(const Kt& id, const A0& a0 = A0(), const A1& a1 = A1())
{
std::cout << "attempt create '" << typeid(X::return_t).name() << "' id='" << id << "' sig='" << typeid(X::signature_t).name() << "'\n";
- typedef X::Id2Class::const_iterator it_t;
+ typedef typename X::Id2Class::const_iterator it_t;
const X& x = static_cast<X&>(*this);
it_t it = x.id2class_.find(id);
if (it == x.id2class_.end())
@@ -111,7 +111,7 @@
R create_default(const A0& a0 = A0(), const A1& a1 = A1())
{
std::cout << "attempt create default sig='" << typeid(X::signature_t).name() << "'\n";
- typedef X::Id2Class::const_iterator it_t;
+ typedef typename X::Id2Class::const_iterator it_t;
const X& x = static_cast<X&>(*this);
it_t it = x.id2class_.begin();
if (it == x.id2class_.end())
Modified: trunk/yake/yake/factory/policies.h
===================================================================
--- trunk/yake/yake/factory/policies.h 2008-06-23 22:24:25 UTC (rev 1924)
+++ trunk/yake/yake/factory/policies.h 2008-06-28 19:54:36 UTC (rev 1925)
@@ -19,7 +19,7 @@
{
Exception(const std::string& msg) : msg_(msg)
{}
- virtual const char* what() const
+ virtual const char* what() const throw()
{
return msg_.c_str();
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|