Ambiera Forum

Discussions, Help and Support.

Ambiera Forum > CopperLicht
Cameras and Viewports

smithandweb
Registered User
Quote
2012-05-15 20:53:13

Hi there,

First time using CopperCube and CL, so far enjoying every minute of it! I'm building an app to showcase boat models in a variety of ways. I may be going about this the wrong way, just looking for a little direction.

My scene has 5 cameras: Top, Left, Right, Front, and Perspective. Pretty much the same as viewports. I'm using <li> elements with data attributes to pass camera names. ex:

<li data-view="Top">Top</li>

Any hints on how I could change cameras in the scene when the <li> element is clicked?

Using jQuery to get data attribute:
$(document).ready(function(){

//Get the view from the data-view attribute after click
$("li.view").click(function(){
var $view = $(this).attr("data-view");

//trickery with CL3D.Scene
});


Disclaimer: I'm a web nerd, not an engine nerd.

Thanks!


niko
Moderator
Quote
2012-05-16 06:31:17

I don't know much about jquery (not a web nerd *g*), but what you probably simply want is switching the active camera to another camera in your scene, correct? It should work fairly easily:

You usually get the object of your engine using something like this:
var engine = new CL3D.CopperLicht('yourCanvasID'); 

or if you started using the editor, this:
var engine = startCopperLichtFromFile('yourCanvasID', 'someFile.ccbjs');


Once you have this and you are sure your scene is loaded and running (which I guess you are in the click handler of your list), you can switch to another camera using this:

var scene = engine.getScene();
var cam = scene.getSceneNodeFromName('theNameOfYourCamera');
if (cam != null)
scene.setActiveCamera(cam);


That's it. :)


smithandweb
Registered User
Quote
2012-05-16 17:33:44

Hey niko,

Thanks!

I am using the editor to build my scenes because these are pretty high polycount models imported from 3DS as COLLADA.

One thing I forgot to mention in my last post is that the file is already loaded and running in a canvas with an ID of "model"

Can I use this method to manipulate the render instantly without reloading and redrawing?


niko
Moderator
Quote
2012-05-17 06:26:35

Yes, sure. Everything is in realtime. Just replace 'yourCanvasID' in my code above with 'model'.


smithandweb
Registered User
Quote
2012-05-18 20:58:49

Hey again niko,

I can't seem to get a value for scene from engine.

I've looked at the array in Firebug and CurrentScene = -1 and the Scenes array is empty.

In the Editor I have two Scenes, Solid and Solid-Two, both with a folder node.

I feel like I'm not doing something that should be obvious...


niko
Moderator
Quote
2012-05-19 10:49:21

You probably looked when the file wasn't loaded yet. Do something like that (as shown in most CopperLicht tutorials):

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

// your code here
}


(note no spaces between On Loading Complete :) )


smithandweb
Registered User
Quote
2012-05-22 16:49:56

Got it, thanks niko!


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