lesson 30 variable clarification

Started by
17 comments, last by Tera_Dragon 19 years, 6 months ago
Simple, don't.
Since particles normaly don't have any contrast or sharp edges like regular polygons do, you will be ok with just updating it only 20 or so times a second without any type of interpolation.

as for objects and so on, well if your computer is choking on a couple of kilobytes(unless you have thousands and thousands of objects), Get another computer.

If it still chokes, then you really don't have to interpolate everything, infact if you only want to interpolate one thing, then do it to the camera.
Advertisement
I finally finished writing up the tutorial, and got about 1000 errors (I'm not using the classes that the guy who wrote these tutorials is). I got round to fixing all of these, but then when I ran it it seemed to get stuck in the idle function. So I changed one line of code (not sure if it's the problem though) and get an error. Here's the code:
Vector3 pb1,pb2,xaxis....//changed from:xaxis=(pb2-pb1);xaxis.normalize();//toxaxis=(pb2-pb1).normalize();// Here's the normalise code:void Vector3::normalize(){	float magSq = x*x + y*y + z*z;	if(magSq > 0.0f)	// check for divide by zero	{		float oneOverMag = 1.0f / sqrt(magSq);		x *= oneOverMag;		y *= oneOverMag;		z *= oneOverMag;	}}

And This is the error:
error C2679: binary '=' : no operator defined which takes a right-hand operand of type 'void' (or there is no acceptable conversion)

Any ideas?
____________________________________________________________Programmers Resource Central
The problem is exactly what the compiler is telling you. The member function 'normalise' modifies the object it operates on and returns nothing. I'll walk you through the code as the compiler sees it:
(pb2-pb1) : call operator-(pb2, pb1) and store the result in a temporary.
xaxis=(temp).normalize() : call normalize() on the temporary just created and store what is returned from normalize() in xaxis. Error: normalize() does not return anything.
What the original code does is:
(pb2-pb1) : call operator-(pb2, pb1) and store the result in a temporary.
xaxis=(temp) : copy temp into xaxis.
xaxis.normalize() : call normalize() on xaxis.

Hope that's clear enough.

Enigma
Errm, but still, why doesn't it work?
____________________________________________________________Programmers Resource Central
It might be clearer if I rewrite it as it would be in pure C.
Your way:
xaxis=normalize(pb2-pb1);
Correct way:
xaxis=pb2-pb1;
normalize(xaxis);

The member function normalize() normalizes its argument and returns nothing. When you try to do xaxis=normalize(pb2-pb1) it normalizes the temporary created by subtracting pb1 from pb2 and returns nothing to be assigned to xaxis.

Assume that we're working with 2D vectors and pb1 = {1, 0} and pb2 = {1, 2}.

Your way:
pb2-pb1 : creates a temporary with value {0, 2}.
normalize(temp) : normalizes the temporary to {0, 1} and returns nothing.
xaxis=void : this is an error.

Correct way:
pb2-pb1 : creates a temporary with value {0, 2};
xaxis=temp : copies the temporary to xaxis, leaving xaxis with value {0, 2};
normalize(xaxis) : normalizes xaxis to {0, 1} and returns nothing.

Enigma

EDIT: A couple of typos.

[Edited by - Enigma on October 4, 2004 6:34:00 AM]
Ah I see now. Sorry about that. :-/
____________________________________________________________Programmers Resource Central
w00t!!!! Found my problem, it had nothing to do with that or whatever I thought it could be. I was so certain I had done everything correct. Turns out I had missed a brace ( } ) somewhere and must have just thought it went onto the end of the idle function, this is what was causing my loops to screw up. Thanks for all the help :-D
____________________________________________________________Programmers Resource Central
Something is not working right. When I ncrease the size of the balls to 4 instead of 2 (I correct the double radius in the ball against ball collision detection to 8) the balls collide incorrectly with planes. I hav to minus 2 to the folowing line of code:
l2 = (plane._Normal * (plane._Position - position))/DotProduct;

So it becomes:
l2 = (plane._Normal * (plane._Position - position))/DotProduct - 2;


I can understand this, but isn't anything like this needed for the bals of size 2?

Tera_Dragon


Edit: I just found out that minusing 2 can cause errors, and make the ball able to slip passed the plane. What is the correct way to work out the point of collision for larger spheres please?
____________________________________________________________Programmers Resource Central
Anyone? Please.
____________________________________________________________Programmers Resource Central

This topic is closed to new replies.

Advertisement