<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Recent changes to NewWObject</title><link>https://sourceforge.net/p/farsa/wiki/NewWObject/</link><description>Recent changes to NewWObject</description><atom:link href="https://sourceforge.net/p/farsa/wiki/NewWObject/feed" rel="self"/><language>en</language><lastBuildDate>Fri, 20 Nov 2015 10:22:07 -0000</lastBuildDate><atom:link href="https://sourceforge.net/p/farsa/wiki/NewWObject/feed" rel="self" type="application/rss+xml"/><item><title>NewWObject modified by Tomassino Ferrauto</title><link>https://sourceforge.net/p/farsa/wiki/NewWObject/</link><description>&lt;div class="markdown_content"&gt;&lt;pre&gt;&lt;/pre&gt;
&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Tomassino Ferrauto</dc:creator><pubDate>Fri, 20 Nov 2015 10:22:07 -0000</pubDate><guid>https://sourceforge.net379895bd94a9dff9093af113dd1a05a5ff4a0cc9</guid></item><item><title>NewWObject modified by Tomassino Ferrauto</title><link>https://sourceforge.net/p/farsa/wiki/NewWObject/</link><description>&lt;div class="markdown_content"&gt;&lt;pre&gt;--- v7
+++ v8
@@ -14,7 +14,7 @@
 Introduction
 -------

-All the entities the can be placed in the simulated *World* inherit from the *WObject* class. This includes both physical objects and objects that only have a graphical representation, as well as objects that are perceived by robot sensors (e.g. a light or a coloured area on the ground of the arena). In the next sections we will first introduce the *WObject* class, and then its main subclasses.
+All the entities the can be placed in the simulated *World* inherit from the *WObject* class. This includes both physical objects and objects that only have a graphical representation, as well as objects that are perceived by robot sensors (e.g. a light bulb or a coloured area on the ground). In the next sections we will first introduce the *WObject* class, and then its main subclasses.

 *WObject*
 -------
@@ -22,7 +22,7 @@
 Every *WObject* has several properties, here is the list:

 * tranformation matrix: represents the position and orientation of the object in the 3D coordinate system, as a 4x4 matrix;
-* color: the color of the object. When the object also has a texture, the color modifies its the appearance;
+* color: the color of the object. When the object also has a texture, the color modifies the texture appearance;
 * texture: the texture used on the object;
 * visible: boolean flag, if true the object is displayed in the 3D viewer, otherwise it is not rendered;
 * axes displayed: boolen flag, if true the three axes of the local reference frame are drawn;
@@ -54,13 +54,13 @@
 };
 ~~~~~~~

-When an instance of *MyObject* is created, the constructor is executed with the *addToWorld* parameter set to true, so that the object is added to the World at the end of the *MyObject* constructor. The *WObject* constructor, instead, is called with the *addToWorld* parameter set to false. The *addToWorld* parameter can be omitted in constructors of classes that are never subclassed or where sublcasses share the same *RenderWObject* of the parent class: in this case the constructor always adds the object to the world. (The *addToWorld* parameter will be removed in the future major release of FARSA)
+When an instance of *MyObject* is created, the constructor is executed with the *addToWorld* parameter set to true, so that the object is added to the World at the end of the *MyObject* constructor. The *WObject* constructor, instead, is called with the *addToWorld* parameter set to false. The *addToWorld* parameter can be omitted in constructors of classes that are never subclassed or where sublcasses share the same *RenderWObject* (see below) of the parent class: in this case the constructor always adds the object to the world. (The *addToWorld* parameter will be removed in the future major release of FARSA).

-The *WObject* class has some virtual functions that can be implemented in subclasses. The *preUpdate* and *postUpdate* methods are called respectively before the physic is advanced by one step and after the step is completed. These are useful, for example, to update the tranformation matrix or, in the case of robots implementations, to respectively actuate the robot motors and to read the robot sensors. The other virtual function is *changedMatrix*, which is called whenever the position matrix of the object is changed.
+The *WObject* class has some virtual functions that can be implemented in subclasses. The *preUpdate* and *postUpdate* methods are called respectively before the physic is advanced by one step and after the step is completed. These are useful, for example, to update the tranformation matrix or, in the case of robots implementations, to respectively actuate the robot motors and to read the robot sensors (see [this page]([NewRobot]) for more information on custom robots). The other virtual function is *changedMatrix*, which is called whenever the position matrix of the object is changed.

 Each *WObject* has an associated 3D graphical representation. A subclass of *RenderWObject* is delegated to render a *WObject* subclass via the *registerRenderWObjectFor* static function of the class *RenderWObjectContainer*. This function takes as template parameter the type of the object performing the rendering, while as the only function parameter the name of the class to be rendered (the latter is a string because the QT metaobject system is used).

