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

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Post Reply
Message
Author
User avatar
barsunduk
Regular
Posts: 33
Joined: Fri Jul 18, 2014 1:06 pm
Completed: «Crystal City», «Mega City», «Kilmonger», «Neuronaut», «Love, Death & Veggies», «Arrow Tourney», «Big Red Hood: Halloween», «Succubus Throne»
Projects: «Swordsman Tourney», «This Tiny Galaxy»
Organization: 7DOTS
itch: 7dots
Contact:

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

#1 Post 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

Post Reply

Who is online

Users browsing this forum: Google [Bot]