diff options
author | Diego Borghetti <bdiego@gmail.com> | 2008-08-09 19:59:21 +0400 |
---|---|---|
committer | Diego Borghetti <bdiego@gmail.com> | 2008-08-09 19:59:21 +0400 |
commit | 5bd6a6ae6dc1be86ab421e95f6258cd83ac91c33 (patch) | |
tree | 09208d5c3e29f3b09a2809072fb80f71e785c591 | |
parent | 8c3bf1bc90afc0a785d8d79be52dc5d3cc87db5f (diff) |
branches/blender-2.47
Merge from trunk:
Revision: 16014
Revision: 16022
Revision: 16024
Revision: 16026
Revision: 16028
Revision: 16036
-rw-r--r-- | release/scripts/flt_export.py | 29 | ||||
-rw-r--r-- | release/scripts/flt_palettemanager.py | 149 | ||||
-rw-r--r-- | release/scripts/import_dxf.py | 4 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/anim.c | 12 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/particle_system.c | 18 | ||||
-rw-r--r-- | source/blender/src/transform_conversions.c | 4 | ||||
-rw-r--r-- | source/gameengine/Converter/BL_BlenderDataConversion.cpp | 12 |
7 files changed, 180 insertions, 48 deletions
diff --git a/release/scripts/flt_export.py b/release/scripts/flt_export.py index 9b664e90c35..c099c8e62d1 100644 --- a/release/scripts/flt_export.py +++ b/release/scripts/flt_export.py @@ -525,8 +525,8 @@ class FaceDesc: def __init__(self): self.vertex_index_lst = [] self.mface = None - self.texture_index = -1 - self.material_index = -1 + self.texture_index = 65535 + self.material_index = 65535 self.color_index = 127 self.renderstyle = 0 self.twoside = 0 @@ -979,8 +979,14 @@ class FLTNode(Node): self.header.fw.write_char(0) # Reserved self.header.fw.write_char(alpha) # Template self.header.fw.write_short(-1) # Detail tex pat index - self.header.fw.write_short(face_desc.texture_index) # Tex pattern index - self.header.fw.write_short(face_desc.material_index) # material index + if face_desc.texture_index == -1: + self.header.fw.write_ushort(65535) + else: + self.header.fw.write_ushort(face_desc.texture_index) # Tex pattern index + if face_desc.material_index == -1: + self.header.fw.write_ushort(65535) + else: + self.header.fw.write_ushort(face_desc.material_index) # material index self.header.fw.write_short(0) # SMC code self.header.fw.write_short(0) # Feature code self.header.fw.write_int(0) # IR material code @@ -1015,7 +1021,10 @@ class FLTNode(Node): self.header.fw.write_ushort(8 + (mtex * 8)) # Length self.header.fw.write_uint(uvmask) # UV mask for i in xrange(mtex): - self.header.fw.write_ushort(face_desc.images[i]) # Tex pattern index + if face_desc.images[i] == -1: + self.header.fw.write_ushort(65535) + else: + self.header.fw.write_ushort(face_desc.images[i]) # Tex pattern index self.header.fw.write_ushort(0) # Tex effect self.header.fw.write_ushort(0) # Tex Mapping index self.header.fw.write_ushort(0) # Tex data. User defined @@ -1092,7 +1101,7 @@ class FLTNode(Node): write_prop(self.header.fw,ftype,self.object.properties['FLT']['EXT'][propname],length) #write extension data for i in xrange(datalen): - self.header.fw.write_char(self.object.properties['FLT']['EXT']['data'][i]) + self.header.fw.write_uchar(struct.unpack('>B', struct.pack('>B', self.object.properties['FLT']['EXT']['data'][i]))[0]) self.write_pop_extension() @@ -1180,8 +1189,8 @@ class Database(Node): desc = self.GRR.request_vertex_desc(i) self.fw.write_short(70) # Vertex with color normal and uv opcode. self.fw.write_ushort(64) # Length of record - self.fw.write_ushort(0) # Color name index - self.fw.write_short(0x20000000) # Flags + self.fw.write_ushort(0) # Color name index + self.fw.write_short(1 << 14) # Frozen Normal self.fw.write_double(desc.x) self.fw.write_double(desc.y) self.fw.write_double(desc.z) @@ -1199,7 +1208,7 @@ class Database(Node): print 'Writing texture palette.' # Write record for texture palette for i, img in enumerate(self.GRR.texture_lst): - filename = tex_files[img.name].replace("\\", "/") + filename = tex_files[img.name] self.fw.write_short(64) # Texture palette opcode. self.fw.write_short(216) # Length of record self.fw.write_string(filename, 200) # Filename @@ -1245,7 +1254,7 @@ class Database(Node): cpalette = defaultp.pal count = len(cpalette) for i in xrange(count): - color = struct.unpack('>BBBB',struct.pack('>I',cpalette[i])) + color = struct.unpack('>BBBB',struct.pack('>i',cpalette[i])) self.fw.write_uchar(color[3]) # alpha self.fw.write_uchar(color[2]) # b self.fw.write_uchar(color[1]) # g diff --git a/release/scripts/flt_palettemanager.py b/release/scripts/flt_palettemanager.py index 6edaf2974ab..c2f1380a6fa 100644 --- a/release/scripts/flt_palettemanager.py +++ b/release/scripts/flt_palettemanager.py @@ -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 diff --git a/release/scripts/import_dxf.py b/release/scripts/import_dxf.py index 09e51c22a9f..bb0119a9a81 100644 --- a/release/scripts/import_dxf.py +++ b/release/scripts/import_dxf.py @@ -7,7 +7,7 @@ Group: 'Import' Tooltip: 'Import for DXF geometry data (Drawing eXchange Format).' """ __author__ = 'Kitsu(Ed Blake) & migius(Remigiusz Fiedler)' -__version__ = '1.12 - 2008.07.04 by migius' +__version__ = '1.12 - 2008.08.03 by migius' __url__ = ["http://blenderartists.org/forum/showthread.php?t=84319", "http://wiki.blender.org/index.php/Scripts/Manual/Import/DXF-3D"] __email__ = ["migius(at)4d-vectors.de","Kitsune_e(at)yahoo.com"] @@ -88,7 +88,7 @@ in creating new objects in scene database - probably a database management probl """ History: - v1.0 - 2008.01. by migius + v1.0 - 2007/2008 by migius planned tasks: -- (to see more, search for "--todo--" in script code) -- command-line-mode/batch-mode diff --git a/source/blender/blenkernel/intern/anim.c b/source/blender/blenkernel/intern/anim.c index 1f8dd74a6eb..1592c3e5504 100644 --- a/source/blender/blenkernel/intern/anim.c +++ b/source/blender/blenkernel/intern/anim.c @@ -734,9 +734,8 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Object *par, float par_ ParticleCacheKey *cache; ParticleSystemModifierData *psmd; float ctime, pa_time, scale = 1.0f; - float tmat[4][4], mat[4][4], obrotmat[4][4], pamat[4][4], size=0.0; + float tmat[4][4], mat[4][4], pamat[4][4], size=0.0; float (*obmat)[4], (*oldobmat)[4]; - float xvec[3] = {-1.0, 0.0, 0.0}, q[4]; int lay, a, b, k, step_nbr = 0, counter, hair = 0; int totpart, totchild, totgroup=0, pa_num; @@ -898,14 +897,7 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Object *par, float par_ /* to give ipos in object correct offset */ where_is_object_time(ob, ctime-pa_time); - if(!hair) { - vectoquat(xvec, ob->trackflag, ob->upflag, q); - QuatToMat4(q, obrotmat); - obrotmat[3][3]= 1.0f; - Mat4MulMat4(mat, obrotmat, pamat); - } - else - Mat4CpyMat4(mat, pamat); + Mat4CpyMat4(mat, pamat); Mat4MulMat4(tmat, obmat, mat); Mat4MulFloat3((float *)tmat, size*scale); diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index 766458c9b4f..8025d4aad93 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -4653,7 +4653,7 @@ static void system_step(Object *ob, ParticleSystem *psys, ParticleSystemModifier PTCacheID pid; int totpart, oldtotpart, totchild, oldtotchild, p; float disp, *vg_vel= 0, *vg_tan= 0, *vg_rot= 0, *vg_size= 0; - int init= 0, distr= 0, alloc= 0, usecache= 0; + int init= 0, distr= 0, alloc= 0, usecache= 0, only_children_changed= 0; int framenr, framedelta, startframe, endframe; part= psys->part; @@ -4720,6 +4720,7 @@ static void system_step(Object *ob, ParticleSystem *psys, ParticleSystemModifier totchild = get_psys_tot_child(psys); if(oldtotpart != totpart || (psys->part->childtype && oldtotchild != totchild)) { + only_children_changed = (oldtotpart == totpart); realloc_particles(ob, psys, totpart); alloc = 1; distr= 1; @@ -4740,14 +4741,17 @@ static void system_step(Object *ob, ParticleSystem *psys, ParticleSystemModifier if((psys->part->type == PART_HAIR) && !(psys->flag & PSYS_HAIR_DONE)) /* don't generate children while growing hair - waste of time */ - psys_free_children(psys); - else if(get_psys_tot_child(psys)) - distribute_particles(ob, psys, PART_FROM_CHILD); + psys_free_children(psys); + else if(get_psys_tot_child(psys)) + distribute_particles(ob, psys, PART_FROM_CHILD); } - initialize_all_particles(ob, psys, psmd); - if(alloc) - reset_all_particles(ob, psys, psmd, 0.0, cfra, oldtotpart); + if(only_children_changed==0) { + initialize_all_particles(ob, psys, psmd); + + if(alloc) + reset_all_particles(ob, psys, psmd, 0.0, cfra, oldtotpart); + } /* flag for possible explode modifiers after this system */ psmd->flag |= eParticleSystemFlag_Pars; diff --git a/source/blender/src/transform_conversions.c b/source/blender/src/transform_conversions.c index dcebf6b7557..4db56e31b8d 100644 --- a/source/blender/src/transform_conversions.c +++ b/source/blender/src/transform_conversions.c @@ -911,8 +911,8 @@ static void createTransPose(TransInfo *t, Object *ob) if (arm==NULL || ob->pose==NULL) return; if (arm->flag & ARM_RESTPOS) { - if(t->mode!=TFM_BONESIZE) { - notice ("Pose edit not possible while Rest Position is enabled"); + if(ELEM(t->mode, TFM_DUMMY, TFM_BONESIZE)==0) { + notice("Pose edit not possible while Rest Position is enabled"); return; } } diff --git a/source/gameengine/Converter/BL_BlenderDataConversion.cpp b/source/gameengine/Converter/BL_BlenderDataConversion.cpp index f44318120e8..a6337403cd1 100644 --- a/source/gameengine/Converter/BL_BlenderDataConversion.cpp +++ b/source/gameengine/Converter/BL_BlenderDataConversion.cpp @@ -1939,7 +1939,17 @@ void BL_ConvertBlenderObjects(struct Main* maggie, float* fl = (float*) blenderobject->parentinv; MT_Transform parinvtrans(fl); parentinversenode->SetLocalPosition(parinvtrans.getOrigin()); - parentinversenode->SetLocalOrientation(parinvtrans.getBasis()); + // problem here: the parent inverse transform combines scaling and rotation + // in the basis but the scenegraph needs separate rotation and scaling. + // This is not important for OpenGL (it uses 4x4 matrix) but it is important + // for the physic engine that needs a separate scaling + //parentinversenode->SetLocalOrientation(parinvtrans.getBasis()); + + // Extract the rotation and the scaling from the basis + MT_Matrix3x3 inverseOrientation(parinvtrans.getRotation()); + parentinversenode->SetLocalOrientation(inverseOrientation); + MT_Matrix3x3 scale(inverseOrientation.transposed()*parinvtrans.getBasis()); + parentinversenode->SetLocalScale(MT_Vector3(scale[0][0], scale[1][1], scale[2][2])); parentinversenode->AddChild(gameobj->GetSGNode()); } |