Ambiera Forum

Discussions, Help and Support.

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

2023-03-06 06:44:54

Continuation of previous comment

Above all the ccbPlaySound() code will play the sound file, as you can see it is not necessarily need to provide Properties or soundeffects parameters. They are optional, but if you have specified a property like "radius" then it is required to put a value for it.
The sound will play in the default state if there are wrong property types or provided parameters are not correct. But the sound will have the default value. Though it will throw an error in the debug console if there is anything wrong with the sound file type that you are loading, or if you have wrong property parameters and all.

I might not be able to write all the details how this API works and all, but yeah that's a brief intro to the new Sound Management API, that I have created.

By default all the sounds are non-looping, you probably need to use initiate or update them with the "Looping" property type.

Also, once you have a sound initialized, that means if it is playing, and then you execute the code on that sound again, then it will update the properties of that sound instead of playing another instance of it.

That is why we have a second parameter "Repetitive" if it is set to true, then it will trigger a new sound every time you execute that code. Can be helpful when you are playing a sound on keypress, it prevents the triggering of sound and will only trigger it once if the parameter is set to false.

I think this is all I can wrap up for this API, hope this will be added in the next update, and we can have a better sound system in CopperCube.

Registered User
2023-03-06 20:26:55

Thank you JustinCase for all that you've done. Really like the new API.

2023-03-07 10:19:33

Thanks for your feedback @forloopsadain, Hope I will be able to add more features to the engine. But I don't know what else should I try to fiddle with, it is hard to prioritize requests and other stuff based on my current skills. I am slowly learning the core of the engine and doing stuff that I think I can improve, I do want to improve a lot of other stuff, but my skills are not enough to get succeed or I am just not confident enough.

Hope to get more ideas or features that are necessary to improve. Most of the feature requests we have are about new renderers but that will be not easy to implement for a neophyte like me.

I can't really test out custom animators and scene nodes, without having the access to the editor part. As the debugging process will be a lot hard. So, I am just relying on custom APIs that I can create and test out.

For example, I desperately wanted to have an "ENUM" property type and a sound property type for the extensions. But can't really test them out without having the editor code.

Still, I hope to bring more decent changes and bug fixes.

2023-03-09 14:57:27

Added some new methods to the vector3d class:-

Returns the dot product of two vectors.
Returns the cross product of two vectors.
Creates a new vector3d object that is an exact copy of the original vector3d object but with a different instance.
Returns the angle between two vectors from vector1 to vector2.
Returns a new vector that is made from the largest components of two vectors.
Returns a new vector that is made from the smallest components of two vectors.
Returns the distance between vector1 and vector2.
vector1.lerp(vector2, t)
Linearly interpolates between two vectors.
vector1.slerp(vector2, t)
Spherically interpolates between two vectors.
Calculate a position between the points specified by a current vector(vector1) and target vector(vector2), moving no farther than the distance specified by maxDistanceDelta.
Multiply a vector by a scaler value.
Divide a vector by a scaler value.
Multiplies two vectors component-wise.
Reflects a vector(vector1) off the plane defined by a normal(vector2).
Returns the length of the vector, same as getLength() but added it as well so that users from other game engines won't have to worry.
Returns the squared length of the vector.
Returns a copy of vector with its magnitude clamped to maxLength.

shorthand functions for vectors:-

Shorthand for writing vector3d(0, 0, -1).
Shorthand for writing vector3d(0, -1, 0).
Shorthand for writing vector3d(0, 0, 1).
Shorthand for writing vector3d(-1, 0, 0).
Shorthand for writing vector3d(1, 0, 0).
Shorthand for writing vector3d(0, 1, 0).
Shorthand for writing vector3d(1, 1, 1).
Shorthand for writing vector3d(0, 0, 0).
Shorthand for writing vector3d(-Infinity, -Infinity, -Infinity).
Shorthand for writing vector3d(Infinity, Infinity, Infinity).

More vector3d methods almost all similar to Unity's vector3d class are planned to be added. These vector methods are super helpful and prevent us from writing them again and again.
More custom JS methods might get added like setInterval and setTimeout.

2023-03-11 13:59:35

Updated most of the API Commands with a single change

Updated almost all the codes that use SceneNode as an input. Now you can directly feed the node name instead of a reference or pointer to that node. Also the old method can still be used.

This reduces the use of the ccbGetSceneNodeFromName() command. I personally found this command to be a bit time-consuming when dealing with so many objects in our game, and if you are scripting methods for multiple objects, we have to call the command each time for every individual node.

Now we can simply skip that part and can feed the SceneNode Name directly as a string to almost every command.

