Gracias Gracias:  0
Página 3 de 8 PrimerPrimer 1234567 ... ÚltimoÚltimo
Resultados 31 al 45 de 113

Tema: Sugerencias Script para blender

  1. #31
    Character Artist Avatar de fog
    Fecha de ingreso
    Feb 2004
    Ubicación
    Barcelona
    Mensajes
    861

    Re: Sugerencias Script para blender

    Gracias dmiles.
    De momento tengo ya un UI guarrillo.
    Ahora a ver si me hago con los scriptHandlers para pillar posición del mouse y comezar a pintar

  2. #32
    El Programador
    Fecha de ingreso
    Sep 2005
    Ubicación
    Valencia
    Mensajes
    720

    Re: Sugerencias Script para blender

    Cita Iniciado por fog Ver mensaje
    Gracias dmiles.
    De momento tengo ya un UI guarrillo.
    Wow un ui guarrillo XD esos me encantan XD

  3. #33
    Tresmiltornillero Avatar de Leander
    Fecha de ingreso
    Oct 2004
    Ubicación
    Zaragoza (ESPAÑA)
    Mensajes
    10,969

    Re: Sugerencias Script para blender

    Yo pediría una chorrada útil para precisión, un script ABSVALUE

    Seleccionas varios vértices, arrancas el script, y te pone a replacear 3 valores (X, Y, Z) introduciendo el valor 20 en Y por ejemplo te dejan la coordenada Y (global) de los vértices seleccionados con el valor 20. Así de sencillo.

    Que estoy hasta los huevos de escalarlos a 0 para darme un MEDIAN value y luego tener que volver a moverlos a la posición absoluta que me interesa.

    Gracias.

    DAMILES: por cierto ¿que pasa con las memocamsí que no lo veo en las oficiales, ¿no te lo aceptan o que?
    Última edición por Leander; 22-09-2007 a las 01:31

  4. #34
    El Programador
    Fecha de ingreso
    Sep 2005
    Ubicación
    Valencia
    Mensajes
    720

    Re: Sugerencias Script para blender

    Mis memo que?

    A lo de guardar las porpiedades de las vistas.. sigue estando en el patch tracker, https://projects.blender.org/tracker..._id=9&atid=127

    Por lo visto no están revisando nada de los patch, cuando digo nada, es que llevan más de un año sin revisrarlos, bueno, alguno han revisado, pero en linias generales, están muertos de risa.

    Mi conclusión es que no los revisaran hasta que esté a punto de salir la siguiente versión con nuevas features, y claro esta, el 90% de los patch estarán por actualizar debido a las nuevas incorporaciones y recodes, con lo que el 80% de los patch revisados no llegaran a incluirse por que no están revisados.

    Bueno paciencia, que si no eres un buen coder y tienes acceso a la svn es lo que hay. Aun así, también esta la solución de dar por saco a quien hayan asignado tu patch, de forma que para no oirte te hace caso, eso si, no ha de ser ton, porque si no no te hace caso, y menos si se llama "damiles". XD Ya me oira este en la B-conf.

  5. #35
    Character Artist Avatar de fog
    Fecha de ingreso
    Feb 2004
    Ubicación
    Barcelona
    Mensajes
    861

    Re: Sugerencias Script para blender

    Leader, no será esto lo que buscas?

    Vertex Align:
    Sammler - Mediengestaltung

    Cita Iniciado por Leander Ver mensaje
    Yo pediría una chorrada útil para precisión, un script ABSVALUE

    Seleccionas varios vértices, arrancas el script, y te pone a replacear 3 valores (X, Y, Z) introduciendo el valor 20 en Y por ejemplo te dejan la coordenada Y (global) de los vértices seleccionados con el valor 20. Así de sencillo.

    Que estoy hasta los huevos de escalarlos a 0 para darme un MEDIAN value y luego tener que volver a moverlos a la posición absoluta que me interesa.

    Gracias.

    DAMILES: por cierto ¿que pasa con las memocamsí que no lo veo en las oficiales, ¿no te lo aceptan o que?

  6. #36
    Character Artist Avatar de fog
    Fecha de ingreso
    Feb 2004
    Ubicación
    Barcelona
    Mensajes
    861

    Re: Sugerencias Script para blender

    Cita Iniciado por damiles Ver mensaje
    Wow un ui guarrillo XD esos me encantan XD
    Jajajajaaja siIIIIIIIi de los que te gustan tontin!!!

  7. #37
    Character Artist Avatar de fog
    Fecha de ingreso
    Feb 2004
    Ubicación
    Barcelona
    Mensajes
    861

    Re: Sugerencias Script para blender

    Esto.creo que voy a comenzar por un script más sencillo, esto de los spacehandlers no esta muy documentado, y a mi, me esta costando encontrar referencias o yo soy tonto

  8. #38
    BlenderAdicto Avatar de Caronte
    Fecha de ingreso
    Dec 2004
    Ubicación
    Valencia-España
    Mensajes
    14,691

    Re: Sugerencias Script para blender

    Cita Iniciado por fog Ver mensaje
    Esto.creo que voy a comenzar por un script más sencillo...
    Ooooh!! :

    Bueno, por si acaso échale un vistazo a este script, que aunque es viejo y no creo que funcione en las nuevas compilaciones, no necesita los space-handles (o eso me parece):
    Código:
    #!BPY
    
    """
    Name: 'Sculpt Mesh...'
    Blender: 235
    Group: 'Mesh'
    Tip: 'Sculpts mesh pushing, pulling and twisting'
    """
    
    # $Id:sculpt_mesh.py,v .2 2004/10/17 02:16:31 broken Exp $
    #
    #===============================================#
    # Sculpt Mesh v 0.2 by Tom Musgrove (LetterRip) #
    # and Michael Scardt #
    # if you have any questions about this script #
    # email LetterRip at gmail dot com #
    # #
    #===============================================#
    
    # --------------------------------------------------------------------------
    # Sculpt Mesh v 0.2 by Tom Musgrove (LetterRip) and Michael Scardt
    # --------------------------------------------------------------------------
    # ***** BEGIN GPL LICENSE BLOCK *****
    #
    # This program is free software; you can redistribute it and/or
    # modify it under the terms of the GNU General Public License
    # as published by the Free Software Foundation; either versión 2
    # of the License, or (at your option) any later versión.
    #
    # This program is distributed in the hope that it will be useful,
    # but WITHOUT ANY WARRANTY; without even the implied warranty of
    # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    # GNU General Public License for more details.
    #
    # You should have received a copy of the GNU General Public License
    # along with this program; if not, write to the Free Software Foundation,
    # Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
    #
    # ***** END GPL LICENCE BLOCK *****
    # --------------------------------------------------------------------------
    
    
    import Blender
    from Blender import Object, NMesh, Window, Draw, Mathutils, Types
    from Blender.Mathutils import *
    from math import sin, cos, sqrt, pi, hypot
    
    # Import Psyco if available, psyco can often give substantial speed ups
    try:
     import psyco
    # psyco.log()
    # psyco.profile()
     psyco.full()
    except ImportError:
     pass
    
    displaceMode = 1 # 0 is off, 1 is displaceOut, -1 is displaceIn, 2 is Smooth
    # smooth isn't implemented yet
    displacementHeight = 1.0 #
    radiusMinimum = 5 # the smallest size of the selection radius in pixels
    radiusMaximum = 20 #this gives us a grid size of 100 x 100 which isn't that 
    big of a savings
     #the smaller the grid size the greater the savings
    alpha_size_x = alpha_size_y = 2*radiusMaximum
    # no user friendly gui yet
    # to change the formula used, change fallofftype to
    # one of None, Linear, Sin, Cos, SquareRoot, Squared, Cubic, and Quadratic
    # then change the selectionRadius
    # the xsize and ysize of the image are the first two numbers of the MaskID
    # except in the case of the radial functions, in which case it is the radius
    # alos may change it to inner and outer radius or other such stuff
    # the string is the id of the masque ID for formula based it is falloffType + 
    maxRadius
    falloffType = "Linear"
    selection_size_x = selection_size_y = selectionRadius = 20
    maskName = falloffType+repr(selectionRadius)
    MaskID = (selectionRadius,selectionRadius,maskName)
    
    
    
    win_min_x = win_min_y = win_max_x = win_max_y = win_mid_x = win_mid_y = 
    win_size_x = win_size_y = 0
    #the above are the corners of the 3d view window, and the scaling factors
    mouseX = mouseY = 0
    obj_mat_times_persp_mat = Matrix()
    myMesh = NMesh.New("temp")
    selectedVerts = []
    dictOfAlphaMasks = {}
    myObject = Blender.Object.New('Mesh')
    lastViewVector = [-100,100,-100] #right now these doesn't do much
    currentViewVector = [-100,-100,-100] #but, if we allow screen rotation then 
    they will trigger an update of the matrices
    
    obj_mat = Matrix() #contains the matrix of the object (local? or global? I 
    thinque global.)
    perspMatrix = Matrix() #contains the perspective Matrix, and allows the 
    screen coordinates to be projected to the screen
    
    dictFaces = {}
    faceNormalWorldVecDict = {}
    facedotVecDict = {}
    vectorDirtyDict = {}
    cacheVecCoMultDict = {}
    vectorDirty = False
    # gets the mesh data from the selected object
    # finds the selected verts
    # and then selects verts based on the alpha mask
    def initialize():
     global myObject, myMesh, currentViewVector, lastViewVector
     myObject = Object.GetSelected()[0]
     if myObject.getType() == 'Mesh':
     myMesh = myObject.getData()
     name = myObject.name
     else:
     print "we either did not have a mesh or did not have an object selected"
     mouseX, mouseY = Window.GetMouseCoords()
     updateViewCoords(mouseX, mouseY)
     mouseInView3DWindow(mouseX, mouseY)
     currentViewVector = Window.GetViewVector()
     lastViewVector = currentViewVector
     initializeFaceLists()
     updateRadius(MaskID[0], 0, falloffType) #this initializes the starting 
    alphamask
    
    #we could actually create two lists from each, one that contains the faces 
    with normals towards the
    #camera, and the other without, and thus traverse our faces a bit faster...
    #alos we could use smaller grid subdivisions, which means fewer faces and 
    verts per bin
    #which means likely faster
    def initializeFaceLists():
     selection = {}
     global myMesh, dictFaces, faceNormalWorldVecDict, facedotVecDict
     global vectorDirtyDict, cacheVecCoMultDict
     dictFaces = {}
     faceNormalWorldVecDict = {}
     facedotVecDict = {}
     vectorDirtyDict = {}
     cacheVecCoMultDict = {}
     global alpha_size_x
     global alpha_size_y
     global VectorDirty
     facedotVec = 0.0
     VectorDirty = False
     viewVector = Vector(Window.GetViewVector())
     objectWorldMatrix = myObject.getMatrix('worldspace')
     perspMatrix = Blender.Window.GetPerspMatrix()
     obj_mat_times_persp_mat = objectWorldMatrix*perspMatrix
     for face in myMesh.faces:
     gfn = VecMultMat(Vector(list(face.normal[:3])+[1.0]), objectWorldMatrix)
     gfn = Vector(list(gfn[:3]))
     faceNormalWorldVecDict[face] = gfn
     facedotVecDict[face] = DotVecs(gfn, viewVector)
     for vertex in face.v:
     if vertex not in selection:
     #calculate the vertex screen coordinates...
     vectorDirtyDict[vertex.index] = vertex.co
     tempVec = vertex.co
     hvs = VecMultMat(Vector(list(tempVec[:3])+[1.0]), 
    obj_mat_times_persp_mat)
     hvs[0] /= hvs[3]
     hvs[1] /= hvs[3]
    
     vs = [int(win_mid_x + (hvs[0] * win_size_x)),
     int(win_mid_y + (hvs[1] * win_size_y))]
     cacheVecCoMultDict[vertex.index] = vs
     else:
     vs = cacheVecCoMultDict[vertex.index]
     ##### now ...
    
     vert_grid_x = vs[0]/alpha_size_x
     vert_grid_y = vs[1]/alpha_size_y
     tempList = []
     try:
     tempList = dictFaces[(vert_grid_x, vert_grid_y)]
     tempList.append(face)
     except KeyError:
     tempList.append(face)
     dictFaces[(vert_grid_x, vert_grid_y)] = tempList
     selection[vertex] = True
     ####and now we remove the duplicate faces
     for key in dictFaces.keys():
     listAppended = dictFaces[key]
     nd={}
     for f in listAppended:
     nd[f]=None
     dictFaces[key] = nd.keys()
    
    # takes a vert and based on its screen location relative to the mouse
    # is displaced according to an alphaMask
    # radius and falloff are done via computing the masque once
    # the alphaMaskDict is specified by a MaskID
    # masque ID is a tuple
    # with four values,
    # Xoffset, Yoffset, "maskName"
    # for radius functions, maskName is "FallOffTypeRadius"
    # ie for a linear of radius 8, it would be Linear8
    # and the tuple would be (8,8,"Linear8")
    # for imagebased, it is usually the image name
    def DisplaceSelection(MaskID, mouseX, mouseY, displaceMode=0, 
    displacementHeight= 0.0):
     global myMesh, dictOfAlphaMasks, alpha_size_x, alpha_size_y, dictFaces, 
    faceNormalWorldVecDict
     global facedotVecDict, cacheVecCoMultDict, vectorDirtyDict
    
     selection = {}
     if MaskID not in dictOfAlphaMasks:
     # should handle image masks as well, but for now, we will handle only the 
    radius masks
     updateRadius(MaskID[0], 0, falloffType)
     alphaMaskDict = dictOfAlphaMasks[MaskID]
     maskOffset = []
     maskOffset.append(MaskID[0])
     maskOffset.append(MaskID[1])
     displaceMH = displacementHeight*displaceMode
     mouse_and_maskX = maskOffset[0] - mouseX
     mouse_and_maskY = maskOffset[1] - mouseY
     viewVector = Vector(Window.GetViewVector())
     objectWorldMatrix = myObject.getMatrix('worldspace')
     perspMatrix = Blender.Window.GetPerspMatrix()
     obj_mat_times_persp_mat = objectWorldMatrix*perspMatrix
     emptyVector = Vector()
     #### here we find which grids the alphamasque is in, and return a list of 
    faces
     try:
     list1 = dictFaces[((mouseX + maskOffset[0])/alpha_size_x, (mouseY - 
    maskOffset[1])/alpha_size_y)]
     except KeyError:
     list1 = []
     try:
     list2 = dictFaces[((mouseX + maskOffset[0])/alpha_size_x, (mouseY + 
    maskOffset[1])/alpha_size_y)]
     except KeyError:
     list2 = []
     try:
     list3 = dictFaces[((mouseX - maskOffset[0])/alpha_size_x, (mouseY - 
    maskOffset[1])/alpha_size_y)]
     except KeyError:
     list3 = []
     try:
     list4 = dictFaces[((mouseX - maskOffset[0])/alpha_size_x, (mouseY + 
    maskOffset[1])/alpha_size_y)]
     except KeyError:
     list4 = []
     listAppended = list1+list2+list3+list4
     ####and now we remove the duplicate faces
     nd={}
     for f in listAppended:
     nd[f]=None
     listAppended = nd.keys()
     for face in myMesh.faces:
     if (face in listAppended):
     if faceNormalWorldVecDict[face] == emptyVector:
     gfn = VecMultMat(Vector(list(face.normal[:3])+[1.0]), objectWorldMatrix)
     gfn = Vector(list(gfn[:3]))
     faceNormalWorldVecDict[face] = gfn
     facedotVecDict[face] = DotVecs(gfn, viewVector)
     elif vectorDirty:
     gfn = faceNormalWorldVecDict[face]
     facedotVecDict[face] = DotVecs(gfn, viewVector)
     facedotVec = facedotVecDict[face]
     if facedotVec > 0: # simple backface-culling
     faceDirtyCount = 0
     for vertex in face.v:
     if (vertex.index not in selection):
     # we need to calculate the distance of the vert from the mouse
     # thus we need either the screen x and y of the vert
     # or the UV x,y of the mouse and of the vert
     # the offset is the distance from the mouse location, to the lower 
    left corner
     # of the mask
     try:
     tempCo = vectorDirtyDict[vertex.index]
     except KeyError:
     tempCo = None
     if tempCo == vertex.co:
     vs = cacheVecCoMultDict[vertex.index]
     else:
     vectorDirtyDict[vertex.index] = vertex.co
     tempVec = vertex.co
     hvs = VecMultMat(Vector(list(tempVec[:3])+[1.0]), 
    obj_mat_times_persp_mat)
     hvs[0] /= hvs[3]
     hvs[1] /= hvs[3]
    
     vs = [int(win_mid_x + (hvs[0] * win_size_x)),
     int(win_mid_y + (hvs[1] * win_size_y))]
     cacheVecCoMultDict[vertex.index] = vs
    
     deltaX = vs[0] + mouse_and_maskX
     deltaY = vs[1] + mouse_and_maskY
     try:
     thisDisplacement = alphaMaskDict[(deltaX, deltaY)]
     vertex.sel = 1
     except KeyError:
     thisDisplacement = 0.0
     vertex.sel = 0
     if vertex.sel == 1:
     #if we are just updating the selection
     if displaceMode == 0:
     pass
     #if we are displacing the vertex out
     #or if we are displacing the vertex in
     elif (displaceMode == 1) or (displaceMode == -1):
     tempDisplace = thisDisplacement*displaceMH
     vertex.co[0] += vertex.no[0]*tempDisplace
     vertex.co[1] += vertex.no[1]*tempDisplace
     vertex.co[2] += vertex.no[2]*tempDisplace
     #since the vertex changed,
     #we need to update the faces normal
     #information based on the new vertex location
     faceDirtyCount += 1
     ###we need to find the new screen location of the moved verts
     ### and if they are in a new grid locations we need to add the face to the 
    new grids face list
     # we should probably pop the face off of its original face lists if we 
    expect verts to change
     # quadrants frequently otherwise our facelists will soon have faces that 
    shouldn't be in it...
     # of course we may rebuild our face list often enough that this might not 
    be a significant issue
     # perhaps we should rebuild a single face list based on its length
    
     #we might alos consider subdividing a grid if it has more than a certain 
    number of faces
     #this is to let the loop know that we've already handled this vertex
     #so it doesn't do calculations on it twice
     selection[vertex.index]=True
     #right now we don'l have smooth implemented
     if(faceDirtyCount > 0):
     faceNormalWorldVecDict[face] = emptyVector
    
    
    
    
    
    #displaces verts towards the vert average normal
    def SmoothSelection():
    #we need to first calculate the average normal for the selected verts
    #probably we should exlude outliers to give better results
    #then find the difference between average normal and the current verts 
    normal
     print "we smoothed the selection"
     pass
    
    # takes an image and its size (or just an image and gets the size from the 
    image?
    # use code ideas from this link to implement
    # http://www.elysiun.com/forum/viewtopic.php?t=16326&highlight=getpixel
    # instead of doing positive and negative numbers
    # i define all locations from the lower left corner
    def alphaMaskDictFromAlphaMap(xsize, ysize, alphamap):
     global dictOfAlphaMasks
     alphaMaskDict = {}
     for x in range(0, xsize):
     for y in range (0, ysize):
     alphacoords = (x,y)
     thisDisplacement = alphamap.alphacoords
     alphaMaskDict[alphacoords] = thisDisplacement
     MaskID = (int(xsize/2),int(ysize/2), alphamap.name)
     dictOfAlphaMasks[MaskID] = alphaMaskDict
    #
    #
    def updateRadius(selectionRadius, deltaRadius, falloffType):
     global MaskID, dictOfAlphaMasks
     print "update radius"
     selectionRadius += deltaRadius
     if selectionRadius < radiusMinimum:
     selectionRadius = radiusMinimum
     if selectionRadius > radiusMaximum:
     selctionRadius = radiusMaximum
     maskName = falloffType+repr(selectionRadius)
     MaskID = (selectionRadius, selectionRadius, maskName)
     if MaskID not in dictOfAlphaMasks:
     dictOfAlphaMasks[MaskID] = alphaMaskDictFromRadius(selectionRadius, 
    falloffType)
     selection_size_x = selection_size_y = selectionRadius
     return selectionRadius
    
    def updateDisplacement(displacementHeight, deltaHeight):
     displacementHeight = displacementHeight + deltaHeight
     return displacementHeight
    #
    # not needed but would be nice
    def drawSelectionCircle(selectionRadius):
     #print "Drawing the selection circle"
     pass
    
    # creates an alphamasque from the radius supplied
    # this gives two benefits - the first is that we can use any alphamask
    # instead of using just radius based functions with falloff
    # the second is that this gives us a lookup table and we don't have to
    # calculate the radius function a bazillion times
    def alphaMaskDictFromRadius(radius = 8, falloffType = "None"):
     #note that instead of negative numbers, I'm using an offset of
     #of the radius, and use all positive numbers
     thisRadius2 = 0
     radius2 = radius*radius
     alphaMaskDict = {}
     for x in range(0, radius):
     for y in range(0, radius):
     thisRadius2 = x^2+y^2
     if thisRadius2 <= radius2:
     thisRadius = sqrt(thisRadius2)
     thisDisplacement = radiusFunction(thisRadius, radius, falloffType)
     alphaMaskDict[( x+radius,-y+radius)]=thisDisplacement
     alphaMaskDict[(-x+radius, y+radius)]=thisDisplacement
     alphaMaskDict[(-x+radius,-y+radius)]=thisDisplacement
     alphaMaskDict[( x+radius, y+radius)]=thisDisplacement
     return alphaMaskDict
    
    # falloffTypes are None, Linear, Sin, Cos, SquareRoot, Squared, Cubic, and 
    Quadratic
    # these are adapted from 'Taper and Twist'
    # by flippyneck
    def radiusFunction(thisRadius, maxRadius, falloffType="None"):
     if falloffType == "None":
     return 1.0
     if falloffType == "Cubic":
     return interpolateCubic(0,maxRadius, thisRadius)
     elif falloffType == "Quadratic":
     return interpolateQuadratic(0,maxRadius, thisRadius)
     elif falloffType == "Linear":
     return interpolateLinear(0, maxRadius, thisRadius)
     elif falloffType == "Sin":
     return interpolateSin(0, maxRadius, thisRadius)
     elif falloffType == "Cos":
     return interpolateCos(0,maxRadius, thisRadius)
     elif falloffType == "SquareRoot":
     return interpolateRoot(0,maxRadius, thisRadius)
     elif falloffType == "Squared":
     return interpolateLinear(0,maxRadius, thisRadius)
    
    def interpolateLinear(min, max, myVal):
     ''' returns 0.0 <= myVal <=1.0 '''
     return myVal/float((max-min))
    
    def interpolateSin(min, max, myVal):
     n=interpolateLinear(min, max, myVal)
     return sin(n)
    
    def interpolateCos(min, max, myVal):
     n=interpolateLinear(min, max, myVal)
     return cos(n)
    
    def interpolateSquared(min, max, myVal):
     n=interpolateLinear(min, max, myVal)
     return n**2
    
    def interpolateRoot(min, max, myVal):
     n=interpolateLinear(min, max, myVal)
     return sqrt(n)
    
    def interpolateCubic(min, max, myVal):
     n=interpolateLinear(min, max, myVal)
     return n**3
    
    def interpolateQuadratic(min, max, myVal):
     n=interpolateLinear(min, max, myVal)
     return n**4
    
    # 
    ********************************************************************************
    
    # init screen coordinates
    # these should be updated if the screen is resized, etc.
    def updateViewCoords(screen_x, screen_y):
     global win3d, win_mid_x, win_mid_y, win_max_x, win_max_y, win_min_x, 
    win_min_y
     global win_size_x, win_size_y, acceptable_min_x, acceptable_min_y, 
    acceptable_max_x, acceptable_max_y
     global selection_size_x, selection_size_y
     for win3d in Blender.Window.GetScreenInfo(Blender.Window.Types.VIEW3D):
     win_min_x, win_min_y, win_max_x, win_max_y = win3d.get('vértices')
     win_mid_x = (win_max_x + win_min_x) * 0.5
     win_mid_y = (win_max_y + win_min_y) * 0.5
     win_size_x = (win_max_x - win_min_x) * 0.5
     win_size_y = (win_max_y - win_min_y) * 0.5
    
     acceptable_min_x = screen_x - selection_size_x
     acceptable_min_y = screen_y - selection_size_y
     acceptable_max_x = screen_x + selection_size_x
     acceptable_max_y = screen_y + selection_size_y
     if (win_max_x > screen_x > win_min_x) and (win_max_y > screen_y > 
    win_min_y):
     return True
     else:
     return False
    
    def mouseInView3DWindow(mouseX, mouseY):
    # we calculate the screens midpoints and the scaling factor for the screen
    # and then chek if the mouse is in the view3d area
    # we should really only do the calculations the first time
    # thus it should prbably
     global win3d, win_mid_x, win_mid_y, win_max_x, win_max_y, win_min_x, 
    win_min_y
     global win_size_x, win_size_y, acceptable_min_x, acceptable_min_y, 
    acceptable_max_x, acceptable_max_y
     global selection_size_x, selection_size_y
     for win3d in Blender.Window.GetScreenInfo(Blender.Window.Types.VIEW3D):
     win_min_x, win_min_y, win_max_x, win_max_y = win3d.get('vértices')
     if (win_max_x > mouseX > win_min_x) and (win_max_y > mouseY > win_min_y):
     return True
     else:
     return False
    
    
    
    
    # Here is the main loop
    mouseStartX, mouseStartY = Window.GetMouseCoords()
    mouseX = mouseY = 0
    radiusIncrement = 5
    updateFrequency = 0 # number of pixels to move before updating the vert 
    selection
    selectedVerts = []
    updateBounds = True
    
    initialize()
    done = 0
    while not done:
     evt, val = Window.QRead()
     if evt in [4]: #Draw.RIGHTMOUSE is 3 which is wrong...
     # first we need to chek if the mouse is inside the view3d boundbox
     currentViewVector = Window.GetViewVector()
     if currentViewVector != lastViewVector:
     lastViewVector = currentViewVector
     #vectorDirty = True
     #instead we will initialize the face lists...
     #this should probably be done elsewhere so that there isn't a huge lag on 
    the firt RMB
     #press...
     initializeFaceLists()
     while Window.GetMouseButtons() == 4:
     if Window.GetKeyQualifiers() == 0:
     mouseX, mouseY = Window.GetMouseCoords()
     if mouseInView3DWindow(mouseX, mouseY):
     # determine if the mouse has moved far enough for an update
     mouseDistX = mouseStartX - mouseX
     mouseDistY = mouseStartY - mouseY
     mouseDistanceMoved = hypot(mouseDistX, mouseDistY)
     if mouseDistanceMoved >= updateFrequency:
     mouseStartX, mouseStartY = mouseX, mouseY
     old_mode = Window.EditMode()
     Window.EditMode(0)
     DisplaceSelection(MaskID, mouseX, mouseY, displaceMode, 
    displacementHeight)
     myMesh.update()
     Window.EditMode(old_mode)
     Blender.Window.Redraw(Window.Types.VIEW3D)
     elif Window.GetKeyQualifiers() != 0:
     if displaceMode == +1: displacement_string = "out"
     elif displaceMode == -1: displacement_string = "in"
     menu_result = Draw.PupMenu("Interactive Paint%t|%l|Selection Size: 
    "+str(selectionRadius)+"%x1|Displacement: 
    "+displacement_string+"%x2|%l|Quit%x3")
     if (menu_result == 1):
     selection_size = Draw.PupIntInput("Selection Size:", selectionRadius, 
    1, 100)
     deltaRadius = selection_size - selectionRadius
     selectionRadius = updateRadius(selectionRadius, deltaRadius, 
    falloffType)
     if (menu_result == 2):
     displaceMode *= -1
     if (menu_result == 3):
     done = True
     Draw.Redraw (Window.QTest())
    
    
    
     #drawSelectionCircle(selectionRadius)
    
    # elif evt in [Draw.SKEY]:
    # if val:
    # displaceMode = 2 #smooth mode
    # else:
    # displaceMode = 0
     elif not val or evt in [Draw.MOUSEX, Draw.MOUSEY]: continue #helps speed
     elif evt in [Draw.ESCKEY, Draw.QKEY]: done = True
     elif evt in [Draw.LEFTARROWKEY] and val: #shrinque radius
     selectionRadius = updateRadius(selectionRadius, -radiusIncrement, 
    falloffType)
     elif evt in [Draw.RIGHTARROWKEY] and val: #grow radius
     selectionRadius = updateRadius(selectionRadius, radiusIncrement, 
    falloffType)
     elif evt in [Draw.UPARROWKEY] and val: #grow displacementHeight
     displacementHeight = updateDisplacement(displacementHeight, 0.1)
     elif evt in [Draw.DOWNARROWKEY] and val: #shrinque displacementHeight
     displacementHeight = updateDisplacement(displacementHeight, -0.1)
     else: #otherwise pass the event bak and let Blender handle it
     id = Window.GetScreenInfo(Window.Types.VIEW3D)[0].get('id')
     Window.QAdd(id, evt, val)
     Window.QHandle(id)
     Blender.Redraw(-1) #don't forget to redraw
     pass
    "Algún día todo será digital". Caronte.
    Mi web: NicoDigital.com

  9. #39
    Character Artist Avatar de fog
    Fecha de ingreso
    Feb 2004
    Ubicación
    Barcelona
    Mensajes
    861

    Re: Sugerencias Script para blender

    Weis Caronte, muchas gracias por este script.
    Me lo miro detenidamente a ver si puedo sacar pistas!!

    Esta claro que la meta final es hacer el script que decías al principio, lo haré o haré! Pongo a Ton por testigo!

    También se tiene que decir que llevo demasiado poco tiempo con phynton, así que me tengo que aprender todas las funciones o las más importantes, así no pierdo tanto tiempo buscando las funciones que quiero.

    Pos eso, a ver si poco a poco lo voy pillando todo

  10. #40
    Vampiro Giovanni Avatar de Pepius
    Fecha de ingreso
    Feb 2004
    Ubicación
    Guadassuar, Valencia
    Mensajes
    4,998

    Re: Sugerencias Script para blender

    Pongo a Ton por testigo!
    Con esas cosas no se juega, hijo...

  11. #41
    Character Artist Avatar de fog
    Fecha de ingreso
    Feb 2004
    Ubicación
    Barcelona
    Mensajes
    861

    Re: Sugerencias Script para blender

    Jajajajaja enga vale Pepius. Pues.... pongo a Pepius por testigo?

  12. #42
    Character Artist Avatar de fog
    Fecha de ingreso
    Feb 2004
    Ubicación
    Barcelona
    Mensajes
    861

    Re: Sugerencias Script para blender

    A ver si alguien me puede echar un cable....

    Para mover un objecto como se haría?
    Tengo esto :
    Código:
    myNewPosX, myNewPosY = Window.GetMouseCoords()
    print (myNewPosX, myNewPosY)
    Con esto pillo la X y la Y en el viewport del mouse
    Lo siguiente seria mover un cubo en estas coordenadas.

    Con Cube.LocX no tira.... alguna idea?

    A que por cierto, no hay función para pillar las coordenadas en 3d del mouse. cachis....

  13. #43
    El Programador
    Fecha de ingreso
    Sep 2005
    Ubicación
    Valencia
    Mensajes
    720

    Re: Sugerencias Script para blender

    Me esta dando la sensación de que quieres poner un objeto 3d en un espacio 3d con coordenadas 2d del raton?

  14. #44
    Vampiro Giovanni Avatar de Pepius
    Fecha de ingreso
    Feb 2004
    Ubicación
    Guadassuar, Valencia
    Mensajes
    4,998

    Re: Sugerencias Script para blender

    Cube.setLocation(x,y,z)

    Creo que te servirá.

  15. #45
    BlenderAdicto Avatar de Caronte
    Fecha de ingreso
    Dec 2004
    Ubicación
    Valencia-España
    Mensajes
    14,691

    Re: Sugerencias Script para blender

    Y a lo mejor tienes que redibujar la pantalla para ver los cambios.

    P.D: Hay un sistema para pasar las coordenadas 2D a 3D y debe estar en el script que te he pasado (si no me equivoco).
    "Algún día todo será digital". Caronte.
    Mi web: NicoDigital.com

Página 3 de 8 PrimerPrimer 1234567 ... ÚltimoÚltimo

Temas similares

  1. Blender Script para Blender, duda
    Por Lyng en el foro Programación y Scripts
    Respuestas: 11
    Último mensaje: 09-08-2012, 16:49
  2. script FaST occlusion para Blender
    Por polan en el foro Programación y Scripts
    Respuestas: 9
    Último mensaje: 30-08-2007, 12:15
  3. Respuestas: 12
    Último mensaje: 18-05-2006, 11:37
  4. Script para medidas reales con Blender
    Por Caronte en el foro Plugins
    Respuestas: 2
    Último mensaje: 02-05-2006, 14:03
  5. script 3ds para blender no funciona
    Por flanders en el foro Problemas con Programas
    Respuestas: 9
    Último mensaje: 23-09-2005, 03:15

Actualmente estos son sus permisos de publicación en el foro.

  • -No puedes crear nuevos temas al no estar registrado o no haber iniciado sesión en el foro.
  • -No puedes responder temas al no estar registrado o no haber iniciado sesión en el foro.
  • -No puedes subir archivos adjuntos al no estar registrado o no haber iniciado sesión en el foro.
  • -No puedes editar tus mensajes al no estar registrado o no haber iniciado sesión en el foro.
  •