Hello guys,
I could go ahead with my work (fixed camera engine with pre-rendered hd and pixelation effect).
I don’t know why but I have a strange behavior without any apparent reason.
In pratical…
I load the blender scene (.blend file directly,because with ogre scene i will loose some camera data).
Suppose this scene is made by 4 rooms, so there are
- base building
- 4 cameras (named: Camera_REGION_NAME)
- 4 region (named: Region_REGION_NAME)
So for example there’s the Camera/Region_Dining_Room, Camera/Region_Bathroom etc… so a camera for each area of the scene.
On the simple update of my scene, I will calculate the collisions with te floor, and when the Ray touch a floor region different by the previous, there’s a check if is there a relative blender camera for this region, and a picture (named Render_REGION_NAME.png) to put as a background (scene is invisibile, only depth is wrote), jme3 camera is updated with last blender camera used.
Here some pieces of code of simpleUpdate
[java]
if (!lastRegionName.equals(currentRegionName)) {
//System.out.println("BEFORE Camera changed, \nFRN: " + lastRegionName);
lastRegionName = currentRegionName;
//System.out.println("AFTER Camera changed, \nFRN: " + currentRegionName + "\nLRN: " + lastRegionName);
try {
cameraNode = prepareHDBackground(currentRegionName, sceneNode, cameraNode, tpf);
viewPort.getQueue().setGeometryComparator(RenderQueue.Bucket.Opaque, new PreHDComparator(“Background”));
} catch (Exception e) {
System.out.println("EXCP: " + e.toString());
// Nothing to do
}
//objNode.setLocalTranslation(cam.getLocation());
}
cam.copyFrom(cameraNode.getCamera());
[/java]
and the method for update background picture and camera:
[java]
public CameraNode prepareHDBackground(String name, Node sceneNode, CameraNode camNode, float tpf) {
if (camNode != null) {
camNode.detachAllChildren();
Quaternion rot3 = camNode.getLocalRotation();
camNode.setLocalRotation(new Quaternion(rot3.getZ(), -rot3.getW(), -rot3.getX(), rot3.getY()));
}
camNode = (CameraNode) sceneNode.getChild("Camera_" + name);
Quaternion rot3 = camNode.getLocalRotation();
camNode.setLocalRotation(new Quaternion(-rot3.getZ(), rot3.getW(), rot3.getX(), -rot3.getY()));
Quad q = new Quad(1, 1);
Geometry background = new Geometry("Background", q);
Material mat = new Material(assetManager, "MatDefs/Background.j3md");
mat.setTexture("Texture", (Texture2D) getAssetManager().loadTexture("Textures/Renders/" + name + ".png"));
mat.getAdditionalRenderState().setDepthTest(false);
background.setMaterial(mat);
background.setQueueBucket(RenderQueue.Bucket.Opaque);
System.out.println("Textures/Renders/" + name + ".png");
rootNode.attachChild(background);
return camNode;
}
[/java]
Ok until here is ok, but in some cases (I don’t know why) the background is not shown, except if i keep the relative camera in a certain range position… this has not sense… for example in this screen I will try to explain
This is a screen of a bedroom from blender.
The floor is the region, and there’s a camera, in pratical when the player walks on the bedroom floor, the bedroom camera is activated, and a bacground picture (Bedroom.png) is shown as background. Normally is working, but if i try to move the camera from position 1 to position 2 for example (but is sufficient even in the center of the room or just move it a bit on the right), I will see only the player and black background (because scene color is not wrote, only depth). This event for other cameras and only for some camera positions. I tried to debug, it seems no error, is like background is loaded without any problem, but it seems like background is not loaded… I don’t know how to di for understand this problem. Do you know whether there are some bugs with blender cameras, or if (I hope) there’s a specific reason for this behavior?
Thank you very much!