Orthographic to Perspective script

Hey all,

I just made a script that corrects a model from orthographic to perspective. So if you have a model that looks good in ortho, but is compleatly tweaked when you go to the perspective view, this script will help.
It makes the perspective view from the front, at the set distance, look like the orthographic did before teh script was run.

I made the gui with the GUI creator from The_Nerd (thank you!)
https://blenderartists.org/forum/viewtopic.php?t=28395&highlight=gui+creator

makes this easier:
https://blenderartists.org/tutorials.php?id=3&page=5

Examples:
before
http://blender.sixmonkeys.geek.nz/view_photo.php?set_albumName=Jordnak&id=cubeExtrudeDup

after
http://blender.sixmonkeys.geek.nz/view_photo.php?set_albumName=Jordnak&id=cubeExtrudeDupCorrect

UPDATE BELOW

tell me what you think,
jordank

No replies? oh well. here is an update, with an inverse feature (reverse effects)

Just copy and paste script into the text editor (CTRL+SHIFT+V to paste from windows clip-board)

Update below

Haven’t tried it yet but looks interesting… maybe useful for anamorphic modelling ?

I made it to help tweeking when you are using a reference pic. because the pic is perspective, and you model in ortho, it helps with correction.

fixed the inverse function:

##ORTHO CORRECTION SCRIPT##
#
#by Jordank

import Blender
from Blender import Draw, BGL, Window, NMesh
from Blender.BGL import *

EVENT_SLIDER_1 = 10
EVENT_SLIDER_2 = 11
EVENT_BUTTON_3 = 12
EVENT_TOGGLE_4 = 13
EVENT_TOGGLE_5 = 14
EVENT_TOGGLE_6 = 14
Object_Slider_1 = Draw.Create(5.0)
Object_Slider_2 = Draw.Create(0.0)
Object_Button_3 = Draw.Create(0)
Object_Toggle_4 = Draw.Create(1)
Object_Toggle_5 = Draw.Create(0)
Object_Toggle_6 = Draw.Create(0)

def draw():
	global EVENT_SLIDER_1
	global EVENT_SLIDER_2
	global EVENT_BUTTON_3
	global EVENT_TOGGLE_4
	global EVENT_TOGGLE_5
	global EVENT_TOGGLE_6
	global Object_Slider_1
	global Object_Slider_2
	global Object_Button_3
	global Object_Toggle_4
	global Object_Toggle_5
	global Object_Toggle_6


	BGL.glClearColor(0.500000, 0.500000, 0.500000, 0.0)
	BGL.glClear(GL_COLOR_BUFFER_BIT)

	BGL.glColor3f(0.000000, 0.000000, 0.000000)
	Object_Slider_1 = Draw.Slider("Distance  ", EVENT_SLIDER_1, 5, 60	, 200, 20, Object_Slider_1.val, 0.010000, 30.000000, 1, "Distance from Z extremity at which the perspective view looks like the orthographic view dose now")
	Object_Slider_2 = Draw.Slider("Offset ", EVENT_SLIDER_2, 5, 35, 200, 20, Object_Slider_2.val, 0.000000, 5.000000, 1, "ofset the calculated distance in from the Z extremity")
	Object_Button_3 = Draw.Button("Correct", EVENT_BUTTON_3, 209, 10, 71, 70, "Make the perspective view at the given distance look like the orthographic view dose now")
	Object_Toggle_4 = Draw.Toggle("Correct X", EVENT_TOGGLE_4, 5, 10, 60, 20, Object_Toggle_4.val, "")
	Object_Toggle_5 = Draw.Toggle("Correct Y", EVENT_TOGGLE_5, 75, 10, 60, 20, Object_Toggle_5.val, "")
	Object_Toggle_6 = Draw.Toggle("Invert", EVENT_TOGGLE_6, 145, 10, 60, 20, Object_Toggle_6.val, "Invert the effect")

def event(event, value):
	if event == Draw.ESCKEY and not value: Draw.Exit()

def b_event(event):
	global EVENT_SLIDER_1
	global EVENT_SLIDER_2
	global EVENT_BUTTON_3
	global EVENT_TOGGLE_4
	global EVENT_TOGGLE_5
	global Object_Slider_1
	global Object_Slider_2
	global Object_Button_3
	global Object_Toggle_4
	global Object_Toggle_5

	s = 0

	if event == 0: pass
	elif event == EVENT_BUTTON_3:
		sel = Blender.Object.GetSelected()[0]
		me = sel.getData()
		offset = Object_Slider_2.val
		dis = Object_Slider_1.val
		X = Object_Toggle_4.val
		Y = Object_Toggle_5.val
		for v in me.verts:
			if (s == 0):
				maz = v.co[2]
				max = v.co[0]
				mix = v.co[0]
				may = v.co[1]
				miy = v.co[1]
				s = 1
			else:
				if (v.co[2] > maz):
					maz = v.co[2]
				if (v.co[0] > max):
					max = v.co[0]
				if (v.co[0] < mix):
					mix = v.co[0]
				if (v.co[1] > may):
					may = v.co[1]
				if (v.co[1] < miy):
					miy = v.co[1]

		if (Object_Toggle_6.val == 1):
			dis *= -1
			offset *= -1
			for v in me.verts:
				if (v.co[2] < maz):
					maz = v.co[2]
				if (v.co[0] < max):
					max = v.co[0]
				if (v.co[0] > mix):
					mix = v.co[0]
				if (v.co[1] < may):
					may = v.co[1]
				if (v.co[1] > miy):
					miy = v.co[1]

		midx = (max + mix)/2

		midy = (may + miy)/2

		maz += offset

		if (X == 1):
			for v in me.verts:
				dis2 = v.co[0]-midx
				rto = (dis+(maz-v.co[2]))/dis
				v.co[0] = dis2*rto
		if (Y == 1):
			for v in me.verts:
				dis2 = v.co[1]-midy
				rto = (dis+(maz-v.co[2]))/dis
				v.co[1] = dis2*rto
		me.update()
		Blender.Redraw()
	Draw.Draw()

Draw.Register(draw, event, b_event)