Volker Posted December 28, 2009 Share Posted December 28, 2009 I want to use the force parameter from Collisioncallback. But it is passed as Byte Ptr. How do I get the force as Tvec3? Quote Core2DuoE6570 / Windows7 64bit / 4 Gb RAM / Geforce GTX 260 896Mb / LE 2.3 Dell Inspiron 1720 / Vista SP2 / C2D 2.4 / 8600 GM Link to comment Share on other sites More sharing options...
Canardia Posted December 28, 2009 Share Posted December 28, 2009 Probably something like this would work, but it seems like a good idea to add this to mathlib: void _stdcall EntityCollisionCallback( TEntity entity0, TEntity entity1, byte* position, byte* normal, byte* force, flt speed ) { TVec3 hitforce; hitforce.X=force[0]; hitforce.Y=force[4]; hitforce.Z=force[8]; } Quote ■ Ryzen 9 ■ RX 6800M ■ 16GB ■ XF8 ■ Windows 11 ■ ■ Ultra ■ LE 2.5 ■ 3DWS 5.6 ■ Reaper ■ C/C++ ■ C# ■ Fortran 2008 ■ Story ■ ■ Homepage: https://canardia.com ■ Link to comment Share on other sites More sharing options...
Volker Posted December 29, 2009 Author Share Posted December 29, 2009 void _stdcall EntityCollisionCallback( TEntity entity0, TEntity entity1, byte* position, byte* normal, byte* force, flt speed ) { TVec3 hitforce; hitforce.X=force[0]; hitforce.Y=force[4]; hitforce.Z=force[8]; } Ehm, you mean I should use C++ code in Blitzmax? The most of the EntityCollisionCallback parameters seem to be pretty useless if I can't get them in an usable format for Blitzmax. Quote Core2DuoE6570 / Windows7 64bit / 4 Gb RAM / Geforce GTX 260 896Mb / LE 2.3 Dell Inspiron 1720 / Vista SP2 / C2D 2.4 / 8600 GM Link to comment Share on other sites More sharing options...
Canardia Posted December 29, 2009 Share Posted December 29, 2009 Well, you can use C++ code in BlitzMax, but that's not the point here now. BlitzMax should have a similar method to construct a foreign type from pointers, like in the C++ example I showed. Indeed, Josh started to use those wierd [] operators for float arrays some time ago, so instead of saying Vec3(1,2,3) he says [1,2,3]. So I think the Byte Ptr problem could be easily solved using the fact that Vec3 is just an array of 3 subsequent float (4 byte) values. Quote ■ Ryzen 9 ■ RX 6800M ■ 16GB ■ XF8 ■ Windows 11 ■ ■ Ultra ■ LE 2.5 ■ 3DWS 5.6 ■ Reaper ■ C/C++ ■ C# ■ Fortran 2008 ■ Story ■ ■ Homepage: https://canardia.com ■ Link to comment Share on other sites More sharing options...
Masterxilo Posted December 29, 2009 Share Posted December 29, 2009 Probably something like this would work, but it seems like a good idea to add this to mathlib: void _stdcall EntityCollisionCallback( TEntity entity0, TEntity entity1, byte* position, byte* normal, byte* force, flt speed ) { TVec3 hitforce; hitforce.X=force[0]; hitforce.Y=force[4]; hitforce.Z=force[8]; } Why so complicated? TVec3 *pHitForce = reinterpret_cast<TVec3*>(force); Quote Hurricane-Eye Entertainment - Site, blog. Link to comment Share on other sites More sharing options...
Josh Posted December 29, 2009 Share Posted December 29, 2009 I am not sure why I chose to use byte ptrs in BlitzMax. A Vec3 makes more sense to me, don't you think? Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
macklebee Posted December 29, 2009 Share Posted December 29, 2009 I am not sure why I chose to use byte ptrs in BlitzMax. A Vec3 makes more sense to me, don't you think? yes please. Quote Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590 LE / 3DWS / BMX / Hexagon macklebee's channel Link to comment Share on other sites More sharing options...
Josh Posted December 29, 2009 Share Posted December 29, 2009 Fortunately if I change this, any code that worked with byte ptrs should work with vec3 objects as well. Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.