Skip to content

Commit

Permalink
v2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Rado-1 committed Jun 27, 2015
1 parent 1c43509 commit a284a75
Show file tree
Hide file tree
Showing 10 changed files with 415 additions and 348 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ as an external library.
ZgeBullet is free for commercial use and open source under the [Zlib License](http://opensource.org/licenses/Zlib).

Links:
* Download compiled versions of the library and demo projects from [here](http://googledrive.com/host/0BxwfQ8la88ouQTVuLWJfY1dMVGs/).
* Download compiled versions of the library and demo projects from [here](https://github.com/Rado-1/ZgeBullet/releases).
[//]: # (\if LOCAL_DOC)
* For more information about how to build ZgeBullet Library see this [page](../../wiki/How-to-Build).
* Latest changes are listed in [version history](../../wiki/Version-History).
Expand Down
188 changes: 41 additions & 147 deletions demos/demo1/PhysicsDemo1.zgeproj
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1" ?>
<ZApplication Name="App" Comment="ZgeBullet demo #1. Created by Rado1" Caption="Physics Demo 1" FrameRateStyle="1" ScreenMode="0" CameraPosition="-17.179 10 57.4881" CameraRotation="0 0.0462 0" ViewportRatio="3" ClipFar="800" MouseVisible="255" NoSound="1" AndroidPackageName="com.rado1.PhysicsDemo1">
<ZApplication Name="App" Comment="ZgeBullet demo #1. Created by Rado1" Caption="Physics Demo 1" FrameRateStyle="1" ScreenMode="0" CameraPosition="38.8761 10 45.7017" CameraRotation="0 0.8878 0" ViewportRatio="3" ClipFar="800" MouseVisible="255" NoSound="1" FileVersion="2" AndroidPackageName="com.rado1.PhysicsDemo1">
<OnLoaded>
<ZExternalLibrary Comment="Bullet 3D physics" ModuleName="ZgeBullet" CallingConvention="1" BeforeInitExp="if(ANDROID) this.ModuleName = &quot;./libZgeBullet.so&quot;;">
<Source>
Expand All @@ -11,11 +11,11 @@
https://github.com/Rado-1/ZgeBullet
Download Windows DLL and Android shared library from
http://googledrive.com/host/0BxwfQ8la88ouQTVuLWJfY1dMVGs/
https://github.com/Rado-1/ZgeBullet/releases
Copyright (c) 2012-2015 Radovan Cervenka
Version: 2.0 (2015-06-08)
Version: 2.1 (2015-06-27)
*/
Expand Down Expand Up @@ -63,15 +63,19 @@ const int ZBT_CF_KINEMATIC_OBJECT= 2;
const int ZBT_CF_NO_CONTACT_RESPONSE = 4;
const int ZBT_CF_CUSTOM_MATERIAL_CALLBACK = 8;
const int ZBT_CF_CHARACTER_OBJECT = 16;
//const int ZBT_CF_DISABLE_VISUALIZE_OBJECT = 32;
const int ZBT_CF_DISABLE_SPU_COLLISION_PROCESSING = 64;
// Functions
void zbtCreateWorld() {}
void zbtDestroyWorld() {}
// World
xptr zbtCreateWorld() {}
void zbtDestroyWorld(xptr world) {}
void zbtSetCurrentWorld(xptr world) {}
void zbtSetWorldGravity(float x, float y, float z) {}
Expand Down Expand Up @@ -293,6 +297,8 @@ void zbtSetGeneric6DofSpring(xptr spring,
int axis, int bEnableSpring, float stiffness, float damping,
float equilibriumPoint) {}
void zbtSetEnabled(xptr constraint, int bEnabled) {}
void zbtDeleteConstraint(xptr constraint) {}
Expand Down Expand Up @@ -427,21 +433,31 @@ void zbtGetPositionXYZ(xptr obj,
void zbtGetPosition(xptr obj, xptr outPosition) {}
void zbtSetPosition(xptr obj, float x, float y, float z) {}
void zbtSetPositionXYZ(xptr obj, float x, float y, float z) {}
void zbtSetPosition(xptr obj, xptr position) {}
void zbtGetRotationXYZ(xptr obj,
ref float outRx, ref float outRy, ref float outRz) {}
void zbtGetRotation(xptr obj, xptr outRotation) {}
void zbtSetRotation(xptr obj, float rx, float ry, float rz) {}
void zbtSetRotationXYZ(xptr obj, float rx, float ry, float rz) {}
void zbtSetRotation(xptr obj, xptr rotation) {}
void zbtGetPosRotXYZ(xptr obj,
ref float outX, ref float outY, ref float outZ,
ref float outRx, ref float outRy, ref float outRz) {}
void zbtGetPosRot(xptr obj, xptr outPosition, xptr outRotation) {}
void zbtSetPosRotXYZ(xptr obj,
float x, float y, float z,
float rx, float ry, float rz) {}
void zbtSetPosRot(xptr obj, xptr position, xptr rotation) {}
void zbtSetCollisionFlags(xptr obj, int flags) {}
int zbtIsActive(xptr obj) {}
Expand Down Expand Up @@ -531,6 +547,7 @@ const int SCALABLE_SPHERE_SHAPE = 12;
// VARIABLES
xptr World;
int Scene;
int IsClicked;
int WasClicked;
Expand Down Expand Up @@ -578,7 +595,8 @@ xptr createCollisionShape(int type){
setRandomSeed(getSystemTime());
// init physical world
zbtCreateWorld();
World = zbtCreateWorld();
zbtSetCurrentWorld(World);
zbtSetWorldGravity(0, -10, 0);
// init collision shapes
Expand All @@ -589,10 +607,10 @@ for(int i = 0; i < NUMBER_OF_SHAPES; ++i)
// worse performance for many objects
//xptr sh = zbtCreateStaticPlaneShape(0,1,0,0);
//xptr rb = zbtCreateRigidBodyXYZ(0, sh, 0, 0, 0, 0, 0, 0);
// use the following instead:
xptr sh = zbtCreateBoxShape(200,1,200);
xptr rb = zbtCreateRigidBodyXYZ(0, sh, 0, -1, 0, 0, 0, 0);
zbtSetFriction(rb, 1.0);
// init scene
Scene = -1;
Expand Down Expand Up @@ -680,7 +698,7 @@ switch(Scene){
// set commmon properties
ObjectType = DOMINO_SHAPE;
ObjectMass = 0.1;
ObjectMass = 0.5;
ObjectActivationState = TRUE;
ObjectLinearDamping = ObjectAngularDamping = 0;
ObjectPosition = vector3(x, 2.1, z - 1.5);
Expand Down Expand Up @@ -794,7 +812,7 @@ switch(Scene){
// main 2nd-level beams
ObjectType = CUBE4_SHAPE;
ObjectColor = vector3(1, 0.2, 1);
ObjectRotation.Y = ROT90;
ObjectRotation.X = ROT90;
// 1st
ObjectPosition = vector3(1, 7, 0);
createModel(ObjectModel);
Expand Down Expand Up @@ -934,7 +952,7 @@ switch(Scene){
case 3: // build tower
ObjectType = CUBE1_SHAPE;
ObjectMass = 0.5;
ObjectMass = 0.1;
ObjectActivationState = TRUE;
ObjectLinearDamping = ObjectAngularDamping = DEFAULT_DAMPING;
ObjectRotation.X = 0;
Expand All @@ -948,7 +966,7 @@ switch(Scene){
ObjectPosition = vector3(
cos(j*PIx2 + i*PI2) * 5,
i * 2.01 + 30,
i * 2.0 + 40,
sin(j*PIx2 + i*PI2) * 5);
ObjectRotation.Y = atan2(ObjectPosition.X, ObjectPosition.Z) / PIx2;
Expand Down Expand Up @@ -1002,7 +1020,7 @@ if(shooting){
<RenderText Comment="FPS" TextFloatRef="App.FpsCounter" X="-0.97" Y="0.9" Scale="0.5" Align="1"/>
</OnRender>
<OnClose>
<ZExpression Comment="Destroy physical world" Expression="zbtDestroyWorld();"/>
<ZExpression Comment="Destroy physical world" Expression="zbtDestroyWorld(World);"/>
</OnClose>
<Lights>
<Light Position="50 50 50" Color="1 1 0 1" Kind="1"/>
Expand Down Expand Up @@ -1052,45 +1070,14 @@ v.Y = v.Y < 0 ? -1 : 1;
n.X = v.X;
n.Y = v.Y;
n.Z = v.Z;
/*//
float E, A, C, X, Y, Z;
// Convert range to radians
E = v.Y*PI; // Elevation
A = v.X*PI; // Azimuth
// Convert spherical coordinates into cartesian
C = cos(E);
X = sin(A)*C;
Y = sin(E);
Z = cos(A)*C;
// Assign coordinates
v.X = X;
v.Y = Y;
v.Z = Z;
v.Y = v.Y > 0 ? 1 : -1;
n.X = X;
n.Y = Y;
n.Z = Z;
*/]]>
n.Z = v.Z;]]>
</Expression>
</MeshExpression>
</Producers>
</Mesh>
<Mesh Name="Cylinder2Mesh">
<Producers>
<MeshBox Scale="1 0.5 1" XCount="18" YCount="2" Grid2DOnly="255"/>
<MeshBox Scale="1 0.5 1" XCount="10" YCount="2" Grid2DOnly="255"/>
<MeshExpression Scale="1 2 1" AutoNormals="0">
<Expression>
<![CDATA[float k;
Expand All @@ -1107,38 +1094,7 @@ v.Y = v.Y < 0 ? -1 : 1;
n.X = v.X;
n.Y = v.Y;
n.Z = v.Z;
/*//
float E, A, C, X, Y, Z;
// Convert range to radians
E = v.Y*PI; // Elevation
A = v.X*PI; // Azimuth
// Convert spherical coordinates into cartesian
C = cos(E);
X = sin(A)*C;
Y = sin(E);
Z = cos(A)*C;
// Assign coordinates
v.X = X;
v.Y = Y;
v.Z = Z;
v.Y = v.Y > 0 ? 1 : -1;
n.X = X;
n.Y = Y;
n.Z = Z;
*/]]>
n.Z = v.Z;]]>
</Expression>
</MeshExpression>
</Producers>
Expand All @@ -1162,38 +1118,7 @@ v.Y = v.Y < 0 ? -1 : 1;
n.X = v.X;
n.Y = v.Y;
n.Z = v.Z;
/*//
float E, A, C, X, Y, Z;
// Convert range to radians
E = v.Y*PI; // Elevation
A = v.X*PI; // Azimuth
// Convert spherical coordinates into cartesian
C = cos(E);
X = sin(A)*C;
Y = sin(E);
Z = cos(A)*C;
// Assign coordinates
v.X = X;
v.Y = Y;
v.Z = Z;
v.Y = v.Y > 0 ? 1 : -1;
n.X = X;
n.Y = Y;
n.Z = Z;
*/]]>
n.Z = v.Z;]]>
</Expression>
</MeshExpression>
</Producers>
Expand All @@ -1217,38 +1142,7 @@ v.Y = v.Y < 0 ? -1 : 1;
n.X = v.X;
n.Y = v.Y;
n.Z = v.Z;
/*//
float E, A, C, X, Y, Z;
// Convert range to radians
E = v.Y*PI; // Elevation
A = v.X*PI; // Azimuth
// Convert spherical coordinates into cartesian
C = cos(E);
X = sin(A)*C;
Y = sin(E);
Z = cos(A)*C;
// Assign coordinates
v.X = X;
v.Y = Y;
v.Z = Z;
v.Y = v.Y > 0 ? 1 : -1;
n.X = X;
n.Y = Y;
n.Z = Z;
*/]]>
n.Z = v.Z;]]>
</Expression>
</MeshExpression>
</Producers>
Expand Down Expand Up @@ -1310,7 +1204,7 @@ n.Z = v.Z;
<Group Comment="Bitmaps and Materials">
<Children>
<Material Name="ObjectMaterial" WireframeWidth="0" SpecularColor="0 0 0 1" EmissionColor="0 0 0 1" Blend="1"/>
<Bitmap Name="GroundBitmap">
<Bitmap Name="GroundBitmap" Width="16" Height="16">
<Producers>
<BitmapExpression UseBlankSource="1" Expression="pixel = x &gt; 0.98 || y &gt; 0.98 ? 1 : 0;"/>
</Producers>
Expand All @@ -1320,7 +1214,7 @@ n.Z = v.Z;
<MaterialTexture Texture="GroundBitmap" TextureScale="10 10 1" TextureWrapMode="1" TexCoords="1"/>
</Textures>
</Material>
<Bitmap Name="SkyBitmap" Width="0" Height="3" Filter="2">
<Bitmap Name="SkyBitmap" Width="16" Height="128" Filter="2">
<Producers>
<BitmapFromFile Comment="Imported from sky.png" DataWidth="16" DataHeight="128">
<BitmapFile>
Expand All @@ -1334,7 +1228,7 @@ n.Z = v.Z;
<MaterialTexture Texture="SkyBitmap" TextureScale="1 1 0" TextureY="0.05" TexCoords="1" Origin="0 0 0"/>
</Textures>
</Material>
<Bitmap Name="DigitsBitmap" Width="3" Height="0">
<Bitmap Name="DigitsBitmap" Width="128" Height="16">
<Producers>
<BitmapFromFile Comment="Imported from Digits.bmp" Transparency="1" DataWidth="128" DataHeight="16">
<BitmapFile>
Expand Down
Loading

0 comments on commit a284a75

Please sign in to comment.