Tumle v1.4 irrlicht/newton

Announce new projects or updates of Irrlicht Engine related tools, games, and applications.
Also check the Wiki
koller202
Posts: 143
Joined: Tue May 08, 2007 4:53 am
Location: Thailand

Post by koller202 »

i m error

Code: Select all

c:\documents and settings\numxyz\desktop\tumle\include\icamerafpsphysicsnode.h(24) : error C2555: 'tumle::ICameraFPSPhysicsNode::getIrrlichtNode' : overriding virtual function differs from 'tumle::IPhysicsNode::getIrrlichtNode' only by return type o
r calling convention
        c:\documents and settings\numxyz\desktop\tumle\include\iphysicsnode.h(19) : see declaration of 'IPhysicsNode'
i use 1.3.1 newton 1.53 and vc 6.0 thank you
________
Digital Vaporizers
Last edited by koller202 on Thu Feb 17, 2011 1:17 am, edited 1 time in total.
JonLT
Posts: 152
Joined: Thu Mar 15, 2007 5:47 pm
Location: Denmark

Post by JonLT »

I'm sorry for the late response! :oops: I just started in school again.

I just checked the hello world example and it worked fine on my computer (although i can see that i have uploaded the wrong file to that example, i'll fix this after posting this).

Are you sure you are compiling and linking the files in the /source folder?

Code: Select all

To compile one of the examples in codeBlocks to the following:
- Create a new empty project
- Set up the path and targets as you like
- Add the files from the tumle/source dir. to the project
- Add the example file you wish to compile
- Let the compiler know where to look for irrlicht and newton includes and   
  libs (right-click op the project, select 'build options' and add the irrlicht 
  and newton include-path to the 'search directories'-tab and the libs to the 
  'linker settings' tab)
- Copy the newton.dll and the irrlicht.dll to the directory, you set the file to be created in.
- Hit build.
This worked for my, if it doesn't for you, please post again, and I'll try to be of assistence!

About the C2555: You are right, this is an error in the code, but my compiler didn't care about it. Generally the structure of the classes in tumle, espesially the ones derived from IPhysicsNode, should have been done different. I'm sorry to say, that i'm not planning on fixing this as i have a lot of other stuff to do, and i consider tumle done (not perfect, but done). So my advice to you is, if you still want to use tumle, to use a different compiler, i use gcc(MinGW).
FuzzYspo0N
Posts: 914
Joined: Fri Aug 03, 2007 12:43 pm
Location: South Africa
Contact:

Post by FuzzYspo0N »

hey JonLT is there any chance u acn make this 1.4 compatible. the new OnEvent and event thing makes it not work for recieveing events and such...im working on it, if i fix it ill upload it here for u

EDIT

Here is the 1.4 working version. it shud work the same in your project as is, the examples are working fine my end.

DONT forget the necessities( add include to the include directorys, linking the libs newton and irrlicht and adding all the sources to the project. also, adding the dlls to the project. im gonna make some tutorials for this as i see it as a great help for beginners in physics.)

get it here
167 kb
www.owned.co.za/release/tumle0.2.zip
anandh
Posts: 61
Joined: Thu Sep 14, 2006 12:40 pm
Contact:

Post by anandh »

Hello JonLT,
its Great stuff.
Do you have plans for (simple) vehicles support.
raymond
Posts: 7
Joined: Thu Dec 13, 2007 2:30 pm
Location: China

Post by raymond »

The example runs perfectly on my computer. But when I am trying to use addPhysicsLevelNode to load a level of my own, a error occur.

Code: Select all

scene::IAnimatedMesh* levelMesh = smgr->getMesh("../../media/room.3ds");
ISceneNode* levelNode = smgr->addOctTreeSceneNode(levelMesh->getMesh(0), 0, -1, 128);

IPhysicsNode *physLevelNode = pmgr->addPhysicsLevelNode(levelNode, levelMesh->getMesh(0));  // here's the error
I found that the call of NewtonTreeCollisionEndBuild(collision, 0) in CPhysicsManager.cpp, line 664 caused the problem.

Is there any help?
rooly
Posts: 224
Joined: Tue Oct 25, 2005 4:32 pm
Location: Louisiana, USA, backwater country
Contact:

Post by rooly »

raymond, are you sure that the file is loaded? usually when an error occurs, its in the few lines before that governed the line itself...

i'm just guessing here. if your getting a runtime error, your file probably isn't loading. IN could of course use a little checking at that point, but nothing hurts a good bit of user-side safety.

if your getting a compile error, then i can't help.
When banks compete, you win.
When ISPs compete, you win.
When electronics retailers compete, you win.
When governments compete...you get drafted.
raymond
Posts: 7
Joined: Thu Dec 13, 2007 2:30 pm
Location: China

Post by raymond »

rooly wrote:raymond, are you sure that the file is loaded? usually when an error occurs, its in the few lines before that governed the line itself...

i'm just guessing here. if your getting a runtime error, your file probably isn't loading. IN could of course use a little checking at that point, but nothing hurts a good bit of user-side safety.

if your getting a compile error, then i can't help.
Yes the mesh is loaded. It can be drawn normally. But when I tried to post it to the addPhysicsLevelNode there's a runtime exception.

I have just looked around the souce of the Tumle and find something odd:

Code: Select all

		mb = levelMesh->getMeshBuffer(cMeshBuffer);

		video::S3DVertex2TCoords* mb_vertices = (irr::video::S3DVertex2TCoords*)mb->getVertices();

		u16* mb_indices  = mb->getIndices();

		// I added 2 linew below to see how many indices and
                // vertices there are
		u32 icount = mb->getIndexCount();
                u32 vcount = mb->getVertexCount();
		// add each triangle from the mesh
		for (j=0; j<mb->getIndexCount(); j+=3)
		{
			v1i = mb_indices[j];
			v2i = mb_indices[j+1];
			v3i = mb_indices[j+2];


			// when j loop to a big value, the mb_vertices[v1i] become invalid
			vArray[0] = mb_vertices[v1i].Pos.X;
			vArray[1] = mb_vertices[v1i].Pos.Y;
			vArray[2] = mb_vertices[v1i].Pos.Z;
			vArray[3] = mb_vertices[v2i].Pos.X;
			vArray[4] = mb_vertices[v2i].Pos.Y;
			vArray[5] = mb_vertices[v2i].Pos.Z;
			vArray[6] = mb_vertices[v3i].Pos.X;
			vArray[7] = mb_vertices[v3i].Pos.Y;
			vArray[8] = mb_vertices[v3i].Pos.Z;

			NewtonTreeCollisionAddFace(collision, 3, (float*)vArray, 12, 1);
		}
and seems the invalid memory address caused the following Nowton functino to raised a exception:
NewtonTreeCollisionEndBuild(collision, 0);
I tried 3ds, x and both of them crashed like described above. But when loading a bsp everything is all right.

Why???????
raymond
Posts: 7
Joined: Thu Dec 13, 2007 2:30 pm
Location: China

Post by raymond »

After search the forum I find that's caused by different vertex type. You need to check the vertex type and convert the pointer like this:

Code: Select all

if(mb->getVertexType() == EVT_STANDARD){
  S3DVertex* mb_vertices = (S3DVertex*)mb->getVertices();
  // create collision tree

}else{
  S3DVertex2TCoords* mb_vertices = (S3DVertex2TCoords*)mb->getVertices();
  // create collision tree
}
and tumle0.2 doesn't distinguish two of them. I just modified addPhysicsLevelNode() and everything is all right now.

And I also find scaled the mesh doesn't work correctly. Seems calling node->setScale() doesn't affect the mesh's vertex buffer.

Here comes the function below and it can now load both bsp and 3ds, and the scaled mesh also get work correctly

Code: Select all

IPhysicsNode *CPhysicsManager::addPhysicsLevelNode(scene::ISceneNode *levelNode, scene::IMesh *mesh)
{

    scene::IMesh *levelMesh = mesh;

    if(!levelNode)
    {
        printf("TUMLE: No node passed, level will have no collision\n");
        return 0;
    }

    switch(levelNode->getType())
    {
        case scene::ESNT_MESH:
        {
            scene::IMeshSceneNode *msn = (scene::IMeshSceneNode*)levelNode;
            levelMesh = msn->getMesh();
            break;
        }
        case scene::ESNT_ANIMATED_MESH:
        {
            scene::IAnimatedMeshSceneNode *amsn = (scene::IAnimatedMeshSceneNode*)levelNode;
            levelMesh = amsn->getMesh()->getMesh(0);
            break;
        }
        default:
        {
            printf("TUMLE: passed node has no mesh, passed mesh used to create level collision\n");
        }
    }

    if(!levelMesh)
    {
        printf("TUMLE: no mesh pressent, level will have no collision\n");
        return 0;
    }


	NewtonCollision *collision = NewtonCreateTreeCollision(nWorld, NULL);
	NewtonTreeCollisionBeginBuild(collision);
	u32 cMeshBuffer, j;
	int v1i, v2i, v3i;
	scene::IMeshBuffer *mb;

	float vArray[9]; // vertex array (3*3 floats)
	core::vector3df scale = levelNode->getScale();

	for (cMeshBuffer=0; cMeshBuffer<levelMesh->getMeshBufferCount(); cMeshBuffer++)
	{
		mb = levelMesh->getMeshBuffer(cMeshBuffer);

			if(mb->getVertexType() == video::EVT_STANDARD)
			{
				video::S3DVertex* mb_vertices = (video::S3DVertex*)mb->getVertices();

				u16* mb_indices  = mb->getIndices();

				u32 icount = mb->getIndexCount();
				u32 vcount = mb->getVertexCount();
				// add each triangle from the mesh
				for (j=0; j<mb->getIndexCount(); j+=3)
				{
					v1i = mb_indices[j];
					v2i = mb_indices[j+1];
					v3i = mb_indices[j+2];

					vArray[0] = mb_vertices[v1i].Pos.X * scale.X;
					vArray[1] = mb_vertices[v1i].Pos.Y * scale.Y;
					vArray[2] = mb_vertices[v1i].Pos.Z * scale.Z;
					vArray[3] = mb_vertices[v2i].Pos.X * scale.X;
					vArray[4] = mb_vertices[v2i].Pos.Y * scale.Y;
					vArray[5] = mb_vertices[v2i].Pos.Z * scale.Z;
					vArray[6] = mb_vertices[v3i].Pos.X * scale.X;
					vArray[7] = mb_vertices[v3i].Pos.Y * scale.Y;
					vArray[8] = mb_vertices[v3i].Pos.Z * scale.Z;

					NewtonTreeCollisionAddFace(collision, 3, (float*)vArray, 12, 1);
				}
			}
			else
			{
				video::S3DVertex2TCoords* mb_vertices = (video::S3DVertex2TCoords*)mb->getVertices();

				u16* mb_indices  = mb->getIndices();

				u32 icount = mb->getIndexCount();
				u32 vcount = mb->getVertexCount();
				// add each triangle from the mesh
				for (j=0; j<mb->getIndexCount(); j+=3)
				{
					v1i = mb_indices[j];
					v2i = mb_indices[j+1];
					v3i = mb_indices[j+2];

					vArray[0] = mb_vertices[v1i].Pos.X * scale.X;
					vArray[1] = mb_vertices[v1i].Pos.Y * scale.Y;
					vArray[2] = mb_vertices[v1i].Pos.Z * scale.Z;
					vArray[3] = mb_vertices[v2i].Pos.X * scale.X;
					vArray[4] = mb_vertices[v2i].Pos.Y * scale.Y;
					vArray[5] = mb_vertices[v2i].Pos.Z * scale.Z;
					vArray[6] = mb_vertices[v3i].Pos.X * scale.X;
					vArray[7] = mb_vertices[v3i].Pos.Y * scale.Y;
					vArray[8] = mb_vertices[v3i].Pos.Z * scale.Z;

					NewtonTreeCollisionAddFace(collision, 3, (float*)vArray, 12, 1);
				}
			}

		//video::S3DVertex* mb_vertices = (irr::video::S3DVertex2TCoords*)mb->getVertices();

	}
	NewtonTreeCollisionEndBuild(collision, 0);
    NewtonBody *body = makeNewtonBody(collision, 0,
                                      levelNode->getPosition(),
                                      levelNode->getRotation(),
                                      levelNode->getBoundingBox().getCenter());


	// set the newton world size based on the map size
	float boxP0[3];
	float boxP1[3];
	float matrix[4][4];
	NewtonBodyGetMatrix (body, &matrix[0][0]);
	NewtonCollisionCalculateAABB (collision, &matrix[0][0],  &boxP0[0], &boxP1[0]);
	// you can pad the box here if you wish
	//boxP0.y -= somevalue;
	//boxP1.y += somevaluef;
	NewtonSetWorldSize (nWorld, (float*)boxP0, (float*)boxP1);
    printf("TUMLE: World resized to fit level\n");

    //release the collision
    NewtonReleaseCollision(nWorld, collision);

    //make the physics node
    IPhysicsNode *pNode = new CPhysicsNode(this, PhysicsNodeCount++, levelNode, body, EBT_LEVEL, 0);

    //set the user date of the body
    NewtonBodySetUserData(body, pNode);

    //put the created node in the array
    CreatedPhysicsNodes.push_back(pNode);

    return pNode;
}
JonLT
Posts: 152
Joined: Thu Mar 15, 2007 5:47 pm
Location: Denmark

Post by JonLT »

Thanks FuzzYspo0N for the update!!! :D

I've cleaned a little up in the directory, updated the doc, and made it a little more linux friendly.

The things fixed is the thing with the event receiver, and the thing with the SMaterial class.
Is that right fuzzy?
FuzzYspo0N
Posts: 914
Joined: Fri Aug 03, 2007 12:43 pm
Location: South Africa
Contact:

Post by FuzzYspo0N »

The event reciever was fixed, the examples were updated(sadly i was dumb enough to make some of the paths static to my folder. lol ,

also the texures[0] -> texturelayer[0].texture thing (Smaterial as stated) was resolved too.
You need to check the vertex type and convert the pointer like this:
thats right raymond thanks for the input, i am updating this into the fixes as well, as well as some changes concerning the materials (ie, presets, wood,water, sand, grass,road) etc...
Do you have plans for (simple) vehicles support.
by the way,

Controllable Physics Node -> its in the tumle classes, its a "simple" vehicle. Depending on the types of materials u assign the floor and the wheels it works really well. Have a look at the examples.

JonLT : I am not nhijacking your project :) im adding some stuff i hope thats ok, Ill catch u on msn soon and explain some changes and additions im working on, some including ragdoll, vehicles (auto managed through model tags, ie : wheel1 in the mesh is seperate but automatically gets made into a wheel etc)

This isnt really a priority its just a really neat physics wrapper...
:)
offmonreal
Posts: 6
Joined: Sat Feb 09, 2008 7:12 am
Contact:

