Lightwave converter

Discussion area about developing or extending OGRE, adding plugins for it or building applications on it. No newbie questions please, use the Help forum for that.
User avatar
dennis
Gremlin
Posts: 157
Joined: Mon Nov 11, 2002 4:21 pm
x 3

Post by dennis »

It seems Ogre assumes that objects are 0,0,0 centric. To me this isn't a very realistic assumption.
Example:
A character standing usually stands on floorlevel at 0. If the character is 2 meters tall, the bounding sphere should then be 1 meter instead of 2.

Hmm ... I probably have to take some pivotpoint into the equasion.
User avatar
dennis
Gremlin
Posts: 157
Joined: Mon Nov 11, 2002 4:21 pm
x 3

Post by dennis »

Patch for 0.14 submitted:
createDeferred() => create()
addTextureLayer() => getTechnique(0)->getPass(0)->createTextureUnitState()
V coordinate flipped (v = 1.0f - v)
bounds set
User avatar
dennis
Gremlin
Posts: 157
Joined: Mon Nov 11, 2002 4:21 pm
x 3

Post by dennis »

Why is the alpha now integrated into the colour value and what do we use it for?
PJB
Gnoblar
Posts: 19
Joined: Mon Aug 16, 2004 1:48 am
Location: East Sussex, England

Post by PJB »

Hi Dennis,

sorry if this has been suggested before - I did a search before making the code change and didn't find it on these forums.

I made a change to the lwo converter based on my own experience with material name conflicts for freeby downloaded meshes. The bunch I found all had the same names for many of the materials and so I couldn't get the variety of cars in my test scenes that I wanted.
I added a -n parameter option to the lightwave converter to permit the user to specify a superscript string that is added to all material names in both the material script and the output mesh file.
I just hacked it in using a global variable, but I think this would be a useful feature for very many of your tool's users so perhaps you would consider adding it (more neatly!) to the next update?

BTW: thanks for an incredibly useful tool :)


cheers

Pete Baron
antispam_sibaroni@hotmail.com (remove 'antispam_' to mail me)
http://home.btconnect.com/pete/homepage.html
User avatar
dennis
Gremlin
Posts: 157
Joined: Mon Nov 11, 2002 4:21 pm
x 3

Post by dennis »

Hello Pete,

This seems to be a problem that could otherwise only be fixed by either editing the surface names in Lightwave or hacking the materials in the XML-version of the mesh. So I'll add the option, although I can't promise it will use the -n parameter.

regards,

Dennis
User avatar
TSi
Gnoblar
Posts: 8
Joined: Wed Sep 01, 2004 11:46 am
Location: Århus C, Denmark

Where's the source?

Post by TSi »

Mjello.

I've got the source for this tool from cvs, but it seems that there's been no change in the cvs repository for this tool for a long time. And the source in CVS doesn't compile with g++, and there aren't any makefiles either. So before I begin to write / "port" it to linux, I would loooove to know if there's a different updated source somewhere which compiles using g++ =) And where it is, of course =)
Magnus Møller Petersen
Meddten
Halfling
Posts: 71
Joined: Mon Aug 09, 2004 8:28 pm
Location: Austria

Post by Meddten »

i would like to know that too, if the converter is being still in development or if its canceled
User avatar
dennis
Gremlin
Posts: 157
Joined: Mon Nov 11, 2002 4:21 pm
x 3

Post by dennis »

Yes, I still maintain it. There's a patch in the queue ...

http://sourceforge.net/tracker/?group_i ... tid=302997

The last patch was to keep the converter up to date with 0.14. The source is in \ogrenew\Tools\LightwaveConverter. I currently use VC6 only.
User avatar
Sputnick
Greenskin
Posts: 110
Joined: Wed Sep 08, 2004 11:49 pm
Location: Lausanne, Switzerland

Working with Lightwave is good. Exporting from it is better

Post by Sputnick »

Good to know :wink:
- Sput
Meddten
Halfling
Posts: 71
Joined: Mon Aug 09, 2004 8:28 pm
Location: Austria

Post by Meddten »

How can i apply a patch with tortoise cvs?
User avatar
TSi
Gnoblar
Posts: 8
Joined: Wed Sep 01, 2004 11:46 am
Location: Århus C, Denmark

Doggie does Debbie's Dallas.

Post by TSi »

Meddten wrote:How can i apply a patch with tortoise cvs?
You have to go through sf.net:

Code: Select all

http://sourceforge.net/tracker/?func=add&group_id=2997&atid=302997
What kind of patch is it? For making it compile with gcc? I did that myself to day (was kinda bored). The only thing that still bugs me are the windows api functions _splitpath and friends.
Magnus Møller Petersen
Meddten
Halfling
Posts: 71
Joined: Mon Aug 09, 2004 8:28 pm
Location: Austria

Post by Meddten »

oh sorry for my misunderstanding spelling. i didn´t want to create a patch file i want to download this patchfile

http://sourceforge.net/tracker/index.ph ... tid=302997

and apply it to my version of ogre on my harddisk


how can i do that
User avatar
TSi
Gnoblar
Posts: 8
Joined: Wed Sep 01, 2004 11:46 am
Location: Århus C, Denmark

Patching all the way.

Post by TSi »

I'm not sure you can do that with Tortoise CVS. If you were using Linux, you would normally use the program called 'patch'. Or you could apply the patch by hand, by opening the patch-file, and copy-paste the changes to the files (only four files).

I'm sure other people know how to do this "the proper way" when using Windows =)

5 minutes later...

I found a windows port of patch. You could try that one out:

Code: Select all

http://gnuwin32.sourceforge.net/packages/patch.htm
Magnus Møller Petersen
User avatar
TSi
Gnoblar
Posts: 8
Joined: Wed Sep 01, 2004 11:46 am
Location: Århus C, Denmark

discontinuous vertex maps

Post by TSi »

The lightwave converter doesn't seem to support lightwave objects with discontinuous vertex maps. It converts them with no errors, but the texture mapping is all wrong when the object displayed in Ogre.
Magnus Møller Petersen
User avatar
TSi
Gnoblar
Posts: 8
Joined: Wed Sep 01, 2004 11:46 am
Location: Århus C, Denmark

LightwaveConverter Linux patch.

Post by TSi »

I've submitted a patch to make the converter compile / work under Linux with GCC.

http://sourceforge.net/tracker/index.ph ... tid=302997
Magnus Møller Petersen
User avatar
dennis
Gremlin
Posts: 157
Joined: Mon Nov 11, 2002 4:21 pm
x 3

Re: discontinuous vertex maps

Post by dennis »

TSi wrote:The lightwave converter doesn't seem to support lightwave objects with discontinuous vertex maps. It converts them with no errors, but the texture mapping is all wrong when the object displayed in Ogre.
These discontinuous vertex maps are known as VMADs in the .lwo-format. They are probably one of the greatest assets to the .lwo file format. It's just that they are evil :evil: to convert of course.

A VMAD provides an extra set of UV-coordinates which is tied to the polygon instead of the vertex itself. This means that for the conversion to work, the vertex has to be copied in order for it to contain the second UV-coordinate. Since I probably won't use VMADs any time soon, I don't know when I'll get around to implement a fix.
User avatar
TSi
Gnoblar
Posts: 8
Joined: Wed Sep 01, 2004 11:46 am
Location: Århus C, Denmark

Re: discontinuous vertex maps

Post by TSi »

dennis wrote:Since I probably won't use VMADs any time soon, I don't know when I'll get around to implement a fix.
I thought Lightwave, as default, saves objects with VMADs if applicable. *shrug* I guess I'll look into it when I have time, and when fixing buuugs =)
Magnus Møller Petersen
User avatar
_mental_
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 419
Joined: Mon Jan 27, 2003 11:51 pm
Location: The Woodlands, TX

Post by _mental_ »

I've committed the Linux compile fixes. Could someone check that this still works ok under Win32.
User avatar
dennis
Gremlin
Posts: 157
Joined: Mon Nov 11, 2002 4:21 pm
x 3

Post by dennis »

It still works under Win32. :D
User avatar
_mental_
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 419
Joined: Mon Jan 27, 2003 11:51 pm
Location: The Woodlands, TX

Post by _mental_ »

Cool. Thanks dennis.
User avatar
dennis
Gremlin
Posts: 157
Joined: Mon Nov 11, 2002 4:21 pm
x 3

Post by dennis »

Instantiating MeshManager seems to be requirement now ...

Code: Select all

Index: Tools/LightwaveConverter/src/main.cpp
===================================================================
RCS file: /cvsroot/ogre/ogrenew/Tools/LightwaveConverter/src/main.cpp,v
retrieving revision 1.6
diff -u -r1.6 main.cpp
--- Tools/LightwaveConverter/src/main.cpp	23 Oct 2004 22:24:26 -0000	1.6
+++ Tools/LightwaveConverter/src/main.cpp	25 Oct 2004 15:24:38 -0000
@@ -19,6 +19,7 @@
 Math* mth;
 MaterialManager* matMgr;
 SkeletonManager* skelMgr;
