mirror of
https://github.com/Heretek-AI/GDevelop.git
synced 2026-07-23 02:25:52 -04:00
Adapted to changes in GDCore.
Cleaned headers. git-svn-id: svn://localhost@762 8062f311-0dae-4547-b526-b8ab9ac864a5
This commit is contained in:
@@ -43,7 +43,7 @@ freely, subject to the following restrictions:
|
||||
#include <wx/numdlg.h>
|
||||
|
||||
#include "GDL/CommonTools.h"
|
||||
#include "GDL/IDE/Dialogs/BitmapGUIManager.h"
|
||||
#include "GDCore/IDE/CommonBitmapManager.h"
|
||||
#include <string>
|
||||
#include <cmath>
|
||||
|
||||
@@ -121,7 +121,7 @@ CustomPolygonDialog::CustomPolygonDialog(wxWindow* parent, std::vector<sf::Vecto
|
||||
FlexGridSizer5->Add(StaticText2, 1, wxALL|wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 5);
|
||||
StaticBoxSizer2 = new wxStaticBoxSizer(wxHORIZONTAL, this, _("Positionnement"));
|
||||
GridSizer1 = new wxGridSizer(3, 1, 0, 0);
|
||||
OnCenterRadioBt = new wxRadioButton(this, ID_RADIOBUTTON3, _("Positionner par rapport au centre"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_RADIOBUTTON3"));
|
||||
OnCenterRadioBt = new wxRadioButton(this, ID_RADIOBUTTON3, _("Positionner par rapport au centre"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP, wxDefaultValidator, _T("ID_RADIOBUTTON3"));
|
||||
OnCenterRadioBt->SetValue(true);
|
||||
GridSizer1->Add(OnCenterRadioBt, 1, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
|
||||
OnOriginRadioBt = new wxRadioButton(this, ID_RADIOBUTTON1, _("Positionner par rapport à l\'origine"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_RADIOBUTTON1"));
|
||||
@@ -291,7 +291,7 @@ void CustomPolygonDialog::OnpreviewPnlPaint(wxPaintEvent& event)
|
||||
float yOffset = (previewPnlVerticalScroll->GetThumbPosition() - previewPnlVerticalScroll->GetRange()/2);
|
||||
|
||||
//Draw background
|
||||
dc.SetBrush(BitmapGUIManager::GetInstance()->transparentBg);
|
||||
dc.SetBrush(gd::CommonBitmapManager::GetInstance()->transparentBg);
|
||||
dc.DrawRectangle(0,0, panelSize.GetWidth(), panelSize.GetHeight());
|
||||
|
||||
//Draw Collision Polygon
|
||||
@@ -343,7 +343,7 @@ void CustomPolygonDialog::OnpreviewPnlPaint(wxPaintEvent& event)
|
||||
}
|
||||
|
||||
//Draw origin
|
||||
wxBitmap point(BitmapGUIManager::GetInstance()->point);
|
||||
wxBitmap point(gd::CommonBitmapManager::GetInstance()->point);
|
||||
dc.DrawBitmap(point,
|
||||
(0-point.GetWidth()/2) -xOffset,
|
||||
(0-point.GetHeight()/2) -yOffset,
|
||||
|
||||
@@ -31,10 +31,11 @@ freely, subject to the following restrictions:
|
||||
#include "GDL/ExtensionBase.h"
|
||||
#include "GDL/Version.h"
|
||||
#include "PhysicsAutomatism.h"
|
||||
#include "ScenePhysicsDatas.h"
|
||||
#include <boost/version.hpp>
|
||||
|
||||
/**
|
||||
* This class declare information about the extension.
|
||||
* \brief This class declares information about the extension.
|
||||
*/
|
||||
class Extension : public ExtensionBase
|
||||
{
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<Project>
|
||||
<Option title="PhysicsAutomatism" />
|
||||
<Option pch_mode="2" />
|
||||
<Option compiler="mingw_452" />
|
||||
<Option compiler="gcc" />
|
||||
<Build>
|
||||
<Target title="Debug">
|
||||
<Option output="..\..\Runtime\bin\debug\PhysicsAutomatism.xgdw" prefix_auto="1" extension_auto="0" />
|
||||
@@ -48,6 +48,7 @@
|
||||
<Add option="-g" />
|
||||
<Add option="-m32" />
|
||||
<Add option="-DGD_IDE_ONLY" />
|
||||
<Add option="-DGD_CORE_API=__declspec(dllimport)" />
|
||||
<Add option="-DGD_API=__declspec(dllimport)" />
|
||||
<Add option="-DGD_EXTENSION_API=__declspec(dllexport)" />
|
||||
<Add option="-DDEBUG" />
|
||||
@@ -61,6 +62,7 @@
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-pg -lgmon" />
|
||||
<Add option="-lGDCore" />
|
||||
<Add option="-lgdl" />
|
||||
<Add option="-lwxmsw29d_xrc" />
|
||||
<Add option="-lwxmsw29d_richtext" />
|
||||
@@ -146,6 +148,7 @@
|
||||
<Add option="-Wall" />
|
||||
<Add option="-m32" />
|
||||
<Add option="-DGD_IDE_ONLY" />
|
||||
<Add option="-DGD_CORE_API=__declspec(dllimport)" />
|
||||
<Add option="-DGD_API=__declspec(dllimport)" />
|
||||
<Add option="-DGD_EXTENSION_API=__declspec(dllexport)" />
|
||||
<Add option="-DRELEASE" />
|
||||
@@ -160,6 +163,7 @@
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-s" />
|
||||
<Add option="-lGDCore" />
|
||||
<Add option="-lgdl" />
|
||||
<Add option="-lwxmsw29_xrc" />
|
||||
<Add option="-lwxmsw29_richtext" />
|
||||
@@ -208,7 +212,7 @@
|
||||
<Option output="..\..\Runtime\bin\dev\PhysicsAutomatism.xgdw" prefix_auto="1" extension_auto="0" />
|
||||
<Option object_output="obj\Dev\" />
|
||||
<Option type="3" />
|
||||
<Option compiler="mingw_452" />
|
||||
<Option compiler="gcc" />
|
||||
<Option createStaticLib="1" />
|
||||
<Compiler>
|
||||
<Add option="-O2" />
|
||||
@@ -245,6 +249,7 @@
|
||||
<Add option="-Wall" />
|
||||
<Add option="-m32" />
|
||||
<Add option="-DGD_IDE_ONLY" />
|
||||
<Add option="-DGD_CORE_API=__declspec(dllimport)" />
|
||||
<Add option="-DGD_API=__declspec(dllimport)" />
|
||||
<Add option="-DGD_EXTENSION_API=__declspec(dllexport)" />
|
||||
<Add option="-DDEV" />
|
||||
@@ -259,6 +264,7 @@
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-s" />
|
||||
<Add option="-lGDCore" />
|
||||
<Add option="-lgdl" />
|
||||
<Add option="-lwxmsw29_xrc" />
|
||||
<Add option="-lwxmsw29_richtext" />
|
||||
@@ -356,6 +362,7 @@
|
||||
<Add option="`wx-config --cppflags`" />
|
||||
<Add option="`pkg-config gtk+-2.0 --cflags`" />
|
||||
<Add option="-DGD_IDE_ONLY" />
|
||||
<Add option='-DGD_CORE_API=""' />
|
||||
<Add option='-DGD_API=""' />
|
||||
<Add option='-DGD_EXTENSION_API=""' />
|
||||
<Add option="-DRELEASE" />
|
||||
@@ -365,6 +372,7 @@
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-s" />
|
||||
<Add option="-lGDCore" />
|
||||
<Add option="-lgdl" />
|
||||
<Add option="`wx-config --libs all`" />
|
||||
<Add option="-lsfml-audio" />
|
||||
@@ -399,6 +407,7 @@
|
||||
<Add option="`wx-config --cppflags`" />
|
||||
<Add option="`pkg-config gtk+-2.0 --cflags`" />
|
||||
<Add option="-DGD_IDE_ONLY" />
|
||||
<Add option='-DGD_CORE_API=""' />
|
||||
<Add option='-DGD_API=""' />
|
||||
<Add option='-DGD_EXTENSION_API=""' />
|
||||
<Add option="-DDEBUG" />
|
||||
@@ -406,6 +415,7 @@
|
||||
<Add option="-DSFML_DYNAMIC" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-lGDCore" />
|
||||
<Add option="-lgdl" />
|
||||
<Add option="`wx-config --libs all`" />
|
||||
<Add option="-lsfml-audio" />
|
||||
@@ -546,6 +556,7 @@
|
||||
</Target>
|
||||
</Build>
|
||||
<Compiler>
|
||||
<Add directory="..\..\Core" />
|
||||
<Add directory="..\..\GDL" />
|
||||
<Add directory="..\..\ExtLibs\SFML\include" />
|
||||
<Add directory="..\..\ExtLibs\boost" />
|
||||
|
||||
@@ -25,6 +25,7 @@ freely, subject to the following restrictions:
|
||||
*/
|
||||
|
||||
#include "PhysicsAutomatism.h"
|
||||
#include <string>
|
||||
#include "Box2D/Box2D.h"
|
||||
#include "Triangulation/triangulate.h"
|
||||
#include "GDL/RuntimeScene.h"
|
||||
@@ -32,7 +33,7 @@ freely, subject to the following restrictions:
|
||||
#include "GDL/XmlMacros.h"
|
||||
#include "PhysicsAutomatismEditor.h"
|
||||
#include "GDL/CommonTools.h"
|
||||
#include <string>
|
||||
#include "RuntimeScenePhysicsDatas.h"
|
||||
|
||||
#undef GetObject
|
||||
|
||||
@@ -47,7 +48,8 @@ averageFriction(0.8),
|
||||
averageRestitution(0),
|
||||
linearDamping(0.1),
|
||||
angularDamping(0.1),
|
||||
body(NULL)
|
||||
body(NULL),
|
||||
runtimeScenesPhysicsDatas(NULL)
|
||||
{
|
||||
polygonHeight = 200;
|
||||
polygonWidth = 200;
|
||||
@@ -59,7 +61,7 @@ body(NULL)
|
||||
|
||||
PhysicsAutomatism::~PhysicsAutomatism()
|
||||
{
|
||||
if ( runtimeScenesPhysicsDatas != boost::shared_ptr<RuntimeScenePhysicsDatas>() && body)
|
||||
if ( runtimeScenesPhysicsDatas != NULL && body)
|
||||
runtimeScenesPhysicsDatas->world->DestroyBody(body);
|
||||
}
|
||||
|
||||
@@ -126,8 +128,8 @@ void PhysicsAutomatism::DoStepPostEvents(RuntimeScene & scene)
|
||||
*/
|
||||
void PhysicsAutomatism::CreateBody(const RuntimeScene & scene)
|
||||
{
|
||||
if ( runtimeScenesPhysicsDatas == boost::shared_ptr<RuntimeScenePhysicsDatas>() )
|
||||
runtimeScenesPhysicsDatas = boost::static_pointer_cast<RuntimeScenePhysicsDatas>(scene.GetAutomatismSharedDatas(name));
|
||||
if ( runtimeScenesPhysicsDatas == NULL )
|
||||
runtimeScenesPhysicsDatas = static_cast<RuntimeScenePhysicsDatas*>(scene.GetAutomatismSharedDatas(name).get());
|
||||
|
||||
//Create body from object
|
||||
b2BodyDef bodyDef;
|
||||
@@ -313,7 +315,7 @@ void PhysicsAutomatism::ApplyForce(double xCoordinate, double yCoordinate, Runti
|
||||
void PhysicsAutomatism::ApplyForceUsingPolarCoordinates( float angle, float length, RuntimeScene & scene )
|
||||
{
|
||||
if ( !body ) CreateBody(scene);
|
||||
body->ApplyForce(b2Vec2(cos(angle)*length,-sin(angle)*length), body->GetPosition());
|
||||
body->ApplyForce(b2Vec2(cos(angle*b2_pi/180.0f)*length,-sin(angle*b2_pi/180.0f)*length), body->GetPosition());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -381,7 +383,7 @@ void PhysicsAutomatism::AddRevoluteJointBetweenObjects( const std::string & , Ob
|
||||
{
|
||||
if ( !body ) CreateBody(scene);
|
||||
|
||||
if ( object == NULL || !object->HasAutomatism(name) ) return;
|
||||
if ( object == NULL || !object->HasAutomatismNamed(name) ) return;
|
||||
b2Body * otherBody = static_cast<PhysicsAutomatism*>(object->GetAutomatismRawPointer(name))->GetBox2DBody(scene);
|
||||
|
||||
if ( body == otherBody ) return;
|
||||
@@ -425,8 +427,8 @@ void PhysicsAutomatism::AddGearJointBetweenObjects( const std::string & , Object
|
||||
{
|
||||
if ( !body ) CreateBody(scene);
|
||||
|
||||
if ( object == NULL || !object->HasAutomatism(name) ) return;
|
||||
b2Body * otherBody = boost::static_pointer_cast<PhysicsAutomatism>(object->GetAutomatism(name))->GetBox2DBody(scene);
|
||||
if ( object == NULL || !object->HasAutomatismNamed(name) ) return;
|
||||
b2Body * otherBody = static_cast<PhysicsAutomatism*>(object->GetAutomatismRawPointer(name))->GetBox2DBody(scene);
|
||||
|
||||
if ( body == otherBody ) return;
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -29,18 +29,16 @@ freely, subject to the following restrictions:
|
||||
|
||||
#include "GDL/Automatism.h"
|
||||
#include "GDL/Object.h"
|
||||
#include "ScenePhysicsDatas.h"
|
||||
#include <boost/weak_ptr.hpp>
|
||||
#include "SFML/Config.hpp"
|
||||
#include "SFML/System/Vector2.hpp"
|
||||
#include <iostream>
|
||||
#include <map>
|
||||
#include <vector>
|
||||
#include <set>
|
||||
#include <vector>
|
||||
class TiXmlElement;
|
||||
class RuntimeScene;
|
||||
class b2Body;
|
||||
class PhysicsAutomatismEditor;
|
||||
class RuntimeScenePhysicsDatas;
|
||||
|
||||
namespace sf
|
||||
{
|
||||
@@ -49,143 +47,142 @@ namespace sf
|
||||
|
||||
class GD_EXTENSION_API PhysicsAutomatism : public Automatism
|
||||
{
|
||||
friend class PhysicsAutomatismEditor;
|
||||
friend class PhysicsAutomatismEditor;
|
||||
|
||||
public:
|
||||
PhysicsAutomatism(std::string automatismTypeName);
|
||||
virtual ~PhysicsAutomatism();
|
||||
virtual boost::shared_ptr<Automatism> Clone() { return boost::shared_ptr<Automatism>(new PhysicsAutomatism(*this));}
|
||||
public:
|
||||
PhysicsAutomatism(std::string automatismTypeName);
|
||||
virtual ~PhysicsAutomatism();
|
||||
virtual Automatism * Clone() { return new PhysicsAutomatism(*this);}
|
||||
|
||||
enum Positioning {OnOrigin = 0, OnCenter = 2};
|
||||
enum Positioning {OnOrigin = 0, OnCenter = 2};
|
||||
|
||||
#if defined(GD_IDE_ONLY)
|
||||
/**
|
||||
* Save Automatism to XML
|
||||
*/
|
||||
virtual void SaveToXml(TiXmlElement * elem) const;
|
||||
#endif
|
||||
#if defined(GD_IDE_ONLY)
|
||||
/**
|
||||
* Save Automatism to XML
|
||||
*/
|
||||
virtual void SaveToXml(TiXmlElement * elem) const;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Load Automatism from XML
|
||||
*/
|
||||
virtual void LoadFromXml(const TiXmlElement * elem);
|
||||
/**
|
||||
* Load Automatism from XML
|
||||
*/
|
||||
virtual void LoadFromXml(const TiXmlElement * elem);
|
||||
|
||||
#if defined(GD_IDE_ONLY)
|
||||
/**
|
||||
* Called when user wants to edit the automatism.
|
||||
*/
|
||||
virtual void EditAutomatism( wxWindow* parent, Game & game_, Scene * scene, MainEditorCommand & mainEditorCommand_ );
|
||||
#endif
|
||||
#if defined(GD_IDE_ONLY)
|
||||
/**
|
||||
* Called when user wants to edit the automatism.
|
||||
*/
|
||||
virtual void EditAutomatism( wxWindow* parent, Game & game_, Scene * scene, MainEditorCommand & mainEditorCommand_ );
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Destroy Box2D body if automatism is deactivated
|
||||
*/
|
||||
virtual void OnDeActivate();
|
||||
/**
|
||||
* Destroy Box2D body if automatism is deactivated
|
||||
*/
|
||||
virtual void OnDeActivate();
|
||||
|
||||
b2Body * GetBox2DBody(const RuntimeScene & scene) { if (!body) CreateBody(scene); return body; }
|
||||
inline Object * GetObject() {return object;};
|
||||
inline const Object * GetObject() const {return object;};
|
||||
b2Body * GetBox2DBody(const RuntimeScene & scene) { if (!body) CreateBody(scene); return body; }
|
||||
inline Object * GetObject() {return object;};
|
||||
inline const Object * GetObject() const {return object;};
|
||||
|
||||
std::set<PhysicsAutomatism*> currentContacts; ///< List of other bodies that are in contact with this body.
|
||||
std::set<PhysicsAutomatism*> currentContacts; ///< List of other bodies that are in contact with this body.
|
||||
|
||||
void SetStatic(RuntimeScene & scene);
|
||||
void SetDynamic(RuntimeScene & scene);
|
||||
bool IsStatic();
|
||||
bool IsDynamic();
|
||||
void SetFixedRotation(RuntimeScene & scene);
|
||||
void SetFreeRotation(RuntimeScene & scene);
|
||||
void SetAsBullet(RuntimeScene & scene);
|
||||
void DontSetAsBullet(RuntimeScene & scene);
|
||||
void ApplyForce(double xCoordinate, double yCoordinate, RuntimeScene & scene );
|
||||
void ApplyForceUsingPolarCoordinates( float angle, float length, RuntimeScene & scene );
|
||||
void ApplyForceTowardPosition(float xPosition, float yPosition, float length, RuntimeScene & scene );
|
||||
void ApplyTorque( double torque, RuntimeScene & scene );
|
||||
void SetLinearVelocity( double xVelocity, double yVelocity, RuntimeScene & scene );
|
||||
void SetAngularVelocity( double angularVelocity, RuntimeScene & scene );
|
||||
void SetLinearDamping( float linearDamping_ , RuntimeScene & scene );
|
||||
void SetAngularDamping( float angularDamping_ , RuntimeScene & scene );
|
||||
void AddRevoluteJointBetweenObjects( const std::string & , Object * object, RuntimeScene & scene );
|
||||
void AddRevoluteJoint( float xPosition, float yPosition, RuntimeScene & scene);
|
||||
void SetGravity( float xGravity, float yGravity, RuntimeScene & scene);
|
||||
void AddGearJointBetweenObjects( const std::string & , Object * object, RuntimeScene & scene );
|
||||
void SetStatic(RuntimeScene & scene);
|
||||
void SetDynamic(RuntimeScene & scene);
|
||||
bool IsStatic();
|
||||
bool IsDynamic();
|
||||
void SetFixedRotation(RuntimeScene & scene);
|
||||
void SetFreeRotation(RuntimeScene & scene);
|
||||
void SetAsBullet(RuntimeScene & scene);
|
||||
void DontSetAsBullet(RuntimeScene & scene);
|
||||
void ApplyForce(double xCoordinate, double yCoordinate, RuntimeScene & scene );
|
||||
void ApplyForceUsingPolarCoordinates( float angle, float length, RuntimeScene & scene );
|
||||
void ApplyForceTowardPosition(float xPosition, float yPosition, float length, RuntimeScene & scene );
|
||||
void ApplyTorque( double torque, RuntimeScene & scene );
|
||||
void SetLinearVelocity( double xVelocity, double yVelocity, RuntimeScene & scene );
|
||||
void SetAngularVelocity( double angularVelocity, RuntimeScene & scene );
|
||||
void SetLinearDamping( float linearDamping_ , RuntimeScene & scene );
|
||||
void SetAngularDamping( float angularDamping_ , RuntimeScene & scene );
|
||||
void AddRevoluteJointBetweenObjects( const std::string & , Object * object, RuntimeScene & scene );
|
||||
void AddRevoluteJoint( float xPosition, float yPosition, RuntimeScene & scene);
|
||||
void SetGravity( float xGravity, float yGravity, RuntimeScene & scene);
|
||||
void AddGearJointBetweenObjects( const std::string & , Object * object, RuntimeScene & scene );
|
||||
|
||||
void SetLinearVelocityX( double xVelocity, RuntimeScene & scene );
|
||||
void SetLinearVelocityY( double yVelocity, RuntimeScene & scene );
|
||||
float GetLinearVelocityX( RuntimeScene & scene );
|
||||
float GetLinearVelocityY( RuntimeScene & scene );
|
||||
double GetAngularVelocity( const RuntimeScene & scene );
|
||||
double GetLinearDamping( const RuntimeScene & scene);
|
||||
double GetAngularDamping( const RuntimeScene & scene);
|
||||
void SetLinearVelocityX( double xVelocity, RuntimeScene & scene );
|
||||
void SetLinearVelocityY( double yVelocity, RuntimeScene & scene );
|
||||
float GetLinearVelocityX( RuntimeScene & scene );
|
||||
float GetLinearVelocityY( RuntimeScene & scene );
|
||||
double GetAngularVelocity( const RuntimeScene & scene );
|
||||
double GetLinearDamping( const RuntimeScene & scene);
|
||||
double GetAngularDamping( const RuntimeScene & scene);
|
||||
|
||||
void SetPolygonCoords(const std::vector<sf::Vector2f>&);
|
||||
const std::vector<sf::Vector2f>& GetPolygonCoords() const;
|
||||
void SetPolygonCoords(const std::vector<sf::Vector2f>&);
|
||||
const std::vector<sf::Vector2f>& GetPolygonCoords() const;
|
||||
|
||||
bool HasAutomaticResizing() const;
|
||||
void SetAutomaticResizing(bool);
|
||||
bool HasAutomaticResizing() const;
|
||||
void SetAutomaticResizing(bool);
|
||||
|
||||
float GetPolygonScaleX() const;
|
||||
void SetPolygonScaleX(float, RuntimeScene&);
|
||||
float GetPolygonScaleX() const;
|
||||
void SetPolygonScaleX(float, RuntimeScene&);
|
||||
|
||||
float GetPolygonScaleY() const;
|
||||
void SetPolygonScaleY(float, RuntimeScene&);
|
||||
float GetPolygonScaleY() const;
|
||||
void SetPolygonScaleY(float, RuntimeScene&);
|
||||
|
||||
/**
|
||||
Return a string representing the coordinates vector.
|
||||
\param vec the vector containing coordinates
|
||||
\param coordsSep the separator between coordinates
|
||||
\param composantSep the separator between the X and Y composant of a coordinate
|
||||
\return a std::string representing the vector
|
||||
*/
|
||||
static std::string GetStringFromCoordsVector(const std::vector<sf::Vector2f> &vec, char coordsSep = '\n', char composantSep = ';');
|
||||
/**
|
||||
Return a string representing the coordinates vector.
|
||||
\param vec the vector containing coordinates
|
||||
\param coordsSep the separator between coordinates
|
||||
\param composantSep the separator between the X and Y composant of a coordinate
|
||||
\return a std::string representing the vector
|
||||
*/
|
||||
static std::string GetStringFromCoordsVector(const std::vector<sf::Vector2f> &vec, char coordsSep = '\n', char composantSep = ';');
|
||||
|
||||
/**
|
||||
Return a vector created with a string containing coordinates
|
||||
\param str the string
|
||||
\param coordsSep the separator between coordinates
|
||||
\param composantSep the separator between the X and Y composant of a coordinate
|
||||
\return a std::vector< sf::Vector2f >
|
||||
*/
|
||||
static std::vector<sf::Vector2f> GetCoordsVectorFromString(const std::string &str, char coordsSep = '\n', char composantSep = ';');
|
||||
/**
|
||||
Return a vector created with a string containing coordinates
|
||||
\param str the string
|
||||
\param coordsSep the separator between coordinates
|
||||
\param composantSep the separator between the X and Y composant of a coordinate
|
||||
\return a std::vector< sf::Vector2f >
|
||||
*/
|
||||
static std::vector<sf::Vector2f> GetCoordsVectorFromString(const std::string &str, char coordsSep = '\n', char composantSep = ';');
|
||||
|
||||
bool CollisionWith( const std::string & , std::map <std::string, std::vector<Object*> *> otherObjectsLists, RuntimeScene & scene);
|
||||
bool CollisionWith( const std::string & , std::map <std::string, std::vector<Object*> *> otherObjectsLists, RuntimeScene & scene);
|
||||
|
||||
static std::map < const Scene* , ScenePhysicsDatas > scenesPhysicsDatas; ///< Static map associating scene to datas
|
||||
private:
|
||||
private:
|
||||
|
||||
virtual void DoStepPreEvents(RuntimeScene & scene);
|
||||
virtual void DoStepPostEvents(RuntimeScene & scene);
|
||||
void CreateBody(const RuntimeScene & scene);
|
||||
virtual void DoStepPreEvents(RuntimeScene & scene);
|
||||
virtual void DoStepPostEvents(RuntimeScene & scene);
|
||||
void CreateBody(const RuntimeScene & scene);
|
||||
|
||||
enum ShapeType {Box, Circle, CustomPolygon} shapeType; ///< the kind of hitbox -> Box, Circle or CustomPolygon
|
||||
Positioning polygonPositioning;
|
||||
std::vector<sf::Vector2f> polygonCoords; ///< The list of coordinates of the collision polygon
|
||||
enum ShapeType {Box, Circle, CustomPolygon} shapeType; ///< the kind of hitbox -> Box, Circle or CustomPolygon
|
||||
Positioning polygonPositioning;
|
||||
std::vector<sf::Vector2f> polygonCoords; ///< The list of coordinates of the collision polygon
|
||||
|
||||
bool automaticResizing;
|
||||
float polygonWidth; ///< ONLY for automatic resizing, used to define a scale with automatic resizing
|
||||
float polygonHeight; ///< ONLY for automatic resizing, used to define a scale with automatic resizing
|
||||
bool automaticResizing;
|
||||
float polygonWidth; ///< ONLY for automatic resizing, used to define a scale with automatic resizing
|
||||
float polygonHeight; ///< ONLY for automatic resizing, used to define a scale with automatic resizing
|
||||
|
||||
float polygonScaleX; ///< ONLY for non-automatic resizing -> Use GetPolygonScaleX() instead to be sure to get a correct value
|
||||
float polygonScaleY; ///< ONLY for non-automatic resizing -> Use GetPolygonScaleY() instead to be sure to get a correct value
|
||||
float polygonScaleX; ///< ONLY for non-automatic resizing -> Use GetPolygonScaleX() instead to be sure to get a correct value
|
||||
float polygonScaleY; ///< ONLY for non-automatic resizing -> Use GetPolygonScaleY() instead to be sure to get a correct value
|
||||
|
||||
bool dynamic; ///< Is the object static or dynamic
|
||||
bool fixedRotation; ///< Is the rotation fixed or not
|
||||
bool isBullet; ///< True if the object as to be considered as a bullet ( for better collision handling )
|
||||
float massDensity;
|
||||
float averageFriction;
|
||||
float averageRestitution;
|
||||
float linearDamping;
|
||||
float angularDamping;
|
||||
bool dynamic; ///< Is the object static or dynamic
|
||||
bool fixedRotation; ///< Is the rotation fixed or not
|
||||
bool isBullet; ///< True if the object as to be considered as a bullet ( for better collision handling )
|
||||
float massDensity;
|
||||
float averageFriction;
|
||||
float averageRestitution;
|
||||
float linearDamping;
|
||||
float angularDamping;
|
||||
|
||||
float objectOldX;
|
||||
float objectOldY;
|
||||
float objectOldAngle;
|
||||
float objectOldWidth;
|
||||
float objectOldHeight;
|
||||
float objectOldX;
|
||||
float objectOldY;
|
||||
float objectOldAngle;
|
||||
float objectOldWidth;
|
||||
float objectOldHeight;
|
||||
|
||||
sf::Clock *stepClock;
|
||||
sf::Clock *stepClock;
|
||||
|
||||
b2Body * body; ///< Box2D body, representing the object in the Box2D world
|
||||
boost::shared_ptr<RuntimeScenePhysicsDatas> runtimeScenesPhysicsDatas;
|
||||
b2Body * body; ///< Box2D body, representing the object in the Box2D world
|
||||
RuntimeScenePhysicsDatas * runtimeScenesPhysicsDatas;
|
||||
};
|
||||
|
||||
#endif // PHYSICAUTOMATISM_H
|
||||
|
||||
@@ -1,38 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
|
||||
<CodeBlocks_layout_file>
|
||||
<ActiveTarget name="Development - Edittime" />
|
||||
<File name="Box2D\Box2D\Box2D\Box2D.h" open="0" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor1 position="1565" topLine="30" />
|
||||
</File>
|
||||
<File name="Box2D\Box2D\Box2D\Collision\Shapes\b2CircleShape.h" open="0" top="0" tabpos="4" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor1 position="2470" topLine="55" />
|
||||
</File>
|
||||
<File name="Box2D\Box2D\Box2D\Collision\Shapes\b2PolygonShape.cpp" open="0" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor1 position="10997" topLine="402" />
|
||||
</File>
|
||||
<File name="Box2D\Box2D\Box2D\Collision\Shapes\b2PolygonShape.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor1 position="3937" topLine="99" />
|
||||
</File>
|
||||
<File name="Box2D\Box2D\Box2D\Collision\b2BroadPhase.cpp" open="0" top="0" tabpos="11" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor1 position="980" topLine="85" />
|
||||
</File>
|
||||
<File name="Box2D\Box2D\Box2D\Collision\b2Distance.cpp" open="0" top="0" tabpos="12" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor1 position="1190" topLine="12" />
|
||||
</File>
|
||||
<File name="Box2D\Box2D\Box2D\Common\b2BlockAllocator.cpp" open="0" top="0" tabpos="7" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor1 position="1553" topLine="37" />
|
||||
</File>
|
||||
<File name="Box2D\Box2D\Box2D\Common\b2Settings.h" open="0" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor1 position="1251" topLine="13" />
|
||||
</File>
|
||||
<File name="Box2D\Box2D\Box2D\Common\b2StackAllocator.cpp" open="0" top="0" tabpos="8" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor1 position="1786" topLine="49" />
|
||||
</File>
|
||||
<File name="Box2D\Box2D\Box2D\Dynamics\Contacts\b2ContactSolver.cpp" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor1 position="3533" topLine="77" />
|
||||
</File>
|
||||
<File name="Box2D\Box2D\Box2D\Dynamics\Contacts\b2TOISolver.cpp" open="0" top="0" tabpos="12" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor1 position="5231" topLine="182" />
|
||||
<ActiveTarget name="Release - Edittime" />
|
||||
<File name="RuntimeScenePhysicsDatas.cpp" open="0" top="0" tabpos="8" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor1 position="1780" topLine="32" />
|
||||
</File>
|
||||
<File name="Box2D\Box2D\Box2D\Dynamics\Contacts\b2TOISolver.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor1 position="4" topLine="0" />
|
||||
@@ -40,52 +10,85 @@
|
||||
<File name="Box2D\Box2D\Box2D\Dynamics\b2Body.cpp" open="0" top="0" tabpos="10" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor1 position="6345" topLine="251" />
|
||||
</File>
|
||||
<File name="Box2D\Box2D\Box2D\Dynamics\b2Body.h" open="0" top="0" tabpos="4" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor1 position="12952" topLine="306" />
|
||||
<File name="PhysicsAutomatismEditor.h" open="0" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor1 position="88" topLine="3" />
|
||||
</File>
|
||||
<File name="Box2D\Box2D\Box2D\Dynamics\b2World.cpp" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor1 position="20687" topLine="877" />
|
||||
<File name="Box2D\Box2D\Box2D\Dynamics\Contacts\b2TOISolver.cpp" open="0" top="0" tabpos="12" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor1 position="5231" topLine="182" />
|
||||
</File>
|
||||
<File name="Box2D\Box2D\Box2D\Dynamics\b2World.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor1 position="3825" topLine="74" />
|
||||
<File name="PhysicsAutomatismEditor.cpp" open="0" top="0" tabpos="4" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor1 position="1267" topLine="15" />
|
||||
</File>
|
||||
<File name="ContactListener.cpp" open="0" top="0" tabpos="5" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor1 position="639" topLine="0" />
|
||||
<File name="Box2D\Box2D\Box2D\Collision\b2BroadPhase.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor1 position="1650" topLine="33" />
|
||||
</File>
|
||||
<File name="PhysicsAutomatism.h" open="0" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor1 position="1122" topLine="135" />
|
||||
</File>
|
||||
<File name="Box2D\Box2D\Box2D\Collision\b2BroadPhase.cpp" open="0" top="0" tabpos="11" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor1 position="980" topLine="85" />
|
||||
</File>
|
||||
<File name="PhysicsAutomatism.cpp" open="0" top="0" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor1 position="1822" topLine="40" />
|
||||
</File>
|
||||
<File name="Extension.cpp" open="0" top="0" tabpos="7" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor1 position="1225" topLine="12" />
|
||||
</File>
|
||||
<File name="Box2D\Box2D\Box2D\Collision\Shapes\b2PolygonShape.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor1 position="3937" topLine="99" />
|
||||
</File>
|
||||
<File name="CustomPolygonDialog.h" open="0" top="0" tabpos="6" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor1 position="2028" topLine="52" />
|
||||
</File>
|
||||
<File name="Box2D\Box2D\Box2D\Collision\Shapes\b2PolygonShape.cpp" open="0" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor1 position="10997" topLine="402" />
|
||||
</File>
|
||||
<File name="CustomPolygonDialog.cpp" open="0" top="0" tabpos="5" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor1 position="1438" topLine="45" />
|
||||
</File>
|
||||
<File name="Box2D\Box2D\Box2D\Dynamics\Contacts\b2ContactSolver.cpp" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor1 position="3533" topLine="77" />
|
||||
</File>
|
||||
<File name="Box2D\Box2D\Box2D\Common\b2StackAllocator.cpp" open="0" top="0" tabpos="8" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor1 position="1786" topLine="49" />
|
||||
</File>
|
||||
<File name="Box2D\Box2D\Box2D\Collision\Shapes\b2CircleShape.h" open="0" top="0" tabpos="4" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor1 position="2470" topLine="55" />
|
||||
</File>
|
||||
<File name="ContactListener.h" open="0" top="0" tabpos="4" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor1 position="238" topLine="0" />
|
||||
</File>
|
||||
<File name="CustomPolygonDialog.cpp" open="0" top="0" tabpos="5" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor1 position="88" topLine="3" />
|
||||
<File name="Box2D\Box2D\Box2D\Common\b2Settings.h" open="0" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor1 position="1251" topLine="13" />
|
||||
</File>
|
||||
<File name="CustomPolygonDialog.h" open="0" top="0" tabpos="6" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor1 position="88" topLine="3" />
|
||||
<File name="ContactListener.cpp" open="0" top="0" tabpos="5" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor1 position="639" topLine="0" />
|
||||
</File>
|
||||
<File name="Extension.cpp" open="0" top="0" tabpos="7" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor1 position="980" topLine="3" />
|
||||
<File name="Box2D\Box2D\Box2D\Box2D.h" open="0" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor1 position="1215" topLine="15" />
|
||||
</File>
|
||||
<File name="PhysicsAutomatism.cpp" open="0" top="0" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor1 position="88" topLine="3" />
|
||||
<File name="Box2D\Box2D\Box2D\Dynamics\b2World.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor1 position="3815" topLine="74" />
|
||||
</File>
|
||||
<File name="PhysicsAutomatism.h" open="1" top="0" tabpos="5" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor1 position="1069" topLine="63" />
|
||||
<File name="Box2D\Box2D\Box2D\Dynamics\b2World.cpp" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor1 position="2880" topLine="101" />
|
||||
</File>
|
||||
<File name="PhysicsAutomatismEditor.cpp" open="0" top="0" tabpos="4" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor1 position="88" topLine="3" />
|
||||
</File>
|
||||
<File name="PhysicsAutomatismEditor.h" open="0" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor1 position="88" topLine="3" />
|
||||
</File>
|
||||
<File name="RuntimeScenePhysicsDatas.cpp" open="0" top="0" tabpos="8" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor1 position="51" topLine="3" />
|
||||
</File>
|
||||
<File name="RuntimeScenePhysicsDatas.h" open="0" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor1 position="88" topLine="3" />
|
||||
</File>
|
||||
<File name="ScenePhysicsDatas.cpp" open="0" top="0" tabpos="9" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor1 position="88" topLine="3" />
|
||||
<File name="Box2D\Box2D\Box2D\Common\b2BlockAllocator.cpp" open="0" top="0" tabpos="7" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor1 position="1553" topLine="37" />
|
||||
</File>
|
||||
<File name="ScenePhysicsDatas.h" open="0" top="0" tabpos="4" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor1 position="88" topLine="3" />
|
||||
<Cursor1 position="1116" topLine="17" />
|
||||
</File>
|
||||
<File name="Box2D\Box2D\Box2D\Collision\b2Distance.cpp" open="0" top="0" tabpos="12" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor1 position="1190" topLine="12" />
|
||||
</File>
|
||||
<File name="ScenePhysicsDatas.cpp" open="0" top="0" tabpos="9" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor1 position="1343" topLine="16" />
|
||||
</File>
|
||||
<File name="RuntimeScenePhysicsDatas.h" open="0" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor1 position="2667" topLine="41" />
|
||||
</File>
|
||||
<File name="Box2D\Box2D\Box2D\Dynamics\b2Body.h" open="0" top="0" tabpos="4" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor1 position="12952" topLine="306" />
|
||||
</File>
|
||||
</CodeBlocks_layout_file>
|
||||
|
||||
@@ -39,10 +39,11 @@ freely, subject to the following restrictions:
|
||||
#include <wx/msw/winundef.h>
|
||||
#endif
|
||||
#include "GDL/Game.h"
|
||||
#include "PhysicsAutomatism.h"
|
||||
#include "GDL/IDE/MainEditorCommand.h"
|
||||
#include "GDL/CommonTools.h"
|
||||
#include "GDL/Scene.h"
|
||||
#include "PhysicsAutomatism.h"
|
||||
#include "ScenePhysicsDatas.h"
|
||||
|
||||
#include "CustomPolygonDialog.h"
|
||||
|
||||
|
||||
@@ -29,7 +29,6 @@ freely, subject to the following restrictions:
|
||||
|
||||
class b2World;
|
||||
class b2Body;
|
||||
#include <iostream>
|
||||
#include "GDL/AutomatismsRuntimeSharedDatas.h"
|
||||
class ScenePhysicsDatas;
|
||||
class ContactListener;
|
||||
|
||||
@@ -29,7 +29,6 @@ freely, subject to the following restrictions:
|
||||
|
||||
#include "GDL/AutomatismsSharedDatas.h"
|
||||
#include "RuntimeScenePhysicsDatas.h"
|
||||
#include <iostream>
|
||||
|
||||
/**
|
||||
* Datas shared by Physics Automatism
|
||||
|
||||
@@ -58,6 +58,7 @@
|
||||
<object class="wxRadioButton" name="ID_RADIOBUTTON3" variable="OnCenterRadioBt" member="yes">
|
||||
<label>Positionner par rapport au centre</label>
|
||||
<selected>1</selected>
|
||||
<style>wxRB_GROUP</style>
|
||||
<handler function="OnRadioButton1Select" entry="EVT_RADIOBUTTON" />
|
||||
</object>
|
||||
<flag>wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL</flag>
|
||||
@@ -363,4 +364,4 @@
|
||||
</object>
|
||||
</object>
|
||||
</object>
|
||||
</wxsmith>
|
||||
</wxsmith>
|
||||
|
||||
Reference in New Issue
Block a user