Many thanks to authors!

Post by offmonreal »

Code Tumple is very well designed
Many thanks to authors! :D

Who example for the automobile can will show? :shock:

Thanks beforehand! :D
The user not speaking GOOD on EN
FuzzYspo0N
Posts: 914
Joined: Fri Aug 03, 2007 12:43 pm
Location: South Africa
Contact:

Post by FuzzYspo0N »

To all the tumle users :

There was some really interesting problems with tumle, ALOT of which i have corrected with PinguinDude, he has been helping huge amounts(seeing as my focus is elsewhere atm),

but as soon as i finish a stable version, i will re release it under jonlt's permission (already consented)
rahul
Posts: 5
Joined: Fri Feb 22, 2008 4:47 pm

Post by rahul »

hi PinguinDude and fuzzyspoon i was using tokamak when tumbled upon tumle for my project. Any :D chance you are gonna do a quick latest release (not final build but a bug-fix build) ? :lol: :roll:


thank you once again for all hard work u guys are putting in. :)
FuzzYspo0N
Posts: 914
Joined: Fri Aug 03, 2007 12:43 pm
Location: South Africa
Contact:

Post by FuzzYspo0N »

Pinguin Dude isnt working on this haha :) he is just helping me.

I will see what i can do in terms of a quick release ;:)
rahul
Posts: 5
Joined: Fri Feb 22, 2008 4:47 pm

Post by rahul »

woow fuzzy that was really fast reply. I thought u guys must be so busy that you take a few days time... thank u thank u for the reply...

I will wait eagerly for the bug-fix release. :D :lol:
Post Reply