- 听众
- 收听
- 积分
- 6397
- 主题
- 回帖
- 0
- 精华
注册时间2006-8-12
最后登录1970-1-1
该用户从未签到
|
楼主 |
发表于 2007-3-15 23:31:00
|
显示全部楼层
<DIV class=quote><B>以下是引用<I>iiN[KzcN]</I>在2007-3-15 23:30:00的发言:</B><BR><RE>/*<BR>==================<BR>M_Friction<BR><BR>Handles both ground friction and water friction<BR>==================<BR>*/<BR>void PM_Friction (void)<BR>{<BR> float *vel;<BR> float speed, newspeed, control;<BR> float friction;<BR> float drop;<BR> vec3_t newvel;<BR> <BR> // If we are in water jump cycle, don't apply friction<BR> if (pmove->waterjumptime)<BR> return;<BR><BR> // Get velocity<BR> vel = pmove->velocity;<BR> <BR> // Calculate speed<BR> speed = sqrt(vel[0]*vel[0] +vel[1]*vel[1] + vel[2]*vel[2]);<BR> <BR> // If too slow, return<BR> if (speed < 0.1f)<BR> {<BR> return;<BR> }<BR><BR> drop = 0;<BR><BR>// apply ground friction<BR> if (pmove->onground != -1) // On an entity that is the ground<BR> {<BR> vec3_t start, stop;<BR> pmtrace_t trace;<BR><BR> start[0] = stop[0] = pmove->origin[0] + vel[0]/speed*16;<BR> start[1] = stop[1] = pmove->origin[1] + vel[1]/speed*16;<BR> start[2] = pmove->origin[2] + pmove->player_mins[pmove->usehull][2];<BR> stop[2] = start[2] - 34;<BR><BR> trace = pmove->M_PlayerTrace (start, stop, PM_NORMAL, -1 );<BR><BR> if (trace.fraction == 1.0)<BR> friction = pmove->movevars->friction*pmove->movevars->edgefriction;<BR> else<BR> friction = pmove->movevars->friction;<BR> <BR> // Grab friction value.<BR> //friction = pmove->movevars->friction; <BR><BR> friction *= pmove->friction; // player friction?<BR><BR> // Bleed off some speed, but if we have less than the bleed<BR> // threshhold, bleed the theshold amount.<BR> control = (speed < pmove->movevars->stopspeed) ?<BR> pmove->movevars->stopspeed : speed;<BR> // Add the amount to t'he drop amount.<BR> drop += control*friction*pmove->frametime;<BR> }<BR><BR>// apply water friction<BR>// if (pmove->waterlevel)<BR>// drop += speed * pmove->movevars->waterfriction * waterlevel * pmove->frametime;<BR><BR>// scale the velocity<BR> newspeed = speed - drop;<BR> if (newspeed < 0)<BR> newspeed = 0;<BR><BR> // Determine proportion of old speed we are using.<BR> newspeed /= speed;<BR><BR> // Adjust velocity according to proportion.<BR> newvel[0] = vel[0] * newspeed;<BR> newvel[1] = vel[1] * newspeed;<BR> newvel[2] = vel[2] * newspeed;<BR><BR> VectorCopy( newvel, pmove->velocity );<BR>}<BR></PRE></DIV>
<P>
<P>好东西 ,,,,</P>
<P>不懂到底什么意思...</P> |
|