IrrPhysx 0.2 - Nvidia Physx 2.8.1 wrapper
Greetings Chris !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Greetings Chris !!!!!!!!!!
I have some proposition and questions to you...
1. I think you should add two methods to IrrPhysX namespace to get NxScene and NxActor. Am i right ?
it will be very useful for doing runtime changes or some external things...
2. I have implemented this methods to the namespace,
but when i trying to make revolute joints and sample fluid, nothing works properly. Where i made a mistake ?? Please help !!!!!!!!!!!!!!!!!!
source code
http://etlweb.com/nvPhysxTest.rar
I have some proposition and questions to you...
1. I think you should add two methods to IrrPhysX namespace to get NxScene and NxActor. Am i right ?
it will be very useful for doing runtime changes or some external things...
2. I have implemented this methods to the namespace,
but when i trying to make revolute joints and sample fluid, nothing works properly. Where i made a mistake ?? Please help !!!!!!!!!!!!!!!!!!
source code
http://etlweb.com/nvPhysxTest.rar
-
- Posts: 288
- Joined: Wed Apr 16, 2008 1:45 am
- Contact:
I am not really sure how to add the get actor with how it is set up at the moment, any ideas JP? You commented out cloth object creation which isn't a good work around . I'll try and get creative.
As for the joints I just downloaded them I will look into it and see what I come up with.
We still have a few things on the todo list before the next release I have some time today since I am waiting on some lighting issues with my game and I need joints in the near future so I may get this fixed and added into irrphysx before the todo list gets complete.
As for the joints I just downloaded them I will look into it and see what I come up with.
We still have a few things on the todo list before the next release I have some time today since I am waiting on some lighting issues with my game and I need joints in the near future so I may get this fixed and added into irrphysx before the todo list gets complete.
-
- Posts: 288
- Joined: Wed Apr 16, 2008 1:45 am
- Contact:
Yahhhhhhhhhhhhooooooooooooooo
Yaaaaaaaaaaaaaahooooooooooooooo!!!!!!
My fluid is working somehow now !!!! But not really well....
I'l try to explain: When i create a set of ~2000 particles framerate is stable,
but if set of particles is bigger framerate suxx ^((
Maybe someone (Insomniacp, or JP, or someone else ...) could modify my code and post here ????????????????????????????????
Fragment of code:
screenshot
And full source & binary with vs 9.0 solution
http://etlweb.com/nvPhysxTestFluid.rar
My fluid is working somehow now !!!! But not really well....
I'l try to explain: When i create a set of ~2000 particles framerate is stable,
but if set of particles is bigger framerate suxx ^((
Maybe someone (Insomniacp, or JP, or someone else ...) could modify my code and post here ????????????????????????????????
Fragment of code:
Code: Select all
//particle globals
#define REST_PARTICLES_PER_METER 10
#define KERNEL_RADIUS_MULTIPLIER 1.8f
//#define MOTION_LIMIT_MULTIPLIER (3*KERNEL_RADIUS_MULTIPLIER)
#define MOTION_LIMIT_MULTIPLIER 3
#define PACKET_SIZE_MULTIPLIER 8
NxFluid* fluid = NULL;
NxVec3 gParticleBuffer[10000];
NxU32 gParticleBufferCap = 10000;
NxU32 gParticleBufferNum = 0;
array<ISceneNode*> particles;
NxFluid* CreateFluid(const NxVec3& pos, NxU32 sideNum, NxReal distance, NxScene* scene)
{
// Create a set of particles
gParticleBufferNum = 0;
NxReal rad = sideNum*distance*0.5f;
for (NxU32 i=0; i<sideNum; i++)
{
for (NxU32 j=0; j<sideNum; j++)
{
for (NxU32 k=0; k<sideNum; k++)
{
NxVec3 p = NxVec3(i*distance,j*distance,k*distance);
if (p.distance(NxVec3(rad,rad,rad)) < rad)
{
p += pos - NxVec3(rad,rad,rad);
gParticleBuffer[gParticleBufferNum++] = p;
}
}
}
}
// Set structure to pass particles, and receive them after every simulation step
NxParticleData particles;
//particles.maxParticles = gParticleBufferCap;
particles.numParticlesPtr = &gParticleBufferNum;
particles.bufferPos = &gParticleBuffer[0].x;
particles.bufferPosByteStride = sizeof(NxVec3);
// Create a fluid descriptor
NxFluidDesc fluidDesc;
fluidDesc.maxParticles = gParticleBufferCap;
fluidDesc.kernelRadiusMultiplier = KERNEL_RADIUS_MULTIPLIER;
fluidDesc.restParticlesPerMeter = REST_PARTICLES_PER_METER;
fluidDesc.motionLimitMultiplier = MOTION_LIMIT_MULTIPLIER;
fluidDesc.packetSizeMultiplier = PACKET_SIZE_MULTIPLIER;
fluidDesc.stiffness = 50;
fluidDesc.viscosity = 22;
fluidDesc.restDensity = 1000;
fluidDesc.damping = 0;
fluidDesc.restitutionForStaticShapes = 0.4f;
fluidDesc.dynamicFrictionForStaticShapes= 0.3f;
fluidDesc.collisionResponseCoefficient = 0.5f;
fluidDesc.collisionDistanceMultiplier = 0.1f;
fluidDesc.simulationMethod = NX_F_SPH; //NX_F_NO_PARTICLE_INTERACTION
fluidDesc.initialParticleData = particles;
fluidDesc.particlesWriteData = particles;
fluidDesc.flags &= ~NX_FF_HARDWARE; //~NX_FF_HARDWARE;
fluidDesc.flags |= NX_FF_COLLISION_TWOWAY;
NxFluid* fl = scene->createFluid(fluidDesc);
assert(fl != NULL);
return fl;
}
void ReleaseFluid()
{
if(!particles.empty())
{
s32 num_destroyed=0;
for (u32 i = 0 ; i < particles.size() ; ++i)
{
particles[i]->remove();
particles.erase(i);
num_destroyed++;
}
printf("Particles destroyed: %d\n", num_destroyed);
}
if(fluid)
{
if (physxManager->getScene()) physxManager->getScene()->releaseFluid(*fluid);
fluid = NULL;
}
}
void RenderFluid()
{
//keep physics & graphics in sync
for (NxU32 p=0; p<gParticleBufferNum; p++)
{
NxVec3& particle = gParticleBuffer[p];
particles.push_back(smgr->addSphereSceneNode(.1f,5,0,-1,vector3df(particle.x,particle.y,particle.z)));
}
}
void UpdateFluid()
{
for (u32 i = 0 ; i < particles.size() ; ++i)
{
NxVec3& particle = gParticleBuffer[i];
particles[i]->setPosition(vector3df(particle.x,particle.y,particle.z));
}
}
....
fluid = CreateFluid(NxVec3(0,200,0), 15, 0.1, physxManager->getScene());
RenderFluid();
.....
//Release all
ReleaseFluid();
And full source & binary with vs 9.0 solution
http://etlweb.com/nvPhysxTestFluid.rar
-
- Posts: 288
- Joined: Wed Apr 16, 2008 1:45 am
- Contact:
-
- Posts: 288
- Joined: Wed Apr 16, 2008 1:45 am
- Contact:
Ok, joints is Ok !!!! but....
Ok, now i have solved the problem with joints,
Insomniacp was right, we must update nodes, earlier I have forgot to
add objects to array core::array<SPhysxAndNodePair*> objects;
Thank you Insomniacp !!!!!!!!!!!!!!!!!!!!!!!!!!!
But I don't understand, how to calculate globalAnchor
In my code this parameter is wrong ((( a little ...
screen
modified solution
http://etlweb.com/nvPhysxTest.rar
Insomniacp was right, we must update nodes, earlier I have forgot to
add objects to array core::array<SPhysxAndNodePair*> objects;
Thank you Insomniacp !!!!!!!!!!!!!!!!!!!!!!!!!!!
But I don't understand, how to calculate globalAnchor
In my code this parameter is wrong ((( a little ...
screen
modified solution
http://etlweb.com/nvPhysxTest.rar
Last edited by rootroot1 on Sun Dec 20, 2009 1:33 am, edited 1 time in total.
-
- Posts: 288
- Joined: Wed Apr 16, 2008 1:45 am
- Contact:
The SDK Docs state the following
To get the right position (will vary depending how the box was built, this will be if the center of the box is its origin).
PS, this is what I think you are trying to accomplish correct?
http://www.ozone3d.net/blogs/demoniak3d/?p=27
in the event that you want it to swing like a door you will want the anchor to be the point connecting the two boxes, that way they will be connected at that point. So a door you will want the anchor to be the middle of the door height and on the edge where the hinges would be. Hope this helps you.Sets the point where the two actors are attached, specified in global coordinates.
Set this after setting the actors of the joint.
Sleeping: This call wakes the actor(s) if they are sleeping.
Parameters:
[in] vec Point the actors are attached at, specified in the global frame. Range: position vector
To get the right position (will vary depending how the box was built, this will be if the center of the box is its origin).
Code: Select all
boxPosition=box.getPosition();
boxPosition.Y-=box.getHeight()/2;//I don't think this function exists though
boxPosition.X-=box.getWidth()/2;//Once again I don't think this exists
http://www.ozone3d.net/blogs/demoniak3d/?p=27
Yes, you're right !!!!!!!!!!!!!!!!!!! Thank you for fast replies!!
Ok, coud you calculate this parameter for boxes with dimensions like in my code, and
so it will looks like an example in blog that you've posted above ???
Please ...
My head will explode soon ))))))
createBox(physxManager, smgr, driver, core::vector3df(30.0f,110.0f,-60.0f), core::vector3df(30.0f,60.0f,30.0f), 10)
createBox(physxManager, smgr, driver, core::vector3df(30.0f,50.0f,-60.0f), core::vector3df(30.0f,60.0f,30.0f), 5)
Thanks in advance !!!!!!!!!!!!!!!
Ok, coud you calculate this parameter for boxes with dimensions like in my code, and
so it will looks like an example in blog that you've posted above ???
Please ...
My head will explode soon ))))))
createBox(physxManager, smgr, driver, core::vector3df(30.0f,110.0f,-60.0f), core::vector3df(30.0f,60.0f,30.0f), 10)
createBox(physxManager, smgr, driver, core::vector3df(30.0f,50.0f,-60.0f), core::vector3df(30.0f,60.0f,30.0f), 5)
Thanks in advance !!!!!!!!!!!!!!!
-
- Posts: 288
- Joined: Wed Apr 16, 2008 1:45 am
- Contact:
NxVec3 globalAnchor = NxVec3(45.0f,80.0f,-45.0f);
NxVec3 globalAxis = NxVec3(0,0,1);
That should do it. Took a little to find out how it was built but it was middle as origin, so I did as I stated in earlier post. You can move across the z axis as much as you want since it is the global axis. Glad to help.
NxVec3 globalAxis = NxVec3(0,0,1);
That should do it. Took a little to find out how it was built but it was middle as origin, so I did as I stated in earlier post. You can move across the z axis as much as you want since it is the global axis. Glad to help.
-
- Posts: 70
- Joined: Tue Oct 28, 2008 12:59 pm
IrrPhysx-v0.3 release at link http://sio2.g0dsoft.com/modules/wmpdown ... d=2&lid=29 but i can't download it. Somebody can download it please share. Thank you so much.
That's not the real IrrPhysx unfortunately, 0.3 isn't ready for release yet.
rootroot1, i wasn't going to add any getActor/getScene functions to IrrPhysx as that's Physx specific stuff and I wanted to keep Physx pretty much hidden away from the user when using IrrPhysx. It should be easy enough for you to add those in if you need them for your project though.
Good work on the joints, has that come from SVN or something you've done yourself?
rootroot1, i wasn't going to add any getActor/getScene functions to IrrPhysx as that's Physx specific stuff and I wanted to keep Physx pretty much hidden away from the user when using IrrPhysx. It should be easy enough for you to add those in if you need them for your project though.
Good work on the joints, has that come from SVN or something you've done yourself?
not sure what you mean by that...?You commented out cloth object creation which isn't a good work around
Hi, Chris !!!!!!
Joints was from PhysX SDK lesson, just modified for Irrlicht... but example need getActor method ^((
Could you help me with fluid, some ideas ?? Do you already have some code ?? I've tried to modify CFluidSceneNode, made by sio2, but nothing works !!! ( because of my bad knowledge in drawing VertexPrimitiveList )^(((((
I will be really happy If you give an advice, or some source code !!!!
my mail: generalkalmar@gmail.com
Joints was from PhysX SDK lesson, just modified for Irrlicht... but example need getActor method ^((
Could you help me with fluid, some ideas ?? Do you already have some code ?? I've tried to modify CFluidSceneNode, made by sio2, but nothing works !!! ( because of my bad knowledge in drawing VertexPrimitiveList )^(((((
I will be really happy If you give an advice, or some source code !!!!
my mail: generalkalmar@gmail.com