Model + texture?

Post requests, images, descriptions and reports about work in progress here.
Topic author
abramson
Posts: 408
Joined: 22.07.2003
With us: 21 years 4 months
Location: Bariloche, Argentina

Model + texture?

Post #1by abramson » 10.08.2011, 22:35

Hi all. I have been trying to adapt a model of Vesta made by a guy at unmannedspaceflight (Tyfun). I found two difficulties:

1. I couldn't map a texture on it. I tried what I thought was right: an ssc (see below) defining the mesh and the texture. I noted that the cmod made by 3dstocmod (the original model is a 3ds) lacked a material, so I added a diffuse one (I read at Selden's place that only diffuse models can have their texture replaced by an ssc).

2. I couldn't rotate the model appropriately. I read (also at Selden's) that some programs produce models which are rotated with respect to Celestia needs. So I added a rotation in the ssc. It didn't work.

Surprisingly, commenting out the Mesh line in the ssc correctly wraps the texture on the standard Vesta model of Celestia (it's the video I showed on another thread).

Any idea on what I am doing wrong? Thanks.

Some details. The ssc says something like this:

Code: Select all

Modify "4 Vesta:Vesta" "Sol"
{
  Mesh "vesta.cmod"     # vesta.cmod is in folder ./models
  Texture "vesta.jpg"    # vesta.jpg is in folder ./textures/medres
  Orientation [-90 0 0]   # this one has NO effect
}


The ascii version of the model (I used both this one and the binary, generated by cmodview) says:

Code: Select all

#celmodel__ascii

material
diffuse 0.5 0.5 0.5   <- this I added by hand
opacity 1.0               <- this I added by hand
end_material

mesh
vertexdesc
position f3
normal f3
end_vertexdesc

vertices 11904
-0.350018 0.159879 241.661 -0.000296335 -0.121033 0.992648
-0.298044 23.6474 241.628 0.21904 0.135771 0.966224
...
-0.29615 -1.34105e-006 -227.494 0.0733081 -0.152258 -0.985618
-0.296143 22.4924 -227.609 -0.0670438 -0.0217 -0.997514
1.91186 22.4169 -227.939 -0.225818 -0.0451936 -0.973121

trilist 0 11904
0 1 2 3 4 5 6 7 8 9 10 11
12 13 14 15 16 17 18 19 20 21 22 23
24 25 26 27 28 29 30 31 32 33 34 35
...
11880 11881 11882 11883 11884 11885 11886 11887 11888 11889 11890 11891
11892 11893 11894 11895 11896 11897 11898 11899 11900 11901 11902 11903

end_mesh

Avatar
selden
Developer
Posts: 10192
Joined: 04.09.2002
With us: 22 years 3 months
Location: NY, USA

Re: Model + texture?

Post #2by selden » 11.08.2011, 00:04

The problem is that the CMOD's mesh definition does not include any texture coordinates.
Selden

Avatar
John Van Vliet
Posts: 2944
Joined: 28.08.2002
With us: 22 years 3 months

Re: Model + texture?

Post #3by John Van Vliet » 11.08.2011, 01:49

--- edit ---
Last edited by John Van Vliet on 19.10.2013, 07:13, edited 3 times in total.

Avatar
selden
Developer
Posts: 10192
Joined: 04.09.2002
With us: 22 years 3 months
Location: NY, USA

Re: Model + texture?

Post #4by selden » 11.08.2011, 01:55

John,

The ... in the middle means that he intentionally didn't include all of the points.
Selden

Topic author
abramson
Posts: 408
Joined: 22.07.2003
With us: 21 years 4 months
Location: Bariloche, Argentina

Re: Model + texture?

Post #5by abramson » 11.08.2011, 01:56

john Van Vliet wrote:there is only 6 there
Nay, John. The three dots were there to mean an ellipsis, both in the vertices and in the trilist. There was no point in pasting thousands of numbers. That's not the problem. Thanks anyway.

Avatar
selden
Developer
Posts: 10192
Joined: 04.09.2002
With us: 22 years 3 months
Location: NY, USA

Re: Model + texture?

Post #6by selden » 11.08.2011, 02:05

Here's an example cmod (a cube) which includes texture coordinates in the last two elements of each vertex. They determine what relative position within the texture image is to be placed at each vertex position. In this case, the corners of the picture are at the corners of the cube.

Code: Select all

#celmodel__ascii

material
  diffuse 0.615 0.615 0.615
  opacity 1
  texture0      "my_texture.*"
end_material

 mesh      # cube01

vertexdesc
 position f3 normal f3 texcoord0 f2
end_vertexdesc

vertices 24
-7.929517 -5.359765 -4.552135  0 0 -1  0 1
1.174742 -5.359765 -4.552135  0 0 -1  1 1
1.174742 9.618209 -4.552135  0 0 -1  1 0
-7.929517 9.618209 -4.552135  0 0 -1  0 0
-7.929517 -5.359765 4.552124  0 0 1  0 1
-7.929517 9.618209 4.552124  0 0 1  0 0
1.174742 9.618209 4.552124  0 0 1  1 0
1.174742 -5.359765 4.552124  0 0 1  1 1
-7.929517 -5.359765 -4.552135  -1 0 0  0 1
-7.929517 9.618209 -4.552135  -1 0 0  0 0
-7.929517 9.618209 4.552124  -1 0 0  0 0
-7.929517 -5.359765 4.552124  -1 0 0  0 1
1.174742 -5.359765 -4.552135  1 0 0  1 1
1.174742 -5.359765 4.552124  1 0 0  1 1
1.174742 9.618209 4.552124  1 0 0  1 0
1.174742 9.618209 -4.552135  1 0 0  1 0
-7.929517 9.618209 -4.552135  0 1 0  0 0
1.174742 9.618209 -4.552135  0 1 0  1 0
1.174742 9.618209 4.552124  0 1 0  1 0
-7.929517 9.618209 4.552124  0 1 0  0 0
-7.929517 -5.359765 -4.552135  0 -1 0  0 1
-7.929517 -5.359765 4.552124  0 -1 0  0 1
1.174742 -5.359765 4.552124  0 -1 0  1 1
1.174742 -5.359765 -4.552135  0 -1 0  1 1


 trilist 0 36
    0 2 1
    0 3 2
    4 6 5
    4 7 6
    8 10 9
    8 11 10
    12 14 13
    12 15 14
    16 18 17
    16 19 18
    20 22 21
    20 23 22

 end_mesh
Selden

Avatar
John Van Vliet
Posts: 2944
Joined: 28.08.2002
With us: 22 years 3 months

Re: Model + texture?

Post #7by John Van Vliet » 11.08.2011, 02:10

--- edit ---
Last edited by John Van Vliet on 19.10.2013, 07:12, edited 1 time in total.

Topic author
abramson
Posts: 408
Joined: 22.07.2003
With us: 21 years 4 months
Location: Bariloche, Argentina

Re: Model + texture?

Post #8by abramson » 11.08.2011, 02:43

Thanks, Selden. I tried your cube, put Vesta texture, and got a nice cubic Vesta. So far so good.

I used the same heading in vesta.cmod, and got an invisible object. I commented out the texture directives and got the blank cmod. Something I can't see is not working... :?

Code: Select all

#celmodel__ascii

material
  diffuse 0.615 0.615 0.615
  opacity 1
#  texture0      "vesta.*"  <- commenting out this...
end_material

mesh      # cube01

vertexdesc
position f3 normal f3
#texcoord0 f2              <- and this, shows the model, blank; uncommenting, invisible.
end_vertexdesc

vertices 11904
...


vesta-cmod+texture.jpg


vesta-cmod.jpg

Avatar
selden
Developer
Posts: 10192
Joined: 04.09.2002
With us: 22 years 3 months
Location: NY, USA

Re: Model + texture?

Post #9by selden » 11.08.2011, 11:26

In addition to the header which specifies which of the vertex values are texture coordinates, the mesh needs to provide those coordinates for each vertex. The vertex list in the model that you posted above includes only 6 numeric values for each vertex. An additional 2 values need to be specified.

As best I can tell, the texture mapping needs to have been included in the original 3DS model. If it doesn't have any, 3dsconv and cmodfix can't create them. In other words, you need to load the model into a 3D design program and use it to project a texture onto the model. You also can rotate the model in the design program and export it with the correct orientation.
Selden

Avatar
Fenerit M
Posts: 1880
Joined: 26.03.2007
Age: 17
With us: 17 years 8 months
Location: Thyrrenian sea

Re: Model + texture?

Post #10by Fenerit » 11.08.2011, 12:52

Most probably the model has been tassellated from tabular data and then converted to 3DS "as it is", just because the n° of polys were under 65k. The lacking of "texcoord0 f2"'s string is obviuos.
Never at rest.
Massimo

Topic author
abramson
Posts: 408
Joined: 22.07.2003
With us: 21 years 4 months
Location: Bariloche, Argentina

Re: Model + texture?

Post #11by abramson » 11.08.2011, 12:55

selden wrote:In addition to the header...
Understood! I didn't know all this! I will try again tonight...
Thanks, Selden!

Avatar
selden
Developer
Posts: 10192
Joined: 04.09.2002
With us: 22 years 3 months
Location: NY, USA

Re: Model + texture?

Post #12by selden » 11.08.2011, 13:27

abramson wrote:
selden wrote:In addition to the header...
Understood! I didn't know all this! I will try again tonight...
Thanks, Selden!

You're very welcome.
Selden

W0RLDBUILDER
Posts: 122
Joined: 02.06.2010
With us: 14 years 6 months

Re: Model + texture?

Post #13by W0RLDBUILDER » 11.08.2011, 20:50

Open the 3ds in Anim8or and go to Options>Component>Texture UV... and select Spherical. Re-export as 3ds (or use Selden's script to export a cmod) and it should work with a texture.

Topic author
abramson
Posts: 408
Joined: 22.07.2003
With us: 21 years 4 months
Location: Bariloche, Argentina

Re: Model + texture?

Post #14by abramson » 11.08.2011, 22:05

W0RLDBUILDER wrote:Open the 3ds in Anim8or and go to Options>Component>Texture UV... and select Spherical.

Different versions of Anim8or? I have Settings (not Options) > Component > Texture UV... but no Spherical option there... 8O

I have Scale, Offset, Angle, Axis and a checkbox for Apply interactively. I have tried to use this, but the texture is not wrapped correctly. It's weird, I can manage complex programs, write my own scientific programs in several languages, but my experience with these tools is so poor! I find everything so strange...

fungun
Posts: 315
Joined: 30.07.2007
Age: 63
With us: 17 years 4 months
Location: Iowa, USA

Re: Model + texture?

Post #15by fungun » 11.08.2011, 22:10

You need Anim8or v097d preview for what W0RLDBUILDER said to do.
It's under "Settings" not "Options".
Tim

Avatar
John Van Vliet
Posts: 2944
Joined: 28.08.2002
With us: 22 years 3 months

Re: Model + texture?

Post #16by John Van Vliet » 11.08.2011, 23:12

--- edit ---
Last edited by John Van Vliet on 19.10.2013, 07:11, edited 1 time in total.

Topic author
abramson
Posts: 408
Joined: 22.07.2003
With us: 21 years 4 months
Location: Bariloche, Argentina

Re: Model + texture?

Post #17by abramson » 11.08.2011, 23:27

Thanks Fungun! That helped! Thank you all, Worldbuilder, Selden, all. I'm getting the hang of it! So unusual!

I will upload some images and videos later IF I can get something.

(By the way, in the meantime I found LithUnwrap, very easy to use, that one put me in the right path.)

Topic author
abramson
Posts: 408
Joined: 22.07.2003
With us: 21 years 4 months
Location: Bariloche, Argentina

Re: Model + texture?

Post #18by abramson » 13.08.2011, 21:44

I'm sorry, I got distracted and didn't come back. I succeeded, and it's fun to fly around Vesta. I made a couple of videos. video 1 video 2.

It will be a fun year around Vesta!

W0RLDBUILDER
Posts: 122
Joined: 02.06.2010
With us: 14 years 6 months

Re: Model + texture?

Post #19by W0RLDBUILDER » 15.08.2011, 22:46

fungun wrote:It's under "Settings" not "Options".
Oops, yeah. I fail. It is Settings.

Topic author
abramson
Posts: 408
Joined: 22.07.2003
With us: 21 years 4 months
Location: Bariloche, Argentina

Re: Model + texture?

Post #20by abramson » 15.08.2011, 23:03

W0RLDBUILDER wrote:Oops, yeah. I fail. It is Settings.
That's OK, World. I managed. Thanks.


Return to “Add-on development”