Plethora Peripherals

Plethora Peripherals

3M Downloads

3d canvas fancy vs fabulous rotation inconsistency.

Wojbie opened this issue ยท 1 comments

commented

Minecraft Version

1.19.x

Version

1.102.0 - SC3

Details

Canvas grid items are on seems to be rotating around with player pitch and roll when on Fabulous.
obraz

Not Fabulus
obraz

Fabulous
obraz

Test program used:

local ni = peripheral.wrap("back")
ni.canvas3d().clear()
local canvas = ni.canvas3d().create()
 
local el = {}
 
el[1] = canvas.addBox(0,0,0,1,1,1,0x00ff00ff)
el[2] = canvas.addFrame({3,3,3})
el[3] = canvas.addItem({-3,3,3},"minecraft:redstone",2)
el[4] = canvas.addItem({3,3,-3},"minecraft:crafting_table",2)
--el[5] = canvas.addLine({-3,3,-3},{0,0,0},10,0xff0000ff) --Not implemented
 
el[2].addRectangle(0, 0, 90, 90, 0x0000ffff)
el[2].addText({100,100}, "debug", 0xffffffff, 4)
 
local state = true
while true do
  for _,e in ipairs(el) do
   e.setDepthTested(state)
  end  
  sleep(2)
  state = not state
end
commented

Likely offending code:

RenderSystem.backupProjectionMatrix()
val matrixStack = MatrixStack()
matrixStack.peek().positionMatrix.identity()
val fov = (gr as GameRendererAccessor).invokeGetFov(cam, mc.tickDelta, true)
matrixStack.peek()
.positionMatrix
.mul(Matrix4f().setPerspective((fov * (Math.PI / 180.0).toFloat()).toFloat(), w / h, 0.1f, 1000.0f))
val projection = matrixStack.peek().positionMatrix
RenderSystem.setProjectionMatrix(projection)
val matrixStack2 = MatrixStack()
matrixStack2.push()
matrixStack2.loadIdentity()
matrixStack2.translate(0.0, 0.0, -500.0)
RenderSystem.colorMask(true, true, true, true)
framebuffer.setClearColor(0.0f, 0.0f, 0.0f, 0.0f)
framebuffer.clear(MinecraftClient.IS_SYSTEM_MAC)
framebuffer.beginWrite(true)
RenderSystem.disableDepthTest()
canvas.drawChildren(children.iterator(), matrixStack2, consumers)
matrixStack2.pop()
RenderSystem.viewport(0, 0, mc.window.framebufferWidth, mc.window.framebufferHeight)
RenderSystem.restoreProjectionMatrix()
framebuffer.endWrite()
GlStateManager._glBindFramebuffer(GlConst.GL_FRAMEBUFFER, currentBuffer)
// ===============================
matrices.push()
matrices.translate(position.x, position.y, position.z)
matrices.scale(SCALE, SCALE, SCALE)
applyRotation(matrices)

Though the -cam.pitch here is suspicious too, that was not negated on 1.12

matrices.multiply(RotationAxis.POSITIVE_Y.rotationDegrees(180 - cam.yaw))
matrices.multiply(RotationAxis.POSITIVE_X.rotationDegrees(-cam.pitch))

1.12:
https://github.com/SquidDev-CC/plethora/blob/3c9b41561a3dcc45d08a9167f6e471638cf2e170/src/main/java/org/squiddev/plethora/gameplay/modules/glasses/objects/object3d/ObjectFrame.java#L110C54-L111

In 1.12 it is negated for Item3D:
https://github.com/SquidDev-CC/plethora/blob/3c9b41561a3dcc45d08a9167f6e471638cf2e170/src/main/java/org/squiddev/plethora/gameplay/modules/glasses/objects/object3d/Item3D.java#L158

Perhaps trying to make it generic here caused more problems than it solved