Ambiera Forum

Discussions, Help and Support.

Ambiera Forum > CopperCube > CopperCube Open discussion
Extended Javascript API and Showcase

2022-07-17 16:19:10

I am reserving this thread to post my developer log for the extended javascript API that I am creating for CopperCube, Hopefully, @niko will add all of them to the engine in future updates.

I will be posting list of stuff that I have already done in extending the API. I am going to post API command and what they will do.

here is the list:-

Sets cursor position to a location on the game screen

Returns the number of bones(joint) of an animated scenenode

returns the name of the bone(joint) of an animated scenenode, joint index is the index of bone it should be less than the AnimatedJointCount

Return the current animation frame playing in the scene by the animated scenenode

ccbRenderToTexture(node, material index, camera, X resolution, Y resolution)
captures the scene from the provided camera's view and will apply it as a texture to the supplied node on the supplied material index. X and Y resolution shares the same buffer as screen, so it will be much better if you use your scrwidth and scrheight for X and Y res.

returns the size of the provided texture (width only).

returns the size of the provided texture (Height only).

ccbSetDopplerEffectParameters(DopplerFactor, DistanceFactor)
Allows you set the DopplerEffect to a different value, default is (1.0,1.0) that Coppercube uses. Works for 3D sounds haven't tested it with 2D sounds.
The value ranges from 1.0 to 10.0. This gives a nice effect for fast-moving objects like cars, missiles, or maybe if you add bullet sounds.

Pause and unpause all the currently playing sounds, depending on the boolean(true/false) provided.

ccbSplitScreen(cam1,x1,y1,x2,y2, cam2,x3,y3,x4,y4)

Allows you to split the screen into 2 camera views, you can specify the viewport coordinates for each camera marked as X and Y, Coordinates help in creating, a vertical split or horizontal split, at least one of them needs to be an active camera. This is not the same as ccbRenderToTarget(). This command needs to be executed in onFrameEvent.

ccbSetAnimationFromSceneNode(node1, node2, animationname)
Allows you to apply animations from node2 to node1, if they share the same skeleton(rig), super useful for people who work with Mixamo, now they don't have to apply animations individually to all of their animated nodes. Just apply all the animations to a single node and use the API command to apply the animation from that node to other nodes that use the same skeleton rig. ( Just added another parameter to it, you can now also define the animation name, that you want to play from another node).

More API will be added to the list.


Here goes the list of upgrades that I will be doing to the inbuild nodes and behaviors.

Added Playback speed attribute to the built-in SoundNode. You can now use it to play a sound faster or slower, It also automatically changes the pitch accordingly. Can be used to change pitch during runtime Like after the player drinks a poison, SlowDown the playback speed of sound, and many more.

Added Pause and Unpause boolean to the default sound node, Allow us to pause and unpause that specific node's sound during runtime.

But there are bugs with these upgrades, so not sure if they will make it to the release version. The only bug is It captures only one single sound node in the scene and doesn't detect attributes for multiple nodes. It can be an issue of the debug deploy, but maybe @Niko knows if it will get fixed automatically when deployed as a release.

More upgrades will be added to the list.

2022-07-17 16:21:57

Here is showcase video of the ccbRenderToTexture API command, it can be used to create realtime reflections and mirrors in Coppercube, It is now possible to have dual camera rendering with this API, you can now easily create portals, mirrors and many more stuff.

Watch the unlisted video here on my YouTube Channel:-

2022-07-17 16:41:32

That's amazing. I am impatiently waiting for the next updates.
I just hope the updates will be done soon.
And I also hope that you consider other platforms besides Windows (such as webgl and Android)
vazahat, will these new apis work for all platforms?

2022-07-18 07:01:34

Hi Just_in_Case

did you find ccb* commands / properties in the ccp source that
are not in the manual ???

if Irrklang library is included in the project source then its integration in the
coppercube editor is kept to a minimum ? No Sound FX,
missing file formats, and not for android/iPhone ?

