home |  downloads |  help  |  forum  |  contact us 
Welcome, Guest. Please login or register.
Did you miss your activation email?
May 25, 2013, 01:24:49 PM

Login with username, password and session length
Search:     Advanced search
fragMOTION 1.2.2 Released!
2787 Posts in 689 Topics by 789 Members
Latest Member: seanfisher7886
* Home Help Search Login Register
+  Fragmosoft Forum
|-+  fragMOTION
| |-+  Scripting
| | |-+  Faces, vertex and UVs
« previous next »
Pages: [1] 2 Go Down Print
Author Topic: Faces, vertex and UVs  (Read 2466 times)
Richcat
Newbie
**
Posts: 32


View Profile
Faces, vertex and UVs
« on: December 07, 2011, 02:05:54 PM »

Hi
Still working on exporter script.
Still very much learning, Smiley 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? Huh

Tried
local f = editChar:GetDefaultMesh();
local f1 = f:GetVertexUVCoords();
print(f1,face.uv[1]);

with no luck Sad

Thanks Rich
Logged
fragmo
Administrator
Not A Newbie
*****
Posts: 10664



View Profile
Re: Faces, vertex and UVs
« Reply #1 on: December 07, 2011, 04:19:01 PM »

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
Newbie
**
Posts: 32


View Profile
Re: Faces, vertex and UVs
« Reply #2 on: December 07, 2011, 04:46:14 PM »

Thanks Fragmo Grin

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 Smiley

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 Wink

Rich
Logged
fragmo
Administrator
Not A Newbie
*****
Posts: 10664



View Profile
Re: Faces, vertex and UVs
« Reply #3 on: December 07, 2011, 08:03:03 PM »

Quote
I presume I use a similar script to get tverts, normals, UV's

yes, normals and uvs are stored in the faces

Quote
Are there any other exporter Lua scripts for Fragmotion

I'm not aware of any exporter scripts
Logged
Richcat
Newbie
**
Posts: 32


View Profile
Re: Faces, vertex and UVs
« Reply #4 on: December 08, 2011, 02:49:45 AM »

Thanks Fragmo  Cool - back to testing those out

I haven't found any either for Fragmotion Sad, only some lua 4.0 for another program  Lips Sealed

Rich
Logged
Richcat
Newbie
**
Posts: 32


View Profile
Re: Faces, vertex and UVs
« Reply #5 on: December 09, 2011, 09:08:17 AM »

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
Newbie
**
Posts: 32


View Profile
Re: Faces, vertex and UVs
« Reply #6 on: December 18, 2011, 04:59:58 PM »

Hi Fragmo

Still at it, and have made some advances in my knowledge. Smiley

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. Smiley

Rich
Logged
davidoc
Newbie
**
Posts: 18


View Profile
Re: Faces, vertex and UVs
« Reply #7 on: December 18, 2011, 08:33:42 PM »

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
Newbie
**
Posts: 32


View Profile
Re: Faces, vertex and UVs
« Reply #8 on: December 19, 2011, 03:02:48 AM »

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.

Shocked 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
Newbie
**
Posts: 18


View Profile
Re: Faces, vertex and UVs
« Reply #9 on: December 19, 2011, 09:05:26 AM »

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
Administrator
Not A Newbie
*****
Posts: 10664



View Profile
Re: Faces, vertex and UVs
« Reply #10 on: December 19, 2011, 11:45:37 PM »

Hi Fragmo

Still at it, and have made some advances in my knowledge. Smiley

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. Smiley

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
Newbie
**
Posts: 32


View Profile
Re: Faces, vertex and UVs
« Reply #11 on: December 20, 2011, 02:22:00 AM »

Thanks Fragmo. Cool

I spotted that on the Type library, but struggled with how to implement it.  Embarrassed
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
Newbie
**
Posts: 32


View Profile
Re: Faces, vertex and UVs
« Reply #12 on: January 04, 2012, 05:03:25 PM »

A bit stuck again, wonder if anyone can help Smiley.

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
Administrator
Not A Newbie
*****
Posts: 10664



View Profile
Re: Faces, vertex and UVs
« Reply #13 on: January 04, 2012, 09:03:06 PM »

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
Newbie
**
Posts: 32


View Profile
Re: Faces, vertex and UVs
« Reply #14 on: January 05, 2012, 11:26:27 AM »

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 Go Up Print 
« previous next »
Jump to:  

Powered by MySQL Powered by PHP Fragmosoft Forum | Powered by SMF 1.0.8.
© 2001-2005, Lewis Media. All Rights Reserved.
Valid XHTML 1.0! Valid CSS!