Ambiera Forum

Discussions, Help and Support.

Ambiera Forum > CopperCube > Feature requests and bug reports
"Request" animate a UVW mapping in coppercube

Newbee
Guest
Quote
2021-02-24 16:05:45

Hi, is somebody can create a plugins in .js to animate UVW mapping perhaps with this?
"ccbSetMeshBufferVertexTextureCoord(node, meshbufferindex, vertexindex, coord)" with separate speed parameter something like this:
U speed: Speed_Value
V speed: Speed_Value
W speed: Speed_Value
And a rotating value wille be cool too


Guru
Guest
Quote
2021-02-28 16:35:28

How much can you pay for it?


Newbee
Guest
Quote
2021-03-03 11:28:57




marcw
Registered User
Quote
2021-03-03 13:34:12

Hello Newbee,

What you are asking for is quite interesting.

Please could you explain in detail what you mean by U, V, W speed and rotating ?
Do you have some examples to show ?

:-)


Newbee
Guest
Quote
2021-03-03 15:31:39

Like this:
🔎︎



marcw
Registered User
Quote
2021-03-03 22:15:48

Newbee, thank you for having posted that picture.
It explains better than words.
I too am particularly interested by the mesh editing available in CopperCube for Windows projects.
Your request is a nice challenge and I hope that it will be answered by the experts of this forum.
Anyway, I am going to study that matter even if it is poorly documented.

:-)


marcw
Registered User
Quote
2021-03-04 17:34:12

Hello everybody,

Newbee, I come back with a first basic test.
For that purpose I mainly used the lines of code published by Niko in his tutorial "Creating 3D geometry using JavaScript" found on this page https://www.ambiera.com/coppercu...

In this shared folder on my OneDrive (secured and anonymous access) https://1drv.ms/u/s!AjokN1FU3jK1...
you can find a CCB project for Windows and a JS Behavior.

If you want to try running that CCB project, then you need to store the JS Behavior "behavior_UV_Editing_Test.js" in the "extensions" folder normally found in your "Documents\CopperCube" main folder.

Please note that this is a first approach and it is not yet the solution that you would have expected.
I too am a newbee with CopperCube and with JavaScript.

The behavior performs the following steps :

- creation of a new mesh (a square split into two triangles).
- by 1-second intervals :
- the color of the four vertices are modified.
- the texture is tiled differently.

(I'll try to post the code in a new comment) -> done, but nearly all comments are removed. You can read them in Niko's tutorial.

:-)


marcw
Registered User
Quote
2021-03-04 17:39:25

 

/* <behavior jsname="behavior_UV_Editing_Test" description="UV Editing Test (by a CopperCube newbee)">
</behavior>
*/

behavior_UV_Editing_Test = function()
{

};