refering to:
How to compile CopperCube game with C++ source using Microsoft Visual Studio
I saw the mousepointer, great!

at I see many flags but
Coppercube is made near Vienna and the flag of Austria (the country) is still missing.
"Sei gesegnet Land der Erbsen, Land der Bohnen"

2022-07-18 08:18:32

Hi, @douwedabbe, there are a few scripting command that are not in the manual, but No, the above command are created by me in the C++ source code, they don't come with the source. I implemented them in the Javascript API of Coppercube.

You can also extend the sound engine as well, and I am glad that you noticed the mouse pointer, I followed your advice to have a HALO around the cursor in order to highlight the mouse position.

Yeah, the Neophyte website now has translation, support. The flags you see there are on the basis of analytics, More users from those countries use the website, so I have made their language translation available there, flags are based on the language, they don't represent any country. but maybe I will make a dropdown to select all the flags in the future.

2022-07-18 09:34:20

Ah now I see why flags are there,
in the past there where also arabic users of coppercube,
but they have disapeared meanwhile.

Your site is becoming a neccesity for coppercube users!!!

2022-07-18 18:18:52

Thanks, Mate for your kind words :)

2022-07-19 07:29:29

That's super cool 'just_in_case' - I hope Niko adds them to the release version for everyone to use...

I especially like the 'ccbGetCurrentAnimationFrame' command as then I can check when to play correct walking sounds for animated mesh with full body and also when to run the change animation speed (currently resets each time) so wont look so bad when run.

2022-07-19 08:06:51

Thanks, @Robo, I wish the same that these upgrades will make into the released version. Just added the Doppler Effect parameters API and it sound great.

Registered User
2022-07-19 08:44:04

Awesome! This will be great for storyboard animation in cutscenes and for in-game footstep sounds too - rather than using a timer or proximity events to detect when the feet hit the floor.

If "Animation Frame" =22, Play Sound "yippee-ki-yay.wav"

2022-07-19 14:17:20

Thanks, @veganpete, Speaking of sound I have added some upgrades to the sound node, But there are a few bugs with it, but maybe it is due to debug deploy.

I will be adding more features, there is a lot of space for new things to be added in Coppercube now.

Registered User
2022-07-20 02:06:03

Thanks @just_in_case for dedicating your time to help us in the coppercube community.

2022-07-20 08:11:55

We have to get together and push Niko to add all these into the next update (around Christmas every year) as these are excellent additions and very much needed !

Pause sound - awesome, change sound pitch - fantastic, detect animation frame - brilliant, show mirror image - great, doppler effect - super cool!

Cheers 'just_in_case' - the game engine would be so much better if we can get these added in...

Will have to but your shader to support your great work..

2022-07-20 09:19:23

I am thinking of making a video that showcases all the commands and upgrades that I have done, it will also give you guys an idea of how to use the commands, as some of the commands seems a bit complicated like the SplitScreen command.

@Robo Thanks, I too myself want to see them in the release as soon as possible. Maybe, if @Niko has time he can push updates every month with the help of other Community members who are extending the codes.

Regarding shaders, I have been more into understanding the C++ part right now, so you can say I took a break from shaders, but Yeah I do have the PBR Shader lying on my PC, it is complete but is a bit complicated to use, and I want to make it easier for the end user to set it up without much hassle. That is why I put it on hold until I found a way to make it less complicated.

2022-07-20 14:46:37

I think it would be great if you could add another distortion parameter to the ccbRenderToTexture command, and we could do more with it. For example, reflections from a shiny metal or spherical glass surface.
Like this:

Create reply:

Posted by: (you are not logged in)

Enter the missing letter in: "Inter?ational" (you are not logged in)




Possible Codes

Feature Code
Link [url] [/url]
Bold [b]bold text[/b]
Image [img][/img]
Quote [quote]quoted text[/quote]
Code [code]source code[/code]



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