-The *RenderWObject* class has one virtual function that must be implemented, namely *render*. The rendering is performed via standard OpenGL calls. See [API documentation]([APIDoc]) for more information on the class and on the other functions that can be implemented. If you need to create a purely graphical object, however, It is generally easier to use the *GraphicalWObject* class, described delow.
+The *RenderWObject* class has one virtual function that must be implemented, namely *render*. The rendering is performed via standard OpenGL calls. See [API documentation]([APIDoc]) for more information on the class and on the other functions that can be implemented. If you need to create a purely graphical object, however, It is generally easier to use the *GraphicalWObject* class, described below.

 *GraphicalWObject*
 -------
@@ -142,9 +142,9 @@
 }
 ~~~~~~~

-The example above shows how to use standard OpenGL instructions to draw a circle. Please note that when the *render* function or other rendering functions are executed, the transformation matrix has already been changed to reflect the current position in the world (i.e. it already takes into account the position of the object to which the *GraphicalWObject* is attached).
+The example above shows that standard OpenGL instructions are used to draw the circle. Please note that when the *render* function or other rendering functions are executed, the transformation matrix has already been changed to reflect the current position in the world (i.e. it already takes into account the position of the object to which the *GraphicalWObject* is attached).

 *PhyObject*
 -------

-Objects with physical properties are all subclasses of *PhyObject*, which in turn inheriths *WObject*. We will not give details on how to create new physical objects, because it requires a deep understanding of FARSA internals and knowledge of the Newton Game Dynamics library. You should never need to do something like this, however, because most of the capabilities of the physics library are already available as methods of the *World* class or via *PhyObject* subclasses.
+Objects with physical properties are all subclasses of *PhyObject*, which in turn inheriths *WObject*. We will not give details on how to create new physical objects, because it requires a deep understanding of FARSA internals and knowledge of the Newton Game Dynamics library. You should never need to do something like this, however, because most of the capabilities of the physics library are already available as methods of the *World* class or via *PhyObject* and *PhyJoint* subclasses.
&lt;/pre&gt;
&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Tomassino Ferrauto</dc:creator><pubDate>Tue, 17 Nov 2015 13:59:35 -0000</pubDate><guid>https://sourceforge.nete51e90709de6bc7301179a3b394d4c10707ac524</guid></item><item><title>NewWObject modified by Tomassino Ferrauto</title><link>https://sourceforge.net/p/farsa/wiki/NewWObject/</link><description>&lt;div class="markdown_content"&gt;&lt;pre&gt;&lt;/pre&gt;
&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Tomassino Ferrauto</dc:creator><pubDate>Sat, 14 Nov 2015 08:53:05 -0000</pubDate><guid>https://sourceforge.net903b837c17cb65d60b0d1137cb3c1724c99f51a7</guid></item><item><title>NewWObject modified by Tomassino Ferrauto</title><link>https://sourceforge.net/p/farsa/wiki/NewWObject/</link><description>&lt;div class="markdown_content"&gt;&lt;pre&gt;&lt;/pre&gt;
&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Tomassino Ferrauto</dc:creator><pubDate>Fri, 13 Nov 2015 10:31:51 -0000</pubDate><guid>https://sourceforge.netd27f78f14464fd0109913eda8de3ee937cb5df49</guid></item><item><title>NewWObject modified by Tomassino Ferrauto</title><link>https://sourceforge.net/p/farsa/wiki/NewWObject/</link><description>&lt;div class="markdown_content"&gt;&lt;pre&gt;--- v4
+++ v5
@@ -1,4 +1,4 @@
-[Prev: Creating custom sensors or motors]([CustomSensorMotor]) |  | [Next: Implementing a new robot]([NewRobot])
+[Prev: Creating custom sensors or motors]([CustomSensorMotor]) | [Up: Home]([Home]) | [Next: Implementing a new robot]([NewRobot])
  -------|--------|----------
         |        |

&lt;/pre&gt;
&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Tomassino Ferrauto</dc:creator><pubDate>Thu, 12 Nov 2015 10:36:47 -0000</pubDate><guid>https://sourceforge.net2c7da508245f8ae05eef366e745fb544610c7b5e</guid></item><item><title>NewWObject modified by Tomassino Ferrauto</title><link>https://sourceforge.net/p/farsa/wiki/NewWObject/</link><description>&lt;div class="markdown_content"&gt;&lt;pre&gt;--- v3
+++ v4
@@ -1,3 +1,11 @@
+[Prev: Creating custom sensors or motors]([CustomSensorMotor]) |  | [Next: Implementing a new robot]([NewRobot])
+ -------|--------|----------
+        |        |
+
+**Table of contents**
+
+[TOC]
+
 Implementing a new world object
 =======

&lt;/pre&gt;
&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Tomassino Ferrauto</dc:creator><pubDate>Thu, 12 Nov 2015 10:21:41 -0000</pubDate><guid>https://sourceforge.netd70c7f87c6eba5cd2d919be0283bb9c5c66a0f4c</guid></item><item><title>NewWObject modified by Tomassino Ferrauto</title><link>https://sourceforge.net/p/farsa/wiki/NewWObject/</link><description>&lt;div class="markdown_content"&gt;&lt;pre&gt;--- v2
+++ v3
@@ -23,13 +23,36 @@
 * label displayed: boolean flag, the label is displayed in the 3D viewer only if this is true;
 * use color and texture of owner: boolean flag, if true the object inherits the color and texture of its owner (see below for information on ownership).

-The API documentation lists the functions you can use to manipulate these properties. *WObjects* also have owner/owned relationship: each object can have one owner and can own several other objects. It is the responsability of the owner to delete an owned object (this is done automatically unless configured otherwise).
+The [API documentation]([APIDoc]) lists the functions you can use to manipulate these properties. *WObjects* also have owner/owned relationship: each object can have one owner and can own several other objects. It is the responsability of the owner to delete an owned object (this is done automatically unless configured otherwise).
+
+The constructor of the *WObject* class has one parameter that deserves special care. It is the last one, a boolean value called *addToWorld*, which determines whether the *WObject* constructor should add the object being constructed to the World or not. Of course all objects should be added to the World, so that they are correctly simulated. This should happend, however, after all the constructors in the hierarchy are called (because otherwise the type of the object that is added is not correctly identified). If, for example, a class called *MyObject* inherits from *WObject*, when an instance of *MyObject* is created, the new object should be added to the World only at the end of the constructor of *MyObject*. The *addToWorld* parameter implements a workaround to this problem: is set to false, the constructor of *WObject* does not add the object to the World, and the constructor of the child class is responsible to perform this action (calling the *pushObject* function of the *World* class). Moreover, the same mechanism should be implemented by *WObject* subclasses that are meant to be subclassed. The parameter should only be set explicitly when calling the constructor of the parent class, never when instantiating a new object (in this case the default value should be used). Here is an example:
+
+~~~~~~~
+:::C++
+class MyObject : public WObject
+{
+   [...]
+
+   MyObject(World* world, QString name="unamed", const wMatrix&amp;amp; tm = wMatrix::identity(), bool addToWorld = true)
+       : WObject(world, name, tm, false)
+       , [...]
+   {
+       if (addToWorld) {
+           worldv-&amp;gt;pushObject(this);
+       }
+   }
+
+   [...]
+};
+~~~~~~~
+
+When an instance of *MyObject* is created, the constructor is executed with the *addToWorld* parameter set to true, so that the object is added to the World at the end of the *MyObject* constructor. The *WObject* constructor, instead, is called with the *addToWorld* parameter set to false. The *addToWorld* parameter can be omitted in constructors of classes that are never subclassed or where sublcasses share the same *RenderWObject* of the parent class: in this case the constructor always adds the object to the world. (The *addToWorld* parameter will be removed in the future major release of FARSA)

 The *WObject* class has some virtual functions that can be implemented in subclasses. The *preUpdate* and *postUpdate* methods are called respectively before the physic is advanced by one step and after the step is completed. These are useful, for example, to update the tranformation matrix or, in the case of robots implementations, to respectively actuate the robot motors and to read the robot sensors. The other virtual function is *changedMatrix*, which is called whenever the position matrix of the object is changed.

 Each *WObject* has an associated 3D graphical representation. A subclass of *RenderWObject* is delegated to render a *WObject* subclass via the *registerRenderWObjectFor* static function of the class *RenderWObjectContainer*. This function takes as template parameter the type of the object performing the rendering, while as the only function parameter the name of the class to be rendered (the latter is a string because the QT metaobject system is used).

-The *RenderWObject* class has one virtual function that must be implemented, namely *render*. The rendering is performed via standard OpenGL calls. See API documentation for more information on the class and on the other functions that can be implemented. If you need to create a purely graphical object, however, It is generally easier to use the *GraphicalWObject* class, described delow.
+The *RenderWObject* class has one virtual function that must be implemented, namely *render*. The rendering is performed via standard OpenGL calls. See [API documentation]([APIDoc]) for more information on the class and on the other functions that can be implemented. If you need to create a purely graphical object, however, It is generally easier to use the *GraphicalWObject* class, described delow.

 *GraphicalWObject*
 -------
