Changing the color of a mesh at runtime...

General discussion about Celestia that doesn't fit into other forums.
Avatar
Topic author
Chuft-Captain
Posts: 1779
Joined: 18.12.2005
With us: 18 years 11 months

Changing the color of a mesh at runtime...

Post #1by Chuft-Captain » 05.06.2008, 15:47

Hi,

Would someone be able to tell me what the "Color" statement does in an SSC file? I've seen it used or mentioned somewhere, but can't remember where.

I assumed that it would be used to apply a specific color to an object mesh, but it seems to have no affect in my Celestia. All meshes have a default white color even when the statement is applied. eg:

Code: Select all

Color [ 0 1 0 ]


Question 2: Is there an equivalent LUA function/method to apply a color to a mesh/object?
I cannot see anything like this in the Scripting Wikibook.

Thanks
CC
Last edited by Chuft-Captain on 07.06.2008, 01:25, edited 1 time in total.
"Is a planetary surface the right place for an expanding technological civilization?"
-- Gerard K. O'Neill (1969)

CATALOG SYNTAX HIGHLIGHTING TOOLS LAGRANGE POINTS

Avatar
Cham M
Posts: 4324
Joined: 14.01.2004
Age: 60
With us: 20 years 10 months
Location: Montreal

Re: Color statement in an SSC

Post #2by Cham » 05.06.2008, 16:05

This color command is applied to the dot you see, at a distance. If you wantto apply it to the object itself, add the command line "BlendTexture true".
"Well! I've often seen a cat without a grin", thought Alice; "but a grin without a cat! It's the most curious thing I ever saw in all my life!"

chris
Site Admin
Posts: 4211
Joined: 28.01.2002
With us: 22 years 9 months
Location: Seattle, Washington, USA

Re: Color statement in an SSC

Post #3by chris » 05.06.2008, 17:24

The color property is meant to be the global average surface color of the planet. Thus, Cham is correct that it is the color of the dot seen when a planet is less than a pixel. It is also determines the color of planetshine from an object.

--Chris

Avatar
Topic author
Chuft-Captain
Posts: 1779
Joined: 18.12.2005
With us: 18 years 11 months

Re: Color statement in an SSC

Post #4by Chuft-Captain » 05.06.2008, 17:38

Thanks guys,

I'll try the "BlendTexture true" statement Cham.... however, what I'd really like to is find a LUA method that has the same effect... which would allow for changing the color in a script.

I take it that there is none (or you would have told me about it Chris :wink: )

Cheers
CC


UPDATE: I tried the following Cham, but my object (Class Spacecraft) is still white:

Code: Select all

Color   [ 0 1 1]
BlendTexture true


Perhaps this only works for planets, moons, etc???
"Is a planetary surface the right place for an expanding technological civilization?"
-- Gerard K. O'Neill (1969)

CATALOG SYNTAX HIGHLIGHTING TOOLS LAGRANGE POINTS

Avatar
Topic author
Chuft-Captain
Posts: 1779
Joined: 18.12.2005
With us: 18 years 11 months

Re: Color statement in an SSC

Post #5by Chuft-Captain » 05.06.2008, 17:46

Actually, I suspect the problem is that this only works for Celestia's default spherical meshes, but not for modelled meshes.

My test object is a simple cube implemented as either a 3ds or cmod.

EDIT: Confirmed. Commenting out the "Mesh..." statement and changing the class to "Planet" gives me a colored sphere instead of a white cube.

Now, if only I could use a celX command instead of the SSC statement..... Vincent??? :wink:
"Is a planetary surface the right place for an expanding technological civilization?"
-- Gerard K. O'Neill (1969)

CATALOG SYNTAX HIGHLIGHTING TOOLS LAGRANGE POINTS

Avatar
Topic author
Chuft-Captain
Posts: 1779
Joined: 18.12.2005
With us: 18 years 11 months

Re: Color statement in an SSC

Post #6by Chuft-Captain » 06.06.2008, 14:17

Cham wrote:This color command is applied to the dot you see, at a distance. If you wantto apply it to the object itself, add the command line "BlendTexture true".
Cham, have you used this statement to apply color to spacecraft meshes (or only to planets and moons)?

