Changing the color of a mesh at runtime...

General discussion about Celestia that doesn't fit into other forums.
Vincent
Developer
Posts: 1356
Joined: 07.01.2005
With us: 19 years 10 months
Location: Nancy, France

Re: Color statement in an SSC

Post #21by Vincent » 07.06.2008, 07:08

Chuft-Captain wrote: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.
CC,

Your request sounds quite easy to implement.
Though I'm busy at work at the moment, I should have a chance do it by tomorrow.
Please open a feature request on the Sourceforge Tracker.
@+
Vincent

Celestia Qt4 SVN / Celestia 1.6.1 + Lua Edu Tools v1.2
GeForce 8600 GT 1024MB / AMD Athlon 64 Dual Core / 4Go DDR2 / XP SP3

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

Re: Color statement in an SSC

Post #22by Chuft-Captain » 07.06.2008, 11:03

Vincent wrote:
Chuft-Captain wrote: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.
CC,

Your request sounds quite easy to implement.
Though I'm busy at work at the moment, I should have a chance do it by tomorrow.
Please open a feature request on the Sourceforge Tracker.
Thanks Vincent. Will do.
(BTW: I'm assuming that the colour will be applied to the entire mesh...I suspect trying to selectively apply colour to individual faces would be too difficult, or impossible)

BobHegwood wrote:...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.
Yes, you're right, it is a bit awkward. I've already considered that method as a workaround (for about 2 seconds, and then decided against it). I've used the begin/end hack for a few things in the past, and I know from experience that it's really just too awkward, and probably wouldn't achieve the intended result.... but thanks for the suggestion. :)
"Is a planetary surface the right place for an expanding technological civilization?"
-- Gerard K. O'Neill (1969)

CATALOG SYNTAX HIGHLIGHTING TOOLS LAGRANGE POINTS

Vincent
Developer
Posts: 1356
Joined: 07.01.2005
With us: 19 years 10 months
Location: Nancy, France

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

Post #23by Vincent » 14.06.2008, 10:18

I've posted a fix on SF that adds the object:surfacecolor and object:setsurfacecolor methods to celx:
https://sourceforge.net/tracker/index.p ... tid=371302

object:surfacecolor() returns a triple which corresponds to the r, g, b components of the object surface color.

Example:

Code: Select all

-- Get object initial surface color
r0, g0, b0 = object:surfacecolor()

-- Set object surface color to green
object:setsurfacecolor(0, 1, 0)

-- Give object back its initial surface color
object:setsurfacecolor(r0, g0, b0)


As pointed out by Chuft-Captain, this currently works with Celestia spheres -- and .cms models --, but not with cmod or 3ds meshes.
A different feature request -- assigned to Chris -- should be created for this issue.
@+
Vincent

Celestia Qt4 SVN / Celestia 1.6.1 + Lua Edu Tools v1.2
GeForce 8600 GT 1024MB / AMD Athlon 64 Dual Core / 4Go DDR2 / XP SP3


Return to “Celestia Users”