OBJ file with UVs

About Truespace Archives

These pages are a copy of the official truespace forums prior to their removal somewhere around 2011.

They are retained here for archive purposes only.

OBJ file with UVs // SDK, Plug-in & 3rd Party Area

1  2  |  

Post by frootee // Mar 27, 2009, 2:12pm

frootee
Total Posts: 2667
pic
Anyone have an OBJ file with a UV map?

I have updated the OBJ importer to support UV maps and I'd like to make sure

it is working correctly.


thanks!


Froo

Post by jamesmc // Mar 27, 2009, 8:09pm

jamesmc
Total Posts: 2566
See how you handle flipped and reversed textures. (evil laugh)

Should end up looking like image below

Post by jamesmc // Mar 27, 2009, 9:05pm

jamesmc
Total Posts: 2566
Paradise - no wait just dice. :)

Post by Tiles // Mar 27, 2009, 10:42pm

Tiles
Total Posts: 1037
pic
Just curious, why don't you simply save a textured mesh from Modeler using LUUV? Load it into Blender, save it as OBJ under another name, and you have a different written OBJ file too ... :)

Post by frootee // Mar 28, 2009, 2:21am

frootee
Total Posts: 2667
pic
Thanks James and Tiles.

I have not worked with textures very much, so

I wanted to be sure to work with a textured model

made by someone with more experience than me. :)

Post by Tiles // Mar 28, 2009, 2:39am

Tiles
Total Posts: 1037
pic
I see the point, but doesn't really need lots of experience to save your textured mesh ;)

The 3d meshes at my page comes all with OBJ, and are free to use. When you search for multitextured files have a look for the trees. They have two textures ...

Post by frootee // Mar 28, 2009, 3:40am

frootee
Total Posts: 2667
pic
thanks Tiles :)

Post by Jack Edwards // Mar 28, 2009, 10:27am

Jack Edwards
Total Posts: 4062
pic
Also if you create a primitive in Workspace it comes with a UV mapping that you can export with LUUV. ;)

Post by noko // Mar 29, 2009, 11:23am

noko
Total Posts: 684
Well I volumteer to be beta tester for your plug in :D. I normally import DAZ content via luuv and then bridge it to the nize universe of WS. Man would I love to go straight to WS and not have to follow the detour.

Post by frootee // Mar 29, 2009, 11:38am

frootee
Total Posts: 2667
pic
Thanks noko.

I had to add some functionality to the interface:

There are a couple checkboxes now:


1) Reverse handedness: To get the object to point in the right direction

2) flip backfaces on import


For #1, the object does get reversed, but they are still facing downward sometimes.


Currently there is something funky going on with the uv mapping. UV is totally new to me. I do not have the Material nodes automatically created yet. So for comparison, I am loading a mesh using LUUV, then copying the material node from that LUUV imported object, right into the node imported by the WS importer. I would think they would be identical but they are not.

Post by frootee // Mar 29, 2009, 12:49pm

frootee
Total Posts: 2667
pic
Fixed another problem with the interface.


When I was reversing handedness: right handed vs. left handed, the whole

mesh was inverted: all faces were pointing inward. Fixed that.


But the mesh still faces downward. Not sure why that happens but it seems to be happening to a lot of meshes. Perhaps the WS axes are off by 90 degrees;

i.e. I need to always rotate an object by 90 degrees about the x axis.


Here's a picture showing what I mean.

On the right, is the Tiles's Minnie imported using LUUV.

In the center, is the Minnie model imported using the WS OBJ importer.

This seems to be consistent with other models, though I need to test more.

I'd rather not have the user have to rotate their models after import.

Post by jamesmc // Mar 29, 2009, 2:26pm

jamesmc
Total Posts: 2566
Looking good froo!

Speaking of x,y,z rotation - is there a way to reset WorkSpace like there is on Model side?

i.e. normalize the entire grid before one imports an object.

Post by RAYMAN // Mar 29, 2009, 8:29pm

