0.4RC3 Day40: Joints 2.0

betajaen

30-10-2006 23:44:37

Here we go again.

This time, I'm going to experiment with micro-releases; More stable than a CVS but less feature filled than a point release.

betajaen

01-11-2006 13:01:20

Day 1

Click for video


I've started to implement "FX Scenes", which allow a combination of hardware and software or software and software scenes.

In a complicated physics simulation, you can simulate lower priority bodies in another scene; particles, non-game play elements etc., then just move the nodes in the main scene manager. You mimic the main scene up in the second scene using kinematic and static bodies.

The idea is you can tone-down or up the special effects when needed, and it won't make any impact on the main scene, as either it's on another thread or if you have a PPU on that.

It's very early days and the code is very unoptimised, i.e. 40FPS in debug mode.

The video above is 64 cubes on hardware, and a sphere on software. When I move the sphere around it's moving the cubes around on another scene. If you have the PhysX tutorials installed it's 803.

Code to create the two scenes are:

mScene = mWorld->createScene("Main",mSceneMgr);
mScene->hasGravityAndFloor();


mFXScene = mWorld->createFXScene(mScene);

for (int i=0;i < 64;i++) {
body *b =mFXScene->createBody("cube" + Ogre::StringConverter::toString(i), "cube.1m.mesh", new cubeShape(0.1),10.0f, Vector3(0,i,0));
b->mNode->scale(0.1,0.1,0.1);
}

mScene->createBody("sphere", "sphere.50cm.mesh", new sphereShape(0.5), 10.0f, Vector3(1,1.5,0));


But this is a small step for an entirely new particle system I'm working on...

Stay tuned!

ColeZero

01-11-2006 14:42:15

That looks cool, really, but a little sugestion, nxOgre is the best physics-binding for ogre, but it lacks some of the standart features like ragdoll or vehicle simulation or cloth or water simulation, i don't mean fluids, i mean for example pushing a cube into the water and cube doesn't sink, it swims..
I hope these features, especially ragdoll, will find there way into nxogre..^^

But did i say that FX scenes are very cool...

betajaen

01-11-2006 17:33:26

Ragdolls and Vehicles will be just in the tutorials, until I put them into an expansion pack DLL later on in the year.

I just don't want NxOgre to be too abstract in what it does.

Water, Cloth and Fluid planes* will be in though.


*Fluid planes aren't part of PhysX but I will attempt to write the physics myself.

betajaen

01-11-2006 22:52:49

Day 1 - Part II

Making sure the the right bodies are awake and others are asleep.

Click the image for video