+MeshManager* meshMgr;
 MeshSerializer* meshSerializer;
 MaterialSerializer* materialSerializer;
 SkeletonSerializer* skeletonSerializer;
@@ -651,8 +652,9 @@
 	{
 		logMgr = new LogManager();
 		mth = new Math();
-		matMgr = new MaterialManager();;
-        matMgr->initialise();
+		matMgr = new MaterialManager();
+		matMgr->initialise();
+		meshMgr  = new MeshManager();
 		skelMgr = new SkeletonManager();
 		meshSerializer = new MeshSerializer();
 		materialSerializer = new MaterialSerializer();
@@ -709,9 +711,10 @@
 	else
 	{
 		delete bufferManager;
-	    delete skeletonSerializer;
+		delete skeletonSerializer;
 		delete materialSerializer;
 		delete meshSerializer;
+		delete meshMgr;
 		delete skelMgr;
 		delete matMgr;
 		delete mth;
User avatar
dennis
Gremlin
Posts: 157
Joined: Mon Nov 11, 2002 4:21 pm
x 3

Post by dennis »

Since the matter of supporting VMAD's (discontinuous vertex maps) has come up I feel strong about throwing out some code and do it better.

The datastructures for referencing this mapdata are really complex. What also intrigues me is the way different types of vertexdata can be declared separately. (VertexDeclaration) Does this mean I CAN attach 2 UV-coords to a vertex even though Sinbad stated I can't? (Actually this means attaching a second UV-map to all the vertices and not a single UV-coord to a single vertex.)

One thing I would like to do is to get the best possible mesh after conversion. Currently vertices are being copied per surface/submesh in the order they are encountered. This means that a single triangle could have one vertex at the start, one at the middle and one at the end of the vertexbuffer. Does that matter?

My idea is to traverse the triangles of a surface in some way and copy the vertexdata along the way. What would be the best traversal algorithm?

What should be taken into consideration for the optimal use of the shared vertex data structure? (Currently the user decides if the vertex data should be shared or not. The user can't specify which submeshes should share a vertex data buffer.)
User avatar
TSi
Gnoblar
Posts: 8
Joined: Wed Sep 01, 2004 11:46 am
Location: Århus C, Denmark

Post by TSi »

dennis wrote:One thing I would like to do is to get the best possible mesh after conversion. Currently vertices are being copied per surface/submesh in the order they are encountered. This means that a single triangle could have one vertex at the start, one at the middle and one at the end of the vertexbuffer. Does that matter?
If it does, then you could probably sort the stuff afterwards?
dennis wrote:My idea is to traverse the triangles of a surface in some way and copy the vertexdata along the way. What would be the best traversal algorithm?
Humm.. My idea is to eliminate the VMADs after the object has been loaded, but before you convert the object to a mesh. So I have been looking at doing something like this:

Code: Select all

lwObject::eliminateVMADs() {
  for each layer {
    layer->eliminateVMADs();
  }
}

lwLayer::eliminateVMADs() {
  for each vmap {
     if vmap->perpoly {
        for each point {
           check polygon, check vertex, replace uv-coords for points in toher vmaps.. yada yada.. not totally sure how to do this yet.
        }
     }
  }
}
.. and then finally convert the object to mesh. Anyway, I'm trying it out =)
Magnus Møller Petersen
User avatar
dennis
Gremlin
Posts: 157
Joined: Mon Nov 11, 2002 4:21 pm
x 3

Post by dennis »

I think traversing the polygons in the right order should solve everything in 1 go. I also think spreading the vertices of a single triangle out over the buffer is a bad idea, but I would like to know what some other experienced people think about this. Is the buffer optimised (stripified?) before it's written to disk?
User avatar
sinbad
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 19269
Joined: Sun Oct 06, 2002 11:19 pm
Location: Guernsey, Channel Islands
x 66

Post by sinbad »

The serializer does absolutely nothing to the data apart from writing it. Yeah, having vertices scattered around the buffer is sub-optimal since the vertex cache will not be used to its full. I would iterate over the faces of the mesh and identify unique vertices as you go. Alternatively nVidia has a vertex cache optimising tool IIRC which might offer some tips on this.