Thanks it works . Now how would I get a cilinder as a collisionshape ?zerochen wrote:hi,
bullet obj deactivate after a few seconds so you must active them explicit or disable the deactivation
egCode: Select all
body->setActivationState(EAS_DISABLE_DEACTIVATION)
Raycasting with Irrbullet
Re: Raycasting with Irrbullet
Re: Raycasting with Irrbullet
it is not so hard to implement one yourself
here is a example of my createShape function (note: functionnames dont match to irrBullet)
here is a example of my createShape function (note: functionnames dont match to irrBullet)
Code: Select all
void CCylinderShape::createShape()
{
node->updateAbsolutePosition();
const core::vector3df& extent = node->getBoundingBox().getExtent();
shape = new btCylinderShape(irrlichtToBulletVector(extent * 0.5));
shape->setLocalScaling(irrlichtToBulletVector(node->getScale()));
calculateLocalInertia(mass, core::vector3df(0.0f,0.0f,0.0f));
}
Re: Raycasting with Irrbullet
Im not quite sure how to implement this. Could you maybe point me in the right direction ?
Also is there a function in irrbullet to lock rotations on certain axis?
Also is there a function in irrbullet to lock rotations on certain axis?
Re: Raycasting with Irrbullet
have a look at boxshape.h/.cpp
you have to to copy these files, rename it and replace the createShape function.
allow Y rotation:
you have to to copy these files, rename it and replace the createShape function.
allow Y rotation:
Code: Select all
rigidBody->setAngularFactor(vector3df(0,1,0));
Re: Raycasting with Irrbullet
Mhmm I get these errors:
With
cylindershape.cpp
and cylindershape.h
And I call it like this:
When I replace CCylinderShape with IBoxShape it compiles and works but as a box shape ofcourse.
And it now only rotates around the y axis but how can I set the pivot point?
Code: Select all
C:\Users\Person\Documents\Irrlicht\irrlicht-1.7.2\examples\01.HelloWorld\main.cpp||In function 'int main()':|
C:\Users\Person\Documents\Irrlicht\irrlicht-1.7.2\examples\01.HelloWorld\main.cpp|54|error: expected type-specifier before 'CCylinderShape'|
C:\Users\Person\Documents\Irrlicht\irrlicht-1.7.2\examples\01.HelloWorld\main.cpp|54|error: cannot convert 'int*' to 'ICollisionShape*' in initialization|
C:\Users\Person\Documents\Irrlicht\irrlicht-1.7.2\examples\01.HelloWorld\main.cpp|54|error: expected ',' or ';' before 'CCylinderShape'|
||=== Build finished: 3 errors, 3 warnings ===|
cylindershape.cpp
Code: Select all
#include <ISceneNode.h>
#include "Bullet/btBulletDynamicsCommon.h"
#include "Bullet/btBulletCollisionCommon.h"
#include "cylindershape.h"
using namespace irr;
using namespace core;
using namespace scene;
CCylinderShape::CCylinderShape(ISceneNode* const n, f32 m, bool overrideMargin)
{
node = n;
mass = m;
type = ECST_BOX;
createShape(overrideMargin);
}
void CCylinderShape::createShape()
{
node->updateAbsolutePosition();
const vector3df& extent = node->getBoundingBox().getExtent();
shape = new btCylinderShape(irrlichtToBulletVector(extent * 0.5));
setLocalScaling(node->getScale(), ESP_COLLISIONSHAPE);
calculateLocalInertia(mass, vector3df(0.0f,0.0f,0.0f));
}
CCylinderShape::~CCylinderShape()
{
}
Code: Select all
// Copyright (C) 2009-2011 Josiah Hartzell (Skyreign Software)
// This file is part of the "irrBullet" Bullet physics extension library and wrapper.
// For conditions of distribution and use, see license in irrbullet.h
// The above copyright notice and its accompanying information must remain here.
#ifndef __CYLINDER_SHAPE_H_INCLUDED__
#define __CYLINDER_SHAPE_H_INCLUDED__
#include "collisionshape.h"
class CCylinderShape : public ICollisionShape
{
public:
CCylinderShape(irr::scene::ISceneNode* const n, irr::f32 m, bool overrideMargin = false);
virtual ~CCylinderShape();
protected:
void createShape(bool overrideMargin);
};
#endif // __CYLINDER_SHAPE_H_INCLUDED__
Code: Select all
ICollisionShape *playershape = new CCylinderShape(player, 1, false);
And it now only rotates around the y axis but how can I set the pivot point?
Re: Raycasting with Irrbullet
it looks good
only a few things to do:
- #include <BulletCollision/CollisionShapes/btCylinderShape.h> is missing in cylindershape.cpp
- delete bool overrideMargin from the constructor aswell from the createShape function call
- #include "CCylinderShape.h" in irrbullet.h
also after that you have to recompile the irrbullet.lib
Edit:
oh wait you dont have to delete overrideMargin instead add the parameter to the createShape function
only a few things to do:
- #include <BulletCollision/CollisionShapes/btCylinderShape.h> is missing in cylindershape.cpp
- delete bool overrideMargin from the constructor aswell from the createShape function call
- #include "CCylinderShape.h" in irrbullet.h
also after that you have to recompile the irrbullet.lib
Edit:
oh wait you dont have to delete overrideMargin instead add the parameter to the createShape function
Last edited by zerochen on Sun Jul 15, 2012 2:36 pm, edited 1 time in total.
Re: Raycasting with Irrbullet
It seems to compile fine but where do I find it. I use code::blocks does that matter?
Re: Raycasting with Irrbullet
i dont use code blocks so i cant tell you that.
if recompile works you might find the libs in <irrBullet>\lib folder
if recompile works you might find the libs in <irrBullet>\lib folder
Re: Raycasting with Irrbullet
I get the errors
||=== Irrlicht Example 01 Hello World, Windows ===|
C:\Users\Stijn\Documents\Irrlicht\irrBullet-0.1.8\source\irrBullet.h|51|warning: missing terminating " character|
C:\Users\Stijn\Documents\Irrlicht\irrBullet-0.1.8\source\irrBullet.h|51|error: #include expects "FILENAME" or <FILENAME>|
C:\Users\Stijn\Documents\Irrlicht\irrlicht-1.7.2\examples\01.HelloWorld\main.cpp||In function 'int main()':|
C:\Users\Stijn\Documents\Irrlicht\irrlicht-1.7.2\examples\01.HelloWorld\main.cpp|69|error: expected type-specifier before 'CCylinderShape'|
C:\Users\Stijn\Documents\Irrlicht\irrlicht-1.7.2\examples\01.HelloWorld\main.cpp|69|error: cannot convert 'int*' to 'ICollisionShape*' in initialization|
C:\Users\Stijn\Documents\Irrlicht\irrlicht-1.7.2\examples\01.HelloWorld\main.cpp|69|error: expected ',' or ';' before 'CCylinderShape'|
||=== Build finished: 4 errors, 4 warnings ===|
||=== Irrlicht Example 01 Hello World, Windows ===|
C:\Users\Stijn\Documents\Irrlicht\irrBullet-0.1.8\source\irrBullet.h|51|warning: missing terminating " character|
C:\Users\Stijn\Documents\Irrlicht\irrBullet-0.1.8\source\irrBullet.h|51|error: #include expects "FILENAME" or <FILENAME>|
C:\Users\Stijn\Documents\Irrlicht\irrlicht-1.7.2\examples\01.HelloWorld\main.cpp||In function 'int main()':|
C:\Users\Stijn\Documents\Irrlicht\irrlicht-1.7.2\examples\01.HelloWorld\main.cpp|69|error: expected type-specifier before 'CCylinderShape'|
C:\Users\Stijn\Documents\Irrlicht\irrlicht-1.7.2\examples\01.HelloWorld\main.cpp|69|error: cannot convert 'int*' to 'ICollisionShape*' in initialization|
C:\Users\Stijn\Documents\Irrlicht\irrlicht-1.7.2\examples\01.HelloWorld\main.cpp|69|error: expected ',' or ';' before 'CCylinderShape'|
||=== Build finished: 4 errors, 4 warnings ===|
Re: Raycasting with Irrbullet
what is in line 51 in irrbullet.h?
where is a error. maybe a missing "?
where is a error. maybe a missing "?
Re: Raycasting with Irrbullet
what is in line 51 in irrbullet.h?
where is a error. maybe a missing "?
Code: Select all
#include "CCylinderShape.h
Code: Select all
ICollisionShape *Floorshape = new CCylinderShape(Floor, 0, false);
Re: Raycasting with Irrbullet
hm, dude you forgot a " -> #include "CCylinderShape.h"
Re: Raycasting with Irrbullet
How do you mean? I included it in irrbullet.h.
Re: Raycasting with Irrbullet
Mhmm I misunderstood what you meant but now fixed it. Although I get this error message now:
When I call it like this:
But it seems to recognise the function because when I call
I get this:
Code: Select all
C:\Users\Stijn\Documents\Irrlicht\irrlicht-1.7.2\examples\01.HelloWorld\main.cpp|69|undefined reference to `CCylinderShape::CCylinderShape(irr::scene::ISceneNode*, float)'|
Code: Select all
ICollisionShape *Floorshape = new CCylinderShape(Floor, 0);
Code: Select all
ICollisionShape *Floorshape = new CCylinderShape(Floor, 0,false);
Code: Select all
C:\Users\Stijn\Documents\Irrlicht\irrlicht-1.7.2\examples\01.HelloWorld\main.cpp||In function 'int main()':|
C:\Users\Stijn\Documents\Irrlicht\irrlicht-1.7.2\examples\01.HelloWorld\main.cpp|69|error: no matching function for call to 'CCylinderShape::CCylinderShape(irr::scene::ISceneNode*&, int, bool)'|
C:\Users\Stijn\Documents\Irrlicht\irrBullet-0.1.8\source\cylindershape.h|15|note: candidates are: CCylinderShape::CCylinderShape(irr::scene::ISceneNode*, irr::f32)|
C:\Users\Stijn\Documents\Irrlicht\irrBullet-0.1.8\source\cylindershape.h|13|note: CCylinderShape::CCylinderShape(const CCylinderShape&)|
||=== Build finished: 1 errors, 3 warnings ===|
Re: Raycasting with Irrbullet
yeah always told you that you have to recompile irrbullet.also after that you have to recompile the irrbullet.lib
open project file from irrbullet folder add the cylindershape files to the proj and push compiling^^