Skip to main content
gamedev.net
🔒 Locked

Deleting Selected Object

Started by muimui1911 Jan 26, 2006 at 7:29 AM 0 replies 600+ views
Original Post
muimui1911
muimui1911
hello everyone: I would like to load the object in and delete it freely. e.g. Load the object by File->Load (which i have already done) and then the other things is to delete the selected object. could anyone help me or give me some hints on how to delete the object in memory. all the loaded objects are stored in "vector vObjects".

C3dsLoader obj3dsLoader;
vector<C3dsLoader> vObjects;


//when loading object, this will load the objects geometry into vObjects.
ZeroMemory(szPath, 200);
GetWindowsDirectory(szPath, 200);

if(!GetFilename(szPath))
return 0 ;
else
{
vObjects.push_back( obj3dsLoader );
vObjects[vObjects.size()-1].Init_3ds(szPath);
Load = TRUE;
}
break;

//When I draw the objects out in render scene

	if(load)
	{ 
		for ( int i =0 ; i< vObjects.size(); i++ )
		{
			if (mode == GL_SELECT) 
			{
				glPushName(i);
				vObjects.Render_3ds();
				glPopName();
	
			}
			else
				if(mode == GL_RENDER)
				vObjects.Render_3ds();
		}
	}


Millions of thanks
Supernat02
Supernat02
You can't release the memory for the original C3dsLoader object obj3dsLoader. Since the vector creates a copy of that object, you would just use the vector to erase that copy. I believe it's vObjects.erase(index) or vObjects.delete(index). The proper function call escapes me at the moment.

Good luck,
Chris
Chris ByersMicrosoft DirectX MVP - 2005

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.