Ambiera Forum

Discussions, Help and Support.

Ambiera Forum > CopperLicht
Change camera-mode at runtime

kingkohle
Registered User
Quote
2011-06-01 14:28:57

Hi.. I try to switch between the click&drag-camera and the fake FPS-camera. Here my function:
var engine = startCopperLichtFromFile('3darea', 'copperlichtdata/Check_ControlFF.ccbjs');
var scene = null;

engine.On**Loading**Complete = function()
{
scene = engine.getScene();
scene.setRedrawMode(CL3D.Scene.REDRAW_EVERY_FRAME);
}

changecamanim1 = function()
{
var cam = engine.getScene().getActiveCamera();
cam.getAnimatorOfType('camerafps').setLookByMouseDown = false;
}
changecamanim1();

All I get is an "syntax-error" in /copperlichtdata/myfile.ccbjs
Any ideas? Thx


niko
Moderator
Quote
2011-06-02 06:36:48

I think you get that 'syntax error' always when loading a .ccbjs file, it simply a wrong error message you can ignore, and it shouldn't have anything to do with your problem. Are you sure when the 'changecamanim1' function is called that the FPS camera is currently the active one?


KK
Guest
Quote
2011-06-03 15:54:56

There is only one camera in the scene - means the cam is active. I try to turn the existing (click&drag-) camera into a FPS-controlled one.

I figured a way to do this:
var engine = startCopperLichtFromFile('3darea', 'copperlichtdata/Check_ControlFF.ccbjs');

engine.On***Loading***Complete = function()
{
var scene = engine.getScene();
if (scene)
{

changecamanim1 = function()
{
var cam = scene.getSceneNodeFromName('Camera1');
var animator = new CL3D.AnimatorCameraFPS(cam, engine);
cam.addAnimator(animator);
animator.setLookByMouseDown = false;
}
}
}
It is working to change the camera from FPS-style to non-FPS-style - but not the other way around.
Is this a bug?


niko
Moderator
Quote
2011-06-04 07:31:17

It's probably that the other animator still is there. Use the removeAnimator() function to erase the old one from the node.


KK
Guest
Quote
2011-06-06 19:22:30

Hi again.

I figured out that the above code also works without the line "animator.setLookByMouseDown = true;"... Means adding an any animator is causing the cam to lose the FPS-function.. I tried to add several animators - some of them dont seem to work on WebGL. Especially "setLookByMouseDown"-function dont work for me..

Im getting no errors. It just don´t work for me :( all I could manage is to make an FPS-cam to a non-FPS one. I couldn´t reverse it anyhow.

Any solutions?

Ps: Using removeAnimator() is working but not helping me in this case..


KK
Guest
Quote
2011-06-07 18:05:05

Anyone?


niko
Moderator
Quote
2011-06-08 05:46:48

It probably works because you added a second animator which does all the work after the first one has been executed. You really need to remove the old animators and set a new one. Alternatively, if you somehow are not able to do this, you could also switch to another camera with that behavior already set.


KK
Guest
Quote
2011-06-09 18:41:38

Having 2 cameras brings up one problem. When switched between them their position in space is not the same anymore (when moved around). I tried to set their position relativ to each other - but it did not work.

Anyway, I got it working now! The problem was that it did not work when there is no cam set up in CC. Adding the lines "scene.getRootSceneNode().addChild(cam);
scene.setActiveCamera(cam);" did the trick...

For any others who are wondering about this: From here on you are better off using "cam.getAnimatorOfType('camerafps').setLookByMouseDown(true);" instead of removing and re-appling several animators.

Thanks mucho grande, Niko


KK
Guest
Quote
2011-06-09 19:28:01

The cam in CC has to be -contrary to expectations- set as active, though..


schizzomarino
Registered User
Quote
2013-11-28 21:31:22

EDIT:

Never mind this problem, I am not sure what had happened, but I sent the copperlicht file to the server again, and now everything works fine... (I resent it because I was finding all sorts of problems and I was on my last leg, lol)

I leave my initial remarks just in case someone else has the same problem in the future... solution: resend your copperlicht.js file to the server...






Well, I have the same problem, and following your advice has not fixed it..
I have two animators too:

AnimatorCameraFPS
AnimatorCollisionResponse

For the AnimatorCameraFPS I need to switch from setLookByMouseDown(false) to setLookByMouseDown(true) and as for you it only works if I set it to false (if I set it to true I simply can't look around anymore). I have tried these two ways of doing it:
I first declare the animator and then add it to the camera (once the scene is loaded, in my main xhtml file).
FPSAnim = new CL3D.AnimatorCameraFPS(CameraMain, engine);
FPSAnim.setLookByMouseDown(false);
CameraMain.addAnimator(FPSAnim);

and then within my JS file I tried this:
FPSAnim.setLookByMouseDown(true);

and this:
CameraMain.getAnimatorOfType('camerafps').setLookByMouseDown(true);


But neither work

Actually, and this is the strange thing, it works perfectly on my computer but as soon as I put it online it doesn't anymore...

I know this is an old chat, but as the problem is exactly the same I have put my comment here.

Any solution to this?


Create reply:


Posted by: (you are not logged in)


Enter the missing letter in: "Interna?ional" (you are not logged in)


Text:

 

  

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


   






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