I found the Color [...] statement works fine for planets (without a Blendtexture statement, but neither statement has any effect on spacecraft meshes.

Does anyone know if the color property can be modified via LUA?
eg. an object.setcolor method would be nice, but I haven't any such method in the documentation.
"Is a planetary surface the right place for an expanding technological civilization?"
-- Gerard K. O'Neill (1969)

CATALOG SYNTAX HIGHLIGHTING TOOLS LAGRANGE POINTS

BobHegwood
Posts: 1803
Joined: 12.10.2007
With us: 17 years 1 month

Re: Color statement in an SSC

Post #7by BobHegwood » 06.06.2008, 15:14

Chuft,

You can also use the Anim8or program to add textures to your models (assuming that they are 3ds files.) When finished, you can then convert them to CMODs if you like.
The Anim8or program takes a bit of getting used to, but even a simpleton like me can add textures (and colors) to the faces applied to a 3ds mesh.

Just FYI... :wink:
Brain-Dead Geezer Bob is now using...
Windows Vista Home Premium, 64-bit on a
Gateway Pentium Dual-Core CPU E5200, 2.5GHz
7 GB RAM, 500 GB hard disk, Nvidia GeForce 7100
Nvidia nForce 630i, 1680x1050 screen, Latest SVN

zhar2
Posts: 204
Joined: 22.03.2008
With us: 16 years 8 months

Re: Color statement in an SSC

Post #8by zhar2 » 06.06.2008, 15:28

can you apply the textures straight from blender or 3dmax too?

BobHegwood
Posts: 1803
Joined: 12.10.2007
With us: 17 years 1 month

Re: Color statement in an SSC

Post #9by BobHegwood » 06.06.2008, 15:44

zhar2 wrote:can you apply the textures straight from blender or 3dmax too?

Dunno...
Could not figure out how to even use the Blender, and I have absolutely NO experience with 3dmax.
Sorry, Bob
Brain-Dead Geezer Bob is now using...
Windows Vista Home Premium, 64-bit on a
Gateway Pentium Dual-Core CPU E5200, 2.5GHz
7 GB RAM, 500 GB hard disk, Nvidia GeForce 7100
Nvidia nForce 630i, 1680x1050 screen, Latest SVN

zhar2
Posts: 204
Joined: 22.03.2008
With us: 16 years 8 months

Re: Color statement in an SSC

Post #10by zhar2 » 06.06.2008, 15:59

Well the problem with blender its that its menus configuration seems to be "user hostile" and it takes a good old mouse (with 3 buttoms btw) to work, and as i use a laptop the mouse pad is hell to work on blender (need to buy the mouse).

And 3d max is a sweetheart, could not like it any more (besides its awfull price tag).

Avatar
Topic author
Chuft-Captain
Posts: 1779
Joined: 18.12.2005
With us: 18 years 11 months

Re: Color statement in an SSC

Post #11by Chuft-Captain » 07.06.2008, 00:34

BobHegwood wrote:Chuft,

You can also use the Anim8or program to add textures to your models (assuming that they are 3ds files.) When finished, you can then convert them to CMODs if you like.
The Anim8or program takes a bit of getting used to, but even a simpleton like me can add textures (and colors) to the faces applied to a 3ds mesh.

Just FYI... :wink:
Bob,

Thanks for the comment, however that's something I know already, in fact just about all the textures in my models are applied in exactly that way. I've been using Anim8tor for at least couple of years now (although I'm not the world's best modeller :lol: ).

What I'm trying to do now, (which maybe you didn't pick up from my earlier posts) is something slightly different, which is to change the color of a mesh (or planet/moon) AFTER it has already been loaded into Celestia, hence my question about a LUA method along the lines of a "setcolor".

Each object (at least planets and moons anyway) in Celestia has a "color" property (default white I guess), which is set at load time by the existence of a "Color [...]" statement in the SSC definition.

What I'm looking for is the ability to modify the "loadtime" value dynamically at runtime. The most obvious way to do this is with some sort of setcolor method in LUA (eg. in a celX script). If this capability does not already exist (which is the case I think), then it would require a code change by the DEVs in Celestia's scripting modules.
(I would think this is a simple mod, however I doubt this would be high on the priorities of the DEVs)

Thanks for your comments anyway
CC
"Is a planetary surface the right place for an expanding technological civilization?"
-- Gerard K. O'Neill (1969)

CATALOG SYNTAX HIGHLIGHTING TOOLS LAGRANGE POINTS

chris
Site Admin
Posts: 4211
Joined: 28.01.2002
With us: 22 years 9 months
Location: Seattle, Washington, USA

Re: Color statement in an SSC

Post #12by chris » 07.06.2008, 00:37

Chuft-Captain wrote:
BobHegwood wrote:Chuft,

You can also use the Anim8or program to add textures to your models (assuming that they are 3ds files.) When finished, you can then convert them to CMODs if you like.
The Anim8or program takes a bit of getting used to, but even a simpleton like me can add textures (and colors) to the faces applied to a 3ds mesh.

Just FYI... :wink:
Bob,

Thanks for the comment, however that's something I know already, in fact just about all the textures in my models are applied in exactly that way. I've been using Anim8tor for at least couple of years now (although I'm not the world's best modeller :lol: ).

What I'm trying to do now, (which maybe you didn't pick up from my earlier posts) is something slightly different, which is to change the color of a mesh (or planet/moon) AFTER it has already been loaded into Celestia, hence my question about a LUA method along the lines of a "setcolor".

Each object (at least planets and moons anyway) in Celestia has a "color" property (default white I guess), which is set at load time by the existence of a "Color [...]" statement in the SSC definition.

What I'm looking for is the ability to modify the "loadtime" value at runtime. The most obvious way to do this is with some sort of setcolor method in LUA (eg. in a celX script). If this capability does not already exist (which is the case I think), then it would require a code change by the DEVs in Celestia's scripting modules.
(I would think this is a simple mod, however I doubt this would be high on the priorities of the DEVs)

You are right that a C++ code change is required for this. You're also correct that it shouldn't be too difficult to implement. This is probably a job for Vincent, if he's got the time for it.

--Chris

Avatar
Topic author
Chuft-Captain
Posts: 1779
Joined: 18.12.2005
With us: 18 years 11 months

Re: Color statement in an SSC

Post #13by Chuft-Captain » 07.06.2008, 00:41

chris wrote:... an ssc change is required for this. ...
You mean a "C++" change don't you???


