Print at Dec 17, 2025, 10:42:12 AM

Posted by hansmex at Oct 11, 2010, 4:49:14 PM
Applying a texture in an OBJ file
Ladies and gentlemen,

While playing around with the one-sided box, I decided to try and make a box where textures will be correctly aligned on all visible faces.

Using the one-sided box as a template, I made several "new" boxes with 6 separate faces, trying to manipulate the way textures are applied. However, every time I import the OBJ in SH3D, the textures are applied the same way.

After comparing several OBJ files, I found that the difference with a standard box and a textured box lies in the "vt" and "f v/vt/vn" values.
- In a standard box the "vt" value is omitted because there is no texture, so the we get "f v//vn".
- In a textured box the "vt" value is specified twice and in different ways. Once separately as "vt" and once within the "f" value "f v/vt/vn".

From the data in the OBJ file with texture, I can clearly see that the separate "vt" statement is connected to the size of the texture relative to the size of the object. Does this statement have a second function?

A box with 6 faces (defined in a slightly different way as the standard SH3D box) gives these values when a texture is applied:
f...1/1/1...2/2/1...3/3/1
f...1/1/1...3/3/1...4/4/1

A standard SH3D box gives slightly different values when a texture is applied:
f...1/1/1...2/2/1...3/3/1
f...4/4/1...1/1/1...3/3/1

(Dots entered for clarity, as the forum software doesn't allow multiple spaces.)

Is this difference significant? In both cases the textures are applied correctly only on 3 of the visible sides.

The main questions, then, are:
- Which value(s) should be changed when designing a 6-faced cube in order to change the way textures are oriented on a specific face?
- Can this be defined in an OBJ file in such a way that a general purpose box is defined to which users can apply (in SH3D!) a texture that will always be oriented in the same way on 4 faces of the box?

I hope I explain myself clearly.

Hans
----------------------------------------
Hans

new website - under constuction
hansdirkse.info