<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Brainfold &#187; scene management</title>
	<atom:link href="http://www.brainfold.org/blog/tag/scene-management/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.brainfold.org/blog</link>
	<description>On Python, game development and everything</description>
	<lastBuildDate>Sat, 15 May 2010 21:58:53 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>MVC, my friend</title>
		<link>http://www.brainfold.org/blog/2007/12/15/mvc-my-friend/</link>
		<comments>http://www.brainfold.org/blog/2007/12/15/mvc-my-friend/#comments</comments>
		<pubDate>Sat, 15 Dec 2007 02:29:57 +0000</pubDate>
		<dc:creator>Jussi Lepistö</dc:creator>
				<category><![CDATA[cooperative multitasking]]></category>
		<category><![CDATA[entity system]]></category>
		<category><![CDATA[game development]]></category>
		<category><![CDATA[scene management]]></category>

		<guid isPermaLink="false">http://www.brainfold.org/blog/2007/12/15/mvc-my-friend/</guid>
		<description><![CDATA[As I was finishing high level design of scene management, I realized it was starting to resemble the Model-view-controller pattern. The (hopefully) more or less final design is sort of a hybrid of the alternatives I already presented: Entities contain arbitrary data in attributes. These compose the Model. Entities can contain any amount of features; [...]]]></description>
			<content:encoded><![CDATA[<p>As I was finishing high level design of scene management, I realized it was starting to resemble the <a href="http://en.wikipedia.org/wiki/Model-view-controller">Model-view-controller</a> pattern. The (hopefully) more or less final design is sort of a hybrid of the alternatives I already presented:</p>
<ul>
<li><em>Entities</em> contain arbitrary data in <em>attributes</em>. These compose the <strong>Model</strong>.</li>
<li>Entities can contain any amount of <em>features</em>; these are the <strong>controllers</strong>.</li>
<li><em>Subsystems</em> (for lack of a better name) link entity attributes to lower-level systems - such as the renderer, audio mixer and physics simulation - and thus represent <strong>views </strong>into the scene.</li>
</ul>
<p>Features are normal tasks in the engine, based on cooperative multitasking. They can read from and write to attributes and create, trigger and listen to <em>signals</em> (an implementation of the observer pattern), which is how they communicate with each other. Subsystems also listen to signals to get notified of attribute changes. Attributes can be shared between features; for example <em>transform</em> is a common attribute probably used by almost all features and subsystems. Sharing of attributes is based purely on their names, there's no actual cooperation between features and subsystems except for signals and of course documentation.</p>
<p>I think a rough example is in order again:</p>
<ol>
<li>A ship gets hit, triggering the <em>hit signal.</em></li>
<li>The <em>damage controller feature</em> is listening to this signal and gets notified.</li>
<li>Damage controller decreases ship health accordingly and notices it's below zero:  it adds a <em>destruction sequence feature</em> to the ship entity and stops listening to hit events.</li>
<li>Destruction sequence adds an <em>audio source attribute</em> to the ship entity (if it doesn't already exist), spawns particle effects for a while and finally marks the ship entity for removal.</li>
<li>The <em>audio subsystem</em> notices the new audio source and adds it to the low level audio mixer.</li>
</ol>
<p>What do you think? Input is still welcome, I haven't actually started implementing this yet. <img src='http://www.brainfold.org/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  And I still have at least a couple of open questions:</p>
<ol>
<li>How should signals be triggered externally, for example by features in other entities? Should they just trigger the signals directly, or should there be an "external API" consisting of callable attributes?</li>
<li>Should features occupy named slots like attributes, or should they just reside in a generic list? I'm currently leaning towards the latter approach and reserving names just for attributes, since feature don't have to directly know about each other.</li>
</ol>
<p>I still have to design the rendering pipeline; I already have a general idea of what I want, but details are kind of blurry. But that's the topic of another post.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.brainfold.org/blog/2007/12/15/mvc-my-friend/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Between designs</title>
		<link>http://www.brainfold.org/blog/2007/12/11/between-designs/</link>
		<comments>http://www.brainfold.org/blog/2007/12/11/between-designs/#comments</comments>
		<pubDate>Tue, 11 Dec 2007 12:13:02 +0000</pubDate>
		<dc:creator>Jussi Lepistö</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[entity system]]></category>
		<category><![CDATA[game development]]></category>
		<category><![CDATA[scene management]]></category>

		<guid isPermaLink="false">http://www.brainfold.org/blog/2007/12/11/between-designs/</guid>
		<description><![CDATA[Yesterday and this morning I've read a lot of material on various topics related to scene management, rendering and a host of other subjects. TomF's Tech Blog was especially useful with rendering. I think I now have a relatively good idea about what I need in scene management and what features it should have. However, [...]]]></description>
			<content:encoded><![CDATA[<p>Yesterday and this morning I've read a <span style="text-decoration: underline;">lot</span> of material on various topics related to scene management, rendering and a host of other subjects. <a href="http://www.eelpi.gotdns.org/blog.wiki.html">TomF's Tech Blog</a> was especially useful with rendering. I think I now have a relatively good idea about what I need in scene management and what features it should have. However, at the moment I'm torn between two designs, which are roughly equal to the first and third alternatives in <a href="http://www.brainfold.org/blog/2007/12/10/research-phase/">my last post</a>.  I wrote small and rough examples on both to illustrate, and input would be <span style="text-decoration: underline;">really</span> welcome at this point. The example is a space ship with an AI, a rigid body for physics, an audio source for positional sound, a particle effect for the engine and a turret, which in turn contain its own AI.</p>
<p>1. Data container entities with single-instance subsystems handling all the logic</p>
<div class="codecolorer-container python dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="python codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">ship = Entity<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><br />
ship.<span style="color: black;">visual</span> = ship_mesh<br />
ship.<span style="color: black;">rigid_body</span> = ship_body<br />
ship.<span style="color: black;">logic</span> = ShipAI<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><br />
ship.<span style="color: black;">audio_source</span> = AudioSource<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><br />
<br />
effect = Entity<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><br />
effect.<span style="color: black;">visual</span> = ParticleEffect<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><br />
effect.<span style="color: black;">parent</span> = ship<br />
effect.<span style="color: black;">transform</span> = engine_transform<br />
<br />
turret = Entity<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><br />
turret.<span style="color: black;">visual</span> = turret_mesh<br />
turret.<span style="color: black;">logic</span> = TurretAI<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><br />
turret.<span style="color: black;">parent</span> = ship<br />
turret.<span style="color: black;">transform</span> = turret_slot_transform</div></div>
<p>2. Feature (aka component) container entities, with all the logic and data contained in the features</p>
<div class="codecolorer-container python dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="python codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">ship = Entity<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><br />
ship.<span style="color: black;">add_feature</span><span style="color: black;">&#40;</span>ShipAI<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span><br />
ship.<span style="color: black;">add_feature</span><span style="color: black;">&#40;</span>ship_mesh<span style="color: black;">&#41;</span><br />
ship.<span style="color: black;">add_feature</span><span style="color: black;">&#40;</span>ship_body<span style="color: black;">&#41;</span><br />
ship.<span style="color: black;">add_feature</span><span style="color: black;">&#40;</span>AudioSource<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span><br />
<br />
effect = Entity<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><br />
effect.<span style="color: black;">add_feature</span><span style="color: black;">&#40;</span>Link<span style="color: black;">&#40;</span>ship<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span><br />
effect.<span style="color: black;">add_feature</span><span style="color: black;">&#40;</span>ParticleEffect<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span><br />
effect.<span style="color: black;">transform</span> = engine_transform<br />
<br />
turret = Entity<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><br />
turret.<span style="color: black;">add_feature</span><span style="color: black;">&#40;</span>turret_mesh<span style="color: black;">&#41;</span><br />
turret.<span style="color: black;">add_feature</span><span style="color: black;">&#40;</span>TurretAI<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span><br />
turret.<span style="color: black;">add_feature</span><span style="color: black;">&#40;</span>Link<span style="color: black;">&#40;</span>ship<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span><br />
turret.<span style="color: black;">transform</span> = turret_slot_transform</div></div>
<p>Which do you like more? In my opinion, the first option has the advantage of being perhaps more intuitive and clearer to use: you just assign features to attributes, whose name tells what they are for. On the other hand, the second interface depends less on magic and is perhaps easier to extend with new feature types, as there are no predetermined names for feature "slots" (in the first option, the names are defined by the subsystems that handle the logic of entities).  Of course you could also use subsystems in the second option and "intelligent components" in the first option, but these two interfaces seem to fit those two underlying designs best, at least in my opinion.</p>
<p>If you have <span style="text-decoration: underline;">any</span> questions or general comments about either of the designs, feel free to post them, all input is welcome. <img src='http://www.brainfold.org/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.brainfold.org/blog/2007/12/11/between-designs/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Research phase</title>
		<link>http://www.brainfold.org/blog/2007/12/10/research-phase/</link>
		<comments>http://www.brainfold.org/blog/2007/12/10/research-phase/#comments</comments>
		<pubDate>Mon, 10 Dec 2007 11:21:56 +0000</pubDate>
		<dc:creator>Jussi Lepistö</dc:creator>
				<category><![CDATA[entity system]]></category>
		<category><![CDATA[game development]]></category>
		<category><![CDATA[Red Nebula]]></category>
		<category><![CDATA[scene management]]></category>
		<category><![CDATA[sci-fi]]></category>

		<guid isPermaLink="false">http://www.brainfold.org/blog/2007/12/10/research-phase/</guid>
		<description><![CDATA[I've been doing some research and brainstorming for both the engine (still without a new name) and Red Nebula. I'm trying to design a new scene management package for the engine, including a new renderer. What's certain at this point is that it's going to be based on entities with components. Entities are more or [...]]]></description>
			<content:encoded><![CDATA[<p>I've been doing some research and brainstorming for both the engine (still without a new name) and Red Nebula. I'm trying to design a new scene management package for the engine, including a new renderer. What's certain at this point is that it's going to be based on <em>entities</em> with <em>components</em>. Entities are more or less dumb containers for components, which describe the behaviour of the entity. Data lives in either the entity, its components, or both, depending on the exact design. <a href="http://cowboyprogramming.com/2007/01/05/evolve-your-heirachy/">Evolve Your Hierarchy</a> is a good article on what it's about and why you should do it.</p>
<p><a href="http://www.gamedev.net/community/forums/topic.asp?topic_id=463508">This thread</a> on Gamedev.net has been really helpful for getting them brain juices flowing, and as I wrote there, I've got a couple of alternatives I want to think about further:</p>
<ol>
<li>Very similar to the misguided attempt of creating a unified scene graph for Spineless, but on a higher level, based on game entities, not low-level scene graph nodes. Entities contain just data, while <em>subsystems</em> (or workers as I called them) contain all the logic of how to deal with the data. There are no components per se.</li>
<li>Components define only behaviour, while entities contain components and their (possibly shared) data.</li>
<li>Entities are solely containers for components, while components contain both behaviour and data.</li>
</ol>
<p>At the moment I'm mostly leaning towards the first alternative, though the other two have their advantages too, and all of them seem quite elegant to me. I'll have to think more about this first, and input is of course always welcome.</p>
<p>Brainstorming for Red Nebula has piqued my interest in reading sci-fi again, so I started reading Iain M. Banks' Use of Weapons. I really like his stories and writing style; they're definitely "high sci-fi" in the sense that technology is <span style="text-decoration: underline;">really</span> advanced - space battles generally last only fractions of a second - and there are actions sequences and such, but they're not corny adventure stories or anything. I think the genre is called "hard sci-fi". The other sci-fi writer I really like is Philip K. Dick, though his style is completely different and not that much centered on technology.</p>
<p>I've also done some coding, but not much. Mostly just stubs for the new scene package and small fixes here and there. I should get resource management out of the way at some point, before starting to really work on scene management.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.brainfold.org/blog/2007/12/10/research-phase/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
