- 001
- 002
- 003
- 004
- 005
- 006
- 007
- 008
- 009
- 010
- 011
- 012
- 013
- 014
- 015
- 016
- 017
- 018
- 019
- 020
- 021
- 022
- 023
- 024
- 025
- 026
- 027
- 028
- 029
- 030
- 031
- 032
- 033
- 034
- 035
- 036
- 037
- 038
- 039
- 040
- 041
- 042
- 043
- 044
- 045
- 046
- 047
- 048
- 049
- 050
- 051
- 052
- 053
- 054
- 055
- 056
- 057
- 058
- 059
- 060
- 061
- 062
- 063
- 064
- 065
- 066
- 067
- 068
- 069
- 070
- 071
- 072
- 073
- 074
- 075
- 076
- 077
- 078
- 079
- 080
- 081
- 082
- 083
- 084
- 085
- 086
- 087
- 088
- 089
- 090
- 091
- 092
- 093
- 094
- 095
- 096
- 097
- 098
- 099
- 100
void Character::getWalkScreenDirection(SPVector& dst) {
float stick_y = 0.0f, stick_x = 0.0f;
/*if(isPadMove())*/ {
stick_y = getOffsetLY();
stick_x = getOffsetLX();
}/*else*/{
//stick_y = angleAC_DIRECTION[animator.animation.getDirection()][0];
//stick_x = angleAC_DIRECTION[animator.animation.getDirection()][1];
/*
if(stick_y == 0 && stick_x == 0){
animator.animation.set(AC_DIRECTION_NONE); // stop walking
animator.animation.set(AC_MOVEMENT_IDLE);
animator.animation.update();
}*/ }
dst.asg(0,0,0);
/* if(animator.animation.getDirection() == AC_DIRECTION_NONE){
//CameraCore* camera = game.get_camera();
camera = game.get_camera();
cam_up = camera->up();
SPVector up_tmp = camera->up();
SPVector look = camera->look();
SPVector look_tmp = camera->look();
cam_right = up_tmp.cross(look_tmp);
return;
} */
SPPosition current;
model.getRootPose(current);
bool isRun = this->isRun();
if(animator.getTarget()){
if(animator.getTarget()->get_run(current, isRun)){ // run stance can overwrite depend from target
state(CharacterFlags_MODE_SWAPRUN, true);
state(CharacterFlags_MODE_RUN,isRun);
}
}
CameraCore* camera_compare = game.get_camera();
SPVector cam_compare_pos = camera_compare->pos();
if(cam_compare_pos != cam_pos) {
if(first_time) {
cam_time = game.time.system.current_value(1);
cam_time /= 1000;
first_time = false;
first_stick_x = stick_x; //premiere fois : on rйcup la position du stick en x et y
first_stick_y = stick_y;
}
double move_time = game.time.system.current_value(1);
move_time /= 1000;
if(move_time - cam_time < delta_time) {
//stick_y = first_stick_y;
//stick_x = first_stick_x;
/*if(dst.len() != 0)
{
//animator.animation.set(AC_DIRECTION_FORWARD); // for the animation
animator.animation.enable(true);
animator.animation.set(isRun?AC_MOVEMENT_RUN:AC_MOVEMENT_WALK);
dst.norm();
model.setDirection(dst); // facing the direction
}
return;*/
}
}
if(stick_y==0 && stick_x==0) initializeCameraAxis();
SPVector new_direction;
new_direction.asg(stick_x, 0, stick_y);
if(new_direction.len() != 0) new_direction.norm();
if(direction_reference.len() != 0) direction_reference.norm();
float scalar_product = new_direction.dot(direction_reference);
if(fabs(scalar_product) <= delta) {
direction_reference.asg(new_direction);
initializeCameraAxis();
}
if(cam_compare_pos == cam_pos || (cam_compare_pos != cam_pos && fabs(scalar_product) <= delta)) {
first_time = true;
SPVector up = cam_up;
SPVector right = cam_right;
up.y = 0;
right.y = 0;
// CameraCore* camera_2 = game.get_camera(); //rйtablissement d'une camйra inversйe
// SPPosition pos_test = camera_2->sview();
// SPVector vec_test = pos_test.c;
SPVector vec_test = cam_pos;
SPVector vec_stock;
vec_stock.asg(69.8761444,2.45131993,117.599548);
if(vec_test.equal(vec_stock,0.0000001f)) {
up.x = - up.x;
up.z = - up.z;
}
////////////////
if(up.len() != 0) up.norm();
if(right.len() != 0) right.norm();
up *= stick_y;
right *= stick_x;
dst = up; // update destination vector
dst += right; // i.e. dst = up + right
if(dst.len() != 0) {
//animator.animation.set(AC_DIRECTION_FORWARD); // for the animation
animator.animation.enable(true);
animator.animation.set(isRun?AC_MOVEMENT_RUN:AC_MOVEMENT_WALK);
dst.norm();
model.setDirection(dst); // facing the direction
}
Такой код в нашем движке.
ЗЫ. Код немного ужат, так как не помещался в 100 строк.
TheHamstertamer 26.08.2011 15:58 # +3
SmackMyBitchUp 26.08.2011 16:00 # +2
absolut 28.08.2011 01:43 # 0
Esper 26.08.2011 16:15 # +2
inkanus-gray 26.08.2011 16:22 # 0
sayidandrtfm 26.08.2011 18:37 # 0
RaZeR 27.08.2011 23:05 # 0
guest8 09.04.2019 11:23 # −999