Gamestudio Links
Zorro Links
Newest Posts
Trading Journey
by howardR. 04/28/24 09:55
basik85278
by basik85278. 04/28/24 08:56
Zorro Trader GPT
by TipmyPip. 04/27/24 13:50
Help with plotting multiple ZigZag
by M_D. 04/26/24 20:03
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
M1 Oversampling
by jcl. 04/26/24 11:12
Why Zorro supports up to 72 cores?
by jcl. 04/26/24 11:09
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (Quad, AndrewAMD), 722 guests, and 6 spiders.
Key: Admin, Global Mod, Mod
Newest Members
wandaluciaia, Mega_Rod, EternallyCurious, howardR, 11honza11
19049 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 2 of 3 1 2 3
Re: 3Dgs Box2D wrapper [Re: 3dgs_snake] #361285
03/02/11 09:11
03/02/11 09:11
Joined: Feb 2010
Posts: 320
TANA/Madagascar
3dgs_snake Offline OP
Senior Member
3dgs_snake  Offline OP
Senior Member

Joined: Feb 2010
Posts: 320
TANA/Madagascar
Hi,

I have good news laugh , the plugin is now linked statically with runtime and doesn't require Visual C Runtime anymore (Box2D was generated with the MultiThreaded DLL, it is now fixed). I will upload it here after the contest entries are uploaded in the free ressources.

Best regards.

Re: 3Dgs Box2D wrapper [Re: 3dgs_snake] #361646
03/04/11 08:20
03/04/11 08:20
Joined: Feb 2010
Posts: 320
TANA/Madagascar
3dgs_snake Offline OP
Senior Member
3dgs_snake  Offline OP
Senior Member

Joined: Feb 2010
Posts: 320
TANA/Madagascar
Hello to all,

The plugin has been updated (monolithic header, static linking with runtime, added two advanced demos - using callbacks), it is more like a real plugin now. The download link is on
the first post .


Best regards.

Re: 3Dgs Box2D wrapper [Re: 3dgs_snake] #362203
03/07/11 11:50
03/07/11 11:50
Joined: Apr 2005
Posts: 3,815
Finland
Inestical Offline
Rabbit Developer
Inestical  Offline
Rabbit Developer

Joined: Apr 2005
Posts: 3,815
Finland
Awesome. I use Box2D in my current project, and it's great to see it's capabilities extended to to 3DGS laugh


"Yesterday was once today's tomorrow."
Re: 3Dgs Box2D wrapper [Re: Inestical] #362209
03/07/11 12:33
03/07/11 12:33
Joined: Feb 2010
Posts: 320
TANA/Madagascar
3dgs_snake Offline OP
Senior Member
3dgs_snake  Offline OP
Senior Member

Joined: Feb 2010
Posts: 320
TANA/Madagascar
Hi,

Thanks and good luck for your project.
And I wish you could use the plugin to create some amazing things with 3DGS for your next project smile .

Best regards.

Re: 3Dgs Box2D wrapper [Re: 3dgs_snake] #362300
03/07/11 17:45
03/07/11 17:45
Joined: Oct 2004
Posts: 4,134
Netherlands
Joozey Offline
Expert
Joozey  Offline
Expert

Joined: Oct 2004
Posts: 4,134
Netherlands
Very nice work! laugh


Click and join the 3dgs irc community!
Room: #3dgs
Re: 3Dgs Box2D wrapper [Re: Joozey] #364814
03/21/11 05:31
03/21/11 05:31
Joined: Feb 2010
Posts: 320
TANA/Madagascar
3dgs_snake Offline OP
Senior Member
3dgs_snake  Offline OP
Senior Member

Joined: Feb 2010
Posts: 320
TANA/Madagascar
Hi to all,

The updated version of the plugin is now available on the first page of this post.

I'm now planning to add next stuffs like buoyancy and some little things. If you have some questions, or want some changes to be made, I will really do my best to answer them.

Download link on the first post

Best regards.

Re: 3Dgs Box2D wrapper - Test [Re: 3dgs_snake] #364822
03/21/11 09:41
03/21/11 09:41
Joined: Feb 2010
Posts: 320
TANA/Madagascar
3dgs_snake Offline OP
Senior Member
3dgs_snake  Offline OP
Senior Member

Joined: Feb 2010
Posts: 320
TANA/Madagascar
Me again,

I was obsessed by it for some times now, and I finally made a quick little test. It consist of manipulating a 3D entity with box2D so it will be 3D (with all the camera stuff), but the movement is constrained in 2 axis grin. Test it by yourself (Header and dll needed - download link on the first post).

Code:
//////////////////////////////
// @file
// Test - using box2D with entities
//
// Entity movement is constrained in y, z axis - Corresponding to box2D x, y
//////////////////////////////

#include <acknex.h>
#include <default.c>

#include "ackb2d.h"

