Jump to content

CameraPick error


SpiderPig
 Share

Recommended Posts

Hi,

 

CameraPick() is givening me the following error;

 

"Unhandled exception at 0x752c9b60 in game-Release.exe: 0xC0000005: Access violation writing location 0x00000000."

 

and then it goes to this line in "Disassembly";

 

"752C9B60 rep movs dword ptr es:[edi],dword ptr [esi] "

 

This is my code;

 

TPick* pick

while( !KeyHit() && !AppTerminate() )
{
	if( !AppSuspended() ) // We are not in focus!
	{

		if(MouseHit(1))
		{
		if(CameraPick(pick,camera,Vec3(MouseX(),MouseY(),100),2,0,0))
		{
			EntityColor(pick->entity,Vec4(0,1,0,0));
		};
		};


		UpdatePlayer();

	                UpdateAppTime();
		UpdateWorld(AppSpeed()) ;

		// Render
		SetBuffer(gbuffer);
		RenderWorld();

		SetBuffer(BackBuffer());
		RenderLights(gbuffer);//ComputerTexture=GetColorBuffer(BackBuffer(),1);

		Flip(1) ;
	}
}

 

I tried it without setting the color of the picked entity or a mouse check but it still crashed.

What am I missing?

Link to comment
Share on other sites

Haha, Just figured it out once I posted it...

 

I had to do;

 

TPick pick

 

instead of;

 

TPick* pick

 

and call on it like so;

 

if(MouseHit(1))
		{
		if(CameraPick(&pick,camera,Vec3(MouseX(),MouseY(),100),2,0,0))
		{
				EntityColor(pick.entity,Vec4(0,1,0,0));
		};
		};

 

Well, hope this helps someone else :)

 

Though how do I check which entity I'm picking in order to change the color of only that entity? The following code didn't work for me;

 

		if(MouseHit(1))
		{
		if(CameraPick(&pick,camera,Vec3(MouseX(),MouseY(),100),2,0,0))
		{
			if(pick.entity==cube)
			{
				EntityColor(pick.entity,Vec4(0,1,0,0));
			};
		};
		};

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...