behavior_UV_Editing_Test.prototype.onAnimate = function(node)
{

var timeInSecondsFull = Date.now()/1000;
var timeInSeconds = Math.floor((Date.now()/1000));
var milliseconds = Math.round((timeInSecondsFull - timeInSeconds)*1000);
var moduloSeconds = timeInSeconds % 60;
var cycle = moduloSeconds % 4;
//print (moduloSeconds);
//print (cycle);

var meshnode = ccbGetSceneNodeFromName("cubeMesh1");
var bufferCount = ccbGetSceneNodeMeshBufferCount(meshnode);

if (bufferCount == 0)
alert('The selected node has no 3D geometry.');
else
{

var oldTexture = ccbGetSceneNodeMaterialProperty(meshnode, 0, "Texture1");


for (var i=0; i<bufferCount; ++i)
ccbRemoveMeshBuffer(meshnode, 0);


ccbAddMeshBuffer(meshnode);

ccbSetSceneNodeMaterialProperty(meshnode, 0, 'Lighting', false);
ccbSetSceneNodeMaterialProperty(meshnode, 0, "Texture1", oldTexture);


ccbAddMeshBufferVertex(meshnode, 0, new vector3d(0,10,0));
ccbAddMeshBufferVertex(meshnode, 0, new vector3d(10,10,0));
ccbAddMeshBufferVertex(meshnode, 0, new vector3d(0,0,0));
ccbAddMeshBufferVertex(meshnode, 0, new vector3d(10,0,0));



if (cycle == 0)
{

ccbSetMeshBufferVertexColor(meshnode, 0, 3, 0x10FF0000);
ccbSetMeshBufferVertexColor(meshnode, 0, 2, 0x1000FF00);
ccbSetMeshBufferVertexColor(meshnode, 0, 1, 0x100000FF);
ccbSetMeshBufferVertexColor(meshnode, 0, 0, 0x10888888);


ccbSetMeshBufferVertexTextureCoord(meshnode, 0, 0, new vector3d(0,1,0));
ccbSetMeshBufferVertexTextureCoord(meshnode, 0, 1, new vector3d(1,1,0));
ccbSetMeshBufferVertexTextureCoord(meshnode, 0, 2, new vector3d(0,0,0));
ccbSetMeshBufferVertexTextureCoord(meshnode, 0, 3, new vector3d(1,0,0));
}

if (cycle == 1)
{
ccbSetMeshBufferVertexColor(meshnode, 0, 2, 0x10FF0000);
ccbSetMeshBufferVertexColor(meshnode, 0, 1, 0x1000FF00);
ccbSetMeshBufferVertexColor(meshnode, 0, 0, 0x100000FF);
ccbSetMeshBufferVertexColor(meshnode, 0, 3, 0x10888888);


ccbSetMeshBufferVertexTextureCoord(meshnode, 0, 0, new vector3d(0,2,0));
ccbSetMeshBufferVertexTextureCoord(meshnode, 0, 1, new vector3d(2,2,0));
ccbSetMeshBufferVertexTextureCoord(meshnode, 0, 2, new vector3d(0,0,0));
ccbSetMeshBufferVertexTextureCoord(meshnode, 0, 3, new vector3d(2,0,0));
}

if (cycle == 2)
{
ccbSetMeshBufferVertexColor(meshnode, 0, 1, 0x10FF0000);
ccbSetMeshBufferVertexColor(meshnode, 0, 0, 0x1000FF00);
ccbSetMeshBufferVertexColor(meshnode, 0, 3, 0x100000FF);
ccbSetMeshBufferVertexColor(meshnode, 0, 2, 0x10888888);

ccbSetMeshBufferVertexTextureCoord(meshnode, 0, 0, new vector3d(0,3,0));
ccbSetMeshBufferVertexTextureCoord(meshnode, 0, 1, new vector3d(3,3,0));
ccbSetMeshBufferVertexTextureCoord(meshnode, 0, 2, new vector3d(0,0,0));
ccbSetMeshBufferVertexTextureCoord(meshnode, 0, 3, new vector3d(3,0,0));
}

if (cycle == 3)
{
ccbSetMeshBufferVertexColor(meshnode, 0, 0, 0x10FF0000);
ccbSetMeshBufferVertexColor(meshnode, 0, 3, 0x1000FF00);
ccbSetMeshBufferVertexColor(meshnode, 0, 2, 0x100000FF);
ccbSetMeshBufferVertexColor(meshnode, 0, 1, 0x10888888);


ccbSetMeshBufferVertexTextureCoord(meshnode, 0, 0, new vector3d(0,4,0));
ccbSetMeshBufferVertexTextureCoord(meshnode, 0, 1, new vector3d(4,4,0));
ccbSetMeshBufferVertexTextureCoord(meshnode, 0, 2, new vector3d(0,0,0));
ccbSetMeshBufferVertexTextureCoord(meshnode, 0, 3, new vector3d(4,0,0));
}


ccbAddMeshBufferIndex(meshnode, 0, 0);
ccbAddMeshBufferIndex(meshnode, 0, 1);
ccbAddMeshBufferIndex(meshnode, 0, 2);
ccbAddMeshBufferIndex(meshnode, 0, 1);
ccbAddMeshBufferIndex(meshnode, 0, 3);
ccbAddMeshBufferIndex(meshnode, 0, 2);


ccbUpdateSceneNodeBoundingBox(meshnode);
}

}



smnmhmdy
Registered User
Quote
2021-03-04 20:54:52

I have worked on a similar thing before, hope it's what you're looking for.
/*  
<behavior jsname="behavior_AnimateTextureCoord" description="Animate Texture Coord">
<property name="xSpeed" type="float" default="1"/>
<property name="ySpeed" type="float" default="0"/>
</behavior>
*/

behavior_AnimateTextureCoord = function(){ this.lastTime = 0; }

behavior_AnimateTextureCoord.prototype.onAnimate = function(node, Time){
if(!this.node){
this.node = node;
this.bufferCount = ccbGetSceneNodeMeshBufferCount(node);
this.vertexCount = ccbGetMeshBufferVertexCount(node, 0);

// caching the coordinates will increase performance slightly
this.cachedCoord = [];
for(var i = 0; i < this.bufferCount; i++){
this.cachedCoord[i] = [];
for(var j = 0; j < this.vertexCount; j++){
var textureCoord = ccbGetMeshBufferVertexTextureCoord(node, i, j);
if(!textureCoord) continue;
this.cachedCoord[i][j] = new vector3d(textureCoord.x, textureCoord.y, textureCoord.z);
}
}
}

// time
this.deltaTime = Time - this.lastTime;
this.lastTime = Time;

for(var i = 0; i < this.cachedCoord.length; i++)
for(var j = 0; j < this.cachedCoord[i].length; j++){
var textureCoord = this.cachedCoord[i][j];
textureCoord.x += this.xSpeed * this.deltaTime * 0.001;
textureCoord.y += this.ySpeed * this.deltaTime * 0.001;
ccbSetMeshBufferVertexTextureCoord(node, i, j, textureCoord);
}
}



