diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2008-11-13 00:16:53 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2008-11-13 00:16:53 +0300 |
commit | bdfe7d89e2f1292644577972c716931b4ce3c6c3 (patch) | |
tree | d00eb50b749cb001e2b08272c91791e66740b05d /release/scripts/flt_palettemanager.py | |
parent | 78a1c27c4a6abe0ed31ca93ad21910f3df04da56 (diff) | |
parent | 7e4db234cee71ead34ee81a12e27da4bd548eb4b (diff) |
Merge of trunk into blender 2.5:
svn merge https://svn.blender.org/svnroot/bf-blender/trunk/blender -r12987:17416
Issues:
* GHOST/X11 had conflicting changes. Some code was added in 2.5, which was
later added in trunk also, but reverted partially, specifically revision
16683. I have left out this reversion in the 2.5 branch since I think it is
needed there.
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=16683
* Scons had various conflicting changes, I decided to go with trunk version
for everything except priorities and some library renaming.
* In creator.c, there were various fixes and fixes for fixes related to the -w
-W and -p options. In 2.5 -w and -W is not coded yet, and -p is done
differently. Since this is changed so much, and I don't think those fixes
would be needed in 2.5, I've left them out.
* Also in creator.c: there was code for a python bugfix where the screen was not
initialized when running with -P. The code that initializes the screen there
I had to disable, that can't work in 2.5 anymore but left it commented as a
reminder.
Further I had to disable some new function calls. using src/ and python/, as
was done already in this branch, disabled function calls:
* bpath.c: error reporting
* BME_conversions.c: editmesh conversion functions.
* SHD_dynamic: disabled almost completely, there is no python/.
* KX_PythonInit.cpp and Ketsji/ build files: Mathutils is not there, disabled.
* text.c: clipboard copy call.
* object.c: OB_SUPPORT_MATERIAL.
* DerivedMesh.c and subsurf_ccg, stipple_quarttone.
Still to be done:
* Go over files and functions that were moved to a different location but could
still use changes that were done in trunk.
Diffstat (limited to 'release/scripts/flt_palettemanager.py')
-rw-r--r-- | release/scripts/flt_palettemanager.py | 151 |
1 files changed, 134 insertions, 17 deletions
diff --git a/release/scripts/flt_palettemanager.py b/release/scripts/flt_palettemanager.py index c641a0a4f08..c2f1380a6fa 100644 --- a/release/scripts/flt_palettemanager.py +++ b/release/scripts/flt_palettemanager.py @@ -10,7 +10,7 @@ Tooltip: 'Manage FLT colors' __author__ = "Geoffrey Bantle" __version__ = "1.0 11/21/2007" __email__ = ('scripts', 'Author, ') -__url__ = ('blender', 'elysiun') +__url__ = ('blender', 'blenderartists.org') __bpydoc__ ="""\ @@ -25,7 +25,7 @@ http://wiki.blender.org/index.php/Scripts/Manual/FLTools """ # -------------------------------------------------------------------------- -# flt_palettemanager.py version 0.1 2005/04/08 +# flt_palettemanager.py version 1.0 2005/04/08 # -------------------------------------------------------------------------- # ***** BEGIN GPL LICENSE BLOCK ***** # @@ -55,6 +55,75 @@ import flt_properties import flt_defaultp as defaultp from flt_properties import * +def RGBtoHSV( r, g, b): + minc = min( r, g, b ) + maxc = max( r, g, b ) + v = maxc + + delta = maxc - minc + + if( max != 0 ): + s = delta / maxc + else: + s = 0 + h = -1 + return (h,s,v) + + if( r == maxc ): + h = ( g - b ) / delta + elif( g == maxc ): + h = 2 + ( b - r ) / delta + else: + h = 4 + ( r - g ) / delta + + h *= 60 + if( h < 0 ): + h += 360 + + return(h,s,v) + +def HSVtoRGB(h,s,v): + + if( s == 0 ): + return (v,v,v) + + + h /= 60 + i = math.floor( h) + f = h - i + p = v * ( 1 - s ) + q = v * ( 1 - s * f ) + t = v * ( 1 - s * ( 1 - f ) ) + + if i == 0: + r = v + g = t + b = p + elif i == 1: + r = q + g = v + b = p + + elif i== 2: + r = p + g = v + b = t + elif i==3: + r = p + g = q + b = v + elif i==4: + r = t + g = p + b = v + + else: + r = v + g = p + b = q + + return(r,g,b) + palette_size = 12 palette_x = 0 @@ -68,6 +137,14 @@ cinc = 1.0 / 1024.0 cstep = 0.0 picker = None ptt = "" + + +ts1=None +ts2=None +ts3=None +ts4=None +ts5=None + for i in xrange(1024): colors.append([cstep,cstep,cstep]) cstep = cstep + cinc @@ -128,7 +205,7 @@ def event(evt,val): Draw.Redraw(1) #copy current color and intensity to selected faces. - elif evt == Draw.CKEY: + elif evt == Draw.VKEY: if Blender.Window.EditMode(): Blender.Window.EditMode(0) @@ -136,7 +213,7 @@ def event(evt,val): state = update_state() #retrieve color from palette - color = struct.unpack('>BBBB',struct.pack('>I',colors[curswatch])) + color = struct.unpack('>BBBB',struct.pack('>i',colors[curswatch])) actmesh = state["activeMesh"] if actmesh: if(Blender.Window.GetKeyQualifiers() != Blender.Window.Qual["CTRL"]): @@ -182,7 +259,7 @@ def event(evt,val): Blender.Window.RedrawAll() #grab color and intensity from active face - elif evt == Draw.VKEY: + elif evt == Draw.CKEY: if Blender.Window.EditMode(): Blender.Window.EditMode(0) editmode = 1 @@ -211,6 +288,23 @@ def event(evt,val): Blender.Window.EditMode(1) Blender.Window.RedrawAll() + + elif evt == Draw.GKEY: + if Blender.Window.EditMode(): + Blender.Window.EditMode(0) + editmode =1 + state = update_state() + + actmesh = state["activeMesh"] + activeFace = state["activeFace"] + + if activeFace and "FLT_COL" in actmesh.faces.properties: + (index,intensity) = unpack_face_index(activeFace.getProperty("FLT_COL")) + for face in actmesh.faces: + (index2, intensity2) = unpack_face_index(face.getProperty("FLT_COL")) + if index == index2: + face.sel = 1 + elif evt == Draw.ESCKEY: Draw.Exit() @@ -225,11 +319,11 @@ def update_all(): for object in state["activeScene"].objects: if object.type == "Mesh": mesh = object.getData(mesh=True) - if 'FLT_COL' in mesh.faces.properties: + if 'FLT_COL' in mesh.faces.properties and "FLT_Fcol" in mesh.getColorLayerNames(): mesh.activeColorLayer = "FLT_Fcol" for face in mesh.faces: (index,intensity) = unpack_face_index(face.getProperty('FLT_COL')) - color = struct.unpack('>BBBB',struct.pack('>I',colors[index])) + color = struct.unpack('>BBBB',struct.pack('>i',colors[index])) #update the vertex colors for this face for col in face.col: col.r = int(color[0] * intensity) @@ -284,8 +378,13 @@ def draw_palette(): global colors global curint global curswatch - global picker - + global picker + global ts1 + global ts2 + global ts3 + global ts4 + global ts5 + state = update_state() init_pal() @@ -297,7 +396,7 @@ def draw_palette(): for x in xrange(32): ypos = palette_y for y in xrange(32): - color = struct.unpack('>BBBB',struct.pack('>I',colors[cid])) + color = struct.unpack('>BBBB',struct.pack('>i',colors[cid])) glColor3f(color[0]/255.0,color[1]/255.0,color[2]/255.0) glBegin(GL_POLYGON) glVertex2i(xpos,ypos) @@ -328,7 +427,7 @@ def draw_palette(): xpos = xpos + ssize #draw intensity gradient - color = struct.unpack('>BBBB',struct.pack('>I',colors[curswatch])) + color = struct.unpack('>BBBB',struct.pack('>i',colors[curswatch])) color = [color[0]/255.0,color[1]/255.0,color[2]/255.0] colsteps = [color[0]/255.0,color[1]/255.0,color[2]/255.0] stripwidth = (palette_size * 32.0) / 256 @@ -355,15 +454,15 @@ def draw_palette(): xpos = ((palette_size*32) * (1.0 - curint)) + palette_x glColor3f(1.0,1.0,1.0) glBegin(GL_LINE_LOOP) - glVertex2i(xpos-6,grady-1) - glVertex2i(xpos+6,grady-1) - glVertex2i(xpos+6,grady+palette_size+1) - glVertex2i(xpos-6,grady+palette_size+1) + glVertex2i(int(xpos-6),int(grady-1)) + glVertex2i(int(xpos+6),int(grady-1)) + glVertex2i(int(xpos+6),int(grady+palette_size+1)) + glVertex2i(int(xpos-6),int(grady+palette_size+1)) #glVertex2i(xpos-6,grady+7) glEnd() #draw color picker - color = struct.unpack('>BBBB',struct.pack('>I',colors[curswatch])) + color = struct.unpack('>BBBB',struct.pack('>i',colors[curswatch])) pickcol = (color[0]/255.0,color[1]/255.0,color[2]/255.0) picker = Blender.Draw.ColorPicker(1,highlight[0][0]+1,highlight[0][1]+1,ssize-2,ssize-2,pickcol,ptt) @@ -377,6 +476,24 @@ def draw_palette(): glVertex2i(highlight[0][0],highlight[0][1]) glEnd() + #draw text string explanations + xpos = palette_size*32+20 + ypos = palette_size*32+10 + glRasterPos2d(xpos,ypos) + ts1 = Blender.Draw.Text("FLT Palette Manager V 1.0") + ypos = ypos - 20 + glRasterPos2d(xpos,ypos) + ts3 = Blender.Draw.Text("CKEY - Copy Active Face Color*") + ypos = ypos - 20 + glRasterPos2d(xpos,ypos) + ts2 = Blender.Draw.Text("VKEY - Paste Color to Selected Faces") + ypos = ypos - 20 + glRasterPos2d(xpos,ypos) + ts4 = Blender.Draw.Text("GKEY - Select Faces With Same Color") + ypos = ypos - 15 + glRasterPos2d(xpos,ypos) + ts5 = Blender.Draw.Text("(*Requires mesh with UV coordinates)", 'small') + def gui(): glClearColor(0.5,0.5,0.5,1.0) glClear(GL_COLOR_BUFFER_BIT) @@ -385,4 +502,4 @@ def gui(): init_pal() Draw.Register(gui,event,but_event) - +
\ No newline at end of file |