Page 1 of 1

How to use the 3D Stage to draw a 3D box?

Posted: Fri Oct 21, 2022 12:09 am
by barsunduk
I tried to draw a 3d box on a 3d scene but failed...
When using RotateMatrix angle != 0, sprites move far to the side. The same thing happens when using an OffsetMatrix.
(It’s also sad that linear and ease doesn’t work when using matrix transformations.)

I want to make a scene where you can go behind the boxes and find some items there.

Image

Test project

Test 2

Code: Select all

init:
    # camera transform
    transform _3d(x=0, y=0, a=0):
        perspective True
        subpixel True
        [b]# ease 1 not working[/b]
        ease 1 matrixtransform RotateMatrix(0, a, 0) * OffsetMatrix(x, 0, y)

    # box transform
    transform spr_3d(x=0, y=0, a=0, dx=0):
        subpixel True
        perspective True
        xpos x zpos y
        matrixtransform RotateMatrix(0, a, 0)

    # dark side
    image box1d:
        "box1"
        matrixcolor BrightnessMatrix(-.15)
    image box2d:
        "box2"
        matrixcolor BrightnessMatrix(-.15)

init python:
    # box side length
    side_3d = 500

    # show 1 side
    def show_3d(spr, x, y, a=0):
        renpy.show("%s_%s_%s_%s" % (spr, x, y, a),
            what=spr, at_list=[spr_3d(x, y, a), truecenter])

    # show all 4 sides
    def show_box_3d(spr, x, y, a=0):
        w2 = int(side_3d / 2)
        show_3d(spr, x, y+w2, a)
        show_3d(spr+"d", x-w2, y, a+90)
        show_3d(spr+"d", x+w2, y, a-90)
        show_3d(spr, x, y-w2, a)

label start:
    # turn on 3d
    show layer master at _3d(y=-555)

    # show boxes
    $ show_box_3d("box1", -750, 2250)
    $ show_box_3d("box2", 750, 2250)

    pause
    return