[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [38404] branches/soc-2011-cucumber/source/ gameengine/Ketsji: KX_FontObject now supports the x and y offset options.

Daniel Stokes kupomail at gmail.com
Thu Jul 14 22:41:53 CEST 2011


Revision: 38404
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=38404
Author:   kupoman
Date:     2011-07-14 20:41:52 +0000 (Thu, 14 Jul 2011)
Log Message:
-----------
KX_FontObject now supports the x and y offset options.

Modified Paths:
--------------
    branches/soc-2011-cucumber/source/gameengine/Ketsji/KX_FontObject.cpp
    branches/soc-2011-cucumber/source/gameengine/Ketsji/KX_FontObject.h

Modified: branches/soc-2011-cucumber/source/gameengine/Ketsji/KX_FontObject.cpp
===================================================================
--- branches/soc-2011-cucumber/source/gameengine/Ketsji/KX_FontObject.cpp	2011-07-14 20:32:24 UTC (rev 38403)
+++ branches/soc-2011-cucumber/source/gameengine/Ketsji/KX_FontObject.cpp	2011-07-14 20:41:52 UTC (rev 38404)
@@ -36,8 +36,6 @@
 #include "KX_Scene.h"
 #include "KX_PythonInit.h"
 #include "BLI_math.h"
-#include "MT_Vector3.h"
-#include "MT_Matrix3x3.h"
 
 extern "C" {
 #include "BLF_api.h"
@@ -79,6 +77,7 @@
 	m_text = split_string(text->str);
 	m_fsize = text->fsize;
 	m_line_spacing = text->linedist;
+	m_offset = MT_Vector3(text->xof, text->yof, 0);
 
 	/* FO_BUILTIN_NAME != "default"	*/
 	/* I hope at some point Blender (2.5x) can have a single font	*/
@@ -132,10 +131,19 @@
 	float size = m_fsize * m_object->size[0] * RES;
 	float aspect = 1.f / (m_object->size[0] * RES);
 
+	// Get a working copy of the OpenGLMatrix to use
+	double mat[16];
+	memcpy(mat, this->GetOpenGLMatrix(), sizeof(double)*16);
+
+	//Account for offset
+	MT_Vector3 offset = this->NodeGetWorldOrientation() * m_offset;
+	mat[12] += offset[0]; mat[13] += offset[1]; mat[14] += offset[2];
+
+	//Orient the spacing vector
 	MT_Vector3 spacing = MT_Vector3(0, m_fsize*m_line_spacing, 0);
 	spacing =this->NodeGetWorldOrientation() * spacing;
-	double mat[16];
-	memcpy(mat, this->GetOpenGLMatrix(), sizeof(double)*16);
+
+	//Draw each line, taking spacing into consideration
 	for(int i=0; i<m_text.size(); ++i)
 	{
 		if (i!=0)

Modified: branches/soc-2011-cucumber/source/gameengine/Ketsji/KX_FontObject.h
===================================================================
--- branches/soc-2011-cucumber/source/gameengine/Ketsji/KX_FontObject.h	2011-07-14 20:32:24 UTC (rev 38403)
+++ branches/soc-2011-cucumber/source/gameengine/Ketsji/KX_FontObject.h	2011-07-14 20:41:52 UTC (rev 38404)
@@ -67,6 +67,7 @@
 	float			m_resolution;
 	float			m_color[4];
 	float			m_line_spacing;
+	MT_Vector3		m_offset;
 
 	class RAS_IRenderTools*	m_rendertools;	//needed for drawing routine
 




More information about the Bf-blender-cvs mailing list