mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 02:15:43 -04:00
new files
This commit is contained in:
parent
2e724b5e4d
commit
35308b683e
15
direct/src/deadrec/Sources.pp
Normal file
15
direct/src/deadrec/Sources.pp
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
#begin lib_target
|
||||||
|
#define TARGET deadrec
|
||||||
|
|
||||||
|
#define SOURCES \
|
||||||
|
correction.cxx prediction.cxx
|
||||||
|
|
||||||
|
#define INSTALL_HEADERS \
|
||||||
|
correction.h prediction.h
|
||||||
|
|
||||||
|
#define IGATESCAN \
|
||||||
|
correction.h prediction.h
|
||||||
|
|
||||||
|
#define LOCAL_LIBS \
|
||||||
|
directbase
|
||||||
|
#end lib_target
|
126
direct/src/deadrec/correction.cxx
Normal file
126
direct/src/deadrec/correction.cxx
Normal file
@ -0,0 +1,126 @@
|
|||||||
|
// Filename: correction.cxx
|
||||||
|
// Created by: cary (20Dec00)
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#include "correction.h"
|
||||||
|
#include <clockObject.h>
|
||||||
|
|
||||||
|
Correction::Correction(LPoint3f& start, LVector3f& s_vel) : _curr_p(start),
|
||||||
|
_curr_v(s_vel) {
|
||||||
|
}
|
||||||
|
|
||||||
|
Correction::~Correction(void) {
|
||||||
|
}
|
||||||
|
|
||||||
|
void Correction::step(void) {
|
||||||
|
}
|
||||||
|
|
||||||
|
void Correction::new_target(LPoint3f&, LVector3f&) {
|
||||||
|
}
|
||||||
|
|
||||||
|
LPoint3f Correction::get_pos(void) const {
|
||||||
|
return _curr_p;
|
||||||
|
}
|
||||||
|
|
||||||
|
LVector3f Correction::get_vel(void) const {
|
||||||
|
return _curr_v;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
PopCorrection::PopCorrection(LPoint3f& start, LVector3f& s_vel)
|
||||||
|
: Correction(start, s_vel) {
|
||||||
|
}
|
||||||
|
|
||||||
|
PopCorrection::~PopCorrection(void) {
|
||||||
|
}
|
||||||
|
|
||||||
|
void PopCorrection::step(void) {
|
||||||
|
}
|
||||||
|
|
||||||
|
void PopCorrection::new_target(LPoint3f& target, LVector3f&) {
|
||||||
|
_curr_p = target;
|
||||||
|
}
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
LerpCorrection::LerpCorrection(LPoint3f& start, LVector3f& s_vel)
|
||||||
|
: Correction(start, s_vel), prev_p(start), save_p(start), have_both(false),
|
||||||
|
time(0.) {
|
||||||
|
}
|
||||||
|
|
||||||
|
LerpCorrection::~LerpCorrection(void) {
|
||||||
|
}
|
||||||
|
|
||||||
|
void LerpCorrection::step(void) {
|
||||||
|
if (have_both) {
|
||||||
|
if (time < 0.5) {
|
||||||
|
// half second lerp
|
||||||
|
float tmp = time * 2.;
|
||||||
|
LVector3f vtmp = save_p - prev_p;
|
||||||
|
_curr_p = (tmp * vtmp) + prev_p;
|
||||||
|
time += ClockObject::get_global_clock()->get_dt();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void LerpCorrection::new_target(LPoint3f& target, LVector3f&) {
|
||||||
|
if (have_both) {
|
||||||
|
time = 0.;
|
||||||
|
prev_p = _curr_p;
|
||||||
|
save_p = target;
|
||||||
|
} else {
|
||||||
|
save_p = target;
|
||||||
|
_curr_p = prev_p;
|
||||||
|
time = 0.;
|
||||||
|
have_both = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
SplineCorrection::SplineCorrection(LPoint3f& start, LVector3f& s_vel)
|
||||||
|
: Correction(start, s_vel), have_both(false), prev_p(start), save_p(start),
|
||||||
|
prev_v(s_vel), save_v(s_vel), time(0.) {
|
||||||
|
}
|
||||||
|
|
||||||
|
SplineCorrection::~SplineCorrection(void) {
|
||||||
|
}
|
||||||
|
|
||||||
|
void SplineCorrection::step(void) {
|
||||||
|
if (have_both) {
|
||||||
|
if (time < 0.5) {
|
||||||
|
// half second lerp
|
||||||
|
float tmp = time * 2.;
|
||||||
|
_curr_p = (tmp * tmp * tmp * A) + (tmp * tmp * B) + (tmp * C) + D;
|
||||||
|
_curr_v = (3. * tmp * tmp * A) + (2. * tmp * B) + C;
|
||||||
|
time += ClockObject::get_global_clock()->get_dt();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SplineCorrection::new_target(LPoint3f& target, LVector3f& v_target) {
|
||||||
|
if (have_both) {
|
||||||
|
time = 0.;
|
||||||
|
prev_p = _curr_p;
|
||||||
|
prev_v = _curr_v;
|
||||||
|
save_p = target;
|
||||||
|
save_v = v_target;
|
||||||
|
A = (2. * (prev_p - save_p)) + prev_v + save_v;
|
||||||
|
B = (3. * (save_p - prev_p)) - (2. * prev_v) - save_v;
|
||||||
|
C = prev_v;
|
||||||
|
D = prev_p;
|
||||||
|
} else {
|
||||||
|
save_p = target;
|
||||||
|
save_v = v_target;
|
||||||
|
_curr_p = prev_p;
|
||||||
|
_curr_v = prev_v;
|
||||||
|
time = 0.;
|
||||||
|
A = (2. * (prev_p - save_p)) + prev_v + save_v;
|
||||||
|
B = (3. * (save_p - prev_p)) - (2. * prev_v) - save_v;
|
||||||
|
C = prev_v;
|
||||||
|
D = prev_p;
|
||||||
|
have_both = true;
|
||||||
|
}
|
||||||
|
}
|
64
direct/src/deadrec/correction.h
Normal file
64
direct/src/deadrec/correction.h
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
// Filename: correction.h
|
||||||
|
// Created by: cary (20Dec00)
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#ifndef __CORRECTION_H__
|
||||||
|
#define __CORRECTION_H__
|
||||||
|
|
||||||
|
#include <directbase.h>
|
||||||
|
#include <luse.h>
|
||||||
|
|
||||||
|
class Correction {
|
||||||
|
protected:
|
||||||
|
LPoint3f _curr_p;
|
||||||
|
LVector3f _curr_v;
|
||||||
|
PUBLISHED:
|
||||||
|
Correction(LPoint3f&, LVector3f&);
|
||||||
|
virtual ~Correction(void);
|
||||||
|
|
||||||
|
virtual void step(void);
|
||||||
|
virtual void new_target(LPoint3f&, LVector3f&);
|
||||||
|
|
||||||
|
LPoint3f get_pos(void) const;
|
||||||
|
LVector3f get_vel(void) const;
|
||||||
|
};
|
||||||
|
|
||||||
|
class PopCorrection : public Correction {
|
||||||
|
PUBLISHED:
|
||||||
|
PopCorrection(LPoint3f&, LVector3f&);
|
||||||
|
virtual ~PopCorrection(void);
|
||||||
|
|
||||||
|
virtual void step(void);
|
||||||
|
virtual void new_target(LPoint3f&, LVector3f&);
|
||||||
|
};
|
||||||
|
|
||||||
|
class LerpCorrection : public Correction {
|
||||||
|
private:
|
||||||
|
LPoint3f prev_p, save_p;
|
||||||
|
bool have_both;
|
||||||
|
float time;
|
||||||
|
PUBLISHED:
|
||||||
|
LerpCorrection(LPoint3f&, LVector3f&);
|
||||||
|
virtual ~LerpCorrection(void);
|
||||||
|
|
||||||
|
virtual void step(void);
|
||||||
|
virtual void new_target(LPoint3f&, LVector3f&);
|
||||||
|
};
|
||||||
|
|
||||||
|
class SplineCorrection : public Correction {
|
||||||
|
private:
|
||||||
|
LPoint3f A, B, C, D;
|
||||||
|
bool have_both;
|
||||||
|
LPoint3f prev_p, save_p;
|
||||||
|
LVector3f prev_v, save_v;
|
||||||
|
float time;
|
||||||
|
PUBLISHED:
|
||||||
|
SplineCorrection(LPoint3f&, LVector3f&);
|
||||||
|
virtual ~SplineCorrection(void);
|
||||||
|
|
||||||
|
virtual void step(void);
|
||||||
|
virtual void new_target(LPoint3f&, LVector3f&);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* __CORRECTION_H__ */
|
57
direct/src/deadrec/prediction.cxx
Normal file
57
direct/src/deadrec/prediction.cxx
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
// Filename: prediction.cxx
|
||||||
|
// Created by: cary (20Dec00)
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#include "prediction.h"
|
||||||
|
|
||||||
|
Prediction::Prediction(LPoint3f& start) : _curr_p(start), _curr_v(0., 0., 0.) {
|
||||||
|
}
|
||||||
|
|
||||||
|
Prediction::~Prediction(void) {
|
||||||
|
}
|
||||||
|
|
||||||
|
void Prediction::step(void) {
|
||||||
|
}
|
||||||
|
|
||||||
|
void Prediction::new_telemetry(LPoint3f& t_pos) {
|
||||||
|
}
|
||||||
|
|
||||||
|
LPoint3f Prediction::get_pos(void) const {
|
||||||
|
return _curr_p;
|
||||||
|
}
|
||||||
|
|
||||||
|
LVector3f Prediction::get_vel(void) const {
|
||||||
|
return _curr_v;
|
||||||
|
}
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
NullPrediction::NullPrediction(LPoint3f& start) : Prediction(start) {
|
||||||
|
}
|
||||||
|
|
||||||
|
NullPrediction::~NullPrediction(void) {
|
||||||
|
}
|
||||||
|
|
||||||
|
void NullPrediction::step(void) {
|
||||||
|
}
|
||||||
|
|
||||||
|
void NullPrediction::new_telemetry(LPoint3f& t_pos) {
|
||||||
|
// _curr_v = _curr_p - t_pos;
|
||||||
|
_curr_v = t_pos - _curr_p;
|
||||||
|
_curr_p = t_pos;
|
||||||
|
}
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
LinearPrediction::LinearPrediction(LPoint3f& start) : Prediction(start) {
|
||||||
|
}
|
||||||
|
|
||||||
|
LinearPrediction::~LinearPrediction(void) {
|
||||||
|
}
|
||||||
|
|
||||||
|
void LinearPrediction::step(void) {
|
||||||
|
}
|
||||||
|
|
||||||
|
void LinearPrediction::new_telemetry(LPoint3f& t_pos) {
|
||||||
|
}
|
45
direct/src/deadrec/prediction.h
Normal file
45
direct/src/deadrec/prediction.h
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
// Filename: prediction.h
|
||||||
|
// Created by: cary (20Dec00)
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#ifndef __PREDICTION_H__
|
||||||
|
#define __PREDICTION_H__
|
||||||
|
|
||||||
|
#include <directbase.h>
|
||||||
|
#include <luse.h>
|
||||||
|
|
||||||
|
class Prediction {
|
||||||
|
protected:
|
||||||
|
LPoint3f _curr_p;
|
||||||
|
LVector3f _curr_v;
|
||||||
|
PUBLISHED:
|
||||||
|
Prediction(LPoint3f&);
|
||||||
|
virtual ~Prediction(void);
|
||||||
|
|
||||||
|
virtual void step(void);
|
||||||
|
virtual void new_telemetry(LPoint3f&);
|
||||||
|
|
||||||
|
LPoint3f get_pos(void) const;
|
||||||
|
LVector3f get_vel(void) const;
|
||||||
|
};
|
||||||
|
|
||||||
|
class NullPrediction : public Prediction {
|
||||||
|
PUBLISHED:
|
||||||
|
NullPrediction(LPoint3f&);
|
||||||
|
virtual ~NullPrediction(void);
|
||||||
|
|
||||||
|
virtual void step(void);
|
||||||
|
virtual void new_telemetry(LPoint3f&);
|
||||||
|
};
|
||||||
|
|
||||||
|
class LinearPrediction : public Prediction {
|
||||||
|
PUBLISHED:
|
||||||
|
LinearPrediction(LPoint3f&);
|
||||||
|
virtual ~LinearPrediction(void);
|
||||||
|
|
||||||
|
virtual void step(void);
|
||||||
|
virtual void new_telemetry(LPoint3f&);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* __PREDICTION_H__ */
|
Loading…
x
Reference in New Issue
Block a user