Ambiera Forum

Discussions, Help and Support.

Ambiera Forum > CopperCube > Announcements and Showcase
CopperCubePlugin Released

sakura
Registered User
Quote
2023-03-12 16:55:38

Long time no see, and sorry for the lack of time to develop the program as I've been very busy lately! I'm glad to see everyone again.

I recently spent some time developing CopperCubePlugin, a plugin that extends CopperCube and adds a lot of features to CopperCube, and it's native, which means that games you develop with CopperCubePlugin don't need to carry it to avoid anti-virus software reporting it as a virus.

It consists of CopperCubePlugin.exe and CopperCubePlugin.dll, as it is a plugin, some anti-virus software will report it as a virus, but please don't worry, it is safe.

🔎︎


I changed the communication method, now it doesn't use TCP, which means that no ports will be opened on your computer, there is no networking operation and the security is better.

CopperCubePlugin.dll is based on C++ development, so it is safe and has been checked by anti-virus software and reported as safe.

CopperCubePlugin.exe passed most anti-virus software , and both are reported as safe on my computer.


sakura
Registered User
Quote
2023-03-12 16:59:43

The most significant feature of CopperCubePlugin is that it brings multi-file project management, which means that developing large games is possible.

🔎︎



sakura
Registered User
Quote
2023-03-12 17:00:35

I added an "import" function to CopperCube, which allows you to import multiple JavaScript files instead of writing all the code in one file.

For example:
🔎︎


The advantage of this is that multiple files can be used with git to develop the game in a distributed way, each person can write their own files and finally compile them with the CopperCubePlugin.

The import function can also be used in every JavaScript file, which means a more flexible way of development, but be careful not to repeat imports, which can lead to dead loops.

The import function not only imports JavaScript files, but also supports importing TXT, JSON and Shader files.

For example:
import("lang\en.txt");
import("json\database.json");
import("shader\flash.shader");



sakura
Registered User
Quote
2023-03-12 17:01:09

Language:
🔎︎



sakura
Registered User
Quote
2023-03-12 17:03:57

TXT:
You can store a lot of text in TXT and don't need to add \r\n, it will be processed automatically when it is compiled to the game, which means you can fill the text normally without caring about line breaks. In the demo I used this feature to implement multi-language.

🔎︎



sakura
Registered User
Quote
2023-03-12 17:04:36

JSON:
With this feature, you can use JSON as a database. Just write the JSON file normally without removing line breaks, and when you compile the game, it will turn this JSON file into a JSON object, and you can use this JSON object directly in the game.

🔎︎



sakura
Registered User
Quote
2023-03-12 17:05:19

Shader:
The Shader in CopperCube was quite a pain to write, you needed to add \n and + symbols to each line of the Shader code in order to turn it into a JavaScript string, now you just need to write the code normally in the Shader file and then use "import" to import the game.

Original:
var vertexShader = 
"float4x4 mWorldViewProj; // World * View * Projection \n" +
"float4x4 mInvWorld; // Inverted world matrix \n" +
"float4x4 mTransWorld; // Transposed world matrix \n" +
" \n" +
"// Vertex shader output structure \n" +
"struct VS_OUTPUT \n" +
"{ \n" +
" float4 Position : POSITION; // vertex position \n" +
" float4 Diffuse : COLOR0; // vertex diffuse \n" +
" float2 TexCoord : TEXCOORD0; // tex coords \n" +
"}; \n" +
" \n" +
"VS_OUTPUT main ( in float4 vPosition : POSITION, \n" +
" in float3 vNormal : NORMAL, \n" +
" float2 texCoord : TEXCOORD0 )\n" +
"{ \n" +
" VS_OUTPUT Output; \n" +
" \n" +
" // transform position to clip space \n" +
" Output.Position = mul(vPosition, mWorldViewProj); \n" +
" \n" +
" // transformed normal would be this: \n" +
" float3 normal = mul(vNormal, mInvWorld); \n" +
" \n" +
" // position in world coodinates would be this: \n" +
" // float3 worldpos = mul(mTransWorld, vPosition); \n" +
" \n" +
" Output.Diffuse = float4(1.0, 1.0, 1.0, 1.0); \n" +
" Output.TexCoord = texCoord; \n" +
" \n" +
" return Output; \n" +
"}


Now:
🔎︎



sakura
Registered User
Quote
2023-03-12 17:06:13

Tip: When importing TXT, JSON and Shader files, it will use the file name as the variable name to import the game, please be careful not to repeat the variable name to cause overwriting.

In addition to that, I have developed a global function library, which can be managed using the global.js file, which I have included in the archive.

When you extract the archive, you can see the following file:
🔎︎



sakura
Registered User
Quote
2023-03-12 17:06:57

This is the content of the global.js file:
🔎︎

You can use // to turn the module on and off.


sakura
Registered User
Quote
2023-03-12 17:07:33

🔎︎


With this feature, you can write functions in it, and subsequently you can open any ccb project and use the functions in it directly, which is very convenient.

You can even use these functions in CopperCube's extensions and plugin files.

If you have a nice function, feel free to share it. This feature was developed with the hope that everyone can add additional functions to CopperCube.

