📄 viewport.java
字号:
/* * J3DME Fast 3D software rendering for small devices * Copyright (C) 2001 Onno Hommes * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */package net.jscience.j3dme;/** * This class represents the viewport. The viewport is the connection * between the viewer and the camera. The viewport can be linked to one * camera at a time. It is like wiring your display to the specified * camera. By switching cameras you can quickly look forward or backward * or look into other virtual worlds. * @see Camera */public class ViewPort{ private Renderer renderer; protected Camera camera; protected int x,y,width,height; protected int cx,cy; private int mx,my; /** * Return a ViewPort object<p> * The viewport needs a renderer to visualize the scene to the viewer, * and a camera. In addition you must specify the location and dimensions * of the viewport on your display. As part of the dimensions you must * specify if you need a border or not. * * @param r The platform specific renderer object * @param c The camera to look through * @param xv The top left x coordinate of the viewport location * @param yv The top left y coordinate of the viewport location * @param wv The width of the viewport * @param hv The height of the viewport * @param border The border indicator * @return A viewport with the supplied specifications. */ public ViewPort(Renderer r,Camera c,int xv,int yv,int wv,int hv){ // Initialize ViewPort parameters renderer = r; camera = c; x = xv; y = yv; width = wv; height = hv; // Determine 2D coordinate origin mx = x + width; my = y + height; cx = mx/2; cy = my/2; } /** * Render the current camera view onto the displau<p> * This method will display the scene visible through the current * attached camera. */ public void renderScene(){ renderer.drawScene(this); } /** * Return the current attached camera<p> * @return The camera attached to the viewport. */ public Camera getCamera() { return camera; } /** * Attach a new camera to the viewport<p> * @param c The new camera object */ public void setCamera(Camera c) { camera = c; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -