edit *.wrl file, add a new node

I tried to add a new transform node in my virtual world object. With Matlab function vrnode I have been able to obtain the handle and set some of existing field of the virtual world object. I am wondering HOW can I add a new transform node under the existing transform node via Matlab directly without manipulating the raw *.wrl file.
Below is the list of fields available. It seems to be that the addChildren field here shall add a new child node to the existing node, so I tried syntax to use the addChildren field, but none of them works. Is it possible? Below is the list return by fields function.
Thank you.
Field Access Type Sync
-----------------------------------------------------------
addChildren eventIn MFNode off
removeChildren eventIn MFNode off
children exposedField MFNode off
center exposedField SFVec3f off
rotation exposedField SFRotation off
scale exposedField SFVec3f off
scaleOrientation exposedField SFRotation off
translation exposedField SFVec3f off
bboxCenter field SFVec3f off
bboxSize field SFVec3f off

 Respuesta aceptada

Jan Houska
Jan Houska el 6 de Jun. de 2014

0 votos

Hi Steven,
as the parent field, you should use the children field, not addChildren, which is an event. Like in the following code snippet, based on the shipping vrbounce example:
w = vrworld('vrbounce');
open(w);
parenttransform = w.Ball;
newtransform = vrnode(parenttransform, 'children', 'NewTransform', 'Transform')

3 comentarios

Steven
Steven el 9 de Jun. de 2014
Thanks. I finally created one. BUT the new transform does not apply on the object when I pass new rotation parameter to it. The original object transform node does control the rotation and translation perfectly, but the new sub-node doesn't seem to control anything. Did I put it under the wrong parent node? The reason I implemented these code is because I want to make a multi-rotation of a object toward two axes.
Thanks
Jan Houska
Jan Houska el 10 de Jun. de 2014
Transforms apply only to their children. They do not apply to their siblings. So if you have created the new transform as a sibling of some existing nodes, it would not apply to them.
BTW, have you tried the interactive 3D World Editor? It shows you the effects of your changes immediately and gives better understanding of what's going on when you add a node. You can then always return back to command line if you prefer.
Steven
Steven el 17 de Jun. de 2014
Thank you so much. I finally figure out how it works.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Animation en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 5 de Jun. de 2014

Comentada:

el 17 de Jun. de 2014

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by