Announcements

Between mid-October and November, the content on AREA will be relocated to the Autodesk Community M&E Hub and the Autodesk Community Gallery. Learn more HERE.

How can I use 3DXI or IGameMesh with MXS

How can I use 3DXI or IGameMesh with MXS

Anonymous
Not applicable
366 Views
2 Replies
Message 1 of 3

How can I use 3DXI or IGameMesh with MXS

Anonymous
Not applicable
I need genarate tangent/binormal in my maxscript,
how can I use IGameMesh or how can I write my own maxscript to do that
is there something similar to below:

IGameMesh::GetNormal(int index) // Return a correct normal
IGameMesh::GetTangent(int index) // Return an incorrect tangent
IGameMesh::GetBinormal(int index) // Return an incorrect binormal
0 Likes
367 Views
2 Replies
Replies (2)
Message 2 of 3

Anonymous
Not applicable
You can use GetFaceVertexTangentBinormal to get tangent and binormal index

int face_index=face->meshFaceIndex; <<notice : must use meshFaceIndex
for(int c=0;c<3;++c)
{
tangent_index=game_mesh->GetFaceVertexTangentBinormal(face_index,c, normal_map_uv_channel);
//notice : must use normal map channel index to get tangent and binormal index
point3 max_binormal;
bool ret=game_mesh->GetBinormal(tangent_index,max_binormal,normal_map_uv_channel);
....
}

face_index must match the face_index to get normal;
and the normap_map_uv_channel must is the normal map texture used uv map
0 Likes
Message 3 of 3

Anonymous
Not applicable

for(int c=0;c<3;++c)


I want do that using maxscript , I found a funtion on web, but maybe we can using some simple code like you c++ code

fn computeTangentSpace_old obj &tSpace = (

local theMesh = snapshotAsMesh obj

tSpace = #()

for nFace = 1 to theMesh.numFaces do (
local face = getFace theMesh nFace
local tface = getTVFace theMesh nFace

local v1 = getVert theMesh face
local v2 = getVert theMesh face
local v3 = getVert theMesh face

local uv1 = getTVert theMesh tface
local uv2 = getTVert theMesh tface
local uv3 = getTVert theMesh tface

local dV1 = v1 - v2
local dV2 = v1 - v3

local dUV1 = uv1 - uv2
local dUV2 = uv1 - uv3

local area = dUV1.x * dUV2.y - dUV1.y * dUV2.x
local sign = if area < 0 then -1 else 1

local tangent =

tangent.x = dV1.x * dUV2.y - dUV1.y * dV2.x
tangent.y = dV1.y * dUV2.y - dUV1.y * dV2.y
tangent.z = dV1.z * dUV2.y - dUV1.y * dV2.z

tangent = (normalize tangent) * sign

local normal = getFaceNormal theMesh nFace
local binormal = (normalize (cross normal tangent)) * sign

append tSpace #(tangent, binormal, normal)
)

delete theMesh
)
0 Likes