Now FxScene can:
  1. Wake the bodies up when needed.[/*:m]
  2. Send the others to sleep, to speed up simulation time.[/*:m][/list:u]
    In the video above; the sleeping bodies are represented by red and the awake by yellow. As I move the ball through out the small cubes, the bodies are awaking and sleeping automatically before the ball touches them.

    This allows amazing speed up time, cleaning up really old bodies or particles and allowing just the local area being simulated fully.

    I'm getting around 40FPS on release here with 514 bodies on the hardware and 2 on software. I believe the bottleneck is the separate scenenode/entity system I have. Perhaps when implement some instancing or some magic shader; the FPS will go way up.

betajaen

03-11-2006 16:53:04

Day 3




mBehaviour = new particles::particleBehaviour("ribbon.mesh",Vector3(0.1,0.001,0.05));
mBehaviour->naturalMovement = Vector3(0,0.000075 ,0);
mBehaviour->deviationX = 0.000005;
mBehaviour->deviationY = 0.000005;
mBehaviour->deviationZ = 0.000005;
mBehaviour->isWeightless = true;

int i=0;
for (int x=0;x < 9;x++) {
for (int y=0;y < 9;y++) {
for (int z=0;z < 9;z++) {
mWorld->mParticleSystem->createParticle(
Vector3(NxMath::rand(-25,25),NxMath::rand(3,28),NxMath::rand(-25,25)),
mBehaviour,
mFXScene
);
}
}
}


Look at the NxActor count then look at the FPS. Oh yeah.

Wretched_Wyx

03-11-2006 17:30:30

Hallelujah. I've been waiting for the day when the particle side of things got a boost, and it looks like it's arrived. That is very slick man.

djb

03-11-2006 19:47:56

Hi,

Have you considered using fluids for the particle system? It should be possible to handle say 10k particles with collision (between particles and the environment) without problems. Plus you get emitters for free.

The only thing is rendering them...

David

betajaen

03-11-2006 21:24:01

I considered it. It'd certainly be useful for "cloud" particles, such as steam.

I'll have a little go, but after I finish the other particle classes (emitter, destroyer, attractor and deflector).

betajaen

07-11-2006 19:30:43

Day 8
Perhaps I should avert your eyes to [b]a good friend[/b] the showcase forum.

It will be pretty much in any tutorial that uses more than the force keys. ;)

ColeZero

07-11-2006 20:27:25

Yeah, the GUI code is so....simple, ok not that simple, but i don't need to use CEGUI just for a test gui...thx...^^

betajaen

07-11-2006 20:41:24

I like to call it Simple but unreadable.

I would of been killed if I said CEGUI was a requirement to run the tutorials, so I wrote my own instead. CEGUI is great, but way over the top for the things required in the tutorials.

betajaen

16-11-2006 22:50:57

Day 17 - Cloth


Thanks to this really clever chap, I implemented cloth using his code into NxOgre.


Code is ever so simple as always:


blueprint<cloth> bp;
bp.width = 3.0f;
bp.height = 2.0f;
bp.delta = 0.15f/1.5f;

cloth *c = bp.create(Vector3(0,3,0),mScene);


It's still quite simple, you have no option of how rigidness, or other parameters you can expect or does it tear but since that code has already been written for me. It won't take me to long to implement it.

You can thank mkh42 for this. :D

p.s. I'm getting 500-600 FPS with cloth and it's rendered on software!

CaseyB

16-11-2006 23:07:10

:shock:
HOLY CRAP!
:shock:
That looks AMAZING! I'm so excited!

betajaen

16-11-2006 23:14:34

And technically I'm doing micro-release per 3 new feature posts, you'll see a new copy of NxOgre within a day or two ;)

Wretched_Wyx

16-11-2006 23:15:09

That is really freakin' sweet. Thanks a bunch mkh42, and Betajaen of course :wink:. Can't wait to see this some time down the road, with all it's pretty updates and elegant new features... I've watched the video several times, just grinning knowing that it's working!

ColeZero

17-11-2006 15:28:10

Nice work, but you should attach the the flag to something, or add a second or third cloth to the scene, or let it fall down on some boxes, laying on the ground is not that cool, you know.:), but great, really good work, very good guys..
About the fps, if you enable selfcollision the fps is getting really down(still smooth, but not that high^^), especially when you enable tearing....

betajaen

18-11-2006 12:23:35

Day 19



Reading from Nikki's latest thread, and from watching a few others either modifying NxOgre to include UserData or going through the non-OO way to implement the NxOgre body as part of their GameObject system. I decided to unionise things.

Presenting, Custom Bodies (Code from Tutorial 121):


class GameObject : public body {
public:
GameObject(String name, pose _pose, GameManager *mgr);
~GameObject();

};



GameObject::GameObject(String name, pose _pose, GameManager *mgr) : body(name, new cubeShape(1), 10, _pose, mgr->mScene) {

mEntity = mgr->mSceneMgr->createEntity(name + ".goentity", "cube.1m.mesh");
mNode->attachObject(mEntity);

SceneNode * mParticleNode = mNode->createChildSceneNode(mName + "particlefx");
ParticleSystem* mParticleSystem = owner->mSceneMgr->createParticleSystem(mName + "fx","nx.fx.smoke");
mParticleNode->attachObject(mParticleSystem);

}


GameObject::~GameObject() {
SceneNode* mParticleNode = (SceneNode*) mNode->getChild(mName + "particlefx");
mParticleNode->detachObject(mName + "fx");
mNode->removeAndDestroyChild(mName + "particlefx");
owner->mSceneMgr->destroyParticleSystem(mName + "fx");
}



GameManager::~GameManager() {
for (int i=0;i < mGameObjects.size();i++) {
mScene->unregisterCustomBody(reinterpret_cast<body*>(mGameObjects[i]));
delete mGameObjects[i];
}
}
void GameManager::createGameObject(String name, pose _pose) {
GameObject* go = new GameObject(name, _pose, this);
mScene->registerCustomBody(go);
mGameObjects.push_back(go);
}


Not bad indeed.

p.s.

Don't worry about that micro-release, It'll either be released today or tomorrow. I just have to clean up a few things first. ;)

mkh42

04-12-2006 10:34:36

Hello
what's about the micro release ??
did i missed something?
Greetings
Martin

betajaen

04-12-2006 10:40:43

Nope; RC3 will be released within a few days.

Then I have a surprise for you lot on the 24th ;)

mkh42

05-12-2006 17:00:14

sounds great. :D

betajaen

09-12-2006 23:44:52

Day 40

I've done many many things in NxOgre for the last 3 weeks, most of them are secret though. :D

However, today I'll show you something I've improved on; Joints!



The old code was quite horrible, and it caused a memory leak or two(Scene never deleted them on shutdown), and there was also no way of releasing the joint through NxOgre.

So I present, Joints 2.0:

// Create a Pulley joint like the one in the screenshot.
pulleyJoint *mJoint = joint::createPulleyJoint(mScene, myCube,myOtherCube, Vector3(-1,16,0), Vector3(1,16,0), Vector3(-1,0,0), 10, 1);

...

// Release the pulley some way through the application
joint::destroyJoint(mJoint);


There you go, and no need to keep track of them or delete them afterwards.

I must warn you, this is a tip of a very large iceberg of changes and additions to NxOgre ;)

kungfoomasta

10-12-2006 08:19:04

I may have missed this somewhere, but is there a roadmap, priority list, or current goals that are available? I'm curious.. :P

KungFooMasta

betajaen

10-12-2006 10:54:31

Not really, it's all in my head. I either pick a SDK Tutorial and wrap the feature shown and write the tutorial, or come up with a fantastic idea then write that in.

Although I consider it semi-complete when the features of 10x to 30x are wrapped and written.