Irrlicht with Bullet Softbody sample sourcecode

Post those lines of code you feel like sharing or find what you require for your project here; or simply use them as tutorials.
rookie
Posts: 16
Joined: Thu Dec 29, 2011 9:44 pm

Re: Irrlicht with Bullet Softbody sample sourcecode

Post by rookie »

I solved the problem with cubeSoftBody->addForce(btVector3(0,10050, 0 ), 10); since I suppose it was reacting to the force but its magnitude was low. I increased the forces magnitude & now it seems to be working fine. Now I am trying to add other models but the i is showing certain part of it & not the entire model. The person responsible for this code said the simulation would be slow if indexcount is greater than 2000 but nothing about it being shown partly. Please help me.
Granyte
Posts: 850
Joined: Tue Jan 25, 2011 11:07 pm
Contact:

Re: Irrlicht with Bullet Softbody sample sourcecode

Post by Granyte »

just a question how do you step the world?

also just calling addforce apply a force per frame wich mean that a much lower framerate computer would have a much slower acceleration rate
rookie
Posts: 16
Joined: Thu Dec 29, 2011 9:44 pm

Re: Irrlicht with Bullet Softbody sample sourcecode

Post by rookie »

Step simulation part-->

while(device->run())
{
dynamicsWorld->stepSimulation(1/15.0f, 1);
for (int i=0; i<mb->getVertexCount(); i++)
{

int index = testMesh_map.find(i)->second;
btSoftBody::Node* node = vertices.find(index)->second;
mb_vertices.Pos.X = node->m_x.x();
mb_vertices.Pos.Y = node->m_x.y();
mb_vertices.Pos.Z = -node->m_x.z();
}

if(receiver.IsKeyDown(irr::KEY_SPACE)){
// qDebug() << "HI";
cubeSoftBody->addForce(btVector3(0,10050, 0 ), 10);
}
else if(receiver.IsKeyDown(irr::KEY_ESCAPE))
break;

driver->beginScene(true, true, SColor(0,200,200,200));
smgr->drawAll();
driver->endScene();
}

I tried playing with stepsimulation parameters but no change at all. Let me know about the partial model. Indexcount is 8000 something but the program takes in only 2000 something.
rookie
Posts: 16
Joined: Thu Dec 29, 2011 9:44 pm

Re: Irrlicht with Bullet Softbody sample sourcecode

Post by rookie »

I am trying to merge the provided code with Qt. This is my simulation. It is printing 7,8,9 but not displaying anything.
void MainWindow::drawIrrlichtScene()
{
qDebug() << "MainWindow::drawIrrlichtScene()";

while(m_Device->run())
{
qDebug() << "start simulation" << endl;

m_dynamicsWorld->stepSimulation(1/60.0f, 1);qDebug() << "0";
for (int i=0; i<mb->getVertexCount(); i++)
{

int index = testMesh_map.find(i)->second;/*qDebug() << "1";*/
btSoftBody::Node* node = vertices.find(index)->second;/*qDebug() << "2";*/
mb_vertices.Pos.X = node->m_x.x();/*qDebug() << "3";*/
mb_vertices.Pos.Y = node->m_x.y();/*qDebug() << "4";*/
mb_vertices.Pos.Z = -node->m_x.z();/*qDebug() << "5";*/
}

// if(m_receiver->IsKeyDown(irr::KEY_SPACE)){
// qDebug() << "HI";
// m_cubeSoftBody->addForce(btVector3(0,10050, 0), 10);qDebug() << "6";
// }
m_Driver->beginScene( true, false, SColor( 255, 128, 128, 128 ));qDebug() << "7";
m_Scene->drawAll();qDebug() << "8";
m_Driver->endScene();qDebug() << "9";
}
}

Let me know.
rookie
Posts: 16
Joined: Thu Dec 29, 2011 9:44 pm

Re: Irrlicht with Bullet Softbody sample sourcecode

Post by rookie »

I am trying to embed the code into Qt. the model displays perfectly if i don't use the stepsimulation part. As I add the step simulation the model is not being displayed. I really need this. Please help me out.

void CurioModel::drawIrrlichtScene()
{
u32 TimeStamp = m_Device->getTimer()->getTime();
u32 DeltaTime = 0;
// while(m_Device->run())
{
qDebug() << "start simulation";
m_Driver->beginScene(true, true, SColor(255,100,101,140));

DeltaTime = m_Device->getTimer()->getTime() - TimeStamp;
TimeStamp = m_Device->getTimer()->getTime();

m_dynamicsWorld->stepSimulation(DeltaTime*0.001f, 120);
for (int i=0; i<mb->getVertexCount(); i++)
{
int index = testMesh_map.find(i)->second;
btSoftBody::Node* node = vertices.find(index)->second;
mb_vertices.Pos.X = node->m_x.x();
mb_vertices.Pos.Y = node->m_x.y();
mb_vertices.Pos.Z = -node->m_x.z();
}


m_Scene->drawAll();
m_Driver->endScene();
}
}
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Irrlicht with Bullet Softbody sample sourcecode

Post by CuteAlien »

@rookie: Just 2 minor feastures of the forum which you might be missing:
1. You can edit old posts. So if you only want to change a line you can just click edit and do that.
2. There is code tag. You can see tags directly above the edit-field when posting (click on full edit if you do only a quick-reply to see those). That makes code a lot more readable!
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
rookie
Posts: 16
Joined: Thu Dec 29, 2011 9:44 pm

Re: Irrlicht with Bullet Softbody sample sourcecode

Post by rookie »

I am trying to merge the code with Qt. I am performing all functions inside a class which is derived from QGraphicsItem. I am calling the following function inside paint function of the derived class. It prints start simulation but it doesn't display anything not even the rigid body inside the new window which opens up when I declare a object of the derived class. I have declared classes derived from QGraphicsView & QGraphicsScene. Model is the class derived from QGraphicsItem. Please help me. I am stuck here.

Code: Select all

void Model::drawIrrlichtScene()
{
    u32 TimeStamp = m_Device->getTimer()->getTime();
    u32 DeltaTime = 0;
//    while(m_Device->run())
//        {
            qDebug() << "start simulation";
            m_Driver->beginScene(true, true, SColor(255,100,101,140));
 
            DeltaTime = m_Device->getTimer()->getTime() - TimeStamp;
            TimeStamp = m_Device->getTimer()->getTime();
 
            m_dynamicsWorld->stepSimulation(DeltaTime*0.001f, 120);
            for (int i=0; i<mb->getVertexCount(); i++)
            {
                int index = testMesh_map.find(i)->second;
                btSoftBody::Node* node = vertices.find(index)->second;
                mb_vertices[i].Pos.X = node->m_x.x();
                mb_vertices[i].Pos.Y = node->m_x.y();
                mb_vertices[i].Pos.Z = -node->m_x.z();
            }
 
 
            m_Scene->drawAll();
            m_Driver->endScene();
//        }
}
 
Granyte
Posts: 850
Joined: Tue Jan 25, 2011 11:07 pm
Contact:

Re: Irrlicht with Bullet Softbody sample sourcecode

Post by Granyte »

i just started working on the soft body exemple it works but i don't understand at all how it does
Post Reply