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.

Re: Irrlicht with Bullet Softbody sample sourcecode

Postby rookie » Wed Jan 04, 2012 7:41 pm

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.
rookie
 
Posts: 16
Joined: Thu Dec 29, 2011 9:44 pm

Re: Irrlicht with Bullet Softbody sample sourcecode

Postby Granyte » Thu Jan 05, 2012 12:28 am

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
Granyte
 
Posts: 513
Joined: Tue Jan 25, 2011 11:07 pm

Re: Irrlicht with Bullet Softbody sample sourcecode

Postby rookie » Thu Jan 05, 2012 6:38 pm

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[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();
}

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

Postby rookie » Thu Jan 05, 2012 9:01 pm

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[i].Pos.X = node->m_x.x();/*qDebug() << "3";*/
mb_vertices[i].Pos.Y = node->m_x.y();/*qDebug() << "4";*/
mb_vertices[i].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

Postby rookie » Sat Jan 07, 2012 12:00 am

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[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();
}
}
rookie
 
Posts: 16
Joined: Thu Dec 29, 2011 9:44 pm

Re: Irrlicht with Bullet Softbody sample sourcecode

Postby CuteAlien » Sat Jan 07, 2012 11:34 am

@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.freenode.net
My patches&stuff: http://www.michaelzeilfelder.de/irrlicht.htm
Games with Irrlicht: http://www.irrgheist.com/
News: http://www.reddit.com/r/irrlicht/
User avatar
CuteAlien
Admin
 
Posts: 5349
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany

Re: Irrlicht with Bullet Softbody sample sourcecode

Postby rookie » Mon Jan 09, 2012 9:19 pm

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.
cpp 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();
//        }
}
 
rookie
 
Posts: 16
Joined: Thu Dec 29, 2011 9:44 pm

Re: Irrlicht with Bullet Softbody sample sourcecode

Postby Granyte » Tue Jan 10, 2012 12:47 am

i just started working on the soft body exemple it works but i don't understand at all how it does
Granyte
 
Posts: 513
Joined: Tue Jan 25, 2011 11:07 pm

Previous

Return to Code Snippets

Who is online

Users browsing this forum: No registered users and 0 guests