package org.jzy3d.debug.axe;
import java.nio.FloatBuffer;
import javax.media.opengl.GL;
import javax.media.opengl.glu.GLU;
import org.jzy3d.colors.Color;
import org.jzy3d.maths.BoundingBox3d;
import org.jzy3d.plot3d.primitives.axes.AxeBox;
import org.jzy3d.plot3d.primitives.axes.layout.AxeBoxLayout;
import org.jzy3d.plot3d.primitives.axes.layout.IAxeLayout;
import org.jzy3d.plot3d.rendering.view.Camera;
import org.jzy3d.plot3d.text.align.Halign;
import org.jzy3d.plot3d.text.align.Valign;
import com.sun.opengl.util.BufferUtil;
/**The AxeBox displays a box with front face invisible and ticks labels.
* @author Martin Pernollet
*/
public class DebugBox extends AxeBox{
public DebugBox(BoundingBox3d bbox){
super(bbox, new AxeBoxLayout());
}
public DebugBox(BoundingBox3d bbox, IAxeLayout layout){
super(bbox, layout);
}
/***********************************************************/
/**
* Draws the AxeBox. The camera is used to determine which axis is closest
* to the ur point ov view, in order to decide for an axis on which
* to diplay the tick values.
*/
@Override
public void draw(GL gl, GLU glu, Camera camera){
// Set scaling
gl.glLoadIdentity();
gl.glScalef(scale.x, scale.y, scale.z);
// Set culling
gl.glEnable(GL.GL_CULL_FACE);
//gl.glFrontFace(GL.GL_CCW);
//gl.glCullFace(GL.GL_FRONT);
gl.glFrontFace(GL.GL_CW);
gl.glCullFace(GL.GL_BACK);
// Draw cube in feedback buffer for computing hidden quads
quadIsHidden = getHiddenQuads(gl);
printHiddenQuads();
// Plain part of quad macking the surrounding box
if( layout.isFaceDisplayed() ){
Color quadcolor = layout.getQuadColor();
gl.glPolygonMode(GL.GL_BACK, GL.GL_FILL);
gl.glColor4f(quadcolor.r, quadcolor.g, quadcolor.b, quadcolor.a);
gl.glLineWidth(1.0f);
gl.glEnable(GL.GL_POLYGON_OFFSET_FILL);
gl.glPolygonOffset(1.0f, 1.0f); // handle stippling
drawCube(gl, GL.GL_RENDER);
gl.glDisable(GL.GL_POLYGON_OFFSET_FILL);
}
// Edge part of quads making the surrounding box
Color gridcolor = layout.getGridColor();
gl.glPolygonMode(GL.GL_FRONT, GL.GL_LINE);
gl.glColor4f(gridcolor.r, gridcolor.g, gridcolor.b, gridcolor.a);
gl.glLineWidth(1);
drawCube(gl, GL.GL_RENDER);
// Draw grids on non hidden quads
gl.glPolygonMode(GL.GL_FRONT, GL.GL_LINE);
gl.glColor4f(gridcolor.r, gridcolor.g, gridcolor.b, gridcolor.a);
gl.glLineWidth(1);
gl.glLineStipple(1, (short)0xAAAA);
gl.glEnable(GL.GL_LINE_STIPPLE);
for(int quad=0; quad<6; quad++)
if(!quadIsHidden[quad])
drawGridOnQuad(gl, quad);
gl.glDisable(GL.GL_LINE_STIPPLE);
// Draw ticks on the closest axes
wholeBounds.reset();
wholeBounds.add(boxBounds);
//gl.glPolygonMode(GL.GL_FRONT_AND_BACK, GL.GL_LINE);
// Display x axis ticks
if(xrange>0 && layout.isXTickLabelDisplayed()){
int xselect = findClosestXaxe(camera);
if(xselect>=0){
BoundingBox3d bbox = drawTicks(gl, glu, camera, xselect, AXE_X, layout.getXTickColor());
wholeBounds.add(bbox);
}
else{
//System.err.println("no x axe selected: " + Arrays.toString(quadIsHidden));
// HACK: handles "on top" view, when all face of cube are drawn, which forbid to select an axe automatically
BoundingBox3d bbox = drawTicks(gl, glu, camera, 2, AXE_X, layout.getXTickColor(), Halign.CENTER, Valign.TOP);
wholeBounds.add(bbox);
}
}
// Display y axis ticks
if(yrange>0 && layout.isYTickLabelDisplayed()){
int yselect = findClosestYaxe(camera);
if(yselect>=0){
BoundingBox3d bbox = drawTicks(gl, glu, camera, yselect, AXE_Y, layout.getYTickColor());
wholeBounds.add(bbox);
}
else{
//System.err.println("no y axe selected: " + Arrays.toString(quadIsHidden));
// HACK: handles "on top" view, when all face of cube are drawn, which forbid to select an axe automatically
BoundingBox3d bbox = drawTicks(gl, glu, camera, 1, AXE_Y, layout.getYTickColor(), Halign.RIGHT, Valign.GROUND);
wholeBounds.add(bbox);
}
}
// Display z axis ticks
if(zrange>0 && layout.isZTickLabelDisplayed()){
int zselect = findClosestZaxe(camera);
if(zselect>=0){
BoundingBox3d bbox = drawTicks(gl, glu, camera, zselect, AXE_Z, layout.getZTickColor());
wholeBounds.add(bbox);
}
}
// Unset culling
gl.glDisable(GL.GL_CULL_FACE);
}
/******************************************************************/
/** DRAW AXEBOX ELEMENTS **/
/**
* Make all GL calls allowing to build a cube with 6 separate quads.
* Each quad is indexed from 0.0f to 5.0f using glPassThrough,
* and may be traced in feedback mode when mode=GL.GL_FEEDBACK
*/
protected void drawCube(GL gl, int mode){
for(int q=0; q<6; q++){
if(mode==GL.GL_FEEDBACK)
gl.glPassThrough((float)q);
gl.glBegin(GL.GL_QUADS);
for(int v=0; v<4; v++){
gl.glVertex3f( quadx[q][v], quady[q][v], quadz[q][v]);
}
gl.glEnd();
}
}
/******************************************************************/
/** COMPUTATION OF HIDDEN QUADS **/
/*
* Render the cube into the feedback buffer, in order to parse feedback
* and determine which quad where displayed or not.
*/
protected boolean [] getHiddenQuads(GL gl){
int feedbacklength = 1024;
FloatBuffer floatbuffer = BufferUtil.newFloatBuffer(feedbacklength);
float [] feedback = new float[feedbacklength];
// Draw the cube into feedback buffer
gl.glFeedbackBuffer(feedbacklength, GL.GL_3D_COLOR, floatbuffer);
gl.glRenderMode(GL.GL_FEEDBACK);
drawCube(gl, GL.GL_FEEDBACK);
gl.glRenderMode(GL.GL_RENDER);
// Parse feedback buffer and return hidden quads
floatbuffer.get(feedback);
//System.out.println(feedback);
return getEmptyTokens(6, feedback, feedbacklength);
}
/**
* This utility function inform wether a GL_PASS_THROUGH_TOKEN was followed
* by other OpenGL tokens (GL_POLYGON_TOKEN, GL_LINE_TOKEN, etc), or not.
* In the first case, the given token is considered as non empty, in the other
* case, it is considered as empty.
* The expected use of this function is to inform the user wether a polygon
* has been displayed or not in the case Culling was activated.
*
* Note: this function is only intended to work in the case where gl.glFeedbackBuffer
* is called with GL.GL_3D_COLOR as second argument, i.e. vertices are made of
* x, y, z, alpha values and a color. Thus, no texture may be used, and trying
* to parse a GL_BITMAP_TOKEN, GL_DRAW_PIXEL_TOKEN, or GL_COPY_PIXEL_TOKEN
* will throw a RuntimeException.
*
* Note: this function only works with PASS_THROUGH_TOKEN with a
* positive integer value, since this value will be used as an index in
* the boolean array returned by the function
*
* TODO: use a map to associate a float token to a polygon with an id?
*
* @throws a RuntimeException if a parsed token is either GL_BITMAP_TOKEN, GL_DRAW_PIXEL_TOKEN, or GL_COPY_PIXEL_TOKEN.
*/
protected boolean[] getEmptyTokens(int ntokens, float[] buffer, int size){
boolean[] isempty = new boolean[ntokens];
boolean printout = true; // for debugging parsing
int count = size;
float token_type;
float prevtoken_type = Float.NaN;
float passthrough_value = Float.NaN;
float prevpassthrough_value = Float.NaN;
int prevtoken_id;
float EMPTY_TOKEN = 0.0f;
int nEmptyCells = 0;
while(count>0){
token_type = buffer[size-count];
count--;
// Case of a PASS THROUGH token
if (token_type == GL.GL_PASS_THROUGH_TOKEN) {
passthrough_value = buffer[size - count];
count--;
if(printout)
System.out.println("GL.GL_PASS_THROU
没有合适的资源?快使用搜索试试~ 我知道了~
org.jzy3d-0.8.2-demo-eclipse-project
共89个文件
java:70个
jar:7个
png:5个
5星 · 超过95%的资源 需积分: 16 91 下载量 116 浏览量
2011-03-18
22:42:02
上传
评论
收藏 5.57MB ZIP 举报
温馨提示
org.jzy3d-0.8.2-demo-eclipse-project jogl演示例子
资源详情
资源评论
资源推荐
收起资源包目录
org.jzy3d-0.8.2-demo-eclipse-project.zip (89个子文件)
org.jzy3d.demos.0.8
.project 397B
bin
win32
jogl.dll 308KB
jogl_cg.dll 112KB
jogl_awt.dll 20KB
gluegen-rt.dll 20KB
.settings
org.eclipse.jdt.core.prefs 630B
src
org
jzy3d
trials
bezier
BezmeshDemo.java 3KB
Bezmesh.java 6KB
g2d
FrameG2D.java 758B
G2dSurfaceTrial.java 4KB
misc
PolygonOrderingStrategy.java 3KB
Angles.java 1KB
BBox.java 1KB
Concurrency.java 582B
contour
meshes
ContourLinesDemo.java 4KB
demos
scatter
ScatterDemoFromFile.java 2KB
ScatterSphereDemo.java 2KB
ScatterDemo.java 1KB
Scatter4D.java 4KB
MultiColorScatterDemo.java 1KB
interactive
InteractiveScatterDemo.java 4KB
InteractiveSphereDemo.java 3KB
textures
TextureDemo.java 2KB
offscreen
BigSurfaceOffscreenDemo.java 2KB
light
SurfaceLightTrial.java 4KB
AbstractLightDemo.java 2KB
SphereLightDemo.java 3KB
HistogramLightDemo.java 3KB
histogram
barchart
SVGKeyboardSaver.java 2KB
BarChartDemo.java 5KB
DiscreteTickProvider.java 1KB
LabeledMouseSelector.java 3KB
ToggleTextTooltipRenderer.java 903B
CustomLegendRenderer.java 2KB
CustomMouseControl.java 2KB
BarChartBar.java 6KB
AffinityColorGen.java 713B
CustomKeyboardControl.java 3KB
simplebarchart
HistogramDemo.java 1KB
dynamic
AddRemoveElementsDemo.java 2KB
overlay
OverlayDemo.java 3KB
animation
ParametrizedMapper.java 329B
AnimatedSurfaceDemo.java 3KB
radar
RadarDemo.java 790B
contour
ContourPlotsDemo.java 3KB
HeightMapDemo.java 3KB
UserChosenContoursDemo.java 3KB
Contour3DDemo.java 2KB
FilledContoursDemo.java 3KB
IRunnableDemo.java 123B
background
BackgroundDemo.java 2KB
graphs
TextureGraphDemo.java 3KB
PickableGraphDemo.java 3KB
DefaultGraphDemo.java 3KB
swt
SwtDemo.java 257B
IDemo.java 189B
axelayout
AxeRendererDemo.java 2KB
surface
big
chromatogram.png 523KB
SurfaceFactory.java 4KB
ChromatogramDemo.java 2KB
delaunay
BadDelaunayResult.java 2KB
GeneratedDelaunaySurfaceDemo.java 3KB
IncrementalDelaunayDemo.java 4KB
SphericDelaunaySurfaceDemo.java 2KB
BuildSurfaceDemo.java 2KB
ColorWaveDemo.java 2KB
WireSurfaceDemo.java 2KB
MexicanDemo.java 2KB
multiview
MultiplePanelsDemo.java 3KB
SplitPaneDividerDemo.java 8KB
AbstractDemo.java 233B
composites
CompositeDemo.java 1KB
MyCustomCylinder.java 2KB
Launcher.java 5KB
debug
surf
DelaunaySurfaceProblem.java 7KB
axe
DebugAxeSnippet.java 3KB
DebugBox.java 12KB
build
classes
.classpath 881B
data
screenshots
BigSurfaceOffscreenDemo_0.png 107KB
PickableGraphDemo.png 87KB
SphericDelaunaySurfaceDemo.png 81KB
ChromatogramDemo.png 110KB
lib
gluegen-rt.jar 17KB
org.jzy3d-0.8.2.jar 674KB
swt-debug.jar 1.86MB
org.convexhull.jar 26KB
jogl.jar 1.02MB
opencsv-2.1.jar 11KB
swt.jar 1.33MB
共 89 条
- 1
Benzema0909
- 粉丝: 4
- 资源: 91
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- Screenshot_20240427_031602.jpg
- 网页PDF_2024年04月26日 23-46-14_QQ浏览器网页保存_QQ浏览器转格式(6).docx
- 直接插入排序,冒泡排序,直接选择排序.zip
- 在排序2的基础上,再次对快排进行优化,其次增加快排非递归,归并排序,归并排序非递归版.zip
- 实现了7种排序算法.三种复杂度排序.三种nlogn复杂度排序(堆排序,归并排序,快速排序)一种线性复杂度的排序.zip
- 冒泡排序 直接选择排序 直接插入排序 随机快速排序 归并排序 堆排序.zip
- 课设-内部排序算法比较 包括冒泡排序、直接插入排序、简单选择排序、快速排序、希尔排序、归并排序和堆排序.zip
- Python排序算法.zip
- C语言实现直接插入排序、希尔排序、选择排序、冒泡排序、堆排序、快速排序、归并排序、计数排序,并带图详解.zip
- 常用工具集参考用于图像等数据处理
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论9