#define PI 3.14159265
#define INV_PI 0.318309886

// Variables
b2World *world = NULL;
VECTOR gravity;
var phys_scale = 30;

// Box update function
void box_update()
{
	// The current entity body
	b2Body *box_body = NULL;
	
	// Create a box2D representation for the entity
	b2BodyDef *bodyDef = NULL;
	bodyDef = b2BodyDef_Create();
	b2BodyDef_SetType(bodyDef, B2_DYNAMICBODY);
	b2BodyDef_SetPosition(bodyDef, vector(-my->y / phys_scale, my->z / phys_scale, 0.0));
	// Body
	box_body = b2World_CreateBody(world, bodyDef);
	
	/// Box Polygon
	b2PolygonShape *dynamicBox = NULL;
	dynamicBox = b2PolygonShape_Create();
	b2PolygonShape_SetAsBox1(dynamicBox, 8 / phys_scale, 8 / phys_scale);
	
	// Fixture
	b2FixtureDef *fixtureDef = NULL;
	fixtureDef = b2FixtureDef_Create();
	b2FixtureDef_SetShape(fixtureDef, dynamicBox);
	b2FixtureDef_SetDensity(fixtureDef, 1.0);
	b2FixtureDef_SetRestitution(fixtureDef, 0.2);
	b2FixtureDef_SetFriction(fixtureDef, 0.3);
	
	b2Body_CreateFixture(box_body, fixtureDef);
	
	// Destroy unused objects
	b2BodyDef_Destroy(bodyDef);
	b2PolygonShape_Destroy(dynamicBox);
	b2FixtureDef_Destroy(fixtureDef);
		
	// Color entity
	set(my, LIGHT);
	vec_set(my->blue, vector(10+random(150), random(10), random(150)));
	
	// Display shadow
	set(my, SHADOW);
	
	VECTOR position;
	var angle;
	
	while(1)
	{
		// Get properties from physics engine
		b2Body_GetPosition(box_body, &position);
		angle = b2Body_GetAngle(box_body);
		
		// Copy changes into shape objects
		vec_set(my.x, vector(0, position.x * phys_scale, position.y * phys_scale));
		my->roll = 180 * angle * INV_PI;
		
		wait(1);
	}
}

// Sphere update function
void sphere_update()
{
	// The current entity body
	b2Body *box_body = NULL;
	
	// Create a box2D representation for the entity
	b2BodyDef *bodyDef = NULL;
	bodyDef = b2BodyDef_Create();
	b2BodyDef_SetType(bodyDef, B2_DYNAMICBODY);
	b2BodyDef_SetPosition(bodyDef, vector(-my->y / phys_scale, my->z / phys_scale, 0.0));
	// Body
	box_body = b2World_CreateBody(world, bodyDef);
	
	/// Box circle
	b2CircleShape *dynamicCircle = b2CircleShape_Create();
	b2CircleShape_SetRadius(dynamicCircle, 8 / phys_scale);
	
	// Fixture
	b2FixtureDef *fixtureDef = NULL;
	fixtureDef = b2FixtureDef_Create();
	b2FixtureDef_SetShape(fixtureDef, dynamicCircle);
	b2FixtureDef_SetDensity(fixtureDef, 1.0);
	b2FixtureDef_SetRestitution(fixtureDef, 0.6);
	b2FixtureDef_SetFriction(fixtureDef, 0.3);
	
	b2Body_CreateFixture(box_body, fixtureDef);
	
	// Destroy unused objects
	b2BodyDef_Destroy(bodyDef);
	b2CircleShape_Destroy(dynamicCircle);
	b2FixtureDef_Destroy(fixtureDef);
		
	// Color entity
	set(my, LIGHT);
	vec_set(my->blue, vector(10+random(150), random(10), random(150)));
	
	// Display shadow
	set(my, SHADOW);
	
	VECTOR position;
	var angle;
	
	while(1)
	{
		// Get properties from physics engine
		b2Body_GetPosition(box_body, &position);
		angle = b2Body_GetAngle(box_body);
		
		// Copy changes into shape objects
		vec_set(my.x, vector(0, position.x * phys_scale, position.y * phys_scale));
		my->roll = 180 * angle * INV_PI;
		
		wait(1);
	}
}

//////////////////////////////
// Close engine on escape
//////////////////////////////
void esc_handler()
{
	//////////////////////////////
	// Destroy world
	//////////////////////////////	
	b2World_Destroy(world);
	sys_exit("");
}

