Ambiera Forum

Discussions, Help and Support.

Ambiera Forum > CopperCube > Feature requests and bug reports
Externally load specific mesh

kingkohle
Registered User
Quote
2010-11-26 11:42:54

Hi pals..

This one might be tough: I try to externally load a specific mesh. I am not sure how to achieve this. The meshes will have a unique name. Is it possible to call these by name (via a button)? Maybe with variables?

Maybe with the button-action "run JavaScript"?! And then variables? Like: if name "ABC" (button) equal to "ABC" (external file) then load the mesh.. Some ideas by anyone?


Thx
KK


niko
Moderator
Quote
2010-11-26 14:38:14

I guess you are using the WebGL target, right? You can do it this way (involves some JavaScript programming, though and is not that easy for non-programmers): Create a second coppercube file which includes your 3d model. In your main scene, you need to add some javascript code (preferably don't write it in the CopperCube editor, but in a text editor of your choice and include it then into your .html file).
Take a look at the CopperLicht (http://www.ambiera.com/copperlic...) API, this is all you can use to manipulate your scenes with. In the documentation, you'll find that CL3D.CopperLicht includes a method for loading a scene (load()). With that, you should be able to load the external second scene, and when finished, grab that scene node with the mesh you need and copy or move it to your scene.

You can also of course trigger your loading code by an 'Execute javascript code' action from the editor, for example.


kingkohle
Registered User
Quote
2010-11-26 15:56:26

Yes, I am onto WebGL. Thanks for the hint. I will give this a try. This overview is all I need as I can rely on some coder-pals to work it out in detail. But of course I also would like to figure this out for myself first.

Thanks


kingkohle
Registered User
Quote
2010-11-30 13:29:06

Hi niko,

I arranged a button with the action "when clicked do something" and then "execute JavaScibt" .This button should externally load a mesh. The JS looks like this:


var engine = new CL3D.CopperLicht('3darea');
{
engine.load('mesh.ccbjs');
}


After the button is pressed it attempts to load the file. But then it constantly switches between the message: "loading" and "Could not open file mesh.ccbjs"


I suppose it is not much missing of a working script. Can you please tell me how to get this done.


Thx heaps^^
KK


niko
Moderator
Quote
2010-11-30 16:40:23

Probably it simply wasn't able to open the file, as it wrote. Are you sure the filename is correct, and the path as well? You could also try with the absolute path, just to be sure (like http://localhost/yourwebsiterpath/mesh.ccbjs)


kingkohle
Registered User
Quote
2010-11-30 17:32:35

Aww.. You were right. I forgot to spell it like: "copperlichtdata/...ccbjs" (I thought the index wound be in there as well *stupidme*)

So, it is working now. Not very convenient, though. Sometimes you have to press the button several times.. Sometimes it struggles to load its texture. Therefore I am still trying to set the "ingComplete" or anything that keeps it together.. Is there a set of commands forcing the mesh be only displayed when everthing is loaded *sortofthing*

Thx
KK


niko
Moderator
Quote
2010-11-30 17:36:30

Well, there is a method for checking how much textures there are still to load and how many have been loaded already. With this, you should be able to achieve this.
Use the texture manager for this (CL3D.TextureManager) which you can get using engine.getTextureManager() (in CL3D.CopperLicht). It has the method getCountOfTexturesToLoad().


kingkohle
Registered User
Quote
2010-11-30 18:07:53

Cheers.. I will dig into it.

One more question for today: when setting up to change a scene via the CopperLicht-engine the command would be called "gotoScene()", right?!

All I want to do is to change the scene via this JS for now. So my button in CC has the following action "when clicked do something" and then "execute JavaScript":

------------
var engine = new CL3D.CopperLicht('3darea');

{
gotoScene("Scene2");
}
------------

What is missing? It is not working for me doing it this way.. Anyone?!

**Ps: I know there is a function in CC for that. There is more script coming after - so it has to be this way^^


Thx
KK


niko
Moderator
Quote
2010-11-30 18:14:07

That function takes a scene instance as parameter, you are probably looking for gotoSceneByName("yourSceneName")?


kingkohle
Registered User
Quote
2010-12-03 16:57:11

This one might work as well. I try to arrange to go to a scene (or get a reference) AND load a specific mesh in that scene. So it has to be in one executed JS after clicking the button.

So "gotoScenebyName" should also work once "load(mesh)" is followed straight away, I asume?! ^^

Thx
KopperKube^^


bob
Guest
Quote
2010-12-03 23:05:45

that will be cool to load a external 3d object from disk or from a url directly via the action editor, idem for textures...i think that will be a good idea, but it's just my opinion...


adamwest
Registered User
Quote
2010-12-04 22:17:30

Yeah this would be so cool to have that as an action implemented + you could write a coppercube-converter. Converting every format into ccbjs... Or set the ability to load most basic formats. Ether way that would be awesome!!


niko
Moderator
Quote
2010-12-05 16:33:25


So "gotoScenebyName" should also work once "load(mesh)" is followed straight away, I asume?! ^^


Hm, you mean going to a scene which is loaded in a mesh, and not waiting for the scene to be loaded? That won't work, sorry. You need at least some time to wait before you can be sure that the scene is loaded, because it's over the internet after all.


kingkohle
Registered User
Quote
2010-12-06 13:08:28

Hi,

I mean more like this: Remember there is a button with the action "when clicked do something". This should execute the following:

when clicked > gotoScenebyName > when switching the scene has completed >then load a specific mesh in that scene > get sure it loads everything properly (like: engine.ingComplete or else)

So when executed it should go to another scene and load a mesh in that switched scene - all done over one button. Isn't that possible?!

I tried it with that script, but it isn't working:

_______________

var engine = new CL3D.CopperLicht('3darea');

{
gotoSceneByName("OnlyThePlayer");

engine.load('copperlichtdata/mesh1.ccbjs');

engine.ingComplete = function()
{
alert("loading completed")
};

}
_______________


I think my code in general is crap. But should it work somehow like this? Maybe with a line inserted to just load the mesh once the scene has changed.. Please help


Thx
KK


niko
Moderator
Quote
2010-12-06 16:31:10

From looking at your code, it looks fine. But I take a closer look at this and see if I can find your problem. This could take one or two days though.
Hint: Maybe you can find your problem yourself by simply taking a look into the JavaScript console, if there is any error. This is often the case.


Create reply:


Posted by: (you are not logged in)


Enter the missing letter in: "Internation?l" (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