Newton2 + Irrlicht 1.6 + irrEdit

Post your questions, suggestions and experiences regarding game design, integration of external libraries here. For irrEdit, irrXML and irrKlang, see the
ambiera forums
Post Reply
NioZero
Posts: 7
Joined: Tue Nov 17, 2009 1:04 am
Location: Concepción, Chile
Contact:

Newton2 + Irrlicht 1.6 + irrEdit

Post by NioZero »

hello..

I'm working in a project and i need to create a complete newton physic scene from a .irr file created by irrEdit ... I was able to extract each node from the scene, but "ISceneNode::getMesh()" is not working anymore (in earlier versions of Irrlicht was present if I am right)

I tried some examples, but many are outdated (although the examples work fine with old functions, but does not help

the code is something like this...

Code: Select all

AppSceneManager->loadScene("level.irr");

core::array<scene::ISceneNode *> nodes;
AppSceneManager->getSceneNodesFromType(scene::ESNT_ANY, nodes);

for (u32 i=0; i < nodes.size(); ++i){

	scene::ISceneNode * node = nodes[i];
	
	NewtonCollision* nmapcollision = NewtonCreateTreeCollision(AppWorld, NULL);
	NewtonTreeCollisionBeginBuild(nmapcollision);
	
	// This throws the following error in VisualStudio 2008
	// error C2039: 'getMesh' : is not a member of 'irr::scene::ISceneNode'
	scene::IMesh *mesh = node->getMesh();
	
	for(u32 cMeshBuffer=0; cMeshBuffer<mesh->getMeshBufferCount(); cMeshBuffer++){
	
		mb = mesh->getMeshBuffer(cMeshBuffer);
		S3DVertex2TCoords* mb_vertices = (S3DVertex2TCoords*)mb->getVertices();
		u16* mb_indices  = mb->getIndices();
		
		// add each triangle from the mesh
		for (j=0; j<mb->getIndexCount(); j+=3){
			// ...
		}
	}
	
	NewtonTreeCollisionEndBuild(nmapcollision, 0);
	NewtonBody* nmapbody = NewtonCreateBody(AppWorld, nmapcollision);
}
if anyone knows a better way to load a .irr scene in newton, or a tutorial for irrlicht1.6 + newton2 will be helpful..
Image
Image
Lonesome Ducky
Competition winner
Posts: 1123
Joined: Sun Jun 10, 2007 11:14 pm

Post by Lonesome Ducky »

Did ISceneNode ever have getMesh()? Try getting all scene nodes of mesh scene node, animated mesh scene node, and so on and then cast the ISceneNode pointer to that type to use getMesh()
Alpha Omega
Posts: 288
Joined: Wed Oct 29, 2008 12:07 pm

Post by Alpha Omega »

Did you ever call NewtonTreeCollisionAddFace() in your code? Doesn't look like it.
NioZero
Posts: 7
Joined: Tue Nov 17, 2009 1:04 am
Location: Concepción, Chile
Contact:

Post by NioZero »

Alpha Omega wrote:Did you ever call NewtonTreeCollisionAddFace() in your code? Doesn't look like it.
I've only put the relevant code in the quote... the real code is much larger

Lonesome Ducky wrote:Did ISceneNode ever have getMesh()? Try getting all scene nodes of mesh scene node, animated mesh scene node, and so on and then cast the ISceneNode pointer to that type to use getMesh()
no, I want a method that can extract the mesh from any node... not only from a mesh scene or animated node... if can not do that, then I'll just go that way.





Does anyone know a page with tutorials for the latest version of Irrlicht?
Image
Image
ledgarl
Posts: 30
Joined: Wed Oct 25, 2006 1:58 pm
Location: Bogota,Colombia

Post by ledgarl »

use this:

AppSceneManager->loadScene("level.irr");

core::array<scene::ISceneNode *> nodes;
AppSceneManager->getSceneNodesFromType(scene::ESNT_ANY, nodes);
For (u32 i=0; i < nodes.size(); ++i){


scene::ISceneNode * node = nodes;


...
scene::IAnimatedMesh* aMesh;
io::IAttributes* attributes = FileSystem->createEmptyAttributes(driver);
node->serializeAttributes(attributes);
int indexAttrib = attributes->findAttribute("Mesh");

c8 name[100];
attributes->getAttributeAsString("Mesh",name);

aMesh = AppSceneManager->getMesh(name);
scene::IMesh *mesh = levelMesh->getMesh(0);


for(u32 cMeshBuffer=0; cMeshBuffer<mesh->getMeshBufferCount(); cMeshBuffer++){

mb = mesh->getMesh(0)->getMeshBuffer(cMeshBuffer);

...
Post Reply