For example previously to get the property of a scene node we use this command.

 var s = ccbGetSceneNodeFromName("cubeMesh1");
var position = ccbGetSceneNodeProperty(s,"Position");

With this new addition/update, we can also get a position like this.

 var position = ccbGetSceneNodeProperty("cubeMesh1","Position");

This reduces the line of codes used and can speed up scripting for someone with a slow typing speed like me.

Hope others who deal with scripting find this addition/update useful as well.

2023-03-14 15:00:37

Added another useful API command, that deals with Collision during runtime. We can now disable or enable Collision during runtime with this command.

Now works with Physics Simulations as well.

Talking of Collision, I also tried fixing the same when making the scene node invisible and visible and was able to partially do it. But has some issues, so dropped that for now. For now, we can compensate this by setting the collision off and on, either by iterating through all "Mesh" nodes, in an onFrameEvent in javascript, or either by turning the node collision off when making it invisible and turning it back on when making it visible again.

2023-03-14 23:15:04

I'm putting into my game different sound volumes to possibly alert enemies when crouching, walking and running (and falling).

I'm having a bit of difficulty calculating the correct 'volume' amount to use as the enemy alert for different sounds.

I wonder if a new C++ API could be added to actually measure the absolute volume of each sound being played and not just the volume figure used when playing ? - such that all different sounds can be measured relatively the same against each other to get an accurate figure for any sound that is played ?

would be great if this would work....

2023-03-15 01:39:26

the collision feature sounds good. might help performance a little. though wouldn't it make more sense to make it a part of "ccbSetSceneNodeProperty" instead? so


2023-03-15 02:43:10

@Robbo, I don't know if it is possible in irrklang to get relative sound. However you can get the volume for the sound, the engine internally uses a sound volume between 0 and 1, which then gets multiplied by the master volume of the engine.

Also if you want you can do something like this in CC, to manage different sound levels for different sound effects.
You can download the extension from the neophyte website.

@andres, yes it can be possible that way, but I didn't want to put my code into SetProperty Part so that it won't cause any bugs and other issues, and it will be easy for @niko to manage the API. Also, I think it can be written faster as it, doesn't takes "Collision" as an extra attribute, so it's a +point for a person with having slow typing speed. Also just managed to fix it, and now it works for the Physics Simulations as well.
Desperately wants to fix the issue with the visibility of nodes as well. But I think I am going to be busy as my Exams are starting from 16th of March.

2023-03-15 08:25:26

Thanks but I already have my own volume controls for different sound types.
Each sound volume in how it was saved originally will determine its actual playing volume for any given volume used in the engine.

The only other way I know is to normalize every sound effect I have in a sound editing software such that they are all re-recorded at the same volume or intensity and thus can be compared to each other equally but this will take hours as have hundreds of sound effects...

2023-03-15 10:08:32


"but this will take hours as have hundreds of sound effects"

With Audacity you can create a normalize macro and easily auto batch process hundreds of sound files with it afaik, maybe that could help?

2023-05-01 06:32:30

Added a command to make any scene node with "collide when moved" behavior jump, just like the inbuilt FPS camera.

ccbMakeSceneNodeJump(node, jumpForce)

2023-05-01 07:35:18

nice, with more high level API like this, coding would be more appealing for non-coder. Sometime I feel like doing coding with high level API is way easier than mix alot of behaviour an action together.

Ask: there's anyway to make API like those specific event behaviour? For exp, if we wanna check the distance of two object, we have to check their distance every update and do some math, but with a specific API, we just need the name/varible of two node to get what we want, it would save alot of time.

The same for things like checking angle between two object... the higher level the api are, the more it would feel like real language.

2023-05-01 16:32:11

That can be an idea but might be extra work, and right now I am focussed more on fixing bugs, probably in future, I will add this.

2023-05-02 10:58:06

Hi, I just wanted to say that I’m very impressed by irrKlang and its features. I have been using it for my game project and it works flawlessly. I love how easy it is to integrate irrKlang with other game engines like Unity or Unreal. I also appreciate how irrKlang supports 3D sound effects and spatialization. It makes my game sound more realistic and immersive. I also like how irrKlang can play sounds from memory or custom sources. It gives me more flexibility and control over the sound.

Thank you for creating and maintaining irrKlang. It is a great sound library and I highly recommend it to anyone who needs a high level audio solution for their games or applications.

Regards, Hanna from CodeIT (http://)

Edit by moderator:- Link, to CodeIT website has been removed as it seems to be a spam post.

Create reply:

Posted by: (you are not logged in)

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