Revision 209ea1c7
Added by Leszek Koltunski about 4 years ago
src/main/java/org/distorted/library/main/DistortedNode.java | ||
---|---|---|
39 | 39 |
*/ |
40 | 40 |
public class DistortedNode implements InternalChildrenList.Parent |
41 | 41 |
{ |
42 |
private static final int DEFAULT_FBO_SIZE = 100; |
|
43 |
|
|
42 | 44 |
private MeshBase mMesh; |
43 | 45 |
private DistortedEffects mEffects; |
44 | 46 |
private InternalSurface mSurface; |
... | ... | |
49 | 51 |
|
50 | 52 |
private int mFboW, mFboH, mFboDepthStencil; |
51 | 53 |
private boolean mRenderWayOIT; |
54 |
private float mFOV, mNear; |
|
52 | 55 |
|
53 | 56 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
54 | 57 |
|
... | ... | |
257 | 260 |
} |
258 | 261 |
else |
259 | 262 |
{ |
260 |
width = 100;
|
|
261 |
height= 100;
|
|
263 |
width = DEFAULT_FBO_SIZE;
|
|
264 |
height= DEFAULT_FBO_SIZE;
|
|
262 | 265 |
} |
263 | 266 |
} |
264 | 267 |
|
265 |
return new DistortedFramebuffer(1,mFboDepthStencil, InternalSurface.TYPE_TREE, width, height); |
|
268 |
DistortedFramebuffer fbo = new DistortedFramebuffer(1,mFboDepthStencil, InternalSurface.TYPE_TREE, width, height); |
|
269 |
|
|
270 |
if( mFOV!=InternalOutputSurface.DEFAULT_FOV || mNear!=InternalOutputSurface.DEFAULT_NEAR ) |
|
271 |
{ |
|
272 |
fbo.setProjection(mFOV,mNear); |
|
273 |
} |
|
274 |
|
|
275 |
return fbo; |
|
266 | 276 |
} |
267 | 277 |
|
268 | 278 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
292 | 302 |
mParent = null; |
293 | 303 |
mRenderWayOIT = false; |
294 | 304 |
|
305 |
mFOV = InternalOutputSurface.DEFAULT_FOV; |
|
306 |
mNear= InternalOutputSurface.DEFAULT_NEAR; |
|
307 |
|
|
295 | 308 |
mFboW = 0; // i.e. take this from |
296 | 309 |
mFboH = 0; // mEffects's stretch{X,Y} |
297 | 310 |
mFboDepthStencil = DistortedFramebuffer.DEPTH_NO_STENCIL; |
... | ... | |
317 | 330 |
mParent = null; |
318 | 331 |
mRenderWayOIT = false; |
319 | 332 |
|
333 |
mFOV = InternalOutputSurface.DEFAULT_FOV; |
|
334 |
mNear= InternalOutputSurface.DEFAULT_NEAR; |
|
335 |
|
|
320 | 336 |
mFboW = node.mFboW; |
321 | 337 |
mFboH = node.mFboH; |
322 | 338 |
mFboDepthStencil = node.mFboDepthStencil; |
... | ... | |
523 | 539 |
} |
524 | 540 |
} |
525 | 541 |
|
542 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
543 |
/** |
|
544 |
* Set Projection Matrix for the Framebuffer contained in this Node. |
|
545 |
* <p> |
|
546 |
* If this Node is a Leaf and has no Framebuffer in it, this call does nothing. |
|
547 |
* |
|
548 |
* @param fov Vertical 'field of view' of the Projection frustrum (in degrees). |
|
549 |
* Valid values: 0<=fov<180. FOV==0 means 'parallel projection'. |
|
550 |
* @param near The Near plane. |
|
551 |
*/ |
|
552 |
public void setProjection(float fov, float near) |
|
553 |
{ |
|
554 |
if( fov < 180.0f && fov >=0.0f ) |
|
555 |
{ |
|
556 |
mFOV = fov; |
|
557 |
} |
|
558 |
|
|
559 |
if( near< 1.0f && near> 0.0f ) |
|
560 |
{ |
|
561 |
mNear= near; |
|
562 |
} |
|
563 |
else if( near<=0.0f ) |
|
564 |
{ |
|
565 |
mNear = 0.01f; |
|
566 |
} |
|
567 |
else if( near>=1.0f ) |
|
568 |
{ |
|
569 |
mNear=0.99f; |
|
570 |
} |
|
571 |
|
|
572 |
if( mData.mFBO!=null ) |
|
573 |
{ |
|
574 |
mData.mFBO.setProjection(mFOV,mNear); |
|
575 |
} |
|
576 |
} |
|
577 |
|
|
526 | 578 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
527 | 579 |
/** |
528 | 580 |
* Enables/disables DEPTH and STENCIL buffers in the Framebuffer object that we render this Node to. |
Also available in: Unified diff
1. library: new API DistortedNode.setProjection()
2. cube: adjustments for Pyraminx.