Archived

This topic is now archived and is closed to further replies.

Nibbles

Probably a very simple problem

Recommended Posts

Nibbles    569
hi, I''m working on a camera and I can''t get this to work:
  
void Init_Camera(CCamera Camera)
{
	CVector PositionVectorTemp =	{ 0.0f, 0.0f, 0.0f };
	CVector UpVectorTemp =			{ 0.0f, 1.0f, 0.0f };
	CVector ViewVectorTemp =		{ 0.0f, 0.0f, 1.0f };

	Camera.PositionVector = PositionVectorTemp;
	Camera.UpVector = UpVectorTemp;
	Camera.ViewVector = ViewVectorTemp;
}
  
getting Camera.PositionVector (or any other one), doesn''t get the data from PositionVectorTemp (or any other). Was wondering why. Thanks, Scott Email Website
"If you try and don''t succeed, destroy all evidence that you tried."

Share this post


Link to post
Share on other sites
Nibbles    569
nevermind... i solved it.

simply changing

  
void Init_Camera(CCamera Camera)

to

  
void Init_Camera(CCamera &Camera)


did the trick, but I really don''t know why...

Scott

Email
Website

"If you try and don''t succeed, destroy all evidence that you tried."

Share this post


Link to post
Share on other sites
Stoffel    250
Because your original version is "pass by value", meaning a new camera is copied from your argument and passed to the function. The second version is "pass by reference", where the actual argument is passed into the function. Without using "*" or "&" on your arguments, they are all passed by value.

Share this post


Link to post
Share on other sites