I am currently trying to create various sound effects for the Truck Game.
It turns out its quite hard.
I have resorted to finding some sound effect libraries but I have also found a few very useful tools
http://thirdcog.eu/apps/cfxr
cfxr can generate random sounds that you can modify.
I have been finishing them off by using audacity.
http://audacity.sourceforge.net
Two great tools.
Saturday, 27 October 2012
Thursday, 13 September 2012
IPhone 5 Crazy
I've written very little recently due to being busy at work, but I just felt I had to say.
IPhone 5, yes thats crazy!!!
http://www.apple.com/iphone/specs.html
IPhone 5, yes thats crazy!!!
http://www.apple.com/iphone/specs.html
Wednesday, 15 August 2012
QT - Installation Tip - Can't start process install_name_tool
You may receive the following error when installing QT on the mac.
Can't start process install_name_tool
A simple fix can be found by
- > Opening up Xcode
- > Preferences
- > Click install on command line tools
Now try re-installing QT.
Hope it helps.
Duncan.
Tuesday, 14 August 2012
Quick Batch Image resizing tip
Today I had quite a few photos to resize, but I really didn't want to have to do them manually.
After a bit of googling I found out that as normal the mac has some great utilities built in.
sips --resampleWidth 1500 *
Will resample all the pictures in your directory to have a maximum width of 1500 pixels.
You can choose an output directory, or I would just backup your images first just incase you want the originals.
The images end up with a reasonable file size to.
Sips can do all sorts of other thing to like converting file formats.
After a bit of googling I found out that as normal the mac has some great utilities built in.
sips --resampleWidth 1500 *
Will resample all the pictures in your directory to have a maximum width of 1500 pixels.
You can choose an output directory, or I would just backup your images first just incase you want the originals.
The images end up with a reasonable file size to.
Sips can do all sorts of other thing to like converting file formats.
Friday, 10 August 2012
IOS Sound Conversion - Sound Effects - Audacity - afconvert
I'm currently in the process of creating some sound effects for my latest game.
I have been chopping them up in Audacity and saving them as wav files.
Being a little lazy I want a simple way of converting them into a format that runs well on the IOS devices.
So after saving my sound effects as .wav files.
I open up a terminal and change to the directory where your sound effects are located.
Then run the following command
afconvert -c 1 -b 32768 -d LEI16@11025 -f 'caff' TruckStart.wav TruckStart.caf
This will cut a 330KB wav file down to around 45KB.
-b is the bitrate
-d is the the little-endian integer 16-bit variant of linear PCM sound setting
the @11025 is the frequency range.
-c 1 converts the sound effect to single channel (mono)
And its converted to the caf format recommend by Apple.
Hope that is of some help.
Duncan.
Thursday, 9 August 2012
JewelBlast3D Puzzle Game - IPhone - IPad - Free Game
Quite some time ago I built a free game called JewelBlast3D
You can download it for free at
http://itunes.apple.com/us/app/jewelblast3d/id507150133?mt=8
I'm quite amazed as it is still regularly getting some downloads on the App store.
It has made me think about the type of games people like on mobile platforms.
When I first had a gameboy quite a few years ago, I used to play for hours on Tetris and when I would go to sleep my dad would pick up the gameboy and play for hours!
I don't think much has changed since the early days people still like a good puzzle game that they can play over and over again. In the end I would compete with my dad to get the highest score.
At some point I want to have a go at re-writting Jewel Blaster, hopefully I will get the time!
Duncan.
JewelBlast3D Free IPhone Game |
http://itunes.apple.com/us/app/jewelblast3d/id507150133?mt=8
I'm quite amazed as it is still regularly getting some downloads on the App store.
It has made me think about the type of games people like on mobile platforms.
When I first had a gameboy quite a few years ago, I used to play for hours on Tetris and when I would go to sleep my dad would pick up the gameboy and play for hours!
I don't think much has changed since the early days people still like a good puzzle game that they can play over and over again. In the end I would compete with my dad to get the highest score.
At some point I want to have a go at re-writting Jewel Blaster, hopefully I will get the time!
Duncan.
Wednesday, 1 August 2012
Cocos3d, Explosions in Monster Truck Trials
When a coin is collected initially we initially had a simple fade out. This was to boring.
I hope its of some use.
Duncan.
How would we create an explosion in cocos3d? One concept would be to create clones of the original object and fire them off in various directions.
As we have the physics engine available, the following process was chosen.
- Spawn 10 new copies of the current one.
- Create a collision mask so that only explosion object can influence each other.
- Randomly change thier direction.
- Apply a little impulse.
- Create a fade out event that on completion removes the objects from the 3d and physics worlds.
The impulse alone would not be enough to make the objects go all over the place but as they are being spawned in the same locations the physics engine will make them react with each other as long as they have the same collision mask.
And here is the code.
float previous = node.rotation.y;
for (int x = 0; x < 10; x++) {
int random = [Helper getRandomNumberBetweenMin:1 andMax:10];
CC3MeshNode* newCoin = [node copyAutoreleased];
newCoin.uniformScale = 0.05 * random;
newCoin.location = node.location;
newCoin.quaternion = node.quaternion;
[_activeWorld addChild:newCoin];
[newCoin rotateBy:cc3v( previous + (80 * random), previous + (80 * random), previous + (20 * random))];
previous = newCoin.rotation.y;
CC3PhysicsObject3D* explosionObject = [_physicsWorld createMyPhysicsObject:newCoin shape:boxShape2 mass:100 restitution:0.1 position:newCoin.location isStatic: NO : COL_PARTICLE : COL_PARTICLE];
explosionObject.rigidBody->applyCentralImpulse(btVector3(5,5,0));
CCFadeOut* fadeOut2 = [CCFadeOut actionWithDuration: random * 0.2];
CCSequence *seq = [CCSequence actions:fadeOut2, [CCCallFuncN actionWithTarget:explosionObject selector:@selector(remove)], nil];
[explosionObject.node runAction:seq];
}
Duncan.
Sunday, 29 July 2012
Monster Truck Trials - IPhone / Ipad Game - Adobe Premier - Preview
So apparently it is a good idea to do some pre-launch media, well how do you do that?
One first step in the right direction would be to get a video trailer together.
I have created the following trailer for my new game "Monster Truck Trials" (Working title)
I used a program called reflection to record the in game scenes from my IPad.
I created some basic rendered graphics using blender.
Then using adobe premier I pinned it all together.
I'm not a music composer but it is important to make sure that any music you use is licensed, this is the same for any external media you use in your production.
I have found that http://luckylionstudios.com provide some great backing tracks!
Friday, 27 July 2012
Mountain Lion - Quick Review.
How exciting a new release of the Mac OS.
After a 4 GB download which took me over a day on normal broadband speeds in west wales, the installation started, it lied to me a few times at first it stated there was 30 minutes to go, then eventually 4 minutes, then back up to 30 minutes, I'm not sure if I misread something but overall it defiantly took a good hour.
Now to restart my mac..... well it worked, otherwise I would no doubt of started this post with "Mountain Lion Wrecked My Mac" which it didn't it went nice and smoothly.
Things I like so far.
After a 4 GB download which took me over a day on normal broadband speeds in west wales, the installation started, it lied to me a few times at first it stated there was 30 minutes to go, then eventually 4 minutes, then back up to 30 minutes, I'm not sure if I misread something but overall it defiantly took a good hour.
Now to restart my mac..... well it worked, otherwise I would no doubt of started this post with "Mountain Lion Wrecked My Mac" which it didn't it went nice and smoothly.
Things I like so far.
- I can now get to the top of my mail quickly by clicking the sort bar
- The notifications are handy
- Safari, seems more responses, it used to hang a lot with the timer icon, this seems to of stopped.
- Performance, its hard to tell it seem similar but I did get a lot of hanging before with lots of applications open, maybe this will improve.
Moans
- It does feel like a service pack that I just had to pay £13.99 for not a new operating system.
- I seem to have to re-install or update a lot of things, x-code has to be upgraded to the latest version, another 1.5GB download, also x11 needs re-installing.
Overall.
I think it was worth the upgrade and I'm sure I will find some new toys to play with.
Make sure you have plenty of time to download everything and make the installations.
Make sure you have plenty of time to download everything and make the installations.
Tuesday, 24 July 2012
Bullet Physics - Cocos3d - Collisions using contact-added callback and masks
Within my current game I want my truck to be able to come into contact with a power up.
When this happens I don't want it to influence the truck, just register the impact.
There is quite a straight forward way of dealing with collisions using bullet and this is using the contact added callback.
You will need to create one method that handles what happens when a collision occurs and then set a bullet variable to be equal to this method.
Then all you will have to do is register each object that uses the callback for collisions.
Create a function with the following signature
When this happens I don't want it to influence the truck, just register the impact.
There is quite a straight forward way of dealing with collisions using bullet and this is using the contact added callback.
You will need to create one method that handles what happens when a collision occurs and then set a bullet variable to be equal to this method.
Then all you will have to do is register each object that uses the callback for collisions.
Create a function with the following signature
bool contact_callback( btManifoldPoint &btmanifoldpoint,
const btCollisionObject *btcollisionobject0,
int part_0, int index_0,
const btCollisionObject *btcollisionobject1,
int part_1, int index_1 )
Within this method you will be returned a pair of objects that have collided, it is up to you what you do with them.
I use the
rigidBody->setUserPointer(physicsObject);
method of the rigidBody to set a pointer to my own object.
This allows me to cast the pointer from the collisions to my own objects.
CC3PhysicsObject3D *phyObject0 = ( CC3PhysicsObject3D * )( ( btRigidBody * )btcollisionobject0 )->getUserPointer();
Note even if you remove an object that comes into contact immediatly from your physics world it will still call this call back a few times, I have an isBeingRemoved property on my own object which I set as a further check.
Then all you have to do is register your callback with the world
gContactAddedCallback = contact_callback;
I do this at the bottom of my world initialisation code.
Finally I register any rigid bodies that you want to call this callback method when a collision has occurred.
pObject.rigidBody->setCollisionFlags(pObject.rigidBody->getCollisionFlags() | btRigidBody::CF_NO_CONTACT_RESPONSE |btCollisionObject::CF_CUSTOM_MATERIAL_CALLBACK );
Here pObject is my physics. I use two flags here
btRigidBody::CF_NO_CONTACT_RESPONSE
Which register the rigid body as not having an affect on the physics world
and
btCollisionObject::CF_CUSTOM_MATERIAL_CALLBACK
Which registers the object to call the gContactAddedCallback related call back function.
I hope the above is of some help!
Duncan.
Monday, 23 July 2012
Custom motion states - btMotionState - Bullet Physics
Instead of having one main loop where the rendering of world objects are performed, it makes sense to use Bullets motion states. Instead of updating the position of all your objects with each render loop, you can use bullet to only update objects that have moved!
What do you need to do?
Well you will need to create your own motion state.
Within Xcode create yourself a c++ header.
Rename it to .hpp
This will allow you to have a mixture of c++ and Objective-C code.
When my class is only going to be small I have written my entire class within the header file, this is no doubt bad practice but for small classes I find it easier to manage.
Remember an Objective-C class cannot inherit a C++ class, but you can write a C++ class with Objective-C code.
So I create my class which inherits btMotionState.
What do you need to do?
Well you will need to create your own motion state.
Within Xcode create yourself a c++ header.
Rename it to .hpp
This will allow you to have a mixture of c++ and Objective-C code.
When my class is only going to be small I have written my entire class within the header file, this is no doubt bad practice but for small classes I find it easier to manage.
Remember an Objective-C class cannot inherit a C++ class, but you can write a C++ class with Objective-C code.
So I create my class which inherits btMotionState.
class MyMotionState : public btMotionState {
Now within my class I have the code which updates my cocos3d node.
virtual void setWorldTransform(const btTransform &worldTrans) {
if(NULL == mVisibleobj)
return;
btQuaternion rot = worldTrans.getRotation();
mVisibleobj.quaternion = CC3Vector4Make(rot.getX(), rot.getY(), rot.getZ(), -rot.getW());
btVector3 pos = worldTrans.getOrigin();
mVisibleobj.location = CC3VectorMake(pos.getX(), pos.getY(), pos.getZ());;
}
It's that simple.
On creation of an instance of this motion state make sure you can set a reference to your CC3Node.
MyMotionState(const btTransform &initialpos, CC3Node *node) {
mVisibleobj = node;
mPos1 = initialpos;
}
Now use your new motion state instead of the default one.
Duncan.
Wednesday, 18 July 2012
Bullet to Cocos3d - btQuaternion to CC3Vector4
Oh, how I feel silly, I discovered that my quaternion definition is wrong.
The previous post is a bit of a waste now as all you need to set is the following
-btq.getW()
One silly
Duncan.
The previous post is a bit of a waste now as all you need to set is the following
btQuaternion btq = transform.getRotation();
CC3Vector4 quaternion = CC3Vector4Make(btq.getX(), btq.getY(), btq.getZ(), -btq.getW());
Notice the
-btq.getW()
One silly
Duncan.
Thursday, 12 July 2012
Bullet physics btRaycastVehicle + Cocos3D
My long term goal is to make some form of truck game. I'm not 100% sure what the game objectives will be, but I do know that it will be in 3D and will require simulated physics.
As a little example of what I have accomplished so far(very basic) I have recorded the following video.
Now that I have got Cocos3D up and running with Bullet physics, I thought the first step would be to try and implement some of their examples.
This is where the ray cast vehicle came into play.
I have had to make some alterations to the btRaycastVehicle library to get it up and running.
I could not for the live of me get the steering rotation to render correctly within cocos3d.
So I stripped out the steering rotation from within bullet and now do this within my cocos3d app.
In
void btRaycastVehicle::updateWheelTransform( int wheelIndex , bool interpolatedTransform)
I have changed
wheel.m_worldTransform.setBasis(steeringMat * rotatingMat * basis2);
to
Now within my cocos3d application I have a wheel node that renders the position and steering angle of the physics wheel and a child node that is actually the tyre.
I rotate the tyre node manually from my wheels rotation information
tyre.rotation = cc3v(-1 * (wheelInf.m_rotation * (180/3.142)),0,0);
As a little example of what I have accomplished so far(very basic) I have recorded the following video.
Now that I have got Cocos3D up and running with Bullet physics, I thought the first step would be to try and implement some of their examples.
This is where the ray cast vehicle came into play.
I have had to make some alterations to the btRaycastVehicle library to get it up and running.
I could not for the live of me get the steering rotation to render correctly within cocos3d.
So I stripped out the steering rotation from within bullet and now do this within my cocos3d app.
In
void btRaycastVehicle::updateWheelTransform( int wheelIndex , bool interpolatedTransform)
I have changed
wheel.m_worldTransform.setBasis(steeringMat * rotatingMat * basis2);
to
wheel.m_worldTransform.setBasis(steeringMat * btMatrix3x3(m_chassisBody->getOrientation()));
Now within my cocos3d application I have a wheel node that renders the position and steering angle of the physics wheel and a child node that is actually the tyre.
I rotate the tyre node manually from my wheels rotation information
tyre.rotation = cc3v(-1 * (wheelInf.m_rotation * (180/3.142)),0,0);
The above converts the m_rotation in radians to the degrees required for cocos3d rotation.
Unfortunatly after all this it has shown to me that a raycast vehicle doesn't really work for trucks moving over terrain, so I will now need to construct one from scratch! Lets see what happens....
Duncan.
Wednesday, 11 July 2012
Create a Bullet Physics library for IOS, iPhone, IPad, Xcode
This is a rough run down, on how I get the Bullet Physics library working within my applications.
First of all I find out what is the latest stable build by going to
http://code.google.com/p/bullet/downloads/list
At current it is
Bullet 2.80 Physics SDK SP1 (svn r2531)
Don't download this library we will get hold of it by SVN.
This gives me the current revision number
I then create a directory where I would like to build the libraries.
from the terminal I go to my main build directory and create a new one for my bullet library
mkdir ./Bullet2.8-2531
I now use a build script written by Hoon Hwangbo
cd ./Bullet2.8
git clone git@github.com:Eonil/Bullet-PhysicsEngine-BuildScript-iOS.git
Now you need to update the build script to use the latest revision.
vi ./Bullet-PhysicsEngine-BuildScript-iOS/Script/BuildAll.sh
Find the line that reads
svn checkout http://bullet.googlecode.com/svn/trunk/ -r 2440 ./Source
and replace 2440 ( the revision number when the script was written) with 2531 (the current revision number)
save your file and exit vi (or whatever program you are using)
Now compile your library
sh ./Bullet-PhysicsEngine-BuildScript-iOS/Script/BuildAll.sh ./Build
Now I create a new project in Xcode ( I generally use a cocos3d template)
Now click on your target and goto "Linked Frameworks and Libraries"
Click + then add other, navigate to your compiled libraries directories and add the libraries you require, as a guide go for
So I go to my target, click on build settings and locate "User Header Search Paths"
I then add the path to my Package directory.
Now all I have to do within my code is import the header as follows
**Note at current this only works on the device, I have managed to get this working not he simulator, but need to simplify it before adding the instructions.
First of all I find out what is the latest stable build by going to
http://code.google.com/p/bullet/downloads/list
At current it is
Bullet 2.80 Physics SDK SP1 (svn r2531)
Don't download this library we will get hold of it by SVN.
This gives me the current revision number
I then create a directory where I would like to build the libraries.
from the terminal I go to my main build directory and create a new one for my bullet library
mkdir ./Bullet2.8-2531
I now use a build script written by Hoon Hwangbo
cd ./Bullet2.8
git clone git@github.com:Eonil/Bullet-PhysicsEngine-BuildScript-iOS.git
Now you need to update the build script to use the latest revision.
vi ./Bullet-PhysicsEngine-BuildScript-iOS/Script/BuildAll.sh
Find the line that reads
svn checkout http://bullet.googlecode.com/svn/trunk/ -r 2440 ./Source
and replace 2440 ( the revision number when the script was written) with 2531 (the current revision number)
save your file and exit vi (or whatever program you are using)
Now compile your library
sh ./Bullet-PhysicsEngine-BuildScript-iOS/Script/BuildAll.sh ./Build
Now I create a new project in Xcode ( I generally use a cocos3d template)
Now click on your target and goto "Linked Frameworks and Libraries"
Click + then add other, navigate to your compiled libraries directories and add the libraries you require, as a guide go for
- libBulletCollision.a
- libBulletDynamics.a
- libBulletMultiThreaded.a
- libBulletSoftBody.a
- libLinearMath.a
- libMiniCL.a
This does seem to manually add your directory settings to your build configuration but I still add my main directory (probably not needed)
So I go to my target, click on build settings and locate "User Header Search Paths"
I then add the path to my Package directory.
Now all I have to do within my code is import the header as follows
#import "btBulletCollisionCommon.h"
Finally rename your .m files that include the header to .mm to allow for the inclusion of external c++ code.
You should now be able to build your project.
You should now be able to build your project.
I hope this was of some help.
**Note at current this only works on the device, I have managed to get this working not he simulator, but need to simplify it before adding the instructions.
Duncan.
Monday, 9 July 2012
Bullet Physics, Cocos3d, Debug Drawer - setDebugDrawer
I have recently managed to get the Bullet Physics debug drawer working within cocos3d.
To implement this I have created a C++ class that has access to singleton class which in turn can draw on my 3d scene.
My class inherits btIDebugDraw
class debugDrawer : public btIDebugDraw
Within
To implement this I have created a C++ class that has access to singleton class which in turn can draw on my 3d scene.
My class inherits btIDebugDraw
class debugDrawer : public btIDebugDraw
Within
debugDrawer::drawLine(const btVector3& from,const btVector3& to,const btVector3& color)
{
RuleSet *rule = [General SharedGeneral].RuleSet;
[rule debugLine:from.x() y:from.y() z:from.z() :to.x() dy:to.y() dz:to.z()];
}
Within my shared class I have my line drawing code
-(void) debugLine :(float)x y:(float)y z:(float) z:(float)dx dy:(float)dy dz:(float) dz {
float arr_location[] = {x,y,z, dx,dy, dz };
CC3LineNode* lineNode = [CC3LineNode nodeWithName: @"Line test"];
[lineNode populateAsLineStripWith: 2
vertices: arr_location
andRetain: YES];
lineNode.color = ccGREEN;
[_lines addObject:lineNode];
[_activeWorld addChild:lineNode];
//Thanks Bill :-)
}
I referenced my shared object which allows me to draw lines in my 3d world.
When I initialise my 3d world I attach my debugDrawer
debugDrawer *debug;
debug = new debugDrawer;
dynamicsWorld->setDebugDrawer(debug);
At the end of every synchronisation of my physics world I call my debugDrawer
_discreteDynamicsWorld->debugDrawWorld(); // This is the internal name of the class
Before calling each synchronisation on my physics world I call a debugStart session,
this removes all my previous lines from the scene, if you want pretty patterns don't bother with the following :-)
[general.RuleSet debugStart];
Within my shared class I have
-(void) debugStart {
for (CC3LineNode* lineNode in _lines) {
[_activeWorld removeChild:lineNode];
}
[_lines removeAllObjects];
}
Now I can see if my physics objects are being rendered correctly.
This only implements line drawing there are other methods within btIDebugDraw
that you could implement for further functionality.
All the best.
Duncan.
Drawing a line in Cocos3D
I'm currently working on a debug drawer for Bullet Physics.
To get this up and running I need to be able to draw some lines within cocos3d.
I almost figured it out, but in the end Bill directed me in the right direction.
float arr_location[] = {0.0,0.0,0.0, 5,5, 5 };
CC3LineNode* lineNode = [CC3LineNode nodeWithName: @"Line test"];
[lineNode populateAsLineStripWith: 2
vertices: arr_location
andRetain: YES];
lineNode.color = ccGREEN;
[self addChild:lineNode];
Populate arr_location with your way points for the line and add the node to your scene.
The plans I have for my debug drawer will be to record all lines added to the scene so I can remove them on the next debug draw and replace them with the new lines.
Tuesday, 26 June 2012
Gem Catcher - Free IPhone / IPad Gem Puzzle Game
Ok, here is my latest game, made using cocos3d and bullet physics.
I have made a few mistakes with the release cycle for this game, which has been a bit annoying.
The lessons that I have learnt are.
- Make sure that you have enabled the iAd network
- Make sure that you have added a restore option to the game
- Release the game on a Friday evening
Due to the above little mistakes I'm unsure how well this game will fair, but we will see, it has mainly been a learning curve with using the Bullet Physics engine within an IOS app.
There was some teething troubles but I got there in the end and it is now available to use in any forth coming productions.
Get your free copy now....
Friday, 15 June 2012
IOS + Arduino + Cocos3d
Exploring the capabilities of the IOS devices is a passion of mine!
Even though the IPhone/IPad has many internal sensors, it does have its limitations, can it tell me how warm it is? NO, Can it give me an accurate reading of how far away an object is? NO.
Thats a shame, well fortunately it is possible to integrate an IOS device with an external device.
In my test environment I have successfully connected an app to an Arduino micro controller, in turn I have connected this to an ultrasonic sensor,
Remember this sensor could be any sensor! and there are no limitations to what you decide to do with the data when it reaches the IOS device.
In my example I have used cocos3d to display a cube on screen, when the application receives distance data from the micro controller it updates the cubes position.
But the sensors information could be rendered on a graph, or even transmitted over the internet a an external server.
Just to give you an idea of what is possible have a look at the following video!
Subscribe to:
Posts (Atom)