ambiera logo

Ambiera Forum

Discussions, Help and Support.

folder icon Ambiera Forum > CopperCube > Announcements and Showcase
forum topic indicator First extension.."Special Child"
person icon
veganpete
Registered User
Quote
2023-11-02 15:01:46

Hi, my first ever extension - made it for myself but decided to share in case it's useful...
embedded external image
🔎︎

https://veganpete.itch.io/vps-co...

It allows you to child one node to another but the child will keep it's own scale/rotation/visibility properties, instead of being dictated to by the parent.

I added x/y/z offset too so you can manually adjust the child-node's offset from the parent position (default is 0,0,0).

Main reason I made this is because I was encountering the same problem every day - if I child one node to another, Coppercube then gets confused whenever I try to scale/rotate/position the child independently of the parent and the child will always rotate/scale with the parent - which I don't always want to happen.

Most people probably wouldn't even notice this as a problem, it's because my workflow is completely bonkers and entirely visual with no code.

This extension allows me to adjust parent/child values independently of each other - may be useful for others, probably not.

person icon
edwin123
Registered User
Quote
2023-11-02 18:22:03

cool, its very usefull thanks for sharing emoji icon_grin

person icon
VP
Guest
Quote
2023-11-02 20:02:36

Thank you. You're welcome.

person icon
Guest
Guest
Quote
2023-11-02 20:46:25

@VP
There's a couple corrections you need to do for your code to work. I went ahead and pasted them in the code below. I've not had time to test it because I am at work. Good luck on your learning to code journey!

/*  
<behavior jsname="behavior_specialchild" description="Special Child Behaviour">
<property name="Parent" type="scenenode"/>
<property name="OffsetX" type="int" default="0"/>
<property name="OffsetY" type="int" default="0"/>
<property name="OffsetZ" type="int" default="0"/>
</behavior>
*/

behavior_specialchild = function () {};
behavior_specialchild.prototype.onAnimate = function (currentNode) {
var PP = ccbGetSceneNodeProperty(this.Parent, "Position");
ccbSetSceneNodeProperty(
currentNode,
"Position",
PP.x + this.OffsetX,
PP.y + this.OffsetY,
PP.z + this.OffsetZ
);
};


person icon
VP
Guest
Quote
2023-11-02 21:19:50

Thanks, it had a typo in it - I'd typed OffsetX instead of X_Offset etc. Here's the code, should be working.....

/*
<behavior jsname="behavior_specialchild" description="Special Child Behaviour">
<property name="Parent" type="scenenode"/>
<property name="X_Offset" type="Int" default="0"/>
<property name="Y_Offset" type="Int" default="0"/>
<property name="Z_Offset" type="Int" default="0"/>
</behavior>
*/

behavior_specialchild=function(){};
behavior_specialchild.prototype.onAnimate=function(currentNode)
{
var PP=ccbGetSceneNodeProperty(this.Parent,"Position");
var CPx = this.X_Offset
var CPy = this.Y_Offset
var CPz = this.Z_Offset
ccbSetSceneNodeProperty(currentNode,"Position",PP.x+(CPx),PP.y+(CPy),PP.z+(CPz));
}

person icon
VP
Guest
Quote
2023-11-02 21:25:54

Oh,I see what you mean now......

I can ditch the var CPx = this.X_Offset and just use this.X_Offset directly instead of declaring it as a variable.

Thanks.

person icon
just_in_case
Moderator
Quote
2023-11-03 15:02:25

You won't beleive how happy I am to see that you created your first scripted extension and you are trying to learn javascript. Thanks a lot for this wonderful extension :)

person icon
VP
Guest
Quote
2023-11-03 16:20:19

Thank you just_in_case me too.

It's obviously only very basic, but it did help me to understand things a little bit better and it's made me interested in making more scripts.

person icon
andgameplay
Registered User
Quote
2023-11-03 17:09:49

Congratulations VP for your first script!

You are great!

person icon
Alireza
Guest
Quote
2023-11-04 14:55:26

Thanks for this useful extension.
one question :
Are vp and veganpete the same user?

person icon
VP
Guest
Quote
2023-11-04 16:35:16

Hi Alireza, yes,same person - sorry for the confusion. I have dyslexia, so when I get logged out, it's much easier for me to log in as VP (Guest).

Whenever I create a post, I'll take the time to log in as VeganPete, but if it's just a quick comment/reply to someone else's thread, I'll often use VP (Guest) account instead.

Just for openness, I've never posted anything here other than as VeganPete or VP. My account on itch.io is "VP".

My real name is actually Pete Tinsley - the reason I use the Vegan tag is because, although being many other things, I'm primarily an animal activist. I'm an aeronautical engineer by trade, I'm also a "disabled" war veteran and used to be a martial arts instructor and a military chemical-weapon/bomb-disposal operative - I also enjoy tinkering with hacking/cracking and electronics as a hobby - that's why a lot of my projects are themed around animals, engineering, and war.

Glad you like the plugin.

person icon
VP
Guest
Quote
2023-11-04 16:39:43

Thanks for your kind workds andgameplay I only just noticed your comment! :)

person icon
chrisz
Registered User
Quote
2023-11-04 20:24:45

Fantastic. That is very usefull.
Thanks a lot.

person icon
VP
Guest
Quote
2023-11-05 00:36:41

You're very welcome Chrisz. Really glad you find it useful.

person icon
Guest
Guest
Quote
2023-11-10 19:05:54

Many congratulations for your first extension


Create reply:










 

  

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


icon_holyicon_cryicon_devilicon_lookicon_grinicon_kissicon_monkeyicon_hmpf
icon_sadicon_happyicon_smileicon_uhicon_blink   






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