當前位置: 首頁>>代碼示例>>Golang>>正文


Golang Mat4.RotationAxisAngle方法代碼示例

本文整理匯總了Golang中github.com/runningwild/mathgl.Mat4.RotationAxisAngle方法的典型用法代碼示例。如果您正苦於以下問題:Golang Mat4.RotationAxisAngle方法的具體用法?Golang Mat4.RotationAxisAngle怎麽用?Golang Mat4.RotationAxisAngle使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/runningwild/mathgl.Mat4的用法示例。


在下文中一共展示了Mat4.RotationAxisAngle方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: makeRoomMats

func makeRoomMats(room *roomDef, region gui.Region, focusx, focusy, angle, zoom float32) (floor, ifloor, left, ileft, right, iright mathgl.Mat4) {
    var m mathgl.Mat4
    floor.Translation(float32(region.Dx/2+region.X), float32(region.Dy/2+region.Y), 0)

    // NOTE: If we want to change 45 to *anything* else then we need to do the
    // appropriate math for rendering quads for furniture
    m.RotationZ(45 * math.Pi / 180)
    floor.Multiply(&m)
    m.RotationAxisAngle(mathgl.Vec3{X: -1, Y: 1}, -float32(angle)*math.Pi/180)
    floor.Multiply(&m)

    s := float32(zoom)
    m.Scaling(s, s, s)
    floor.Multiply(&m)

    // Move the viewer so that the focus is at the origin, and hence becomes centered
    // in the window
    m.Translation(-focusx, -focusy, 0)
    floor.Multiply(&m)

    ifloor.Assign(&floor)
    ifloor.Inverse()

    // Also make the mats for the left and right walls based on this mat
    left.Assign(&floor)
    m.RotationX(-math.Pi / 2)
    left.Multiply(&m)
    m.Translation(0, 0, float32(room.Size.Dy))
    left.Multiply(&m)
    ileft.Assign(&left)
    ileft.Inverse()

    right.Assign(&floor)
    m.RotationX(-math.Pi / 2)
    right.Multiply(&m)
    m.RotationY(-math.Pi / 2)
    right.Multiply(&m)
    m.Scaling(1, 1, 1)
    right.Multiply(&m)
    m.Translation(0, 0, -float32(room.Size.Dx))
    right.Multiply(&m)
    swap_x_y := mathgl.Mat4{
        0, 1, 0, 0,
        1, 0, 0, 0,
        0, 0, 1, 0,
        0, 0, 0, 1,
    }
    right.Multiply(&swap_x_y)
    iright.Assign(&right)
    iright.Inverse()

    return floor, ifloor, left, ileft, right, iright
}
開發者ID:hilerchyn,項目名稱:haunts,代碼行數:53,代碼來源:room_viewer.go


注:本文中的github.com/runningwild/mathgl.Mat4.RotationAxisAngle方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。