@@ -111,9 +134,9 @@
 }
 ~~~~~~~

-The example above shows how ro use standard OpenGL instructions to draw a circle. Please note that when the *render* function or other rendering functions are executed, the transformation matrix has already been changed to reflect the current position in the world (i.e. it already takes into account the position of the object to which the *GraphicalWObject* is attached).
+The example above shows how to use standard OpenGL instructions to draw a circle. Please note that when the *render* function or other rendering functions are executed, the transformation matrix has already been changed to reflect the current position in the world (i.e. it already takes into account the position of the object to which the *GraphicalWObject* is attached).

 *PhyObject*
 -------

-Objects with physical properties are all subclasses of *PhyObject*, which in turn inheriths *WObject*. We will not give any detail on how to create new physical objects, because it requires a deep understanding of FARSA internals and to know the Newton Game Dynamics library. You should never need to do something like this, however, because most of the capabilities of the physics library are already available as methods of the *World* class or via *PhyObject* subclasses.
+Objects with physical properties are all subclasses of *PhyObject*, which in turn inheriths *WObject*. We will not give details on how to create new physical objects, because it requires a deep understanding of FARSA internals and knowledge of the Newton Game Dynamics library. You should never need to do something like this, however, because most of the capabilities of the physics library are already available as methods of the *World* class or via *PhyObject* subclasses.
&lt;/pre&gt;
&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Tomassino Ferrauto</dc:creator><pubDate>Wed, 21 Oct 2015 11:44:35 -0000</pubDate><guid>https://sourceforge.net1f31d38373a99615cb469046dcdd7477a3ad8893</guid></item><item><title>NewWObject modified by Tomassino Ferrauto</title><link>https://sourceforge.net/p/farsa/wiki/NewWObject/</link><description>&lt;div class="markdown_content"&gt;&lt;pre&gt;--- v1
+++ v2
@@ -1,4 +1,119 @@
 Implementing a new world object
 =======

-QUQUIQI
+In this page we will talk about *WObject* and related classes. *WObject* is the base for all classes modelling objects that live in the simulated world, both physical and purely graphical entities. We will also introduce helper classes to easily create graphical entities and briefly talk about physical entities
+
+Introduction
+-------
+
+All the entities the can be placed in the simulated *World* inherit from the *WObject* class. This includes both physical objects and objects that only have a graphical representation, as well as objects that are perceived by robot sensors (e.g. a light or a coloured area on the ground of the arena). In the next sections we will first introduce the *WObject* class, and then its main subclasses.
+
+*WObject*
+-------
+
+Every *WObject* has several properties, here is the list:
+
+* tranformation matrix: represents the position and orientation of the object in the 3D coordinate system, as a 4x4 matrix;
+* color: the color of the object. When the object also has a texture, the color modifies its the appearance;
+* texture: the texture used on the object;
+* visible: boolean flag, if true the object is displayed in the 3D viewer, otherwise it is not rendered;
+* axes displayed: boolen flag, if true the three axes of the local reference frame are drawn;
+* label: a textual label associated with the object, that can be displayed or not (see "label displayed");
+* label position: the position of the label in the object frame of reference;
+* label displayed: boolean flag, the label is displayed in the 3D viewer only if this is true;
+* use color and texture of owner: boolean flag, if true the object inherits the color and texture of its owner (see below for information on ownership).
+
+The API documentation lists the functions you can use to manipulate these properties. *WObjects* also have owner/owned relationship: each object can have one owner and can own several other objects. It is the responsability of the owner to delete an owned object (this is done automatically unless configured otherwise).
+
+The *WObject* class has some virtual functions that can be implemented in subclasses. The *preUpdate* and *postUpdate* methods are called respectively before the physic is advanced by one step and after the step is completed. These are useful, for example, to update the tranformation matrix or, in the case of robots implementations, to respectively actuate the robot motors and to read the robot sensors. The other virtual function is *changedMatrix*, which is called whenever the position matrix of the object is changed.
+
+Each *WObject* has an associated 3D graphical representation. A subclass of *RenderWObject* is delegated to render a *WObject* subclass via the *registerRenderWObjectFor* static function of the class *RenderWObjectContainer*. This function takes as template parameter the type of the object performing the rendering, while as the only function parameter the name of the class to be rendered (the latter is a string because the QT metaobject system is used).
+
+The *RenderWObject* class has one virtual function that must be implemented, namely *render*. The rendering is performed via standard OpenGL calls. See API documentation for more information on the class and on the other functions that can be implemented. If you need to create a purely graphical object, however, It is generally easier to use the *GraphicalWObject* class, described delow.
+
+*GraphicalWObject*
+-------
+
+The *GraphicalWObject* class provides some facilities that are useful when dealing with world objects that are purely graphical elements. First of all there is no need to create a separate class to which rendering is delegated. The class provides virtual functions that can be implemented to render the object, analogous to the functions of *RenderWObject*. Furthermore there is the possibility to "attach" the object to another object. This means that the *GraphicalWObject* always maintans the relative position to the object to which it is attached. This is useful, for example, to attach graphical elements to a robot.
+
+The file *graphicalmarkers.h* contains few examples of *GraphicalWObject* subclasses. One of them is a simple circular disk. The source code is the following one:
+
+~~~~~~~
+:::C++
+class CircularGraphicalMarker : public GraphicalWObject
+{
+   Q_OBJECT
+public:
+   /**
+    * \brief Constructor
+    *
+    * \param radius the radius of the disk
+    * \param world the world the object lives in
+    * \param name the name of this object
+    * \param tm the transformation matrix for this object
+    */
+   CircularGraphicalMarker(real radius, World* world, QString name = "unamed", const wMatrix&amp;amp; tm = wMatrix::identity());
+
+   /**
+    * \brief Destructor
+    */
+   virtual ~CircularGraphicalMarker();
+
+protected:
+   /**
+    * \brief Performs the actual drawing
+    *
+    * Reimplement to draw what you need
+    * \param renderer the RenderWObject object associated with this one.
+    *                 Use it e.g. to access the container
+    * \param gw the OpenGL context
+    */
+   virtual void render(RenderWObject* renderer, QGLContext* gw);
+
+private:
+   /**
+    * \brief The radius of the disk
+    */
+   const real m_radius;
+};
+
+CircularGraphicalMarker::CircularGraphicalMarker(real radius, World* world, QString name, const wMatrix&amp;amp; tm) :
+   GraphicalWObject(world, name, tm),
+   m_radius(radius)
+{
+}
+
+CircularGraphicalMarker::~CircularGraphicalMarker()
+{
+}
+
+void CircularGraphicalMarker::render(RenderWObject* renderer, QGLContext* gw)
+{
+   // Pushing our transformation matrix
+   renderer-&amp;gt;container()-&amp;gt;setupColorTexture(gw, renderer);
+   glPushMatrix();
+   GLMultMatrix(&amp;amp;tm[0][0]);
+
+   // Drawing the disk. We disable lightining
+   glPushAttrib(GL_LIGHTING_BIT);
+   glDisable(GL_LIGHTING);
+   glColor3f(color().redF(), color().greenF(), color().blueF());
+
+   // Actually drawing the disk
+   GLUquadricObj *pObj = gluNewQuadric();
+   gluDisk(pObj, 0.0f, m_radius, 20, 1);
+   gluDeleteQuadric(pObj);
+
+   // Restoring lighting status
+   glPopAttrib();
+
+   glPopMatrix();
+}
+~~~~~~~
+
+The example above shows how ro use standard OpenGL instructions to draw a circle. Please note that when the *render* function or other rendering functions are executed, the transformation matrix has already been changed to reflect the current position in the world (i.e. it already takes into account the position of the object to which the *GraphicalWObject* is attached).
+
+*PhyObject*
+-------
+
+Objects with physical properties are all subclasses of *PhyObject*, which in turn inheriths *WObject*. We will not give any detail on how to create new physical objects, because it requires a deep understanding of FARSA internals and to know the Newton Game Dynamics library. You should never need to do something like this, however, because most of the capabilities of the physics library are already available as methods of the *World* class or via *PhyObject* subclasses.
&lt;/pre&gt;
&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Tomassino Ferrauto</dc:creator><pubDate>Mon, 19 Oct 2015 21:42:56 -0000</pubDate><guid>https://sourceforge.net9d71ae959a45bc1515c09daac57f2da11b70c049</guid></item><item><title>NewWObject modified by Tomassino Ferrauto</title><link>https://sourceforge.net/p/farsa/wiki/NewWObject/</link><description>&lt;div class="markdown_content"&gt;&lt;h1 id="implementing-a-new-world-object"&gt;Implementing a new world object&lt;/h1&gt;
&lt;p&gt;QUQUIQI&lt;/p&gt;&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Tomassino Ferrauto</dc:creator><pubDate>Thu, 08 Oct 2015 14:42:02 -0000</pubDate><guid>https://sourceforge.net05457e05c6b116aad09ecf6d78224462af62c1a0</guid></item></channel></rss>