Tip: Although you can also write functions in global.js, I don't recommend doing so, it's not convenient to manage the module.

I also brought complete JSON object support to CopperCube, and now you can use JSON.parse and JSON.stringify to convert JSON.

Not only that, but because it is a complete JSON object, this means that:

JSON.parse(text, reviver);
JSON.stringify(value, replacer, space);


They all have multiple optional parameters, consistent with the standard functions.

I will add more native Javascript function support in the future to make CopperCube better.


sakura
Registered User
Quote
2023-03-12 17:09:10

Tip: To use my plugin, you need to first start CopperCubePlugin.exe, then open any ccb project, compile and run the game, when you see "Sakura Plugin" and version number appear in the debug console, it means the plugin has been started.

🔎︎


Tip: CopperCubePlugin is a service so it is not designed to exit automatically. If it disappears from your process list, there may be an exception and you can give me feedback on the problem.

If you want to close it, you can terminate it directly using Task Manager, and then it is recommended that you restart CopperCube in order to uninstall the plugin.
But my advice is not to terminate the service.
It will only load plugins for CopperCub that already have the project open.

Here is the download address:
https://send.cm/d/LmRt
Password:Sakura

Edit:- Download at your own risk, Suspicious file, detected as a virus by windows defender.


okeoke
Registered User
Quote
2023-03-12 17:23:32

Hi sakura,

Not trying to be mean, but can you explain what is a benefit of using this plugin?

It's already possible to use multiple js files without the extension. For desktop all your data variables, functions, classes, and etc are mutually accessible from every action and behavior. I'm usually initializing my helper function and classes in an empty action files, and then add this file to "run before the first draw" on my first scene.

I.e. I just create an action:
var data = { a: 2, b: 1};
function Dog(x, y,z) {
this.x = x;
this.y = y;
this.z = z;
}
action_InitClasses = function () {
}

action_InitClasses.prototype.execute = function (node) {
}


And then I just add this to the "before the first draw". This way I have access to the Dog class and data variable from anywhere in my project.

If you're targeting a webgl it's even simpler since you can just use js modules syntax, which is more flexible since you can import/export the exact functions you need instead of the whole script.

Regarding importing shader text, you can still put everything into a separate file and just read the file content as string using built-in API command - that way you don't need to format hlsl to string.

JSON object is a simple polyfill:
JSON = {
parse: function (sJSON) { return eval('(' + sJSON + ')'); },
stringify: function (vContent) {
if (vContent instanceof Object) {
var sOutput = '';
if (vContent.constructor === Array) {
for (var nId = 0; nId < vContent.length; sOutput += this.stringify(vContent[nId]) + ',', nId++);
return '[' + sOutput.substr(0, sOutput.length - 1) + ']';
}
if (vContent.toString !== Object.prototype.toString) {
return '"' + vContent.toString().replace(/"/g, '\\$&') + '"';
}
for (var sProp in vContent) {
sOutput += '"' + sProp.replace(/"/g, '\\$&') + '":' + this.stringify(vContent[sProp]) + ',';
}
return '{' + sOutput.substr(0, sOutput.length - 1) + '}';
}
return typeof vContent === 'string' ? '"' + vContent.replace(/"/g, '\\$&') + '"' : String(vContent);
}
};

It also doesn't seem I don't need an extension for that.


sakura
Registered User
Quote
2023-03-12 17:49:51

wrote:
Hi sakura,

Not trying to be mean, but can you explain what is a benefit of using this plugin?

It's already possible to use multiple js files without the extension. For desktop all your data variables, functions, classes, and etc are mutually accessible from every action and behavior. I'm usually initializing my helper function and classes in an empty action files, and then add this file to "run before the first draw" on my first scene.



The polyfill of this JSON object is not complete, you can look at the standard JSON.parse and JSON.stringify and you will notice it has extra parameters, my goal is to make CopperCube more standard to support the new functions.

It's not just as simple as using multiple JavaScript files, it can store the files together in the same directory so that git can manage them better, while the action and behavior files are stored under Documents.

With the global library, you can also use JSON.parse and JSON.stringify in action and behavior files, as well as more functions that may be added in the future.

In the meantime, we can use git to open source the global library and add more functions to improve CopperCube.

This import feature is performed while compiling the game, which means that a single program file can be generated without carrying other files.

This is just the first step for now, and more features will be developed for the plugin in the future.


sakura
Registered User
Quote
2023-03-12 18:04:14

The goal of the plugin is to make it appear that these functions and features are native to CopperCube, you don't need to add files for helper functions, or polyfill JavaScript functions every time.


okeoke
Registered User
Quote
2023-03-12 18:12:00

JSON stringify has two more parameters, but these are related to actual text formatting. If you're using it for serialization/deserialization you're most likely not using them, since this only increases the message size.

Regarding git - you still will not be able to use it effectively, since it's not able to merge .ccb files. This means every time someone makes a change in a project file itself, i.e. modifies ccb file the new copy of the file will be created in git. So repository size will grow constantly. As far as I know that's the reason people still use perforce for game projects.

And also this is not the point, since it's already possible to use multiple files as I'm describing in my post.


Create reply:


Posted by: (you are not logged in)


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