// Main test
void main()
{
	// Set video mode
	video_mode = 4;
	// limit fps to be in sync with box2D timestep
	fps_max = 60;
	
	// Randomize
	random_seed(0);
	
	// Shadow type
	shadow_stencil = 2;
	
	// Wait for graphics to be ready
	// Wait for the execution of startup functions
	wait(1);
	
	// Set key handler
	on_esc = esc_handler;
	
	// load empty level
	level_load(NULL);
	
	vec_set(&gravity, vector(0.0, -10.0, 0.0));
	var do_sleep = 1;
	
	world = b2World_Create(&gravity, do_sleep);
	
	// Set debug draw to default
	ackDebugDraw *debug = ackDebugDraw_Create(phys_scale);
	ackDebugDraw_SetFlags(debug, E_SHAPEBIT | E_JOINTBIT);
	b2World_SetDebugDraw(world, debug);
	
	// Create entities
	ent_create("cube.mdl", vector(0, -8, 120), box_update);
	ent_create("cube.mdl", vector(0, 8, 150), box_update);
	ent_create("sphere.mdl", vector(0, -8, 200), sphere_update);
	ent_create("sphere.mdl", vector(0, 8, 200), sphere_update);
	
	// position camera
	vec_set(camera.x, vector(-212, -3, 56));
	//set(camera, ISOMETRIC);
	
	/// Body def
	b2BodyDef *groundBodyDef = NULL;
	groundBodyDef = b2BodyDef_Create();
	b2BodyDef_SetPosition(groundBodyDef, vector(0.0, -10.0, 0.0));
	
	/// Body
	b2Body *groundBody = b2World_CreateBody(world, groundBodyDef);
	// Create ground entity
	ENTITY *ground_ent = ent_create("cube.mdl", nullvector, NULL);
	//set(ground_ent, LIGHT);
	vec_set(ground_ent->blue, vector(0, 255, 255));
	
	ground_ent->scale_x = 20;
	ground_ent->scale_y = 40;
	c_updatehull(ground_ent, 1);
	ground_ent->z -= 8;
	
	/// Ground Polygon
	b2PolygonShape *groundBox = NULL;
	groundBox = b2PolygonShape_Create();
	b2PolygonShape_SetAsBox1(groundBox, 50.0, 10.0);
	
	b2Body_CreateFixture2(groundBody, groundBox, 0);
		
	var velocity_iterations = 6;
	var position_iteration = 2;
	var timeStep = 1.0 / 60.0;
	
	while(1)
	{
		// Step in 2d world
		b2World_Step(world, timeStep, velocity_iterations, position_iteration);
		b2World_ClearForces(world);
				
		wait(1);
	}
}



Best regards.

Re: 3Dgs Box2D wrapper - Test [Re: 3dgs_snake] #364835
03/21/11 12:04
03/21/11 12:04
Joined: May 2002
Posts: 7,441
ventilator Offline
Senior Expert
ventilator  Offline
Senior Expert

Joined: May 2002
Posts: 7,441
as a successor to the 256kb contest a 2d physics game contest would be fun. laugh

Re: 3Dgs Box2D wrapper - Test [Re: ventilator] #364838
03/21/11 12:31
03/21/11 12:31
Joined: Feb 2010
Posts: 320
TANA/Madagascar
3dgs_snake Offline OP
Senior Member
3dgs_snake  Offline OP
Senior Member

Joined: Feb 2010
Posts: 320
TANA/Madagascar
Yes, that is a good idea,

we will then see plenty of good 2d examples grin

Re: 3Dgs Box2D wrapper - Test [Re: 3dgs_snake] #409001
10/10/12 08:58
10/10/12 08:58
Joined: Feb 2010
Posts: 320
TANA/Madagascar
3dgs_snake Offline OP
Senior Member
3dgs_snake  Offline OP
Senior Member

Joined: Feb 2010
Posts: 320
TANA/Madagascar
Hi,

It is an old thread, I know ( tongue ), but some days ago someone asked me about an example using the plugin (2.5D with WED created level), so I will post here some (I hope ...) usefull links :




The first link points to a simple (not verry useful) platformer with all the files I used to create it. The sample uses a 3d level created in wed. For this kind of setup, you need 2 types of representations for your model (3D representation created in wed and a 2D representation to be used in box2D). My workflow was the following :

  • Created a level in WED (The details for the collisions)
  • Save the level grin
  • Export the level to MDL
  • Export the MDL to 3ds using MED
  • Open the 3ds with blender
  • Created a plane at the position you want your player to move (For a 2D outline)
  • Created the outline using the boolean modifier
  • Exported the model to 3ds
  • Reimporrt the outline into MED (to be loadable in 3DGS - You can also load a 3ds but have not tried)
  • Used the outline to create collision data (with ent_buffers)
  • Load the level and create collision data
  • Create player and colision data
  • ...


The second link points to a Box2D tutorial. The plugin is more like a wrapper than a real plugin (But you can create some superset functions based on your needs (PANEL, ENTITY or draw_) so it is quite easy to translate any Box2D application from other languages (Flash, C++) to Lite-C.

Hope that was useful.

Page 2 of 3 1 2 3

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1