mirror of
https://github.com/Ragora/T2-CPP.git
synced 2026-01-19 18:14:44 +00:00
Added more code to allow setting transform
The new code should be much faster
This commit is contained in:
parent
9e8db1e612
commit
172d88a546
|
|
@ -9,8 +9,17 @@ namespace DX
|
|||
{
|
||||
public:
|
||||
SceneObject(unsigned int obj);
|
||||
float * SceneObject::getPosition();
|
||||
float * SceneObject::getRotation();
|
||||
void SceneObject::setRotation(float []);
|
||||
void SceneObject::setPosition(float []);
|
||||
void * worldtoobj;
|
||||
void * objtoworld;
|
||||
void * renderobjtoworld;
|
||||
void * renderworldtoobj;
|
||||
|
||||
Point3F position;
|
||||
Point3F scale;
|
||||
};
|
||||
|
||||
} // End NameSpace DX
|
||||
|
|
|
|||
|
|
@ -106,6 +106,10 @@ extern char * (*getReturnBuffer)(U32 bufferSize);
|
|||
extern void (*addMethodB)(const char *nsName, const char *name, BoolCallback cb, const char *usage, S32 minArgs, S32 maxArgs);
|
||||
extern void (*addMethodS)(const char *nsName, const char *name, StringCallback cb, const char *usage, S32 minArgs, S32 maxArgs);
|
||||
extern void (*addMethodI)(const char *nsName, const char *name, IntCallback cb, const char *usage, S32 minArgs, S32 maxArgs);
|
||||
extern const char * (*getMatrixRotation)(void * matptr, unsigned int *, unsigned int);
|
||||
extern const char * (*getMatrixPosition)(void * matptr, unsigned int *, unsigned int);
|
||||
extern void (*setMatrixRotation)(void * matptr, S32 argc, const char **argv, unsigned int *, unsigned int);
|
||||
extern void (*setMatrixPosition)(void * matptr, S32 argc, const char **argv, unsigned int *, unsigned int);
|
||||
extern bool (*addVariable)(const char *name, S32 t, void *dp);
|
||||
|
||||
extern void (*printf)(const char* fmt,...);
|
||||
|
|
@ -116,7 +120,7 @@ extern const char * (*execute)(S32 argc, const char *argv[]);
|
|||
extern const char * (*executef)(S32 argc, ...);
|
||||
extern const char * (*executem)(Linker::SimObject *object, S32 argc, const char *argv[]);
|
||||
extern const char * (*evaluate)(const char* string, bool echo, const char *fileName, bool cf);
|
||||
}
|
||||
};
|
||||
|
||||
//d-util
|
||||
extern int (*dSscanf)(const char *buffer, const char *format, ...);
|
||||
|
|
|
|||
|
|
@ -1,10 +1,43 @@
|
|||
#include <DXAPI/SceneObject.h>
|
||||
|
||||
#include <LinkerAPI.h>
|
||||
namespace DX
|
||||
{
|
||||
//This is required to make these update properly over the network
|
||||
//memPatch("602D1E","9090");
|
||||
SceneObject::SceneObject(unsigned int obj) : position(*(float*)(obj + 168), *(float*)(obj + 184), *(float*)(obj + 200)),
|
||||
scale(*(float*)(obj + 284), *(float*)(obj + 288), *(float*)(obj + 292)),
|
||||
scale(*(float*)(obj + 284), *(float*)(obj + 288), *(float*)(obj + 292)), worldtoobj((void*)(obj+0xdc)),objtoworld((void*)(obj+0x9c)),renderobjtoworld((void*)(obj+360)),renderworldtoobj((void*)(obj+424)),
|
||||
NetObject(obj)
|
||||
{
|
||||
}
|
||||
float * SceneObject::getPosition(){
|
||||
if (this->base_pointer_value) {
|
||||
const char * results = Con::getMatrixPosition(objtoworld,NULL,0);
|
||||
float pos[3];
|
||||
sscanf (results,"%g %g %g", &pos[0], &pos[1], &pos[2]);
|
||||
return pos;
|
||||
}
|
||||
}
|
||||
float * SceneObject::getRotation(){
|
||||
if (this->base_pointer_value) {
|
||||
const char * results = Con::getMatrixRotation(objtoworld,NULL,0);
|
||||
float pos[4];
|
||||
sscanf (results,"%g %g %g %g", &pos[0], &pos[1], &pos[2], &pos[3]);
|
||||
return pos;
|
||||
}
|
||||
}
|
||||
void SceneObject::setRotation(float rot []) {
|
||||
char arg0[128] = "";
|
||||
sprintf (arg0,"%g %g %g %g", rot[0], rot[1], rot[2], rot[3]);
|
||||
char * argv[] = { &arg0[0], NULL };
|
||||
int argc = 1;
|
||||
Con::setMatrixRotation(objtoworld,argc,(const char **)argv,NULL,0);
|
||||
}
|
||||
|
||||
void SceneObject::setPosition(float pos []) {
|
||||
char arg0[128] = "";
|
||||
sprintf (arg0,"%g %g %g", pos[0], pos[1], pos[2]);
|
||||
char * argv[] = { &arg0[0], NULL };
|
||||
int argc = 1;
|
||||
Con::setMatrixPosition(objtoworld,argc,(const char **)argv,NULL,0);
|
||||
}
|
||||
}
|
||||
|
|
@ -33,6 +33,10 @@ namespace Con
|
|||
char* (*getReturnBuffer)(U32 bufferSize) =
|
||||
(char *(__cdecl *)(U32))
|
||||
0x42caa0;
|
||||
const char * (*getMatrixRotation)(void * matptr, unsigned int *, unsigned int) = (const char * (__cdecl *)(void *, unsigned int *, unsigned int)) 0x5503A0;
|
||||
void (*setMatrixRotation)(void * matptr, S32 argc, const char **argv, unsigned int *, unsigned int) = (void (__cdecl *)(void *, S32, const char **, unsigned int *, unsigned int)) 0x550420;
|
||||
const char * (*getMatrixPosition)(void * matptr, unsigned int *, unsigned int) = (const char * (__cdecl *)(void *, unsigned int *, unsigned int)) 0x550260;
|
||||
void (*setMatrixPosition)(void * matptr, S32 argc, const char **argv, unsigned int *, unsigned int) = (void (__cdecl *)(void *, S32, const char **, unsigned int *, unsigned int)) 0x550300;
|
||||
|
||||
void (*addMethodI)(const char *nsName, const char *name, IntCallback cb, const char *usage, S32 minArgs, S32 maxArgs) =
|
||||
(void (__cdecl *)(const char *, const char *,IntCallback,const char *,S32,S32))
|
||||
|
|
|
|||
|
|
@ -25,6 +25,28 @@ BOOL APIENTRY DllMain( HMODULE hModule,
|
|||
|
||||
extern "C"
|
||||
{
|
||||
static S32 gravid=0;
|
||||
static float movespeed=0.0;
|
||||
__declspec(dllexport) void ServerProcess(unsigned int deltaTime)
|
||||
{
|
||||
//memPatch("602D1E","9090");
|
||||
float *pos;
|
||||
float *rot;
|
||||
if (gravid!=0) {
|
||||
if (movespeed != 0.0) {
|
||||
float timeinseconds=(deltaTime/1000.0f);
|
||||
void * objptr = Sim::findObject(gravid);
|
||||
if ((unsigned int)(objptr)) {
|
||||
DX::SceneObject newobj=DX::SceneObject((unsigned int)objptr);
|
||||
pos=newobj.getPosition();
|
||||
rot=newobj.getRotation();
|
||||
pos[2]+=(movespeed*timeinseconds);
|
||||
newobj.setPosition(pos);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
__declspec(dllexport) void ModInitialize(void)
|
||||
{
|
||||
// Init WSA
|
||||
|
|
@ -79,6 +101,10 @@ extern "C"
|
|||
|
||||
// Add this Gvar to signify that TSExtension is active
|
||||
static bool is_active = true;
|
||||
|
||||
|
||||
Con::addVariable("$TSExtension::UberGravity", TypeF32, &movespeed);
|
||||
Con::addVariable("$TSExtension::UberId",TypeS32, &gravid);
|
||||
Con::addVariable("$TSExtension::isActive", TypeBool, &is_active);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue