coldet wraper lib to come soon...
Blitz3D Forums/Blitz3D Programming/coldet wraper lib to come soon...
| ||
I have written a wrapper for coldet. A collision dectection lib. Everything works fine except that the matrix function I use must be pretty buggy. Is there a matrix guru out there? Untill I find the problem I post the problematic function here. When this is solved I will release the lib. DLL void _stdcall coldet_set_matrix(void *a,float px,float py,float pz,float pitch,float yaw,float roll) { CollisionModel3D*model= static_cast<CollisionModel3D*>(a); //the matrix float mat[16]; //convert to radians //where pir=pi/180 pitch=pitch*pir; yaw=yaw*pir; roll=roll*pir; float A = cos(pitch); float B = sin(pitch); float C = cos(yaw); float D = sin(yaw); float E = cos(roll); float F = sin(roll); float AD = A * D; float BD = B * D; mat[0] = C * E; mat[1] = -C * F; mat[2] = D; mat[3] = 0; mat[4] = BD * E + A * F; mat[5] = -BD * F + A * E; mat[6] = -B * C; mat[7] = 0; mat[8] = -AD * E + B * F; mat[9] = AD * F + B * E; mat[10] = A * C; mat[11] = 0; mat[12] = px; mat[13] = py; mat[14] = pz; mat[15] = 1; model->setTransform (mat); } |
| ||
Sorry, what is this lib for?? Is it better collision than the one of Blitz?? What are the advantages?? |
| ||
You can snatch the matrix from Blitz using GetMatElement. That is probably the easiest way of getting it. Then you would just need to send it to your dll... Something like this should work: Function FetchMatrix(entity) matrixbank = CreateBank(16*4) temp = CreatePivot() RotateEntity temp,EntityPitch(entity,True),EntityYaw(entity,True),EntityRoll(entity,True) PositionEntity temp,EntityX(entity,True),EntityY(entity,True),EntityZ(entity,True) ; And include scale if you need that too PokeFloat matrixbank, 0,GetMatElement(temp,0,0) PokeFloat matrixbank, 4,GetMatElement(temp,0,1) PokeFloat matrixbank, 8,GetMatElement(temp,0,2) PokeFloat matrixbank,12,0 ;....etc.... ; And then send the bank to your dll... Coldet_SetMatrix(bla,matrixbank) FreeBank matrixbank FreeEntity temp End Function |
| ||
Dang ... that worked. I never thought that getmatelement might work. Thanks Fredborg !!! Expect a full functional release today or tommorow. @RepeatUntil. Yes it is a collsion lib. The good thing about this is that you can have mesh to mesh collision, no response collision in blitz. And also make your own collision system with custom responses etc. Bye for now. Elias. |
| ||
sounds very interesting, i'd like to see what it adds to NG's dll. |