Page 1 of 2
Changing the color of a mesh at runtime...
Posted: 05.06.2008, 15:47
by Chuft-Captain
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:
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
Re: Color statement in an SSC
Posted: 05.06.2008, 16:05
by Cham
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".
Re: Color statement in an SSC
Posted: 05.06.2008, 17:24
by chris
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
Re: Color statement in an SSC
Posted: 05.06.2008, 17:38
by Chuft-Captain
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
)
Cheers
CC
UPDATE: I tried the following Cham, but my object (Class Spacecraft) is still white:
Perhaps this only works for planets, moons, etc???
Re: Color statement in an SSC
Posted: 05.06.2008, 17:46
by Chuft-Captain
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???
Re: Color statement in an SSC
Posted: 06.06.2008, 14:17
by Chuft-Captain
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.
Re: Color statement in an SSC
Posted: 06.06.2008, 15:14
by BobHegwood
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...
Re: Color statement in an SSC
Posted: 06.06.2008, 15:28
by zhar2
can you apply the textures straight from blender or 3dmax too?
Re: Color statement in an SSC
Posted: 06.06.2008, 15:44
by BobHegwood
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
Re: Color statement in an SSC
Posted: 06.06.2008, 15:59
by zhar2
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).
Re: Color statement in an SSC
Posted: 07.06.2008, 00:34
by Chuft-Captain
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...
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
).
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
Re: Color statement in an SSC
Posted: 07.06.2008, 00:37
by chris
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...
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
).
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
Re: Color statement in an SSC
Posted: 07.06.2008, 00:41
by Chuft-Captain
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. ???
Re: Color statement in an SSC
Posted: 07.06.2008, 00:42
by chris
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
Re: Color statement in an SSC
Posted: 07.06.2008, 00:45
by Chuft-Captain
Chris, please refresh my last post as I added a question as you were typing.
Re: Color statement in an SSC
Posted: 07.06.2008, 00:54
by chris
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
Re: Color statement in an SSC
Posted: 07.06.2008, 01:09
by Chuft-Captain
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???
Re: Color statement in an SSC
Posted: 07.06.2008, 01:10
by chris
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
Re: Color statement in an SSC
Posted: 07.06.2008, 01:21
by Chuft-Captain
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.
Re: Changing the color of a mesh at runtime...
Posted: 07.06.2008, 01:42
by BobHegwood
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.
Thanks, Brain-Dead