PS. I assume the reason that color cannot be applied to model meshes (as opposd to Celestia's default meshes) is that the color/texture information is encoded into the mesh by the modeling tool, and is therefore in-accessible to Celestia's code. ???
Last edited by Chuft-Captain on 07.06.2008, 00:44, edited 1 time in total.
"Is a planetary surface the right place for an expanding technological civilization?"
-- Gerard K. O'Neill (1969)

CATALOG SYNTAX HIGHLIGHTING TOOLS LAGRANGE POINTS

chris
Site Admin
Posts: 4211
Joined: 28.01.2002
With us: 22 years 9 months
Location: Seattle, Washington, USA

Re: Color statement in an SSC

Post #14by chris » 07.06.2008, 00:42

Chuft-Captain wrote:
chris wrote:... an ssc change is required for this. ...
You mean a "C++" change don't you???

Oops! Yes, I meant a C++ change.

--Chris

Avatar
Topic author
Chuft-Captain
Posts: 1779
Joined: 18.12.2005
With us: 18 years 11 months

Re: Color statement in an SSC

Post #15by Chuft-Captain » 07.06.2008, 00:45

Chris, please refresh my last post as I added a question as you were typing.
Last edited by Chuft-Captain on 07.06.2008, 01:08, edited 3 times in total.
"Is a planetary surface the right place for an expanding technological civilization?"
-- Gerard K. O'Neill (1969)

CATALOG SYNTAX HIGHLIGHTING TOOLS LAGRANGE POINTS

chris
Site Admin
Posts: 4211
Joined: 28.01.2002
With us: 22 years 9 months
Location: Seattle, Washington, USA

Re: Color statement in an SSC

Post #16by chris » 07.06.2008, 00:54

Chuft-Captain wrote:
chris wrote:... an ssc change is required for this. ...
You mean a "C++" change don't you???


PS. I assume the reason that color cannot be applied to model meshes (as opposd to Celestia's default meshes) is that the color/texture information is encoded into the mesh by the modeling tool, and is therefore in-accessible to Celestia's code. ???

That's right. However, it might be possible to change this. The texture can override whatever is in the model, and I think I can do the same for the model without too much trouble.

--Chris

Avatar
Topic author
Chuft-Captain
Posts: 1779
Joined: 18.12.2005
With us: 18 years 11 months

Re: Color statement in an SSC

Post #17by Chuft-Captain » 07.06.2008, 01:09

That would be handy. :) (Especially if we were able to dynamically apply either RGB colors (and/or bitmapped textures)

One final question:

Which is rendered more efficiently (ie. faster) in Celestia?:
A planetary mesh (ie. spherical),
OR a simple cube (about 6 polygons).

Logic would suggest that a sphere would require considerably more polys than a cube, however I suspect that the "Celestia meshes" (ie. non spacecraft meshes) have been implemented in some clever optimized fashion???
Last edited by Chuft-Captain on 07.06.2008, 01:11, edited 1 time in total.
"Is a planetary surface the right place for an expanding technological civilization?"
-- Gerard K. O'Neill (1969)

CATALOG SYNTAX HIGHLIGHTING TOOLS LAGRANGE POINTS

chris
Site Admin
Posts: 4211
Joined: 28.01.2002
With us: 22 years 9 months
Location: Seattle, Washington, USA

Re: Color statement in an SSC

Post #18by chris » 07.06.2008, 01:10

Chuft-Captain wrote:That would be handy. :)

One final question:

Which is rendered more efficiently (ie. faster) in Celestia?:
A planetary mesh (ie. spherical),
OR a simple cube (about 6 polygons).

Logic would suggest that a sphere would require considerably more polys than a cube, however I suspect that the "Celestia meshes" (ie. non spacecraft meshes) have been implemented in some clever optimized fashion???

Spheres are optimized, but a cube will still be faster.

--Chris

Avatar
Topic author
Chuft-Captain
Posts: 1779
Joined: 18.12.2005
With us: 18 years 11 months

Re: Color statement in an SSC

Post #19by Chuft-Captain » 07.06.2008, 01:21

chris wrote:
Chuft-Captain wrote:That would be handy. :) (Especially if we were able to dynamically apply either RGB colors (and/or bitmapped textures)

One final question:

Which is rendered more efficiently (ie. faster) in Celestia?:
A planetary mesh (ie. spherical),
OR a simple cube (about 6 polygons).

Logic would suggest that a sphere would require considerably more polys than a cube, however I suspect that the "Celestia meshes" (ie. non spacecraft meshes) have been implemented in some clever optimized fashion???

Spheres are optimized, but a cube will still be faster.

--Chris
Ok thanks. This means that for performance, I'd need to use modelled meshes (for which color/texture can only be applied in the modelling tool, and cannot currently be changed in either SSC or script), rather than default spheres (for which color CAN currently be set, but only once at load time)

Therefore, if yourself or Vincent can find a way to modify the color of a model mesh at runtime, then this would be very useful, and might open up a few new possibilities.

PS. Time to change the title of this thread I think.
"Is a planetary surface the right place for an expanding technological civilization?"
-- Gerard K. O'Neill (1969)

CATALOG SYNTAX HIGHLIGHTING TOOLS LAGRANGE POINTS

BobHegwood
Posts: 1803
Joined: 12.10.2007
With us: 17 years 1 month

Re: Changing the color of a mesh at runtime...

Post #20by BobHegwood » 07.06.2008, 01:42

One other possible workaround until the feature you want can be implemented. You were quite right that I misunderstood your intention with this thread. However, one can also change the color of a mesh simply by replacing the mesh at the appropriate time if that helps.

In other words, in your SSC file, you can refer to one colored model using a Beginning and Ending directive, and then switch to a differently colored model with a new set of Beginning/Ending directives. It's a bit awkward, but it can be done.

Just FYI again. :wink:

Thanks, Brain-Dead
Brain-Dead Geezer Bob is now using...
Windows Vista Home Premium, 64-bit on a
Gateway Pentium Dual-Core CPU E5200, 2.5GHz
7 GB RAM, 500 GB hard disk, Nvidia GeForce 7100
Nvidia nForce 630i, 1680x1050 screen, Latest SVN


Return to “Celestia Users”