on 22-06-2012 06:48 AM
Why not tangents/binormal in mdx???
help
Solved! Go to Solution.
28-06-2012 10:15 AM - edited 28-06-2012 10:18 AM
spacerim wrote:Why not tangents/binormal in mdx???
help
Hi, I will find out for you. Please wait for further updates.
And just a reminder that in 0.98 SDK, "Model file type is the one under development. It may be changed in the future versions."
on 26-07-2012 06:05 PM
on 26-07-2012 06:34 PM
Hi:
@Spacerim :Just for had more knowledge.. may I ask if tangent and binormal are part of the MDX file spec from 3D MAx studio?
Cheers,
30-08-2012 07:52 AM - edited 30-08-2012 07:58 AM
ok
// mdx byte -> vector type
ushort[] indices = mdx.indices.ToArray();
byte[] vertexs = mdx.vertexs;
Vector3[] pos = new Vector3[mesh.num_vertex];
Vector3[] nor = new Vector3[mesh.num_vertex];
Vector2[] tex = new Vector2[mesh.num_vertex];
byte[] m1 = new byte[4];
byte[] m2 = new byte[4];
byte[] m3 = new byte[4];
for( int i = 0; i < mesh.num_vertex; i++ ) {
int offset = mesh.sufrace[0].offsets+(i*32);
for( int j = 0; j < 4; j++ )
{
m1[j] = vertexs[j+offset];
m2[j] = vertexs[4+j+offset];
m3[j] = vertexs[8+j+offset];
}
pos[i].X = BitConverter.ToSingle(m1, 0);
pos[i].Y = BitConverter.ToSingle(m2, 0);
pos[i].Z = BitConverter.ToSingle(m3, 0);
offset = mesh.sufrace[1].offsets+(i*32);
for( int j = 0; j < 4; j++ )
{
m1[j] = vertexs[j+offset];
m2[j] = vertexs[4+j+offset];
m3[j] = vertexs[8+j+offset];
}
nor[i].X = BitConverter.ToSingle(m1, 0);
nor[i].Y = BitConverter.ToSingle(m2, 0);
nor[i].Z = BitConverter.ToSingle(m3, 0);
offset = mesh.sufrace[3].offsets+(i*32);
for( int j = 0; j < 4; j++ )
{
m1[j] = vertexs[j+offset];
m2[j] = vertexs[4+j+offset];
}
tex[i].X = BitConverter.ToSingle(m1, 0);
tex[i].Y = BitConverter.ToSingle(m2, 0);
}
//calculation tangent
Vector4[] tan = new Vector4[mesh.num_vertex];
Vector3[] tan1 = new Vector3[mesh.num_vertex];
Vector3[] tan2 = new Vector3[mesh.num_vertex];
for( int i = 0; i < mdx.indices.Count; i+=3 ) {
ushort i1 = indices[i];
ushort i2 = indices[ (i+1) % mdx.indices.Count];
ushort i3 = indices[ (i+2) % mdx.indices.Count];
Vector3 v1 = pos[i1];
Vector3 v2 = pos[i2];
Vector3 v3 = pos[i3];
Vector2 t1 = tex[i1];
Vector2 t2 = tex[i2];
Vector2 t3 = tex[i3];
float x1 = v2.X - v1.X;
float x2 = v3.X - v1.X;
float y1 = v2.Y - v1.Y;
float y2 = v3.Y - v1.Y;
float z1 = v2.Z - v1.Z;
float z2 = v3.Z - v1.Z;
float s1 = t2.X - t1.X;
float s2 = t3.X - t1.X;
float s3 = t2.Y - t1.Y;
float s4 = t3.Y = t1.Y;
float r = (s1*s4-s2*s3);
if( Math.Abs(r) <= 0.00001f )
r = 1.0f;
else
r = 1.0f / r;
Vector3 sdir,tdir;
sdir.X = (s4*x1-s3*x2)*r;
sdir.Y = (s4*y1-s3*y2)*r;
sdir.Z = (s4*z1-s3*z2)*r;
tdir.X = (s1*x2-s2*x1)*r;
tdir.Y = (s1*y2-s2*y1)*r;
tdir.Z = (s1*z2-s2*z1)*r;
tan1[i1] += sdir;
tan1[i2] += sdir;
tan1[i3] += sdir;
tan2[i1] += tdir;
tan2[i2] += tdir;
tan2[i3] += tdir;
}
for( int i = 0; i < mesh.num_vertex; i++ ) {
;
tan[i].Xyz = tan1[i] - nor[i] * tan1[i].Dot(nor[i]);
tan[i] = tan[i].Normalize();
tan[i].W = (nor[i].Cross(tan1[i])).Dot(tan2[i]) < 0.0f ? -1.0f : 1.0f;
}
// tangent vector -> mdx byte
mesh.vertex_formats[2] = VertexFormat.Float4;
mesh.sufrace[2].offsets = ?????????
vertexs = ???????????
...very difficult......
on 30-08-2012 03:10 PM
Hi:
I don't read there the binormal ,but tanget seems. there.. Why are does ??? there? Another thing you can calculate them when loading mdx files, changing the model source code did you know that?
Cheers
on 01-09-2012 09:00 AM
You are right;Try to keep in mind;
on 02-09-2012 10:52 PM
Hi:
Thanks. Nice image!!!. How big it's the texture?
Cheers
PSM Developer Registration (for free) on PSM DevPortal is required to post on the forum.
Please sign out then sign in again to the forum and PSM DevPortal after you have completed the registration.
フォーラムへ投稿をするにはPSM DevPortalへの登録(無料)が必要です。
登録後はフォーラムと
PSM DevPortalを一度ログアウトし、再度ログインしてください。


Website ©2013 Sony Computer Entertainment Europe
All content, game titles, trade names and/or trade dress, trademarks, artwork and associated imagery are trademarks and/or copyright material of their respective owners. All rights reserved. [more info]
%%http://community.eu.playstation.com/t5/Announcements/Beta-Trial-Information/td-p/11386362
best_shooter.png%%http://community.eu.playstation.com/t5/Announcements/Introducing-Best-of-PlayStation/td-p/13741979
best_driver.png%%http://community.eu.playstation.com/t5/Announcements/Introducing-Best-of-PlayStation/td-p/13741979
best_performer.png%%http://community.eu.playstation.com/t5/Announcements/Introducing-Best-of-PlayStation/td-p/13741979
best_footballer.png%%http://community.eu.playstation.com/t5/Announcements/Introducing-Best-of-PlayStation/td-p/13741979
best_fighter.png%%http://community.eu.playstation.com/t5/Announcements/Introducing-Best-of-PlayStation/td-p/13741979
best_creator.png%%http://community.eu.playstation.com/t5/Announcements/Introducing-Best-of-PlayStation/td-p/13741979
best_action_player.png%%http://community.eu.playstation.com/t5/Announcements/Introducing-Best-of-PlayStation/td-p/13741979
dev2.png%%http://community.eu.playstation.com/t5/Website-and-Forum-Help-Feedback/Producer-and-Developer-Ranks/td-p/18407352
trophy.gif%%http://community.eu.playstation.com/t5/Website-and-Forum-Help-Feedback/The-Community-Awards-FAQ/td-p/18407096
PSlogoSM.png%%http://community.eu.playstation.com/t5/Website-and-Forum-Help-Feedback/Online-Support-Coordinator-rank/td-p/18414870