[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [37877] branches/soc-2011-oregano/source/ gameengine/NodeLogic: Added bare bones of Entity and component system and corrected some commentaries .
Sven von Brand
svbrand at alumnos.inf.utfsm.cl
Mon Jun 27 22:36:08 CEST 2011
Revision: 37877
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=37877
Author: svbrand
Date: 2011-06-27 20:36:08 +0000 (Mon, 27 Jun 2011)
Log Message:
-----------
Added bare bones of Entity and component system and corrected some commentaries.
Modified Paths:
--------------
branches/soc-2011-oregano/source/gameengine/NodeLogic/CMakeLists.txt
branches/soc-2011-oregano/source/gameengine/NodeLogic/NL_IQueueItem.h
branches/soc-2011-oregano/source/gameengine/NodeLogic/NL_NodeLink.cpp
Added Paths:
-----------
branches/soc-2011-oregano/source/gameengine/NodeLogic/NL_Component.cpp
branches/soc-2011-oregano/source/gameengine/NodeLogic/NL_Component.h
branches/soc-2011-oregano/source/gameengine/NodeLogic/NL_Entity.cpp
branches/soc-2011-oregano/source/gameengine/NodeLogic/NL_Entity.h
Modified: branches/soc-2011-oregano/source/gameengine/NodeLogic/CMakeLists.txt
===================================================================
--- branches/soc-2011-oregano/source/gameengine/NodeLogic/CMakeLists.txt 2011-06-27 20:18:04 UTC (rev 37876)
+++ branches/soc-2011-oregano/source/gameengine/NodeLogic/CMakeLists.txt 2011-06-27 20:36:08 UTC (rev 37877)
@@ -29,6 +29,8 @@
)
set(SRC
+ NL_Component.cpp
+ NL_Entity.cpp
NL_NodeEngine.cpp
NL_NodeGraph.cpp
NL_NodeLink.cpp
@@ -42,6 +44,9 @@
NL_IQueueItem.h
NL_Node.cpp
NL_Node.h
+
+ NL_Component.h
+ NL_Entity.h
NL_NodeEngine.h
NL_NodeGraph.h
NL_NodeLink.h
Added: branches/soc-2011-oregano/source/gameengine/NodeLogic/NL_Component.cpp
===================================================================
--- branches/soc-2011-oregano/source/gameengine/NodeLogic/NL_Component.cpp (rev 0)
+++ branches/soc-2011-oregano/source/gameengine/NodeLogic/NL_Component.cpp 2011-06-27 20:36:08 UTC (rev 37877)
@@ -0,0 +1,96 @@
+/**
+ * $Id: NL_Component.cpp$
+ *
+ * Copyright (c) 2009-2010
+ *
+ * This software is provided 'as-is', without any express or implied warranty.
+ * In no event will the authors be held liable for any damages arising from the use
+ * of this software.
+ * Permission is granted to anyone to use this software for any purpose,
+ * including commercial applications, and to alter it and redistribute it freely,
+ * subject to the following restrictions:
+ *
+ * 1. The origin of this software must not be misrepresented; you must not claim that you
+ * wrote the original software. If you use this software in a product, an acknowledgment
+ * in the product documentation would be appreciated but is not required.
+ * 2. Altered source versions must be plainly marked as such, and must not be misrepresented
+ * as being the original software.
+ * 3. This notice may not be removed or altered from any source distribution.
+ */
+
+/**
+* This will be the Component in the node engine, it is based in the NL_NodeEngine.cpp, but it
+* will run the logic for a list of Entities.
+* And Entity defines logic to be run under certain conditions, such as which Game Objects it
+* will affect and which logic it is related to. The relation is through labels and the logic
+* is in the components. Entities are NL_Entity.cpp.
+*
+* Next to do: Define how to apply logic to a group of Entities.
+**/
+
+#include "NL_Component.h"
+#include "NL_NodeLink.h"
+
+unsigned int NL_Component::sCurrentFrame;
+NL_Component* NL_Component::sCurrentComponent;
+
+NL_Component::NL_Component()
+{
+ //This list has to be run only on asociated Entities
+ m_runlists = new NL_DList[NL_Node::PRIORITY_COUNT];
+}
+
+NL_Component::~NL_Component()
+{
+
+}
+
+void NL_Component::QueueData(NL_IQueueItem* data)
+{
+ // find the right position in queue to store data
+ NL_IQueueItem* item;
+ NL_Timestamp stamp = data->m_timestamp;
+ NL_DList::iterator<NL_IQueueItem> it(m_queueData);
+ for (it.back(); !it.end(); --it)
+ {
+ item = *it;
+ if (stamp >= item->m_timestamp)
+ {
+ item->AddFront(data);
+ return;
+ }
+ }
+ // stamp is lower than all stamp on queue, will be the first so add on front
+ m_queueData.AddFront(data);
+}
+
+//This should add a label and all entities not already related through this label.
+void NL_Component::AddLabel()
+{
+
+}
+
+//This should remove the label and remove all entities related to this component only through this label.
+void NL_Component::RemoveLabel()
+{
+
+}
+void NL_Component::CheckLabel()
+{
+
+}
+
+void NL_Component::AddProperty()
+{
+
+}
+
+void NL_Component::RemoveProperty()
+{
+
+}
+
+void NL_Component::CheckProperty()
+{
+
+}
Added: branches/soc-2011-oregano/source/gameengine/NodeLogic/NL_Component.h
===================================================================
--- branches/soc-2011-oregano/source/gameengine/NodeLogic/NL_Component.h (rev 0)
+++ branches/soc-2011-oregano/source/gameengine/NodeLogic/NL_Component.h 2011-06-27 20:36:08 UTC (rev 37877)
@@ -0,0 +1,69 @@
+/**
+ * $Id: NL_Component.h$
+ *
+ * Copyright (c) 2009-2010
+ *
+ * This software is provided 'as-is', without any express or implied warranty.
+ * In no event will the authors be held liable for any damages arising from the use
+ * of this software.
+ * Permission is granted to anyone to use this software for any purpose,
+ * including commercial applications, and to alter it and redistribute it freely,
+ * subject to the following restrictions:
+ *
+ * 1. The origin of this software must not be misrepresented; you must not claim that you
+ * wrote the original software. If you use this software in a product, an acknowledgment
+ * in the product documentation would be appreciated but is not required.
+ * 2. Altered source versions must be plainly marked as such, and must not be misrepresented
+ * as being the original software.
+ * 3. This notice may not be removed or altered from any source distribution.
+ */
+
+// This file defines the public type for Components for the runtime engine
+#ifndef _NL_COMPONENT_H
+#define _NL_COMPONENT_H
+
+#include "Python.h"
+
+#include "NL_NodeGraph.h"
+#include "NL_IQueueItem.h"
+
+class NL_Component
+{
+public:
+ static unsigned int sCurrentFrame;
+ static NL_Component* sCurrentComponent;
+
+ NL_Component();
+ virtual ~NL_Component();
+
+ void QueueData(NL_IQueueItem* data);
+
+ //Labels
+ void AddLabel();
+ void RemoveLabel();
+ void CheckLabel();
+
+ //Properties
+ void AddProperty();
+ void RemoveProperty();
+ void CheckProperty();
+
+protected:
+ // list of graph belonging to this engine
+ // use NL_QListHead for automatic replication
+ // (not normally needed as there is only one engine)
+ NL_QListHead<NL_NodeGraph> m_graphs;
+ // list of runlist, one for each priority
+ NL_DList *m_runlists;
+ // list of node waiting to be rescheduled
+ NL_DList m_queueNode;
+ // list of NL_QueueData waiting to be delivered
+ NL_DList m_queueData;
+ // list of Entities related to this Component
+ NL_DList m_entities;
+ // list of Labels related to this Component
+ NL_DList m_labels;
+ // acceleration structure to insert data in pending list
+};
+
+#endif
Added: branches/soc-2011-oregano/source/gameengine/NodeLogic/NL_Entity.cpp
===================================================================
--- branches/soc-2011-oregano/source/gameengine/NodeLogic/NL_Entity.cpp (rev 0)
+++ branches/soc-2011-oregano/source/gameengine/NodeLogic/NL_Entity.cpp 2011-06-27 20:36:08 UTC (rev 37877)
@@ -0,0 +1,71 @@
+/**
+ * $Id: NL_Entity.cpp$
+ *
+ * Copyright (c) 2009-2010
+ *
+ * This software is provided 'as-is', without any express or implied warranty.
+ * In no event will the authors be held liable for any damages arising from the use
+ * of this software.
+ * Permission is granted to anyone to use this software for any purpose,
+ * including commercial applications, and to alter it and redistribute it freely,
+ * subject to the following restrictions:
+ *
+ * 1. The origin of this software must not be misrepresented; you must not claim that you
+ * wrote the original software. If you use this software in a product, an acknowledgment
+ * in the product documentation would be appreciated but is not required.
+ * 2. Altered source versions must be plainly marked as such, and must not be misrepresented
+ * as being the original software.
+ * 3. This notice may not be removed or altered from any source distribution.
+ */
+
+/**
+* This will be the Entity in the node engine, it will hold references to Game Objects, Scene
+* and have local properties and labels.
+* And Entity defines logic to be run under certain conditions, such as which Game Objects it
+* will affect and which logic it is related to. The relation is through labels and the logic
+* is in the components, NL_Component.cpp.
+*
+* Next to do: Game Object referencing, setter and getter, property setter and getter
+**/
+#include "NL_Entity.h"
+
+NL_Entity::NL_Entity()
+{
+
+}
+
+NL_Entity::~NL_Entity()
+{
+
+}
+
+//This should add a label and add this entity to each component it is not already related through this label.
+void NL_Entity::AddLabel()
+{
+
+}
+
+//This should remove the label and remove this entity from each component related to it only through this label.
+void NL_Entity::RemoveLabel()
+{
+
+}
+void NL_Entity::CheckLabel()
+{
+
+}
+
+void NL_Entity::AddProperty()
+{
+
+}
+
+void NL_Entity::RemoveProperty()
+{
+
+}
+
+void NL_Entity::CheckProperty()
+{
+
+}
Added: branches/soc-2011-oregano/source/gameengine/NodeLogic/NL_Entity.h
===================================================================
--- branches/soc-2011-oregano/source/gameengine/NodeLogic/NL_Entity.h (rev 0)
+++ branches/soc-2011-oregano/source/gameengine/NodeLogic/NL_Entity.h 2011-06-27 20:36:08 UTC (rev 37877)
@@ -0,0 +1,57 @@
+/**
+ * $Id: NL_Entity.h$
+ *
+ * Copyright (c) 2009-2010
+ *
+ * This software is provided 'as-is', without any express or implied warranty.
+ * In no event will the authors be held liable for any damages arising from the use
+ * of this software.
+ * Permission is granted to anyone to use this software for any purpose,
+ * including commercial applications, and to alter it and redistribute it freely,
+ * subject to the following restrictions:
+ *
+ * 1. The origin of this software must not be misrepresented; you must not claim that you
+ * wrote the original software. If you use this software in a product, an acknowledgment
+ * in the product documentation would be appreciated but is not required.
+ * 2. Altered source versions must be plainly marked as such, and must not be misrepresented
+ * as being the original software.
+ * 3. This notice may not be removed or altered from any source distribution.
+ */
+
+// This file defines the public type for Entities for the runtime engine
+#ifndef _NL_ENTITY_H
+#define _NL_ENTITY_H
+
+#include "Python.h"
+
+#include "NL_Entity.h"
+#include "NL_IQueueItem.h"
+
+class NL_Entity
+{
+public:
+ static unsigned int sCurrentFrame;
+ static NL_Entity* sCurrentEntity;
+
+ NL_Entity();
+ virtual ~NL_Entity();
+
+ //Labels
+ void AddLabel();
+ void RemoveLabel();
+ void CheckLabel();
+
+ //Properties
+ void AddProperty();
+ void RemoveProperty();
+ void CheckProperty();
+
+
+protected:
+ // list of labels of the Entity
+ NL_DList *m_labels;
+ // list of properties of the Entity
+ NL_DList *m_properties;
+};
+
+#endif
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list