VRML 3D scene from MATLAB command prompt

3 views (last 30 days)
Hello Everyone,
Is there a way to open a new VRML world, add a background to the scene, and add different 3D Transform nodes depending on an indexing parameter passed from a MATLAB just using a command prompt? To clarify, using the following command requires the file to exist upfront to create the VRML world. Is it possible to create even 'filename' if it does not exist?
>> myworld = vrworld('filename', 'new');
The following command requires the existence of the node 'node_name' in the 'filename' to further manipulate the node object. What if we want to add this node depending on an input (say if i==1 insert 'plane.wrl' to the VRML world else insert 'helicopter.wrl' which are located in some folder).
>> mynode = vrnode(vrworld_object, 'node_name')
Thanks for your time.

Accepted Answer

Jan Houska
Jan Houska on 30 Jul 2012
You can create a new VRML world from scratch like this:
w = vrworld(''); % create an empty world and open it
open(w);
% ... add any nodes if desired ...
save(w, 'myworld.wrl'); % save under a new name
close(w);
You can add nodes to an existing open world (either loaded from a file or created as above) like this:
t1 = vrnode(w, 'MyTransform', 'Transform'); % add a Transform on the root
t2 = vrnode(t1, 'children', 'AnotherTransform', 'Transform'); % add child to t1
See also the documentation for the "vrnode" function.
  2 Comments
Mesfin
Mesfin on 31 Jul 2012
Thanks Jan for your advice. Do you know a reference material on building 3D world from a MATLAB command window? The V-Realm builder documentation shows only editing using the software.
Jan Houska
Jan Houska on 2 Aug 2012
There is no other reference manual (that I know of) than the product documentation. But, if you carefully read the reference pages of the "vrworld" and "vrnode" objects, you will see that the functions allowing to build and edit virtual worlds are described there - including the two I have suggested above.

Sign in to comment.

More Answers (1)

Cornelis
Cornelis on 20 Jun 2013
Dear Jan,
my vrml editor does not seem to be working. I'm running MATLAB Version: 8.0.0.783 (R2012b) on a 64bit win7 machine and have got Simulink 3D Animation Version 6.2 (R2012b) installed.
I can use *.wrl files I have created on a different machine with different version but cannot edit them (or newly created .wrl files). Also when I try other routes to launch the editor (eg via the new apps tab) I get the same error message (see below).
Could you please point me in the right direction?
Many thanks!
kind regards
Cornelis
Subscripted assignment dimension mismatch.
Error in repmat (line 54) B(nelems) = A;
Error in vr.edit.retrieveIconData (line 2303) iconData(:,:,[1 2 3]) = alpha .* double(iconData) + (1-alpha).* repmat(reshape(vr.edit.IconsBackgroundColor,1,1,[]),16,16);
Error in vr.edit/createuitoolbar (line 859) uipushtool(toolbar, 'TooltipString', 'New File', ...
Error in vr.edit (line 125) createuitoolbar(obj);
Error in vredit (line 23) vr.edit(get(w, 'FileName'));

Tags

Community Treasure Hunt

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

Start Hunting!