Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[split] Rotating on Y axis like Map Object (Plane)
#1
(03-09-2023, 11:47 PM)Ofnuts Wrote: Map object is not unusable (or even that hard to understand).... until you want to map something to an existing cylinder in your image, that elicits considerable amounts of trial and error, first for the size/position/rotation, then for the lighting. If/when they redo Map object with a live preview on the canvas then things will be a lot easier.

I have been looking to map the y axis of plane mode via a python script
any help would be greatly appreciated

specifically try to get orientaion y to rotate(-180, 180, 5)
but all attempts so far have given the incorrect results. I can do this manually but when i need to create so many layers it becomes too time consuming. 

her is the last script i tried:

'''
import math
from gimpfu import *

def rotate_image_on_y(image, drawable):
    for angle in range(-180, 185, 5):
        # Create a duplicate of the drawable (layer)
        duplicate_layer = pdb.gimp_layer_new_from_drawable(drawable, image)
        
        # Add the duplicate layer to the image
        pdb.gimp_image_insert_layer(image, duplicate_layer, None, -1)
        
        # Rotate the duplicate layer on the Y-axis
        pdb.gimp_item_transform_rotate(duplicate_layer, math.radians(angle), True, 0, 0)

    pdb.gimp_displays_flush()

register(
    "rotate_image_on_y",
    "Rotate Image on Y-Axis",
    "Rotate image on the Y-axis",
    "Your Name",
    "Your Name",
    "2023",
    "<Image>/Filters/MyScripts/Rotate Image on Y-Axis",
    "*",
    [],
    [],
    rotate_image_on_y)

main()

'''
Reply
#2
Rotating along the Y axis (or the X axis for that matter) in Map object/Plane is actually a perspective transform:

   

As a simplified solution (ie, you assume you are very far away, and using a telescope), the side towards you is the same size as the side far from you, and the whole thing is just a scaling along the X Axis (for a cosine of the angle of rotation).
Reply
#3
(06-08-2023, 05:39 PM)Ofnuts Wrote: Rotating along the Y axis (or the X axis for that matter) in Map object/Plane is actually a perspective transform:



As a simplified solution (ie, you assume you are very far away, and using a telescope), the side towards you is the same size as the side far from you, and the whole thing is just a scaling along the X Axis (for a cosine of the angle of rotation).

Im looking for the python fu cammands
Reply
#4
(06-08-2023, 06:17 PM)nachocoin Wrote: Im looking for the python fu cammands

To scale: pdb.gimp_drawable_transform_scale(), pdb.gimp_layer_scale(), pdb.gimp_item_transform_scale()

For perspective: pdb.gimp_item_transform_perspective().

All this with a bit of trigonometry of course.

Or you can use pdb.plug_in_map_object()
Reply


Forum Jump: