func RenderAdvanced(x, y, dx, dy, rot float64, flip bool) { setupTextureList() if textureList == 0 { return } var run, op mathgl.Mat4 run.Identity() op.Translation(float32(x), float32(y), 0) run.Multiply(&op) op.Translation(float32(dx/2), float32(dy/2), 0) run.Multiply(&op) op.RotationZ(float32(rot)) run.Multiply(&op) if flip { op.Translation(float32(-dx/2), float32(-dy/2), 0) run.Multiply(&op) op.Scaling(float32(dx), float32(dy), 1) run.Multiply(&op) } else { op.Translation(float32(dx/2), float32(-dy/2), 0) run.Multiply(&op) op.Scaling(float32(-dx), float32(dy), 1) run.Multiply(&op) } gl.PushMatrix() gl.MultMatrixf((*gl.Float)(&run[0])) gl.Enable(gl.TEXTURE_2D) gl.CallList(textureList) gl.PopMatrix() }
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 }