[SOLVED]Blender3D default camera for rendering


#1

Hello everyone I have a camera imported from blender3D, it is a scene with camera, I want that camera is the default when rendering in jmonkey engine … However, although the camera is as a son of the scene is not the main and that the main camera is the one that comes by default in the engine … Does anyone know how to enable the camera?



#2

i can be wrong(i never tried), but i think its possible only via Game code. Probably SDK use same camera, not depend on scene. it might have its reasons.

anyway maybe @Darkchaos will know.

about how to do it ingame, you need change viewPort camera.

i think it will be:

renderManager.setCamera(); method.

same here, i never needed to change camera, i just always move same camera. or once i just created minimap camera for minimap render, nothing more.


#3

Ok,thanks


#4

And as I do to access the son node of the scene that has the camera, take the camera and assign it to the variable, then put it in the function parameter

cam first_camara = 

renderManager.setCamera(first_camara, paused);

#5

not sure if its sentence or question, but indeed, i would try something like this. (also scene might need to be in rootNode(or subnodes) too since renderer would still need render this node)


#6

413/5000

It would be like taking the son node camera and using it to render the scene … It’s something that exists in unity as well as in godot engine. It’s something basic … It seems that this is not built inside the jmonkey engine and it has to be done hand.
Can I ask the creators of jmonkey in GITHUB to add it to the engine?

Excuse me if you do not understand what I write … I use google translator, my native language is Spanish.


#7

could you explain more?


#8

Both in godot engine and in UNITY3D are the cameras …
The cameras are added to the scene and with a simple properties you can activate or deactivate it … It is not necessary to create a camera from scratch since the engine is ready to work with cameras …
The concept of jmonkey is good, however … It would be very practical and convenient to activate cameras of a scene with a simple property.


#9

I mean if I import a scene from blender3D with camera, I just want to activate that camera … It’s something basic that is in all the current game engines.


#10

you should be able, sorry if you misunderstand me.

here is one of old topics(camera is imported so should exist, just not sure if its added properly to renderer):


#11

Of course you told me to use the property renderManager.setCamera ();
but I do not know how to use the camera that is in the scene.
I mean I keep the camera in a variable … How do you do that?
look at the camera is activated.
thanks for your time.


#12

That is CameraControl, a class to make the Camera follow an object (spatial).
In the EDITOR you cannot use that Camera, because you have your Editor Camera Perspective, but in code you can use setCamera() as has been said.

More clever would be to use

camera.setLocalTranslation(new Vector3f(10f, 20f, 5f));

etc and just set the camera there. or even:

camera.setLocalTransform(myCameraFromTheScene.getLocalTransform());

you get that camera from Escene_principal by using .getChild() I guess. The Problem here is that “Camera” probably is no real “Camera” but just a “Node”, because j3o files might not be able to store cameras. But that doesn’t matter, you only want the position as well and can copy it.


#13

if its not real camera, then he have right, he would need create new camera and add into this Node.

anyway once created then cam.setEnabled() can be used to switch them.


#14

Sorry I am completely new in jmonkey engine and I do not know the syntax … How do I access the child node with getchild? What is the syntax?


#15

https://javadoc.jmonkeyengine.org/com/jme3/scene/Node.html#getChild-java.lang.String-
it is recursive, so if you say “Camera”, it will find it no matter how deep it is.

But if you are new, you might look at the tutorials. Maybe “https://wiki.jmonkeyengine.org/tutorials/scenegraph/assets/fallback/index.html” also helps


#16

and because I can not access the child node? a syntax error appears.
I create a spatial object that supposedly is the scene. But if I want to access their children it does not work.


#17

Node != Spatial, Spatial can be Node or Geometry, so you need to cast
((Node)Escena_principal).getChild()
Because if Spatial was a Geometry (“Model”) it cannot have Children, only Nodes can


#18

Well thanks to all of you I have achieved it even though I could not use the camera, at least I was able to use the position of it and with that it is already a great advance … I am going to do tutorials in Spanish about all this that I learned. thanks to everyone.

CODE RESOLVED:

    /** Load a model. Uses model and texture from jme3-test-data library! */ 
    Spatial Escena_principal = assetManager.loadModel("scenes/Escena_principal.j3o");
    rootNode.attachChild(Escena_principal);
    
    Vector3f posicioncamara =((Node)Escena_principal).getChild("Camera").getLocalTranslation();//I access the child node and then its translation, which is a vector 3.    
    Quaternion rotacioncamara =((Node)Escena_principal).getChild("Camera").getLocalRotation();//I access the child node and then its rotation, which is a vector quaternions.
    
    cam.setLocation(posicioncamara);
    cam.setRotation(rotacioncamara);

#19

Tutorial in spanish…You can see the procedure if you do not understand the language.