|
Post by batvink on Feb 15, 2005 15:43:44 GMT 1
Is this possible? In DB Pro, the scaled object dimensions aren't available, so I think you would need to be able to create a Body from a collision tree, and then scale in a separate function. Somebody on the DB forum said there was a function, but I can't find it
|
|
|
Post by Kjelle69 on Feb 16, 2005 7:01:45 GMT 1
actually yes, in the latest version there are a few un-documented commands for this:
NDB_NewtonCreateTreeCollisionWithScale
set the desired scale into temp vector 1 before calling (NDB_SetVector sx#, sy#, sz#)
also the unpotimized version
NDB_NewtonCreateTreeCollisionWithScaleUnoptimized
you can also do the same for convex hulls:
NDB_NewtonCreateConvexHullWithScale
|
|
|
Post by kjelle69 on Feb 16, 2005 8:57:40 GMT 1
Undocumented commands !!! ??
ยจ'm On IT !!
Updating docs !! ;D
|
|
|
Post by Kjelle69 on Feb 16, 2005 9:42:21 GMT 1
;D ;D ;D
|
|
|
Post by batvink on Feb 16, 2005 13:21:35 GMT 1
Thanks! That saves me a lot of effort sizing and exporting my models again.
|
|
|
Post by batvink on Feb 17, 2005 0:18:27 GMT 1
NDB_NewtonCreateConvexHullWithScale doesn't seem to work. I've set Vector1 up with different values, and only the X vector seems to be accounted for. So, the body scales in the X axis, and evrything else stays the same I've also posted this is the Bug forum
|
|
|
Post by kjelle69 on Feb 17, 2005 10:24:39 GMT 1
Ok, going through the code and I have found the bug. I will fix it this evening.
|
|
|
Post by batvink on Feb 17, 2005 14:08:31 GMT 1
Good stuff. ;D ;D ;D I didn't check to see if Collision Tree Scaling had the same problem, unfortunately I can't check right now. Maybe commercial software houses should learn how to support users like this
|
|
|
Post by kjelle69 on Feb 17, 2005 21:09:54 GMT 1
I have to admit I thought I had found a way to solve this problem, but I hadnt.... Seems that it is possible to scale all hulls in the X direction, works fine, but when scaling other ways, writing the info into the memblock everything freaks out. hmm. writing into the wrong adress space somehow... The FVF format must be faulty formatted ? !!
|
|
|
Post by kjelle69 on Feb 18, 2005 0:39:41 GMT 1
|
|
|
Post by kjelle69 on Feb 18, 2005 3:48:54 GMT 1
Tried to investigate the format of fvf, and I think I understand it now. This is the code to READ, rescale and write back the memblock vertex information. There must be something Strange in the writing of the vertex info with the NewtonCreateConvexHull. First box goes fine, but the following looks like the picture below... int fvf, v_size, v_count;
fvf = DBPro::MemblockDword( Memblock, 0 ); v_size = DBPro::MemblockDword( Memblock, 4 ); v_count = DBPro::MemblockDword( Memblock, 8 );
fprintf( debug, "\tFVF: %d\tVertexSize: %d\tVertexCount %d\n", fvf, v_size, v_count );
for (int j=12; j<=(v_count*v_size); j+=v_size) { fprintf( debug, "\tj: %d\t Before %f\t %f\t %f\n", j, DBPro::MemblockFloat( Memblock, j ), DBPro::MemblockFloat( Memblock, j+4 ),DBPro::MemblockFloat( Memblock, j+8 ) ); DBPro::WriteMemblockFloat( Memblock, j, (DBPro::MemblockFloat( Memblock, j ) * vector[1].m_x)); DBPro::WriteMemblockFloat( Memblock, j+4, (DBPro::MemblockFloat( Memblock, j+4 ) * vector[1].m_y) ); DBPro::WriteMemblockFloat( Memblock, j+8, (DBPro::MemblockFloat( Memblock, j+8 ) * vector[1].m_z) ); fprintf( debug, "\tj: %d\t After %f\t %f\t %f\n", j, DBPro::MemblockFloat( Memblock, j ), DBPro::MemblockFloat( Memblock, j+4 ) , DBPro::MemblockFloat( Memblock, j+8 ) ); }
fprintf( debug, "\nBeginning building of Scaled hull.\n" ); float* pMem = (float*)DBPro::GetMemblockPtr( Memblock ); pMem += 12; float fv_count = (float)v_count; float fv_size = (float)v_size; fprintf( debug, "\nGoin in to building of Scaled hull. Size= %f\t %f\n ", fv_count, fv_size );
tempcollision = NewtonCreateConvexHull( nWorld, fv_count, pMem, fv_size, NULL );
fprintf( debug, "\nCompleted building of Scaled hull.\n" );
// clean up! DBPro::DeleteObject( ObjectCopy ); DBPro::DeleteMesh( Mesh ); DBPro::DeleteMemblock( Memblock );
int i;
for (i=1; i<MAX_OBJECTS; i++) { if (NDB_CollisionArray[i].used == false) break; } NDB_CollisionArray[i].used = true; NDB_CollisionArray[i].Newton_Collision = tempcollision; fprintf( debug, "\nCompleted building of tempcollision. %d\n",i );
fclose(debug); return i; First conversion sometimes goes perfectly: Convex Hull With Scale DEBUG REPORT...
Object from user: 4 copied to object: 5/ncopy converted to FVF '2' Empty Mesh created. FVF: 2 VertexSize: 12 VertexCount 36 j: 12 Before -0.500000 0.500000 -0.500000 j: 12 After -1.500000 1.500000 -1.500000 j: 24 Before 0.500000 0.500000 -0.500000 j: 24 After 1.500000 1.500000 -1.500000 j: 36 Before -0.500000 -0.500000 -0.500000 j: 36 After -1.500000 -1.500000 -1.500000 j: 48 Before -0.500000 -0.500000 -0.500000 j: 48 After -1.500000 -1.500000 -1.500000 j: 60 Before 0.500000 0.500000 -0.500000 j: 60 After 1.500000 1.500000 -1.500000 j: 72 Before 0.500000 -0.500000 -0.500000 j: 72 After 1.500000 -1.500000 -1.500000 j: 84 Before 0.500000 0.500000 -0.500000 j: 84 After 1.500000 1.500000 -1.500000 j: 96 Before 0.500000 0.500000 0.500000 j: 96 After 1.500000 1.500000 1.500000 j: 108 Before 0.500000 -0.500000 -0.500000 j: 108 After 1.500000 -1.500000 -1.500000 j: 120 Before 0.500000 -0.500000 -0.500000 j: 120 After 1.500000 -1.500000 -1.500000 j: 132 Before 0.500000 0.500000 0.500000 j: 132 After 1.500000 1.500000 1.500000 j: 144 Before 0.500000 -0.500000 0.500000 j: 144 After 1.500000 -1.500000 1.500000 j: 156 Before 0.500000 0.500000 0.500000 j: 156 After 1.500000 1.500000 1.500000 j: 168 Before -0.500000 0.500000 0.500000 j: 168 After -1.500000 1.500000 1.500000 j: 180 Before 0.500000 -0.500000 0.500000 j: 180 After 1.500000 -1.500000 1.500000 j: 192 Before 0.500000 -0.500000 0.500000 j: 192 After 1.500000 -1.500000 1.500000 j: 204 Before -0.500000 0.500000 0.500000 j: 204 After -1.500000 1.500000 1.500000 j: 216 Before -0.500000 -0.500000 0.500000 j: 216 After -1.500000 -1.500000 1.500000 j: 228 Before -0.500000 0.500000 0.500000 j: 228 After -1.500000 1.500000 1.500000 j: 240 Before -0.500000 0.500000 -0.500000 j: 240 After -1.500000 1.500000 -1.500000 j: 252 Before -0.500000 -0.500000 0.500000 j: 252 After -1.500000 -1.500000 1.500000 j: 264 Before -0.500000 -0.500000 0.500000 j: 264 After -1.500000 -1.500000 1.500000 j: 276 Before -0.500000 0.500000 -0.500000 j: 276 After -1.500000 1.500000 -1.500000 j: 288 Before -0.500000 -0.500000 -0.500000 j: 288 After -1.500000 -1.500000 -1.500000 j: 300 Before -0.500000 0.500000 0.500000 j: 300 After -1.500000 1.500000 1.500000 j: 312 Before 0.500000 0.500000 0.500000 j: 312 After 1.500000 1.500000 1.500000 j: 324 Before -0.500000 0.500000 -0.500000 j: 324 After -1.500000 1.500000 -1.500000 j: 336 Before -0.500000 0.500000 -0.500000 j: 336 After -1.500000 1.500000 -1.500000 j: 348 Before 0.500000 0.500000 0.500000 j: 348 After 1.500000 1.500000 1.500000 j: 360 Before 0.500000 0.500000 -0.500000 j: 360 After 1.500000 1.500000 -1.500000 j: 372 Before -0.500000 -0.500000 -0.500000 j: 372 After -1.500000 -1.500000 -1.500000 j: 384 Before 0.500000 -0.500000 -0.500000 j: 384 After 1.500000 -1.500000 -1.500000 j: 396 Before -0.500000 -0.500000 0.500000 j: 396 After -1.500000 -1.500000 1.500000 j: 408 Before -0.500000 -0.500000 0.500000 j: 408 After -1.500000 -1.500000 1.500000 j: 420 Before 0.500000 -0.500000 -0.500000 j: 420 After 1.500000 -1.500000 -1.500000 j: 432 Before 0.500000 -0.500000 0.500000 j: 432 After 1.500000 -1.500000 1.500000
Beginning building of Scaled hull.
Goin in to building of Scaled hull. Size= 36.000000 12.000000 Completed building of Scaled hull.
Completed building of tempcollision. 2
The corresponding object looks fine.
|
|
|
Post by batvink on Feb 18, 2005 10:49:57 GMT 1
Just been experimenting with Collision Trees, and they seem to be affected worse. But then if the memblock data is in a different format, the results will be totally unpredictable I suppose.
Unfortunatley, I've never modified memblock meshes so I'm not much help here. I'll see if I can find any extra information, though.
|
|
|
Post by kjelle69 on Feb 19, 2005 22:01:00 GMT 1
Fixed it ! It's crazy how many hours I put down to solve this !! Treecollisions is also working, I have tested all kinds of treecollsions and they are rescaleable ! Somtimes I get an exception but I think it depends a bit how the model looks.
|
|
|
Post by batvink on Feb 19, 2005 22:26:10 GMT 1
Great Stuff, wish I had your patience!
What happens with regard to making the update public? Will it be soon?
|
|
|
Post by kjelle69 on Feb 19, 2005 22:49:53 GMT 1
;D It depends on all the Users Eagerness to get their hands on some Newly updated DLL's If you'd like to I can mail you the freshly compiled DLL. I need some more time with the other parts of the package, waiting for some code from Walaber also, thinking of making an update to the RBD loader also included in the next release.
|
|