nmoze mu chodzi o taki kod ponizej gdzie ruch jest wykonywany caly czas a nie co 100 ms
//---------------------------------------------------------------------------
#pragma hdrstop
#include "tBOT_SRC.h"
#include "MAINFRM.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
__fastcall tBOT::tBOT()
{
particles = new tflamethrower();
particles->reset();
particles->power = 500.0f;
particles->SHOT_SPEED = 377.0f;//+random(10)/10;
particles->NORMAL_TIME = 1;
staticGLOP = 0; TstaticX = 0;
TstaticY = 0;
TstaticZ = 0;
}
__fastcall tBOT::~tBOT()
{
delete particles;
}
void __fastcall tBOT::draw()
{
/*
//glColor3f(1,1,1);
glPushMatrix();
//glLoadIdentity();
//
//FCOpenGL->SUPERPOINT.x = 100000*(sin(FCOpenGL->glop*imopi)*cos(FCOpenGL->heading*imopi));
//FCOpenGL->SUPERPOINT.z = 100000*(cos(FCOpenGL->glop*imopi)*cos(FCOpenGL->heading*imopi));
//FCOpenGL->SUPERPOINT.y = 100000*(sin(FCOpenGL->heading*imopi));
//
//gluLookAt(FCOpenGL->old.x,FCOpenGL->old.y,FCOpenGL->old.z,FCOpenGL->old.x+FCOpenGL->SUPERPOINT.x,
//FCOpenGL->old.y-FCOpenGL->SUPERPOINT.y,FCOpenGL->old.z-FCOpenGL->SUPERPOINT.z,0,1,0);
glTranslatef(pos.x+TstaticX,pos.y+TstaticY,pos.z+TstaticZ);
glRotatef(glop+staticGLOP,0,1,0);
//glRotatef(heading,0,1,0);
//glrotatef(samoloty[i].tempa,1,0,0);
front->DrawSimpleModel();// DrawModelVBO();
//back->DrawModelVBO();
//DrawglArraySelection2(frames[framei]);//,false,[swiatlo2],triplesingletot3dpoint(0,0,0));
glPopMatrix();
*/
//CreateSphere(path[dest_pathi].x,path[dest_pathi].y,path[dest_pathi].z,1000,4);
FCOpenGL->drawbillboardF(pos.x,pos.y,pos.z,128.0f);
}
void __fastcall tBOT::loadbotmodel(AnsiString filename, int trucknum)
{
//TRAILi = -1;
int i;
MODE = 1;
heading = 0;
glop = 0; staticGLOP = 0;
TStringList * s = new TStringList();
//s->LoadFromFile(filename);
front = new TachoGLModel();
// AnsiString UUU = FCyfra->basedir+"\\OpenGL\\MODELS\\Vehicles\\truck"+IntToStr(trucknum)+".tachogl";
AnsiString UUU = FCyfra->basedir+"\\OpenGL\\MODELS\\nazi.tachogl";
front->LoadModel(UUU,false);
AnsiString object_info_file = ExtractFilePath(UUU)+change_filename_ext(UUU,"cfg");
TstaticX = 0;
TstaticY = 0;
TstaticZ = 0;
if (FileExists(object_info_file) == true) {
//ShowMessage(UUU);
//ShowMessage(object_info_file);
TStringList * k = new TStringList();
k->LoadFromFile(object_info_file);
/*
90
true
40
40
40
*/
staticGLOP = StrToFloat(k->Strings[0]);
if (stringtobool(k->Strings[1]) == true)
front->Flip(true,false,false);
front->Scale(StrToFloat(k->Strings[2]),StrToFloat(k->Strings[3]),StrToFloat(k->Strings[4]));
TstaticX = StrToFloat(k->Strings[5]);
TstaticY = StrToFloat(k->Strings[6]);
TstaticZ = StrToFloat(k->Strings[7]);
delete k;
}
projected = new TachoGLModel();
projected->LoadModel(FCyfra->basedir+"\\OpenGL\\MODELS\\pos.tachogl",false);
glop =0;
heading=0;
PATH_POINT_MIN_DISTANCE=500;
s->LoadFromFile(FCyfra->basedir+"\\OpenGL\\MODELS\\"+ExtractFileName(filename)+"_path.cfg");
//setlength(path,s.Count);
path.set_length(s->Count);
for (i = 0; i < s->Count; i++) {
// FCyfra->SZUAJPLIKOW1->get_all_in_nawias2(s->Strings[i],"|",0);
// path[i].x = StrToFloatDef(FCyfra->SZUAJPLIKOW1->w_nawiasiec[0][0],0);
// path[i].y = StrToFloatDef(FCyfra->SZUAJPLIKOW1->w_nawiasiec[0][1],0);
// path[i].z = StrToFloatDef(FCyfra->SZUAJPLIKOW1->w_nawiasiec[0][2],0);
}
pos = triplesingletoT3DPOINTA(0.0f,0.0f,0.0f);//path[0];
dest_pathi=1;
change_path_params(1);
delete s;
framet = GetTickCount();
framei =0;
speed = 10; t = GetTickCount();
znak=1; glop=0;
heading=0; HEIGHT = 64;
}
void __fastcall tBOT::process_frame()
{
if (GetTickCount()-framet >= speed) {
framet = GetTickCount();
framei = framei+1;
// if ( framei >= frames.Length-1 then
// framei= 0;
}
//pos =
//vectors_add(pos,vector_multiple(direction,movespeed*(GetTickCount()-t)/1000));
t = GetTickCount();
pos.y = 0.0f;
bool found = false;
int i;
//pierwszy test dla found to taki ze mamy prosta (od starej pozycji z przed klatki do aktualnej pozycji)
//jak dystans od tej linii do punktu na ścieżce jest wystarczająco mały odbijamy się (to niweluje coś takiego
//jak przelatywanie przez punkty kontrolne)
t3dpoint gjk;
gjk = ClosestPointOnLine(pos,oldpos,path[dest_pathi]);
if (n3ddistance(gjk,path[dest_pathi]) <= 2000.0f) {
pos = path[dest_pathi];
change_path_params(dest_pathi+znak);
}
oldpos = pos;
}
void __fastcall tBOT::change_path_params(int new_pathi)
{
if (new_pathi >= path.Length) dest_pathi = 0;
else if (new_pathi < 0.0f) dest_pathi = path.Length-1; else
dest_pathi = new_pathi;
direction = vectorAB(pos,path[dest_pathi]);
direction = Normalize(direction);
direction.y = 0.0f;
heading = ReturnHeading(direction);
glop = ReturnGlop(direction);
//FAboutGL->Label5->Caption = IntToStr( dest_pathi);
}