RAYMAN
Total Posts: 1496
pic
Frootee I just read the other day that the obj. file doesnt have a right or wrong axis direction and every application handles it differently so you will

be coming in in different directions depending on the application.

no normative !

Post by frootee // Mar 30, 2009, 1:44am

frootee
Total Posts: 2667
pic
thanks james and rayman. :)

Post by RichLevy // Mar 30, 2009, 2:13am

RichLevy
Total Posts: 1140
pic
I agree with the axis situation with obj... every application I have interprets the same file differently.

When is the beta? :D


Rich

Post by frootee // Mar 30, 2009, 2:18am

frootee
Total Posts: 2667
pic
thanks Rich. :)

Not sure when the beta will be ready,

but I think I know what may be wrong with the UV mapping.

Post by Nez // Mar 30, 2009, 4:07am

Nez
Total Posts: 1102
pic
I seem to recall Rayman pointing out the same happens in Kerky and it has an option somewhere to re-orient the model after import which is quite useful...

Post by frootee // Mar 30, 2009, 4:19am

frootee
Total Posts: 2667
pic
Thanks Nez.

I have an option to 'switch handedness'. Workspace

uses a Left Handed Orientation system. Some apps use

a Right Handed Orientation system.


By enabling the 'switch handedness' checkbox (need a good name for it), the OBJ data is converted to the Left Handed Orientation system.

Post by frootee // Mar 30, 2009, 5:56am

frootee
Total Posts: 2667
pic
Ok; this is the type of problem I am having with UVs currently.


I suspect the mapping is not being done correctly somewhere.


Both cubes in the scene have Smooth normals enabled.

Please try autofacet and facet normals as well.


The larger cube in this scene has been imported by LUUV. It looks correct.


The smaller cube has been imported by the WS importer.

It looks wrong. It looks worse when Autofacet is enabled.


Has anyone seen this type of problem before? Any idea as to the cause of the problem?


Thanks!


Froo

Post by Tiles // Mar 30, 2009, 6:37am

Tiles
Total Posts: 1037
pic
Looks like the geometry doesn't match the UV mapping. It is definitely damaged. Shows No UV Mapping warning. And Mesh doesn't even transfer to Modeler. A pity. Would've been interesting what LUUV writes out with that mesh ...

Post by prodigy // Mar 30, 2009, 6:42am

prodigy
Total Posts: 3029
pic
far as i can see froo, there's no UV on your Cube..

Use the UV editor, and you will see how there's no UV.

2nd, select faceted normals (Bad result) , then use set the cube UV on your cube, you will see how the texture back to normality..


Seems your cube has by default some kind of plane uv projection, see the front and back has the same texture position..

hope that helps..

Post by frootee // Mar 30, 2009, 7:03am

frootee
Total Posts: 2667
pic
Thanks Tiles and prodigy.


Tiles: I need to fix that in code.

But, it can be done manually.


In the LE: navigate into the object.

Select the Transform node.


Then, export the OBJMatrix output connector.


Now when you switch to Modeller you will see the object.


But as prodigy pointed out, there is no uv mapping.


Interesting. Maybe that's the missing piece; I am

reading the uv indices correctly, and accessing the coords correctly from the indices. Then, attaching the uv streams to the mesh.


I just exported the trashed cube from LUUV and for vt: I am getting a lot of -nan's (Not A Number). That's a clue.

Post by frootee // Mar 30, 2009, 7:40am

frootee
Total Posts: 2667
pic
Ok; it looks like it's a question of mapping.

As prodigy pointed out, the cube looked ok once cubic mappign was applied.

But wrt to other non-uniform objects, such as characters, do we need to select a specific mapping format? Shrink wrap, for example?


I tried Tiles's Winnie character and the UV map from the WS importer was mangled. However, when I imported the WInnie character from LUUV the uv map looked fine.

Post by prodigy // Mar 30, 2009, 7:53am

prodigy
Total Posts: 3029
pic
No Jason, each object has a specific UV mapping (if it has one) and it changes depending on how the modeler made it during the modeling process..

