Vegastrike 0.5.1 rc1  1.0
Original sources for Vegastrike Evolved
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Prediction Class Referenceabstract

#include <prediction.h>

Inheritance diagram for Prediction:
CubicSplinePrediction LinearPrediction NullPrediction MixedPrediction MixedPrediction

Public Member Functions

 Prediction ()
 
virtual ~Prediction ()
 
virtual void InitInterpolation (Unit *un, const ClientState &last_packet_state, double elapsed_since_last_packet, double deltatime)
 
virtual QVector InterpolatePosition (Unit *un, double deltatime) const =0
 
virtual Quaternion InterpolateOrientation (Unit *un, double deltatime) const =0
 
virtual Transformation Interpolate (Unit *un, double deltatime) const
 

Protected Attributes

QVector A0
 
QVector B
 
QVector A1
 
QVector A2
 
QVector A3
 
Vector VA
 
Vector VB
 
Vector AA
 
Vector AB
 
Quaternion OA
 
Quaternion OB
 
double deltatime
 

Detailed Description

Definition at line 10 of file prediction.h.

Constructor & Destructor Documentation

Prediction::Prediction ( )

Definition at line 12 of file prediction.cpp.

References deltatime.

12  :
13  A0( 0, 0, 0 )
14  , B( 0, 0, 0 )
15  , A1( 0, 0, 0 )
16  , A2( 0, 0, 0 )
17  , A3( 0, 0, 0 )
18  , VA( 0, 0, 0 )
19  , VB( 0, 0, 0 )
20  , AA( 0, 0, 0 )
21  , AB( 0, 0, 0 )
22  , OA()
23  , OB()
24 {
25  this->deltatime = 0.0;
26 }
Prediction::~Prediction ( )
virtual

Definition at line 27 of file prediction.cpp.

28 {}

Member Function Documentation

void Prediction::InitInterpolation ( Unit un,
const ClientState last_packet_state,
double  elapsed_since_last_packet,
double  deltatime 
)
virtual

Reimplemented in CubicSplinePrediction, and NullPrediction.

Definition at line 30 of file prediction.cpp.

References A0, A1, A2, A3, AA, AB, B, Unit::curr_physical_state, deltatime, Unit::GetAcceleration(), ClientState::getOrientation(), ClientState::getPosition(), ClientState::getSpecMult(), ClientState::getVelocity(), Unit::graphicOptions, OA, OB, Unit::old_state, Transformation::orientation, Transformation::position, VA, VB, Unit::Velocity, and Unit::graphic_options::WarpFieldStrength.

Referenced by CubicSplinePrediction::InitInterpolation().

34 {
35  //This function is to call after the state have been updated (which should be after receiving a SNAPSHOT)
36 
37  //This function computes 4 splines points needed for a spline creation
38  //- compute a point on the current spline using blend as t value
39  //- parameter A and B are old_position and new_position (received in the latest packet)
40 
41  /************* VA IS TO BE UNCOMMENTED ****************/
42  //Unit * un = clt->game_unit.GetUnit();
43 
44 //NETFIXME: Why cast to int and then back to double?
45 //double delay = (double)(unsigned int)deltatime;
46 
47  double delay = deltatime;
48  this->deltatime = deltatime;
49  //A is last known position and B is the position we just received
50  //A1 is computed from position A and velocity VA
51  A0 = un->old_state.getPosition();
53  OA = un->old_state.getOrientation();
57  if (elapsed_since_last_packet > 0.)
58  AB = (last_packet_state.getVelocity()*last_packet_state.getSpecMult()-VB)
59  /( (float) elapsed_since_last_packet );
60  //cerr<<"lastvel=("<<last_packet_state.getVelocity().i<<",,"<<last_packet_state.getVelocity().k<<")"<<endl;
61  else
62  AB = un->GetAcceleration();
63  AA = AB; //un->old_state.getAcceleration();//no longer supproted :-/ //NETFIXME now we don't have velocity
64 
65  //A1 = old_position + old_velocity * 1 sec
66  A1 = A0+VA;
67  //A3 is computed from position B and velocity VB
68  //A3 = new_position + new_velocity
69  A2 = B+VB*delay+AB*delay*delay*0.5;
70  //A2 is the predicted position
71  //A2 = new_position + new_velocity
72  A3 = A2+(VB+AB*delay);
74  //cerr<<" *** InitInterpolation "<<un->getFullname()<<","<<un->GetSerial()<<" ";
75  //cerr << un->old_state<<", B="<<B.i<<",,"<<B.k<<", VB="<<VB.i<<",,"<<VB.k<<", delay="<<delay<<", ACCEL="<<AB.i<<","<<AB.j<<","<<AB.k<<endl;
76 }
Transformation Prediction::Interpolate ( Unit un,
double  deltatime 
) const
virtual

Reimplemented in MixedPrediction, and LinearPrediction.

Definition at line 78 of file prediction.cpp.

References InterpolateOrientation(), and InterpolatePosition().

79 {
81 }
virtual Quaternion Prediction::InterpolateOrientation ( Unit un,
double  deltatime 
) const
pure virtual
virtual QVector Prediction::InterpolatePosition ( Unit un,
double  deltatime 
) const
pure virtual

Member Data Documentation

QVector Prediction::A0
protected
QVector Prediction::A1
protected

Definition at line 14 of file prediction.h.

Referenced by InitInterpolation(), and CubicSplinePrediction::InitInterpolation().

QVector Prediction::A3
protected

Definition at line 14 of file prediction.h.

Referenced by InitInterpolation(), and CubicSplinePrediction::InitInterpolation().

Vector Prediction::AA
protected

Definition at line 15 of file prediction.h.

Referenced by InitInterpolation().

Vector Prediction::AB
protected

Definition at line 15 of file prediction.h.

Referenced by InitInterpolation().

QVector Prediction::B
protected

Definition at line 14 of file prediction.h.

Referenced by InitInterpolation(), and LinearPrediction::Interpolate().

Quaternion Prediction::OA
protected

Definition at line 16 of file prediction.h.

Referenced by InitInterpolation(), and LinearPrediction::Interpolate().

Vector Prediction::VA
protected

Definition at line 15 of file prediction.h.

Referenced by InitInterpolation().


The documentation for this class was generated from the following files: