Access violation reading location

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
liger13
Posts: 119
Joined: Tue Jul 18, 2006 4:17 am

Access violation reading location

Post by liger13 »

okay, get this wierd runtime error that says:
Unhandled exception at 0x6f6c6f43 in IntraFusion.exe: 0xC0000005: Access violation reading location 0x6f6c6f43.
and i think it has something todo with this:
http://blogs.msdn.com/chappell/archive/ ... 51856.aspx
but i cant really understand it.

okay. i create a camera in my player class and add a gun mesh as a child to it with this:

Code: Select all

	IAnimatedMesh* gun_mesh = device->getSceneManager()->getMesh("media/models/Gun.obj");
	gun_node = device->getSceneManager()->addAnimatedMeshSceneNode(gun_mesh, camera, -1, core::vector3df(1,-1,2),
																	core::vector3df(0,266,0));
	if (gun_node)
	{
		gun_node->setMaterialFlag(EMF_LIGHTING, false);
		gun_node->setMaterialTexture(0, device->getVideoDriver()->getTexture("Media/Textures/Gun.bmp"));
	}
i then try to change its position from my gameRun class with this line:

Code: Select all

player1->getCamera()->setPosition(core::vector3df(-30,10,4));
it doesnt error if i comment out adding the gun to the camera.
but i get the error. Does anyone understand this?

if i need to supply more lines of my code just ask.
JonLT
Posts: 152
Joined: Thu Mar 15, 2007 5:47 pm
Location: Denmark

Post by JonLT »

I can't find your problem, but this is what i did and it worked:

Code: Select all

     gunNode->remove();
     if(gunType == RIFLE)
     {
     gunNode = smgr->addAnimatedMeshSceneNode(smgr->getMesh("meshes/rifle.3ds"), cam.getNode());
     gunNode->setPosition(vector3df(50,-30,40));
     gunNode->setRotation(vector3df(20,-110,-20));
     currentGun = RIFLE;
     }
I have the camera and the gun in different classes, you shouldn't have to though.
The above code is run, when the player chance gun. I remove the old gun, and add a new one.
I know this isn't quite what you looked for, but it might help anyways? :roll:
liger13
Posts: 119
Joined: Tue Jul 18, 2006 4:17 am

Post by liger13 »

im guessing cam is a different class that holds a CamerSceneNode.

i dont see how that makes any difference for i do pretty much the exact same thing in my code...

the error only happens when i try to acces the camera and have the gun connected to it.

it might have todo with other crashes ive been having sense i moved over to 1.3, i might have to rethink my structure and change some stuff.
Marek
Posts: 12
Joined: Sat Mar 31, 2007 7:34 pm

Post by Marek »

Generally, that error only occurres when you try to acess memory at a point where you did not use "new" at. Or often if the memory space has been NULLed out or in use by another part of your code. I gave your code a really quick run down, and didn't see anything that jumped out at me as wrong. But, what could easily be done is adding an ofstream object to the code, and putting in a debug statement every 3 lines of code where the suspected error is, and that'll help to pinpoint the spot. Again, it just seems like it's trying to refrence memory that hasn't been allocated yet, but that's just my experiance with MingW compiled applications.
-- Marc
Chaos Studios: Lead Programmer
liger13
Posts: 119
Joined: Tue Jul 18, 2006 4:17 am

Post by liger13 »

sense i have a gun class i decided to move the node it it then set the parent of the node via the player class with:

Code: Select all

gun->setNodeParent(camera);
the setNodeParent method:

Code: Select all

void Gun::setNodeParent(irr::scene::ISceneNode *n)
{
	gun_node->setParent(n);
}
and i now the the error on the gun_node->setParent(n); line.

im not sure how im supposed to use the "new" word when im doing this:

Code: Select all

	gun_node = device->getSceneManager()->addAnimatedMeshSceneNode(device->getSceneManager()->getMesh(
															"media/models/Gun.obj"), 
															0, -1, core::vector3df(1,-1,2),
															core::vector3df(0,266,0));
Post Reply