Ambiera Forum

Discussions, Help and Support.

Ambiera Forum > CopperCube > Programming and Scripting
Replace a scene node with a different scene node "help"

ori
Registered User
Quote
2018-09-14 17:15:14

Hi! is someone able to help with making a new action that "replaces a scene node with a different scene node"... Example "ActionOnDie" replace the current mesh or billboard/scene node with a totally different mesh or billboard/scene node.... I guess similar to Hide or unhide a scene node but instead of hiding the scene node it is being replaced by another scene node.

Cheers.


tim12345
Guest
Quote
2018-09-14 19:27:15

this can already be done in the editor by simply deleting the scene node and changing the position or cloning and changing the position of desired scene node simultaneously. but you are wanting a javascript action for this?


ori
Registered User
Quote
2018-09-15 02:48:56

Hi! thanks for the reply! i'm aware that what i'm asking can be achieved in this manner, though the end result is a lot of busy work. If the effect was a scripted action "replace a scene node with a different scene node" it would eliminate this busy work and make work flow faster! particularly if a project has several scene nodes that need to be changed each to a completely different scene node...


tim12345
Guest
Quote
2018-09-15 08:12:17

ah I see. well then you will probably want to create a .js file named action_replace.js and then add something like this to it...

/*  <action jsname="action_replace" description="Replace current scene node with a different scene node">
<property name="ReplacementNode" type="scenenode" />
</action>
*/
action_replace = function()
{
};
action_replace.prototype.execute = function(currentNode)
{
var curPos = ccbGetSceneNodeProperty(currentNode, "Position");
var sourceNode = this.ReplacementNode;
var newscenenode = ccbCloneSceneNode(sourceNode);
ccbSetSceneNodeProperty(newscenenode, "Name", "replacer");
ccbSetSceneNodeProperty(newscenenode, "Visible", true);
ccbSetSceneNodeProperty(newscenenode,"Position",curPos);
ccbRemoveSceneNode(currentNode);
};



ori
Registered User
Quote
2018-09-15 15:25:10

Thank you so much! i really appreciate that you took the time to do this, the script works like a charm...


Create reply:


Posted by: (you are not logged in)


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