Jump to content
Xtreme .Net Talk

Recommended Posts

  • Administrators
Posted

would it be possible to post a bit more code? Without knowing what minB, maxB and oob are it is very hard to translate the code...

Assert evaluates whatever is passed in to either a true or a false - if it equates to false then it kicks out an error message and prompts to debug when compiled in debug mode; In release mode assert doesn't do anything.

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

Posted

minB and maxB are DirectX.Direct3D.Vector3 objects. obj[] is an array containing Vector3 objects. the entire c++ method i need to translate to c# is below. thanks :

 

 

void CalcAABBFromOBB(const D3DXVECTOR3 *obb,D3DXVECTOR3 *minB,D3DXVECTOR3 *maxB)

{

assert(minB);

assert(maxB);

assert(obb);

 

minB->x=maxB->x=obb[0].x;

minB->y=maxB->y=obb[0].y;

minB->z=maxB->z=obb[0].z;

 

for (int i=1;i<8;i++)

{

if (obb.x < minB->x) minB->x=obb.x;

if (obb.x > maxB->x) maxB->x=obb.x;

if (obb.y < minB->y) minB->y=obb.y;

if (obb.y > maxB->y) maxB->y=obb.y;

if (obb.z < minB->z) minB->z=obb.z;

if (obb.z > maxB->z) maxB->z=obb.z;

}

}

  • Administrators
Posted

Not tested it but it should at least compile ;)

void CalcAABBFromOBB(Microsoft.DirectX.Vector3[] obb, Microsoft.DirectX.Vector3 minB,Microsoft.DirectX.Vector3 maxB)
{
System.Diagnostics.Debug.Assert(obb != null);

minB.X =maxB.X = obb[0].X;
minB.Y =maxB.Y = obb[0].Y;
minB.Z =maxB.Z = obb[0].Z;

for (int i=1;i<8;i++)
{
if (obb[i].X < minB.X) minB.X=obb[i].X;
if (obb[i].X > maxB.X) maxB.X=obb[i].X;
if (obb[i].Y < minB.Y) minB.Y=obb[i].Y;
if (obb[i].Y > maxB.Y) maxB.Y=obb[i].Y;
if (obb[i].Z < minB.Z) minB.Z=obb[i].Z;
if (obb[i].Z > maxB.Z) maxB.Z=obb[i].Z;
}
}

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...