[Add] Some scripts that are pissing me off beyond belief!
This commit is contained in:
parent
29b8b5ba18
commit
782e11918c
125
utils/mkplanet/planet.scm
Normal file
125
utils/mkplanet/planet.scm
Normal file
@ -0,0 +1,125 @@
|
||||
; lephisto-planet.creator.scm
|
||||
; Creates a planet.
|
||||
;
|
||||
; The script will create its own menu in the toolbox.
|
||||
|
||||
(define (lephisto-planet-creator planetSize planetColor sunAngle sunTilt glowSize)
|
||||
|
||||
(let*
|
||||
|
||||
(
|
||||
; 1/10th of the planet size
|
||||
(tenth (/ planetSize 10) )
|
||||
|
||||
; Image size 10% bigger than the planet
|
||||
(imgSize (+ planetSize (* tenth 2)) )
|
||||
|
||||
; Getting the inverse of the glowSize so it makes more sense to the user
|
||||
(glowSizeInv (/ 1 glowSize))
|
||||
|
||||
(theImage (car (gimp-image-new imgSize imgSize RGB) ))
|
||||
(layerbase (car (gimp-layer-new theImage imgSize imgSize 0 "planet base" 100 NORMAL) ) )
|
||||
(layeratmosph (car (gimp-layer-new theImage imgSize imgSize 0 "planet atmosphere" 100 NORMAL) ) )
|
||||
(layershadow (car (gimp-layer-new theImage imgSize imgSize 0 "planet shadow" 100 NORMAL) ) )
|
||||
(layerglow (car (gimp-layer-new theImage imgSize imgSize 0 "planet glow" 100 NORMAL) ) )
|
||||
(angleRad (/ (* sunAngle *pi*) 180))
|
||||
(transX (* (sin angleRad) -1))
|
||||
(transY (cos angleRad))
|
||||
)
|
||||
|
||||
(gimp-context-push)
|
||||
(gimp-image-undo-disable theImage)
|
||||
|
||||
(gimp-layer-add-alpha layerbase )
|
||||
(gimp-layer-add-alpha layeratmosph )
|
||||
(gimp-layer-add-alpha layershadow )
|
||||
(gimp-layer-add-alpha layerglow )
|
||||
|
||||
(gimp-image-add-layer theImage layerglow 0)
|
||||
(gimp-image-add-layer theImage layerbase 0)
|
||||
(gimp-image-add-layer theImage layeratmosph 0)
|
||||
(gimp-image-add-layer theImage layershadow 0)
|
||||
|
||||
(gimp-selection-all theImage)
|
||||
(gimp-edit-clear layerbase)
|
||||
(gimp-edit-clear layeratmosph)
|
||||
(gimp-edit-clear layershadow)
|
||||
(gimp-edit-clear layerglow)
|
||||
(gimp-selection-none theImage)
|
||||
|
||||
|
||||
(gimp-ellipse-select theImage tenth tenth planetSize planetSize 2 0 0 0 )
|
||||
(gimp-context-set-foreground planetColor)
|
||||
|
||||
; Fill selection with the planet color
|
||||
(gimp-edit-bucket-fill layerbase 0 0 100 0 FALSE 0 0 )
|
||||
(gimp-edit-bucket-fill layeratmosph 0 0 100 0 FALSE 0 0 )
|
||||
|
||||
; Shrink and blur for the shadow
|
||||
(gimp-selection-feather theImage (* 1.5 tenth) )
|
||||
(gimp-context-set-background '(0 0 0) )
|
||||
(gimp-edit-bucket-fill layershadow 1 0 100 0 FALSE 0 0 );;
|
||||
|
||||
; Add the light around the planet for the atmosphere
|
||||
(gimp-selection-layer-alpha layeratmosph)
|
||||
(gimp-selection-shrink theImage tenth)
|
||||
(gimp-selection-feather theImage (* 2 tenth))
|
||||
(gimp-layer-set-preserve-trans layeratmosph 1)
|
||||
(gimp-selection-invert theImage)
|
||||
(gimp-context-set-background '(255 255 255) )
|
||||
(gimp-edit-bucket-fill layeratmosph 1 5 90 0 FALSE 0 0 )
|
||||
(gimp-selection-invert theImage)
|
||||
(gimp-context-set-foreground '(0 0 0) )
|
||||
(gimp-edit-bucket-fill layeratmosph 0 0 100 0 FALSE 0 0 )
|
||||
(gimp-selection-layer-alpha layeratmosph)
|
||||
(gimp-selection-shrink theImage (/ tenth 3))
|
||||
(gimp-selection-feather theImage tenth)
|
||||
(gimp-selection-invert theImage)
|
||||
(gimp-edit-bucket-fill layeratmosph 1 0 85 0 FALSE 0 0 )
|
||||
(gimp-layer-set-mode layeratmosph 4)
|
||||
|
||||
; Move,resize the shadow layer
|
||||
(gimp-layer-scale layershadow (* (+ 1.5 (/ sunTilt 10)) imgSize) (* (+ 1.5 (/ sunTilt 10)) imgSize) 1 )
|
||||
(gimp-layer-translate layershadow (* (* transX tenth) (+ 3 sunTilt) ) (* (* transY tenth) (+ 3 sunTilt) ) )
|
||||
|
||||
; And now the glow...
|
||||
(gimp-selection-layer-alpha layerbase)
|
||||
(gimp-selection-grow theImage (/ tenth glowSizeInv))
|
||||
(gimp-selection-feather theImage tenth)
|
||||
(gimp-context-set-background planetColor )
|
||||
(gimp-edit-bucket-fill layerglow 1 0 100 0 FALSE 0 0 )
|
||||
(gimp-edit-bucket-fill layerglow 1 7 100 0 FALSE 0 0 )
|
||||
(gimp-edit-bucket-fill layerglow 1 7 100 0 FALSE 0 0 )
|
||||
|
||||
; Mask a part of the glow
|
||||
(set! glowmask (car (gimp-layer-create-mask layerglow 0)))
|
||||
(gimp-image-add-layer-mask theImage layerglow glowmask)
|
||||
(gimp-selection-layer-alpha layershadow)
|
||||
(gimp-edit-bucket-fill glowmask 0 0 100 0 FALSE 0 0 )
|
||||
(gimp-selection-all theImage)
|
||||
(gimp-fuzzy-select layerbase (/ imgSize 2) (/ imgSize 2) 15 1 1 0 0 0)
|
||||
(gimp-edit-cut layershadow)
|
||||
(gimp-layer-resize-to-image-size layershadow)
|
||||
|
||||
(gimp-image-clean-all theImage)
|
||||
(gimp-image-undo-enable theImage)
|
||||
(gimp-display-new theImage)
|
||||
(gimp-context-pop)
|
||||
)
|
||||
)
|
||||
|
||||
(script-fu-register "lephisto-planet-creator"
|
||||
_"Lephisto Planet Creator"
|
||||
"Creates a planet. (For use in Lephisto)"
|
||||
"http://saracraft.net"
|
||||
"10/02/2013"
|
||||
""
|
||||
SF-ADJUSTMENT "Planet Size (pixels)" '(80 40 2000 1 10 0 1)
|
||||
SF-COLOR "Planet Color" '(10 70 100)
|
||||
SF-ADJUSTMENT _"Sun Orientation (degrees) " '(0 0 360 1 10 1 0)
|
||||
SF-ADJUSTMENT _"Sun Tilt " '(1 0 25 1 10 1 0)
|
||||
SF-ADJUSTMENT _"Glow Size" '(.25 .1 .6667 1 2 1 0)
|
||||
)
|
||||
(script-fu-menu-register "script-fu-lephisto-planet-render2"
|
||||
_"<Toolbox>/Lephiso/")
|
||||
|
201
utils/render/spriteRender.py
Executable file
201
utils/render/spriteRender.py
Executable file
@ -0,0 +1,201 @@
|
||||
#!/usr/bin/blender
|
||||
"""
|
||||
Name: 'Lephisto Sprite Renderer'
|
||||
Blender: '242'
|
||||
Group: 'Export'
|
||||
Tip: 'Renders images and places them in a directory'
|
||||
"""
|
||||
#
|
||||
# Lephisto Sprite Renderer
|
||||
#
|
||||
# NOTE: You must set the context.renderPath variable on line 122 to your chosen directory.
|
||||
#
|
||||
|
||||
###########################
|
||||
# importing modules
|
||||
###########################
|
||||
import Blender
|
||||
import math
|
||||
from math import *
|
||||
from Blender.BGL import *
|
||||
from Blender.Draw import *
|
||||
from Blender import Scene
|
||||
from Blender import Object
|
||||
from Blender import Lamp
|
||||
from Blender import Camera
|
||||
from Blender import NMesh
|
||||
from Blender import Types
|
||||
from Blender.Scene import Render
|
||||
|
||||
###########################
|
||||
# random initialization
|
||||
###########################
|
||||
objList = Blender.Object.Get()
|
||||
print objList
|
||||
fileName = Blender.Get('filename')
|
||||
scn = Blender.Scene.GetCurrent()
|
||||
context = scn.getRenderingContext()
|
||||
Render.EnableDispWin()
|
||||
context.extensions = True
|
||||
context.imageType = Render.PNG
|
||||
context.enableOversampling(0)
|
||||
osaafter = 1
|
||||
ypos=5
|
||||
|
||||
sliderLight = Create(0)
|
||||
|
||||
###########################
|
||||
# GUI
|
||||
###########################
|
||||
def draw() :
|
||||
global Button3, Button2, Button1
|
||||
global sliderWidth, sliderLight, sliderSpriteSize, sliderObjectSize
|
||||
global ypos
|
||||
|
||||
glClearColor(0.753, 0.753, 0.753, 0.0)
|
||||
Blender.BGL.glClear(Blender.BGL.GL_COLOR_BUFFER_BIT)
|
||||
|
||||
glColor3f(0.000, 0.000, 0.000)
|
||||
glRasterPos2i(10, ypos)
|
||||
|
||||
Button('Exit', 1, 10, ypos, 50, 15, 'Exit script')
|
||||
ypos = ypos + 20
|
||||
Button('Render', 2, 10, ypos, 50, 15, 'Render the ship with current settings')
|
||||
ypos = ypos + 20
|
||||
Button('Test', 3, 10, ypos, 50, 15, 'Test your settings')
|
||||
ypos = ypos + 20
|
||||
Button('Initialize', 4, 10, ypos, 50, 15, 'Initialize the camera and lights')
|
||||
ypos = ypos + 40
|
||||
|
||||
sliderWidth = 300
|
||||
|
||||
sliderLight = Slider('Light Intensity ', 5, 10, ypos, sliderWidth, 25, sliderLight.val, 0, 10, .1, 'Light Itensity')
|
||||
ypos = ypos + 40
|
||||
|
||||
glColor3f(0.000, 0.000, 0.000)
|
||||
glRasterPos2i(10, ypos)
|
||||
Text('3: Finally push the "Render" button to render your frames.')
|
||||
ypos = ypos + 20
|
||||
glRasterPos2i(10, ypos)
|
||||
Text('2: Hit the "Test" button to see if your lighting is good.')
|
||||
ypos = ypos + 20
|
||||
glRasterPos2i(10, ypos)
|
||||
Text('1: Put in your settings and hit the "initialization" button.')
|
||||
ypos = ypos + 20
|
||||
glRasterPos2i(10, ypos)
|
||||
Text('Usage:')
|
||||
ypos = ypos + 20
|
||||
glRasterPos2i(10, ypos)
|
||||
Text('Created for Lephisto: http://saracraft.net')
|
||||
ypos = ypos + 20
|
||||
glRasterPos2i(10, ypos)
|
||||
Text('Lephisto Sprite Renderer')
|
||||
|
||||
def event(evt, val) :
|
||||
if (evt == QKEY and not val) :
|
||||
Exit()
|
||||
|
||||
def bevent(evt) :
|
||||
if evt == 1 :
|
||||
Exit()
|
||||
elif evt == 2 :
|
||||
render()
|
||||
elif evt == 3 :
|
||||
test()
|
||||
elif evt == 4 :
|
||||
initialize()
|
||||
|
||||
Blender.Draw.Register(draw,event,bevent)
|
||||
|
||||
###########################
|
||||
# Variables that should be
|
||||
# put into gui but will
|
||||
# remain in the script for now
|
||||
###########################
|
||||
spriteSize = 500
|
||||
context.renderPath = "/home/allanis/Code/Lephisto/utils/mksprite/"
|
||||
|
||||
def initialize() :
|
||||
|
||||
####################
|
||||
# Orienting the object(s)
|
||||
# in the correct position
|
||||
####################
|
||||
for obj in objList :
|
||||
if obj.getType() == 'Mesh' :
|
||||
obj.RotZ = 0
|
||||
obj.RotY = 0
|
||||
# obj.RotX = 45
|
||||
|
||||
##########################
|
||||
# Onitializing the camera
|
||||
##########################
|
||||
cam = Blender.Object.Get("Camera")
|
||||
cam.LocZ = 9.0
|
||||
cam.LocX = -5.0
|
||||
cam.LocY = 0
|
||||
cam.RotY = 0
|
||||
cam.RotX = 0
|
||||
cam.RotZ = 0
|
||||
cam.RotZ = -(pi / 2)
|
||||
cam.RotX = (pi / 7)
|
||||
|
||||
###########################
|
||||
# Setting up the lighting, bitches!
|
||||
###########################
|
||||
for obj in objList :
|
||||
if obj.getType() == 'Lamp' :
|
||||
scn.unlink(obj)
|
||||
lamp = Blender.Lamp.New()
|
||||
Lamp1 = Blender.Object.New('Lamp', 'Lamp1')
|
||||
Lamp2 = Blender.Object.New('Lamp', 'Lamp2')
|
||||
Lamp1.LocZ = 4.0
|
||||
Lamp1.LocX = 4.0
|
||||
Lamp1.LocY = 0
|
||||
Lamp2.LocZ = 2.0
|
||||
Lamp2.LocX = -4.0
|
||||
Lamp2.LocY = 0
|
||||
Lamp1.link(lamp)
|
||||
Lamp2.link(lamp)
|
||||
lamp.setEnergy(sliderLight.val)
|
||||
scn.link (Lamp1)
|
||||
scn.link (Lamp2)
|
||||
|
||||
def test() :
|
||||
context.imageSizeX(spriteSize)
|
||||
context.imageSizeY(spriteSize)
|
||||
context.render()
|
||||
|
||||
def render() :
|
||||
###########################
|
||||
# Rendering the first frame
|
||||
###########################
|
||||
origSX = context.imageSizeX()
|
||||
origSY = context.imageSizeY()
|
||||
context.imageSizeX(spriteSize)
|
||||
context.imageSizeY(spriteSize)
|
||||
spriteName = '001'
|
||||
context.render()
|
||||
context.saveRenderedImage(spriteName)
|
||||
Render.CloseRenderWindow()
|
||||
|
||||
###########################
|
||||
# Rendering the rest of the frames
|
||||
###########################
|
||||
for i in range(1,35+1) :
|
||||
n = str(i + 1)
|
||||
for obj in objList :
|
||||
if obj.getType() == 'Mesh' :
|
||||
obj.RotZ = ((pi * 2) / 36) * i
|
||||
spriteName = n.zfill(3)
|
||||
|
||||
context.render()
|
||||
context.saveRenderedImage(spriteName)
|
||||
Render.CloseRenderWindow()
|
||||
|
||||
###########################
|
||||
# Returning settings to normal
|
||||
###########################
|
||||
context.imageSizeX(origSX)
|
||||
context.imageSizeY(origSY)
|
||||
context.enableOversampling(osaafter)
|
Loading…
Reference in New Issue
Block a user