hadoken
Guest
Quote
2021-03-04 21:44:36

@smnmhmdy

Thank you very much for sharing your animated texture coordinates script which is really working great & seriously extending every CC user's game design possibilities! Wow!

Could you also perhaps lend us some more help for our "proper common CC 3rd person controller" endeavor please at "3rd Person Player & Camera Controller 2021" thread?

I personally feel so heavily stuck with it. Since I've come to the conclusion considering a working pointer lock to be the essential base for a proper 3rd Person Controller, I've ran out of ideas:

CC's built-in Model-Viewer-Cam is not very script cooperation friendly by its nature and I can't find an alternative pointer lock feature in CC other than by using that damn (sorry) M-V-Cam.

So, any further constructive support would be so awesome and more than welcome. Please help us with the matter,

This is my latest attempt:
https://www.dropbox.com/s/xr9pq8fy93tfirn/HADOKEN-alternative-3rdPerson-approach-demo-2021-03-04.exe?dl=0

What's working:
- free vertical/horizontal mouse look around player
- camera zoom
- no horizontal mouse movement restrictions
- player run movement
- player jump movement

It still misses:
- right/left strafe
- working backwards movement
- camera wall collision handling
- now I also like your feature for the player only aligning himself with camera facing direction when moving forward


marcw
Registered User
Quote
2021-03-04 22:51:34

Smn Mhmdy, thank you very much for sharing your "behavior_AnimateTextureCoord".

Your script is beautiful and efficient. I guess that it exactly works as intended by the requester.

Again your contribution in this forum will make many happy members.

:-)


smnmhmdy
Registered User
Quote
2021-03-05 09:29:22

@hadoken Thank you, I've posted an update on that showcase thread from earlier, in case you've missed it, I was able to get rid of the built-in model view behavior by using a script controlled orbiting behavior. That also allows us to have collision detection, accessible mouse sensitivity at run time and Shoulder view camera (a bit buggy still). I recommend you to check out the said post for the demo if you haven't already :)

Here's an updated build (containing shoulder view) using the stock coppercube assets:
https://www.dropbox.com/s/2owps2...

You can press V to toggle between shoulder / center view and use Mouse wheel to change the radius.

As you can see shoulder view is a bit buggy and starts freaking out if you go above the players head or below his feet. I'm still trying to work on that one. It also messes with the collision detection but I don't think that's gonna be too hard to fix. The collision detection works much better on non terrain geometry though.

I've checked you guys' 3rd person behavior project and I'm very much impressed of how much you were able to achieve given the limitations. I'm sure we can work on a truly user and dev-friendly 3rd person controlling solution :)

@marcw thank you I appreciate that :)


hadoken
Guest
Quote
2021-03-05 10:56:12

@smnmhmdy
Thanks for your reply.

Don't worry I've tested all your provided (also updated) demos and each one has really impressed me very much!

To bundle our exchange of experience related to the topic as well as to stop hijacking other threads, i will continue further discussion hopefully exclusively at the "3rd Person Player & Camera Controller 2021" thread. Could you please look over there regularly, too? Thanks, there I will get back to you and all interested users soon.

The thing is, I guess I have plenty of wonderful material, skills, creativity and ideas to develop a real showcase game with CC. But while FPS is super supported, the so far not well working TPC hinders me enormously. Meaning I would rather have this issue professionally solved sooner than later.
When I bought the pro version, somehow I actually expected such feature to be already accessible, maybe not out of box, but at least with some intermediate to advanced thinking work but in no case by brain torture).

The latest "tpsTest.exe" with the CC prefabs seems quite near to mission goal.

@csp-games
Dieter - if you're still around and interested - maybe would you be with us for some further enlightenment at least out of curiosity? ;-)


just_in_case
Moderator
Quote
2021-03-05 11:18:38

@smnmhmdy Thanks a lot for sharing this beautiful behavior. Gonna download and try the new demo you shared.

@marcw yours skills are improving really very well.




Newbee
Guest
Quote
2021-03-05 11:19:29

Thanks a lot smnmhmdy
That's working PERFECT! Many thanks!!!


Create reply:


Posted by: (you are not logged in)


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