IPhysics - Newton/Irrlicht framework
-
- Posts: 279
- Joined: Fri Dec 24, 2004 6:37 pm
Well what with my vacations and Eid i became very very busy with other stuff! I wud start working on the project properly from tuesday as i still have a lot of work to do in my personal life! But from tuesday i wud be back to studies and programming schedule! Neways, ill try to make proper character collision as soon as i can!
-
- Posts: 34
- Joined: Sat Jul 30, 2005 9:45 am
- Contact:
Re: CharacterController
Ok sure, it was just some simple obvious addition so nothing special from me but here is what I did:jonasled wrote:So, why not share the source? I'm sure we could all use a cylinder or two!Grey Lantern wrote:ok iv'e looked at the source (rather than the docs) and found that it was simple enough to add in the missing "cylinder" functionality and include the files in my test project so now I have A SPhysicsCylinder with radius and height.
added this in SPhysicsStructs.h after the same code for sphere
Code: Select all
//! Use this for creating a cylinder.
struct SPhysicsCylinder : SPhysicsAttributes
{
/// Radius in x axis.
f32 radius;
/// Radius in y axis.
f32 height;
};
added this in CPhysics.h after the same code for sphere
Code: Select all
IPhysicsEntity* addEntity(SPhysicsCylinder* cylinder);
added this in CPhysics.cpp after the same code for sphere
Code: Select all
IPhysicsEntity* CPhysics::addEntity(SPhysicsCylinder* cylinder)
{
matrix4 offset;
offset.makeIdentity();
NewtonCollision* collision = NewtonCreateCylinder(m_world, cylinder->radius, cylinder->height, offset.M);
NewtonBody* body = NewtonCreateBody(m_world, collision);
NewtonReleaseCollision(m_world, collision);
return setUpRigidBody(body, cylinder);
}
And though I didn't recompile the lib (I use the code straight in my test project) it worked ok for a cylinder (note that default cylinder is created lying down rather that up on edge so rotate if needed in game code when applying to upright mesh.
Re: CharacterController
Thanks, even simple stuff takes time to implement!Grey Lantern wrote:Ok sure, it was just some simple obvious addition so nothing special from me but here is what I did:
Thanks, I noticed that removing them didn't matter, but whenever I update the code all my changes are deleted and have to be redone. I will try to fix this properly and post the files. I hate to see Mac support for a project slip!Coolkat88 wrote:You can make some code cross-platform using macros.
A note about character control. I'm trying to implement a 3rd-person camera, but attaching a collisionResponseAnimator to the character (e.g. sydne.md2) doesn't work with a terrainTriangleSelector. The character just halts at many strange places no matter what I set the slide value to. This is a problem on both Windows and MacOS X.
I have made a million tests and there seems to be no logic to this glitch. The character stops even when the ground is rather flat. It is as if it runs into an invisible wall. That was my primary reason for looking at IPhysics (Newton). My guess is that Irrlicht's collisionResponseAnimator works best for FPS games and that it has not been tested with an arbitrary node. However, I don't really see why it should be any different since a sphere seems to be used for collision detection in either case.
I've went through IPhysics and I'm a bit disappointed that it only supports static meshes. I've looked at the addentity(IPhysicsstaticmesh* mesh) and I'm not sure what makes the mesh static. Is it the octtree or that it uses an IMeshbuffer or what? Because I'm imagining that you would use the same type of implementation for a dynamic mesh like an IAnimatedMeshX or a calc3d mesh.
1.)How would I go about making an implementation for a dynamic mesh?
EDIT: okay I've read over Grey Lanterns stuff and I edited the source code and tried to recompile the library file into my own .a and I got it to compile but when I use it in my project now it's saying that f32 does not name a type and all this crap (I'm using Dev CPP). I didn't have these errors before I messed around with the PhysicsGlobal.h file but I've tried everything on the PhysicsGlobal.h file and what a pain. I've tried all the possible linking combinations as well. I'm exhausted. goodnight.
EDIT #2: After some sleep I fixed the F32 and other compiling problems by just directly including Irrlicht newton and IPhysics instead of relying on the PhysicsGlobal.h file. So it compiles but my mesh doesn't show up now. Can I still use an octtree and have my mesh dynamic?
I don't really want to wait till the next RapChik (when will it be anyway?) but I'm interested to see how you'll implement the dynamic mesh code.
1.)How would I go about making an implementation for a dynamic mesh?
EDIT: okay I've read over Grey Lanterns stuff and I edited the source code and tried to recompile the library file into my own .a and I got it to compile but when I use it in my project now it's saying that f32 does not name a type and all this crap (I'm using Dev CPP). I didn't have these errors before I messed around with the PhysicsGlobal.h file but I've tried everything on the PhysicsGlobal.h file and what a pain. I've tried all the possible linking combinations as well. I'm exhausted. goodnight.
EDIT #2: After some sleep I fixed the F32 and other compiling problems by just directly including Irrlicht newton and IPhysics instead of relying on the PhysicsGlobal.h file. So it compiles but my mesh doesn't show up now. Can I still use an octtree and have my mesh dynamic?
I don't really want to wait till the next RapChik (when will it be anyway?) but I'm interested to see how you'll implement the dynamic mesh code.
Last edited by MM2_23 on Sun Jan 07, 2007 8:30 pm, edited 2 times in total.
-
- Posts: 279
- Joined: Fri Dec 24, 2004 6:37 pm
suggestion
hi
i made a small change to an IPhysics struct definition to make it more general... it doesn't break anything, so i though it might be folded into the next version of the library...
struct SPhysicsCar
{
...
/// The scene node for the car body.
ISceneNode* carBodyNode;
/// The scene node for the <B>front left</B> tire.
ISceneNode* tireNode_FL;
/// The scene node for the <B>front right</B> tire.
ISceneNode* tireNode_FR;
/// The scene node for the <B>rear left</B> tire.
ISceneNode* tireNode_RL;
/// The scene node for the <B>rear right</B> tire.
ISceneNode* tireNode_RR;
...
}
i made a small change to an IPhysics struct definition to make it more general... it doesn't break anything, so i though it might be folded into the next version of the library...
struct SPhysicsCar
{
...
/// The scene node for the car body.
ISceneNode* carBodyNode;
/// The scene node for the <B>front left</B> tire.
ISceneNode* tireNode_FL;
/// The scene node for the <B>front right</B> tire.
ISceneNode* tireNode_FR;
/// The scene node for the <B>rear left</B> tire.
ISceneNode* tireNode_RL;
/// The scene node for the <B>rear right</B> tire.
ISceneNode* tireNode_RR;
...
}
-
- Posts: 279
- Joined: Fri Dec 24, 2004 6:37 pm
Umm, whats the change??? This is the exact same way as its written in the source:
/// The scene node for the car body.
ISceneNode* carBodyNode;
/// The scene node for the <B>front left</B> tire.
ISceneNode* tireNode_FL;
/// The scene node for the <B>front right</B> tire.
ISceneNode* tireNode_FR;
/// The scene node for the <B>rear left</B> tire.
ISceneNode* tireNode_RL;
/// The scene node for the <B>rear right</B> tire.
ISceneNode* tireNode_RR;
/// The scene node for the car body.
ISceneNode* carBodyNode;
/// The scene node for the <B>front left</B> tire.
ISceneNode* tireNode_FL;
/// The scene node for the <B>front right</B> tire.
ISceneNode* tireNode_FR;
/// The scene node for the <B>rear left</B> tire.
ISceneNode* tireNode_RL;
/// The scene node for the <B>rear right</B> tire.
ISceneNode* tireNode_RR;
So I'm done making my SPhysicsDynamicMesh struct using the IAnimatedMeshX type and my mesh appears with texture and now falls with gravity but I can't position the node or rotate it by using setPosition or setRotation. Before when I used the SPhysicsStaticMesh that comes with IPhysics I could manual move the mesh around.
What's the problem now? Is the IAnimatedMeshX not compatible with the setPostion/setRotation functions?? I wouldn't think so.
EDIT: so if I turn of the settransfrom callback in newton then the mesh responds to setpostion but now it does respond to the newton forces and doesn't fall anymore.
What's the problem now? Is the IAnimatedMeshX not compatible with the setPostion/setRotation functions?? I wouldn't think so.
EDIT: so if I turn of the settransfrom callback in newton then the mesh responds to setpostion but now it does respond to the newton forces and doesn't fall anymore.
-
- Posts: 279
- Joined: Fri Dec 24, 2004 6:37 pm
Well i already have it implemented and was planning on adding joints from today but as to avoid any work being done twice i will release another copy of iphysics! BTW Can anyone provide me with some space and a possibility to upload files there via ftp cause uploads by uploadr kind of sites are temporary!
use www.gdlib.net it's just for us...hehe
We're programmers. Programmers are, in their hearts, architects, and the first thing they want to do when they get to a site is to bulldoze the place flat and build something grand. We're not excited by renovation:tinkering,improving,planting flower beds.
changed IAnimatedSceneNode to ISceneNode
@RapChikP
check it again...
check it again...
-
- Posts: 279
- Joined: Fri Dec 24, 2004 6:37 pm
Ma net sucks now adays so i couldnt upload it via gdlib as it doesnt have a progress bar! Neways heres the link:
http://file.uploadr.com/beb4
Updates:
-Camera collision is a lot better works smoothly and works cool in the terrain example too, though the gravity is set too low at the moment as i forgot to try out different values before uploading! Forgot to add a few things which wud have made life a lot easier for you guys, but hopefully will set it up and test it more the next time i upload a release!
-There is no SPhysicsBox or SPhysicsSphere but one SPhysicsPrimitive which can handle all basic primitives! You just set the primitivetype and it creates it!
-There is a new SPhysicsMesh which is added via addEntity and then works smoothly to load any kind of models!
-Other fixes have been done to IPhysics too!
BTW This is just so that no part of the engine is created again by someone else!
@Posttool: Sorry but i cant spot the difference can you just tell me.
http://file.uploadr.com/beb4
Updates:
-Camera collision is a lot better works smoothly and works cool in the terrain example too, though the gravity is set too low at the moment as i forgot to try out different values before uploading! Forgot to add a few things which wud have made life a lot easier for you guys, but hopefully will set it up and test it more the next time i upload a release!
-There is no SPhysicsBox or SPhysicsSphere but one SPhysicsPrimitive which can handle all basic primitives! You just set the primitivetype and it creates it!
-There is a new SPhysicsMesh which is added via addEntity and then works smoothly to load any kind of models!
-Other fixes have been done to IPhysics too!
BTW This is just so that no part of the engine is created again by someone else!
@Posttool: Sorry but i cant spot the difference can you just tell me.