Pages: [1] 2
|
 |
|
Author
|
Topic: Faces, vertex and UVs (Read 2466 times)
|
|
Richcat
|
Hi Still working on exporter script. Still very much learning,  and making good progress but really stuck on how to get the face, vertex, or normals, or UV array to print as 1,3,2 and 4,2,6 etc. Tried local f = editChar:GetDefaultMesh(); local f1 = f:GetVertexUVCoords(); print(f1); end which gave face_Array (039B2378) - which has got me really stumped - how do I get to array info?  Tried local f = editChar:GetDefaultMesh(); local f1 = f:GetVertexUVCoords(); print(f1,face.uv[1]); with no luck  Thanks Rich
|
|
|
|
|
Logged
|
|
|
|
|
fragmo
|
local mesh = editChar:GetDefaultMesh();
local verts, vert_count, faces, face_count = mesh:LockMesh();
for i = 0, vert_count-1, 1 do print(verts[i].x, verts[i].y, verts[i].z); end
mesh:UnlockMesh();
|
|
|
|
|
Logged
|
|
|
|
|
Richcat
|
Thanks Fragmo  Thats a real help, its had me stumped for more that a few days, I presume I use a similar script to get tverts, normals, UV's etc? - time to start testing again  Are there any other exporter Lua scripts for Fragmotion I could look at for reference, and learn from. I have searched but have not found any. PS. The lua 5.0 manual is good bedtime reading  Rich
|
|
|
|
|
Logged
|
|
|
|
|
fragmo
|
I presume I use a similar script to get tverts, normals, UV's yes, normals and uvs are stored in the faces Are there any other exporter Lua scripts for Fragmotion I'm not aware of any exporter scripts
|
|
|
|
|
Logged
|
|
|
|
|
Richcat
|
Thanks Fragmo  - back to testing those out I haven't found any either for Fragmotion  , only some lua 4.0 for another program  Rich
|
|
|
|
|
Logged
|
|
|
|
|
Richcat
|
Hi Fragmo
Just to let you know its working spot on my end, and I'm tweaked it to get faces verts aswell - normals and uv yet to try
Is there anyway to get it to ignore back faces? (EDIT - ignore this something was wrong with the model)
Rich
|
|
|
|
« Last Edit: December 09, 2011, 09:29:33 AM by Richcat »
|
Logged
|
|
|
|
|
Richcat
|
Hi Fragmo Still at it, and have made some advances in my knowledge.  Are the group names stores here in the faces as well? I'm going off the Face Info gadget here as when I hover over a face I get the info panel, which has a lot of info displayed, so assumed all this info is stored in the faces, - but just can't seem to get at it all , such as the group name the face belongs to. I may need to re think my stratergy as to export the correct info for the game, I need to select each group in turn (unless you can have seperate meshes - which I don't think you can) and get its name, normals verts, smoothing, and mesh animation etc. I've got some code to work to get the group first and last child, but can't get any in between. Any pointers will help - some of the fog is begining to clear with your help, but it still quite misty.  Rich
|
|
|
|
|
Logged
|
|
|
|
|
davidoc
|
I also want to know if it's safe to asume only one mesh is allowed in the model. In the first test for my exporter I looped through the groups, but I achived the same result asuming only one mesh is in the model.
If you still want to iterate the groups then get the firts child, then with this child get the next sibling until it's not set
|
|
|
|
|
Logged
|
|
|
|
|
Richcat
|
Hi Daviddoc Yes - thats what I have been doing so far - getting it to read all info from "1" mesh, with basic extraction of faces UV etc , but with your tip on iterating groups and then first child and on so on I'll see if I can to work out how to do individual groups - I had tried this previously as below but kept getting same name of group. editChar:ClearOutput(); local mesh = editChar:GetModel(); local nofg = mesh:GroupCount(pCount); print(nofg); for i = 1, nofg, 1 do local allGroups = mesh:GetGroups(i); local Groupnames1 = allGroups:GetFirstChild(); local Groupname1 = Groupnames1.Name; print(Groupname1); local allGroups = allGroups:GetNextSibling(); end I have downloaded your scripts to have a look at what you did, and will try this again - having had a quick look theres so much in them I'm trying to digest it now.  they are so advanced to my efforts. For instance I was wondering how I was going to write the file out, and you have some code in there I can adapt (If you don't mind) Rich
|
|
|
|
|
Logged
|
|
|
|
|
davidoc
|
I'm glad you find the scripts useful and of course I don't mind if you adapt or modify them, I posted them with that purpose.
|
|
|
|
|
Logged
|
|
|
|
|
fragmo
|
Hi Fragmo Still at it, and have made some advances in my knowledge.  Are the group names stores here in the faces as well? I'm going off the Face Info gadget here as when I hover over a face I get the info panel, which has a lot of info displayed, so assumed all this info is stored in the faces, - but just can't seem to get at it all , such as the group name the face belongs to. I may need to re think my stratergy as to export the correct info for the game, I need to select each group in turn (unless you can have seperate meshes - which I don't think you can) and get its name, normals verts, smoothing, and mesh animation etc. I've got some code to work to get the group first and last child, but can't get any in between. Any pointers will help - some of the fog is begining to clear with your help, but it still quite misty.  Rich There is only 1 mesh This is the triangle structure: typedef struct tagfragTriangle { WORD flags; WORD index[3]; // index into the vertex array returned by IMesh::LockMesh DWORD matID; DWORD groupID; DWORD smoothID; vertex3d faceNormal; vertex3d normals[3]; // vertex normals vertex2d uv[3]; // texture coords DWORD diffuse[3]; // ignore DWORD specular[3]; // ignore WORD uvgroup[3]; // ignore WORD selGroup; // ignore } fragTriangle; The material, group and smoothing group are matID, groupID, and smoothID. They are ID's of objects and you can obtain those objects by calling IUserObject::GetObjectByID
|
|
|
|
|
Logged
|
|
|
|
|
Richcat
|
Thanks Fragmo.  I spotted that on the Type library, but struggled with how to implement it.  I need to read through the FragmotionType libary a few more times, and the other scripts, to increase my understanding. Rich
|
|
|
|
« Last Edit: December 20, 2011, 02:28:21 AM by Richcat »
|
Logged
|
|
|
|
|
Richcat
|
A bit stuck again, wonder if anyone can help  . With help from you guys I can now can iterate throught individual groups to get Group names and faces , textures etc, but can only get vertex coords for all the mesh, I'm trying to find a way to get vertex coords for individual groups, and have had no luck so far. Rich
|
|
|
|
|
Logged
|
|
|
|
|
fragmo
|
There is no vertex list associated with a group. You'll have to loop through all the faces in the mesh and pull the vertices from each face that is assigned to the group you want.
|
|
|
|
|
Logged
|
|
|
|
|
Richcat
|
Thanks Fragmo. I thought as much as I seemed to have tried as many ways as possible with no luck - Just wondered if I was missing the obvious.
One avenue I was looking at was to use sort of script to run throught and Select the individual groups in turn (faces and vertex), (a bit like you can do manaully) and use GetSelVertexCount, as a starting point.
Rich
|
|
|
|
|
Logged
|
|
|
|
|
Pages: [1] 2
|
|
|
 |