and I’ll just throw in my notes for the sector where he starts with the 2D stuff because I had to do a lot of learning on the side to get what he is doing.
I’ll just mention that I didn’t just do all his assignments from beginning to where I am now. I don’t think that will be the best way to learn for a lot of people. I mean I did a lot of reading and figuring it all out. Then trying the code out and a bit of fiddling with it to understand it better. Also for each assignment I at least tried to see if I could piece together in my head where all the new stuff would fit in as he puts out of order code pieces for to make you think. Really though I am always focusing being able to apply this knowledge to my own games, which requires the 2D tutorials more than anything, the others are needed to ramp up and understand his thought process.
The next thing is that he starts doing server client stuff and I don’t want to get into all that right now. So that is where I have decided to just recreate his assignments but without the client server stuff. So I had to figureout what was important and what wasn’t. Next is the actual phsyics stuff which has taken some reading online to figure out. So these notes are what I have so far for tutorial 10.
# So I realize that this tutorial is teaching a whole
# lot of physics. So I want to make basically a list
# or summary of the concepts that I would need to have
# on hand to be able to make one of these without the
# help of at least this tutorial, or at least to understand
# it to that extent.
# The hard stuff really comes from the collisions
# for each puck to puck collision:
# we create a tangent AXIS vector point and same for normal
# we get a point that is paralell to the normal
# by subtracking the two radiuses which yealds
# a third with a diff magnitude but same direction
# then to get the tangent to that, we shift the x and y of
# the normal point by 90 which uses cos and sin angle addition
# but really it’s just -y,x because that is for 90 degrees on
# the unit circle.
# we check for collisions
# if the distance between radiuses is less than the sum of two
# radius magnitudes(Like from center to edge of circle)
# then we know the circles overlap
# SUM OF SQUARED DIFFERENCES of radius
# we take squared differences of the x values and squared
# differences of the y values, and add those, and then compare
# against a squared sum of the radius magnitudes, to avoid using
# square root whcih is slow
# That is the easy part….
# Then we need tangential and normal velocity for both objects
# so we use projection of a velocity vector(with x and y) onto
# the tan and norm axis vector points for each ship.
# then we subtract objectnormvel from hitobjectnormvel to get
# a relative velocity, I guess that means it will know which
# velocity was stronger for the x and y directions.
# it will be the resulting velocity for two velocities that collided?
# even if hitobject had vel of 8 and object had vel 7
# 8-7 = 1 small positive over all velocity.
# CORRECTING FOR PENETRATION
# ALL OF THIS SECTION WILL USE THE NORMAL VELOCITY
# AND NORMAL SPEED
# first we need speed for some reason
# speed is scalar and direction unaware
# velocity is a vector, x and y, so direction aware
# also displacement aware
# relative normal speed is the length of the vector of relative norm vel.
# then we CALCULATE THE PENETRATION:
# sum of radiuses(magnitudes) – (sqrt(sum of squared diff of radiuses))
# so if sum of radiuses is 40 + 40 = 80
# and the difference between the positions of the two is only 2
# then the penetradion is 78 which iunno, I guess that might work
#although it seems like double?
#there is an condition that speed has to be faster that 0.000001
# then calc penetration time as penetration/speed
# ?? why not use velocity here? Maybe because with penetration
# it’s all about magnitude?
# he adds in a penetration time scalar which I think allows us to increase
# how much we back up penetration by.
# then back both the objects up to when they just hit, before penetration
# their new positions calculated by…
# object position – (object norm vel * penetration time * pentimescalar)
# hitobject position – (object norm vel * penetration time * pentimescalar)
# then calculate the new velocities for each object
# by sending them both to AandBnormal
# then calculate the new positions based on the new velocities and
# again the penetration time
#ASSIGNING FINAL VELOCITIES
# again we have the coefficient of resitution
#send object velocites again to AandBnormal to get normal velocities
# set normal vels to equal the calced normalaftervels
# Then we ADD THE NORMAL AND TANGETIAL VELOCITY VECTORS TOGETHER
# AND THIS IS THEN NEW VELOCITY
# do this for each object