Imagine a cube with no mapping, other cube with a cylindrical mapping, other with a plane projection mapping but 45.86 grades... the possibilities are infinite..

Cube, plane cylindrical mapping are just predefined ''UV Shortcuts'' that help the modeler to map quickly a model.. imagine create a wall, without a cube projection mapping?? :D

so this tools are one ''click solutions'' for artists..

The UV must be inside somewhere the object.. but i really have no idea..

Post by Tiles // Mar 30, 2009, 8:00am

Tiles
Total Posts: 1037
pic
Each face has its own UV mapping. That's why you have the texture vertices vt in the obj file. It's the same way indexed than the vertices. You have your face, you have the vertices for this face. And you have the texture vertices for this face too. Which defines the mapping.


Usually the UV range goes from 0 to 1. Not sure if OBJ allows negative UV range or UV range bigger than 1 ...

Post by frootee // Mar 30, 2009, 8:02am

frootee
Total Posts: 2667
pic
Ok thanks Prodigy.

Basically, the OBJ file contains uv indices and uv coordinates.

I am reading these and attaching them correctly.


But I am currently not creating a Map to which this uv data is attached, as you've pointed out.


So, it sounds like I need to create and associate a map with the uv coordinates, and associate the uv map with the mesh. I believe, the code is working correctly up to this point. But, I just need to add this 'map' functionality.


I'll check it out. Thanks!


EDIT: Thanks also TIles! :D


Jason

Post by TomG // Mar 30, 2009, 8:04am

TomG
Total Posts: 3397
Yes, applying a UV mapping in tS once the object is loaded will not be what is required here. One of the big pluses of OBJ is that the file contains the UV mapping, so if someone has taken the time to apply skin, clothes, belts, accessories, etc, all with their own unique UV maps as needed, then they can be saved and loaded from the OBJ.


So it is important to grab the UV mapping from inside the OBJ, and apply that UV mapping to the tS object.


BTW Daz should give you some good test objects, it exports to OBJ and has very relevant UV maps, eg for applying skin materials to characters. Being free, should provide a valuable resource of test material :)


HTH!

Tom

Post by frootee // Mar 30, 2009, 8:38am

frootee
Total Posts: 2667
pic
Cool Figured it out.

I reviewed the RnHeightField.cpp file, which has uv coordinate stuff in it. Turns out I forgot to attach the uv coord stream to the mesh. But I did remember to attach the uv Triangle stream to the mesh:


// Already did this

spMesh->AttachTrianglesStream(spTriangleUvsGen);


// Forgot to do this

//uv coordinates go to custom stream group

spMesh->AttachCustStream(spUvCoordsGen);



Although, it looks like Winnie needs to learn how to put his clothes on. Socks on feet, Not socks on arm.

Post by Jack Edwards // Mar 30, 2009, 8:39am

Jack Edwards
Total Posts: 4062
pic
There is no "Map" needed. Either the UVs imported correctly or they didnt. They are part of the mesh and not the material.

It may be that you're not attaching the UV stream correctly. The UV data is a Custom stream but the UV indices stream is a triangle stream. See the discussion in this thread:
http://forums1.caligari.com/truespace/showthread.php?t=2363&page=2

To test the UV import, you may want to use a UV test pattern bitmap and my DX ConstantTexture material which you can drop on both models to see how the UVs are lining up. Load the test texture into the material then save the material to your library, so you can drag and drop it on the meshes with out needing to reload the texture.

Post by frootee // Mar 30, 2009, 11:08am

frootee
Total Posts: 2667
pic
Hi Jack.

Where is your DX Constant Texture shader?


Also, do you have a test bitmap? I've seen one somewhere around here

with colored squares; each square is numbered.


thanks
Awportals.com is a privately held community resource website dedicated to Active Worlds.
Copyright (c) Mark Randall 2006 - 2024. All Rights Reserved.
Awportals.com   ·   ProLibraries Live   ·   Twitter   ·   LinkedIn