Ambiera ForumDiscussions, Help and Support. |
|
|
|||||
|
I wrote a new extension will hopefully be available soon on the extensions page. behavior_DoOnFunctionCall 1) Attach this behaviour to a given node (or root) 2) Create a list of actions to execute 3) Type a name string into the FunctionName field At runtime, this tiny extension will create a global function object called 'FunctionName'. Calling FunctionName() from anywhere in your document - such as a button or some other user interface - will then execute the list of CCB actions you attached. You can even invoke the actions from another CCB action, using the 'execute javascript' action. This rectifies the lack of an API for most CopperCube actions. It lets you effectively build your own simple API, using the complete range of CopperCube actions, and accessible in the global scope. It is tested and working on WebGL and Flash, and probably the other targets too. |
||||
|
Wow, that's pretty good work there, BMSKiwi. Will this extension let you invoke the actions of an external, non-CopperLicht JavaScript runtime script? I was thinking that maybe a CopperCube made WebGL scene can be further enhanced through an outside 3D physics engine, like for an example this one called "Cannon.js" from here: http://schteppe.github.io/cannon... The reason that I am asking about this, if you look through the Cannon.js website's examples and demos, you will notice that their physics engine seems to really have an emphasis on gravity. And the ability to control, deploy and assign gravity to any node in Coppercube is something that I am really interested in. I don't know if you have already noticed and read my previous thread titled "Is Point of Gravity Posible in Coppercube?", but if you have, I'm sure you will understand why I am asking about all of this. Now, from all of the different Cannon.js demos on their site, there is one in particular Cannon.js demo that I saw that will fit right in with the Point of Gravity feature that I am hoping for Coppercube to have, and it is this one: http://schteppe.github.io/cannon... I don't know if your new behavior_DoOnFunctionCall plugin will be able to help me on this little challenge of mine, that's why I will leave this matter to the experts like you and hope for the best. |
||||
|
Hmmm, this not so easy Amigo. Integrating cannon.js into CCB is something else altogether. This extension won't help. CCB5 has a physics engine built in, bullet.js, which presumably supports gravity but is not available in WebGL for performance reasons. (I think this is a mistake) Your best move is to petition Niko to provide physics in the WebGl and Flash targets. |
||||
|
@BMSKiwi: Yea, I had a feeling about that. You see, I learn something new everyday. Thanks for your sincere and informative response. Well, Niko did say me if (quote) "we get a few more people wanting this feature, I'll implement this in a future version of CopperCube", so if you like my idea about the "Point of Gravity" feature, then by all means please join the small, but growing list of us who want this feature. |
||||
|
Nice addition. Will be added to the website soon. About bullet.js: That one doesn't support collisions between bodies and 'real' 3d geometry, so it won't work, unfortunately. |
||||
|
Update: It's uploaded now to the extension website. |
||||
|
@BMSKiwi, Thanks for this!! I think this may solve my problem in terms of calling SCORM functions (E-learning standard in JS) form CC5. I'm still not quite sure of the implementation though. This is basically how SCORM works, a Student clicks a hyperlink for a SCORM conformant lesson there's a SCORMAPI.js file already loaded within the html file in the API file there are two of the most basic calls to make a Flash or HTML-based lesson SCORM conformant/compliant - LMSinitialize() and before unloading the CC file would pass LMSfinish() to the SCORMAPI.js file An example of how this might work with this behavior would be MOST helpful, and you can find out more about SCORM 1.2 calls by getting the following PDF file http://scorm.com/wp-content/asse... Thanks!! and thanks for all the great work at providing this behavior, I hope it really helps solve this issue for me. |
||||
|
I'm reading these old threads and wonder if there is a straight forward solution for physics in CCB. Is cannon.js still the way to go in 2022/23; or are there any other alternatives? Is there an more indepth "How-to" available on doing it with the neat tool from @BMSKiwi "behavior_DoOnFunctionCall"? May I ask if anyone got a simple working example of any physics in CCB with WebGL output? I've seen the cannoncar example; i really like it. But i don't really see how I can use cannon in CCB; for example with chain-like-physics. Another example uses Copperlicht; but I have no clue how to implement it into CCB - never thought about it until now. I think @VP shared such a CCB file back in the days; it's just not online anymore. Thanks @all |
||||
|
@niko: I just found out that there is an "ammo.js" ported from bullet.js - do you think this can be just swapped and it will work? https://github.com/kripken/ammo.... wrote:
Nice addition. Will be added to the website soon. About bullet.js: That one doesn't support collisions between bodies and 'real' 3d geometry, so it won't work, unfortunately. |
||||
|
@Chris Hi, You can find a sort of working cannon js example here: https://youtu.be/GrxBSINym_8 The idea is that you use cannon js for physics calculation, and only use ccb for the graphics representation. |
||||
|
@okeoke - thx! |
||||
|
Do you know if ccb uses "mesh.useQuaternion = true;" like three.js does? Couldn't find a lot of infos on it... https://github.com/schteppe/cann... |
||||
|
Nope, I believe, ccb doesn't use quaternion coordinates at all. I used a custom function to recalculate those to euler: const radsToDegrees = 180 / Math.PI; Also Z axis direction in coppercube and cannons js are pointed to the opposite sides. So when translating it from cannon you should change z to -z. Same with rotation, but you should do w = -w and z = -z. There is also a built in cannon method in Quaternion class to do the translation to euler, but it didn't work for me: https://schteppe.github.io/cannon.js/docs/classes/Quaternion.html It's called toEuler - I can't pass the anchor link here. |
||||
|
@okeoke thanks, took me some time to wrap my head around it :) @all Does someone know how to replace bullet.js from CCB with ammo.js? I'd like to get (kinda need) bullets with physics and physics within WebGL. So far the samples rock (cannon.js); but I'm having a little hard time understanding the basics of how to implement it. The car is awesome; but it's not suitable for my gameplay. Does anyone got a simple example running which uses some "scale" physics; like the kids used to play back in the old days in the park; bouncing up and down each one another? Or some kinda carousel? |
|