ambiera logo

Ambiera Forum

Discussions, Help and Support.

folder icon Ambiera Forum > CopperLicht
forum topic indicator change camera 1st/3rd person
person icon
jjoe64
Registered User
Quote
2012-10-19 11:49:35

Hi

I use a scene (from copperCube examples) with a 3rd-person camera.

Now I want to change the camera from 3rd to 1st camera while playing by pressing the 'G' key.

I've create a new camera with the collection detection (from tutorial).

There are two problems:
1. When I activate the 1st person camera, the person model still moves.
2. The active 1st-person camera does not move correctly. It stucks and has no gravity ... very buggy

My code is simple:


var engine = startCopperLichtFromFile('3darea', 'copperlichtdata/szene.ccbjs');
var camera3rd = null;
var camera1st = null;
var scene = null;

// this is called when loading the 3d scene has finished
// for some reason in the forum I cannot use the text "O n L o a d ingComplete"
engine.ingComplete = function()
{
scene = engine.getScene();

if (scene)
{
// find the cube scene node
camera3rd = scene.getActiveCamera();
camera1st = new CL3D.CameraSceneNode();
scene.getRootSceneNode().addChild(camera1st);

var animatorFps = new CL3D.AnimatorCameraFPS(camera1st, engine);
animatorFps.setLookByMouseDown(false);
camera1st.addAnimator(animatorFps);

// add the collision response animator to collide against walls

var colanimator = new CL3D.AnimatorCollisionResponse(
new CL3D.Vect3d(10,20,10), // size of the player ellipsoid
new CL3D.Vect3d(0,-10,0), // gravity direction
new CL3D.Vect3d(0,20,0), // position of the eye in the ellipsoid
scene.getCollisionGeometry());

camera1st.addAnimator(colanimator);


// also, force the 3d engine to update the scene every frame
scene.setRedrawMode(CL3D.Scene.REDRAW_EVERY_FRAME);

}
}

// for some reason in the forum I cannot use the text "o n k e y d o w n"
document. = function(event)
{
var key = String.fromCharCode(event.keyCode);
if (key == 'G') {
camera1st.Pos = camera3rd.Pos.clone();
scene.setActiveCamera(camera1st);
}

engine.handleKeyDown(event);
};



What's wrong?

person icon
jjoe64
Registered User
Quote
2012-10-19 15:13:33

the first problem was just because the model was bound to the users keyboard.

the second problem is strange. But now I created both cameras with copperCube and it works....

-closed-


Create reply:










 

  

Possible Codes


Feature Code
Link [url] www.example.com [/url]
Bold [b]bold text[/b]
Image [img]http://www.example.com/image.jpg[/img]
Quote [quote]quoted text[/quote]
Code [code]source code[/code]

Emoticons


icon_holyicon_cryicon_devilicon_lookicon_grinicon_kissicon_monkeyicon_hmpf
icon_sadicon_happyicon_smileicon_uhicon_blink   






Copyright© Ambiera e.U. all rights reserved.
Contact | Imprint | Products | Privacy Policy | Terms and Conditions |