本文整理汇总了Java中com.jme3.renderer.Camera.setParallelProjection方法的典型用法代码示例。如果您正苦于以下问题:Java Camera.setParallelProjection方法的具体用法?Java Camera.setParallelProjection怎么用?Java Camera.setParallelProjection使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.jme3.renderer.Camera
的用法示例。
在下文中一共展示了Camera.setParallelProjection方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateLightCamera
import com.jme3.renderer.Camera; //导入方法依赖的package包/类
/**
* Updates the camera view direction and position based on the light
*/
public void updateLightCamera(Camera lightCam) {
if (target.getType() == Light.Type.Directional) {
DirectionalLight dl = (DirectionalLight) target;
lightCam.setParallelProjection(true);
lightCam.setLocation(Vector3f.ZERO);
lightCam.lookAtDirection(dl.getDirection(), Vector3f.UNIT_Y);
lightCam.setFrustum(-1, 1, -1, 1, 1, -1);
} else {
PointLight pl = (PointLight) target;
lightCam.setParallelProjection(false);
lightCam.setLocation(pl.getPosition());
// direction will have to be calculated automatically
lightCam.setFrustumPerspective(45, 1, 1, 300);
}
}
示例2: ProjectProcessor
import com.jme3.renderer.Camera; //导入方法依赖的package包/类
public ProjectProcessor(Node root, AssetManager assetManager) {
castCam = new Camera((int)128, (int)128);
castCam.setParallelProjection(true);
castCam.setFrustum(-1, 1, -1, 1, 1, -1);
//Textures\tex\magic\magic.jpg
// Textures\tex\sky\default\east.jpg
tex = assetManager.loadTexture("Textures/tex/magic/magic.jpg");
// tex = assetManager.loadTexture("Textures/tex/sky/default/east.jpg");
// tex = assetManager.loadTexture("Interface/item/face/female5.jpg");
mat = new Material(assetManager, "MatDefs/Projection/Projection.j3md");
QuadXYC quad = new QuadXYC(1,1);
projGeo = new Geometry("ProjGeo", quad);
projGeo.setLocalScale(width, height, 1);
Material debugMat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
debugMat.getAdditionalRenderState().setFaceCullMode(RenderState.FaceCullMode.Off);
projGeo.setMaterial(debugMat);
projGeo.setCullHint(Spatial.CullHint.Always);
root.attachChild(projGeo);
}
示例3: SubScreenBridge
import com.jme3.renderer.Camera; //导入方法依赖的package包/类
public SubScreenBridge(RenderManager rm, int width, int height, Node root) {
this.rm = rm;
this.root = root;
cam = new Camera(width, height);
cam.setParallelProjection(true);
cam.setFrustumPerspective(45, 90, 0, 1);
vp = rm.createPreView("Offscreen View", cam);
if (!ToolKit.isAndroid()) vp.setClearFlags(true, true, true);
else vp.setClearFlags(true, false, false);
FrameBuffer offBuffer = new FrameBuffer(width, height, 1);
tex = new Texture2D(width, height, Image.Format.RGBA8);
tex.setMinFilter(Texture.MinFilter.BilinearNoMipMaps);
tex.setMagFilter(Texture.MagFilter.Bilinear);
if (!ToolKit.isAndroid())
offBuffer.setDepthBuffer(Image.Format.Depth);
offBuffer.setColorTexture(tex);
vp.setOutputFrameBuffer(offBuffer);
setSpatial(root);
vp.attachScene(root);
}
示例4: setData
import com.jme3.renderer.Camera; //导入方法依赖的package包/类
@Override
public void setData(EffectData data) {
super.setData(data);
// TextureConstants.TEX_MAGIC default value for test.
texture = LuoYing.getAssetManager().loadTexture(data.getAsString("texture", AssetConstants.TEXTURE_MAGIC));
color = data.getAsColor("color");
projPos.set(data.getAsVector3f("projPos", projPos));
projDir.set(data.getAsVector3f("projDir", projDir)).normalizeLocal();
projUp.set(data.getAsVector3f("projUp", projUp)).normalizeLocal();
debug = data.getAsBoolean("debug", false);
// ---- 初始化,这些是固定的,不会动态改变
castCam = new Camera(1, 1);
castCam.setParallelProjection(true);
castCam.setFrustum(-1, 1, -1, 1, 1, -1);
projMat = new Material(LuoYing.getAssetManager(), AssetConstants.MATERIAL_PROJECTION);
projMat.setTexture("Texture", texture);
// 注:初始贴图颜色,如果效果包含有ColorAnim,则这个Color设置会受影响。
if (color != null) {
projMat.setColor("Color", color);
}
// 创建单位Box来作为投射计算和检测,这个检查体决定了是否进行投射。当这个
// 检测体在视角范围内以及与被投射体相交时(使用BoundingVolume检测),才进行
// 投射渲染。以避免浪费资源。
// 根据这个方式,有可能投射出来的效果并不在projGeo这个包含围盒内,所以尽量
// 让这个检测体靠近或包围住想要被投射的物体的所在面,这样看起来会比较合理。
projGeo = new Geometry("ProjGeo", new Box(0.5f, 0.5f, 0.5f));
projGeo.setCullHint(Spatial.CullHint.Always);
// 把projMat设置到当前effect中主要是为了使各种AnimColor动画能够控制这个
// 效果的颜色,当effect存在AnimColor的时候,AnimColor会在运行时去查找被
// 控制节点下的所有material,并动态控制这些material的颜色属性。
// 注:材质必须设置到Geometry中去,如果是给节点(Node)添加设置材质,则必须
// "先确认"节点下有子Geometry,否则setMaterial无效。
projGeo.setMaterial(projMat);
animNode.attachChild(projGeo);
}
示例5: PssmShadowRenderer
import com.jme3.renderer.Camera; //导入方法依赖的package包/类
/**
* Create a PSSM Shadow Renderer
* More info on the technique at http://http.developer.nvidia.com/GPUGems3/gpugems3_ch10.html
* @param manager the application asset manager
* @param size the size of the rendered shadowmaps (512,1024,2048, etc...)
* @param nbSplits the number of shadow maps rendered (the more shadow maps the more quality, the less fps).
*/
public PssmShadowRenderer(AssetManager manager, int size, int nbSplits) {
assetManager = manager;
nbSplits = Math.max(Math.min(nbSplits, 4), 1);
this.nbSplits = nbSplits;
shadowFB = new FrameBuffer[nbSplits];
shadowMaps = new Texture2D[nbSplits];
dispPic = new Picture[nbSplits];
lightViewProjectionsMatrices = new Matrix4f[nbSplits];
splits = new ColorRGBA();
splitsArray = new float[nbSplits + 1];
//DO NOT COMMENT THIS (it prevent the OSX incomplete read buffer crash)
dummyTex = new Texture2D(size, size, Format.RGBA8);
preshadowMat = new Material(manager, "Common/MatDefs/Shadow/PreShadow.j3md");
postshadowMat = new Material(manager, "Common/MatDefs/Shadow/PostShadowPSSM.j3md");
for (int i = 0; i < nbSplits; i++) {
lightViewProjectionsMatrices[i] = new Matrix4f();
shadowFB[i] = new FrameBuffer(size, size, 1);
shadowMaps[i] = new Texture2D(size, size, Format.Depth);
shadowFB[i].setDepthTexture(shadowMaps[i]);
//DO NOT COMMENT THIS (it prevent the OSX incomplete read buffer crash)
shadowFB[i].setColorTexture(dummyTex);
postshadowMat.setTexture("ShadowMap" + i, shadowMaps[i]);
//quads for debuging purpose
dispPic[i] = new Picture("Picture" + i);
dispPic[i].setTexture(manager, shadowMaps[i], false);
}
setCompareMode(CompareMode.Hardware);
setFilterMode(FilterMode.Bilinear);
shadowCam = new Camera(size, size);
shadowCam.setParallelProjection(true);
for (int i = 0; i < points.length; i++) {
points[i] = new Vector3f();
}
}