[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [51708] branches/ge_candy/source/ gameengine/Ketsji: Basic particles working the game engine.
Matthew Smith
mjdietel at gmail.com
Sun Oct 28 16:33:37 CET 2012
Revision: 51708
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=51708
Author: mokazon
Date: 2012-10-28 15:33:37 +0000 (Sun, 28 Oct 2012)
Log Message:
-----------
Basic particles working the game engine. They will show up at the origin on game start.
Modified Paths:
--------------
branches/ge_candy/source/gameengine/Ketsji/CMakeLists.txt
branches/ge_candy/source/gameengine/Ketsji/KX_KetsjiEngine.cpp
branches/ge_candy/source/gameengine/Ketsji/KX_KetsjiEngine.h
Added Paths:
-----------
branches/ge_candy/source/gameengine/Ketsji/KX_Particle.cpp
branches/ge_candy/source/gameengine/Ketsji/KX_Particle.h
Modified: branches/ge_candy/source/gameengine/Ketsji/CMakeLists.txt
===================================================================
--- branches/ge_candy/source/gameengine/Ketsji/CMakeLists.txt 2012-10-28 15:23:16 UTC (rev 51707)
+++ branches/ge_candy/source/gameengine/Ketsji/CMakeLists.txt 2012-10-28 15:33:37 UTC (rev 51708)
@@ -98,6 +98,7 @@
KX_ObstacleSimulation.cpp
KX_OrientationInterpolator.cpp
KX_ParentActuator.cpp
+ KX_Particle.cpp
KX_PhysicsObjectWrapper.cpp
KX_PolyProxy.cpp
KX_PolygonMaterial.cpp
@@ -178,6 +179,7 @@
KX_ObstacleSimulation.h
KX_OrientationInterpolator.h
KX_ParentActuator.h
+ KX_Particle.h
KX_PhysicsEngineEnums.h
KX_PhysicsObjectWrapper.h
KX_PhysicsPropertiesobsolete.h
Modified: branches/ge_candy/source/gameengine/Ketsji/KX_KetsjiEngine.cpp
===================================================================
--- branches/ge_candy/source/gameengine/Ketsji/KX_KetsjiEngine.cpp 2012-10-28 15:23:16 UTC (rev 51707)
+++ branches/ge_candy/source/gameengine/Ketsji/KX_KetsjiEngine.cpp 2012-10-28 15:33:37 UTC (rev 51708)
@@ -84,6 +84,11 @@
#include "KX_NavMeshObject.h"
+#include <vector>
+#include <time.h>
+#include "KX_Particle.h"
+
+
// If define: little test for Nzc: guarded drawing. If the canvas is
// not valid, skip rendering this frame.
//#define NZC_GUARDED_OUTPUT
@@ -182,10 +187,11 @@
m_logger = new KX_TimeCategoryLogger (25);
for (int i = tc_first; i < tc_numCategories; i++)
- m_logger->AddCategory((KX_TimeCategory)i);
-
+ m_logger->AddCategory((KX_TimeCategory)i);
+ srand ( time(NULL) );
}
+std::vector<KX_Particle*> KX_KetsjiEngine::particlelist;
/**
@@ -196,6 +202,7 @@
delete m_logger;
if(m_usedome)
delete m_dome;
+ particlelist.clear();
}
@@ -1319,7 +1326,6 @@
#endif
scene->RenderBuckets(camtrans, m_rasterizer, m_rendertools);
-
//render all the font objects for this scene
RenderFonts(scene);
@@ -1346,7 +1352,7 @@
{
// We need to first make sure our viewport is correct (enabling multiple viewports can mess this up)
m_canvas->SetViewPort(0, 0, m_canvas->GetWidth(), m_canvas->GetHeight());
-
+ RenderParticles();
m_rendertools->MotionBlur(m_rasterizer);
scene->Render2DFilters(m_canvas);
#ifdef WITH_PYTHON
@@ -1355,6 +1361,66 @@
m_rasterizer->FlushDebugShapes();
}
+void KX_KetsjiEngine::RenderParticles()
+{
+ printf("Size: %i", particlelist.size());
+ for (int x = 1; x < 20; x++)
+ {
+ if (particlelist.size() >= 5000)
+ {
+ delete particlelist.front();
+ particlelist.erase(particlelist.begin());
+ }
+ int rands = 20;
+ double angle [] = {((rand() % (2*rands)) - rands)*0.001, ((rand() % (2*rands)) - rands)*0.001, ((rand() % (2*rands)) - rands)*0.001};
+ //#speed = own['speed'][:]
+ //#speed[0] += angle[0]
+ //#speed[1] += angle[1]
+ //#speed[2] += angle[2]
+ /*if(abs(particlelist + angle[0]) < abs(own['original'][0]) + own['randlimit'] and abs(own['speed'][0] + angle[0]) > abs(own['original'][0]) - own['randlimit'])
+ {
+ own['speed'][0] += angle[0];
+ }
+ if(abs(own['speed'][1] + angle[1]) < abs(own['original'][1]) + own['randlimit'] and abs(own['speed'][1] + angle[1]) > abs(own['original'][1]) - own['randlimit'])
+ {
+ own['speed'][1] += angle[1];
+ }
+ if(abs(own['speed'][2] + angle[2]) < abs(own['original'][2]) + own['randlimit'] and abs(own['speed'][2] + angle[2]) > abs(own['original'][2]) - own['randlimit'])
+ {
+ own['speed'][2] += angle[2];
+ }*/
+ if ((KX_Particle::speed[2] + angle[2])-KX_Particle::speedOrigin[2] < 0.2 && (KX_Particle::speed[2] + angle[2])-KX_Particle::speedOrigin[2] > -0.2)
+ {
+ KX_Particle::speed[2] += angle[2];
+ }
+ if ((KX_Particle::speed[1] + angle[1])-KX_Particle::speedOrigin[1] < 0.2 && (KX_Particle::speed[1] + angle[1])-KX_Particle::speedOrigin[1] > -0.2)
+ {
+ KX_Particle::speed[1] += angle[1];
+ }
+ if ((KX_Particle::speed[0] + angle[0])-KX_Particle::speedOrigin[0] < 0.2 && (KX_Particle::speed[0] + angle[0])-KX_Particle::speedOrigin[0] > -0.2)
+ {
+ KX_Particle::speed[0] += angle[0];
+ }
+ //double pos [] = {0,0,0};
+ //#pos[2] += random.randint(1,100)*0.0004
+ KX_Particle *particle = new KX_Particle(m_frameTime);
+ particle->f4 = KX_Particle::speed[0];
+ particle->f5 = KX_Particle::speed[1];
+ particle->f6 = KX_Particle::speed[2];
+ particlelist.push_back(particle);
+ }
+ glPointSize(2.0);
+ glColor3f(1.0,1.0,1.0);
+ glBegin(GL_POINTS);
+ for (int i = 0; i < particlelist.size(); ++i)
+ {
+ KX_Particle *particle = particlelist.at(i);
+ particle->update(m_frameTime);
+ glVertex3f(particle->f1, particle->f2, particle->f3);
+ }
+ glEnd();
+}
+
void KX_KetsjiEngine::StopEngine()
{
if (m_bInitialized)
Modified: branches/ge_candy/source/gameengine/Ketsji/KX_KetsjiEngine.h
===================================================================
--- branches/ge_candy/source/gameengine/Ketsji/KX_KetsjiEngine.h 2012-10-28 15:23:16 UTC (rev 51707)
+++ branches/ge_candy/source/gameengine/Ketsji/KX_KetsjiEngine.h 2012-10-28 15:33:37 UTC (rev 51708)
@@ -40,6 +40,7 @@
#include "KX_Scene.h"
#include "KX_Python.h"
#include "KX_WorldInfo.h"
+#include "KX_Particle.h"
#include <vector>
#include <set>
@@ -207,11 +208,15 @@
void RenderShadowBuffers(KX_Scene *scene);
void SetBackGround(KX_WorldInfo* worldinfo);
void RenderFonts(KX_Scene* scene);
+ void RenderParticles();
public:
KX_KetsjiEngine(class KX_ISystem* system);
virtual ~KX_KetsjiEngine();
+ static std::vector<KX_Particle*> particlelist;
+ //static std::vector<KX_Particle> particlelist;
+
// set the devices and stuff. the client must take care of creating these
void SetWorldSettings(KX_WorldInfo* worldinfo);
void SetKeyboardDevice(SCA_IInputDevice* keyboarddevice);
Added: branches/ge_candy/source/gameengine/Ketsji/KX_Particle.cpp
===================================================================
--- branches/ge_candy/source/gameengine/Ketsji/KX_Particle.cpp (rev 0)
+++ branches/ge_candy/source/gameengine/Ketsji/KX_Particle.cpp 2012-10-28 15:33:37 UTC (rev 51708)
@@ -0,0 +1,59 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor(s): Matthew Dietel
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file BL_Particle.cpp
+ * \ingroup ketsji
+ */
+
+//#import <vector>
+
+#include "KX_Particle.h"
+#include <iostream>
+#include <list>
+#include <time.h>
+#include <stdio.h>
+using namespace std;
+
+/*class KX_Particle {
+ public:
+ float f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f11;
+ const float speed [3] = {0,0,5};
+ void update (double);
+ KX_Particle();
+};*/
+
+KX_Particle::KX_Particle(double time)
+: f1(0.0), f2(0.0), f3(0.0), f4(0.0), f5(0.0), f6(0.0), f7(0.0), f8(0.0), f9(-5.0), f10(time), f11(0.0)
+{
+}
+double KX_Particle::speedOrigin [] = {0.0,0.0,3.0};
+double KX_Particle::speed [] = {0.0,0.0,3.0};
+void KX_Particle::update(double time)
+{
+ double dtime;
+ dtime = time - f10;
+ f1 += f4 * dtime + 0.5 * f7 * dtime * dtime;
+ f2 += f5 * dtime + 0.5 * f8 * dtime * dtime;
+ f3 += f6 * dtime + 0.5 * f9 * dtime * dtime;
+ f6 += f9 * dtime;
+ f10 = time;
+}
\ No newline at end of file
Added: branches/ge_candy/source/gameengine/Ketsji/KX_Particle.h
===================================================================
--- branches/ge_candy/source/gameengine/Ketsji/KX_Particle.h (rev 0)
+++ branches/ge_candy/source/gameengine/Ketsji/KX_Particle.h 2012-10-28 15:33:37 UTC (rev 51708)
@@ -0,0 +1,39 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor(s): Matthew Dietel
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file KX_Particle.h
+ * \ingroup ketsji
+ */
+
+#ifndef __KX_PARTICLE_H__
+#define __KX_PARTICLE_H__
+
+class KX_Particle
+{
+ public:
+ float f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f11;
+ static double speed [3];
+ static double speedOrigin [3];
+ void update(double);
+ KX_Particle(double);
+};
+#endif
\ No newline at end of file
More information about the Bf-blender-cvs
mailing list