Você está na página 1de 18

VSRD International Journal of Mechanical, Civil, Automobile and Production Engineering, Vol.

VII Issue IX September 2017 / 241


e-ISSN: 2249-8303, p-ISSN: 2319-2208 © VSRD International Journals: www.vsrdjournals.com

RESEARCH PAPER

CONTROLLING VRML WORLD PARAMETERS WITH MATLAB’S


SIMULINK GRAPHIC USER INTERFACE (GUI)
1Dipak
Vinayak Shirbhate* and 2Dilip Sahebrao Ingole
1Principal,
Department of Mechanical Engineering,
Shri Dadasaheb Gavai Charitable Trust Vikramshila Polytechnic, Amravati, Maharashtra, INDIA.
2Professor, Department of Mechanical Engineering,

Prof. Ram Meghe Institute of Technology & Research, Amravati, Maharashtra, INDIA.
*Corresponding Author’s Email ID: dipakshirbhate@gmail.com

ABSTRACT
VRML is an international standard of 3D representation on web. This paper describes how Matlab’s Simulink capabilities can be used
to control various parameters of VRML 3D objects such as speed, light intensity, color, transparency etc. of a complex Grain Cleaning
system.

Keywords: GUI (Graphic User Interface), VRML (Virtual Reality Modelling Language).

1. INTRODUCTION in this work and for 3D visualization MATLAB uses


In this work, the tool used for development of the 3D VRML. Therefore, it was the most convenient to build
virtual world is not V-Realm builder which is provided the 3D interactive scene in VRML and control the
with MATLAB Virtual Reality Toolbox. MATLAB physical properties and movements of the objects from
provides VRML editor called as V-Realm Builder for algorithms written in MATLAB source code. You can
creation and building VRML objects but some time use the Virtual Reality Modeling Language (VRML) to
complexity of 3D objects demands another approach to display three-dimensional objects in a VRML viewer.
build 3D objects using VRML. The objects described in Simulink® 3D Animation™ supports VRML97.
this paper are created with high end Mechanical solid
modelling packages like AutoCAD and CREO. The VRML provides an open and flexible platform for
machine assemblies were created by following steps creating interactive three-dimensional scenes (virtual
 Reading part drawing or obtaining part dimensions worlds). Several VRML97-enabled browsers are
by reverse engineering techniques. available on several platforms. Also, you can choose
 Part modelling from several VRML authoring tools. In addition,
 Part sub assembly and assembly graphical software packages (CAD, visual art, and so on)
offer VRML97 import/export features.
We have developed three MATLAB programs to check
Simulink’s VRML controlling ability. The first demo The Simulink 3D Animation product uses VRML97
program was tried on helical gears which is one of our technology for 3-D visualization.
assembly from Virtual Theory of Machine lab Project.
Then a GUI was created to control light intensity and 3. VRML SUPPORT
speed of 3D VRML objects of Grain cleaning system The Virtual Reality Modeling Language (VRML) is an
line. This MATLAB program was then extended to ISO standard that is open, text-based, and uses a WWW-
control color and transparency of the objects. oriented format. You use VRML to define a virtual
world that you can display with a virtual world viewer
2. WHY VRML? and connect to a Simulink model.
For 3D modelling, a large number of representation
The Simulink 3D Animation software uses many of the
formats are available. VRML is open source format. In
advanced features defined in the current VRML97
this work, VRML has been selected for building the 3D
specification. The standard is ISO/IEC 14772-1:1997,
virtual reality world of grain cleaning system. VRML is
available from
commonly used for visualization of physical worlds. As
http://www.web3d.org/documents/specifications/14772/
for computational algorithms, MATLAB has been used
Dipak Vinayak Shirbhate and Dilip Sahebrao Ingole VSRDIJMCAPE, Vol. VII (IX) September 2017 / 242

V2.0/part1/javascript.html. This format includes a The Simulink 3D Animation server ignores the VRML
description of 3-D scenes, sounds, internal actions, and Script node, but it passes the node to the VRML Viewer.
WWW anchors. Passing the node allows you to run VRML scripts on the
viewer side. You cannot run them on the Simulink 3D
The software analyzes the structure of the virtual world, Animation server.
determines what signals are available, and makes them
available from the MATLAB® and Simulink In keeping with the VRML97 specification, the Simulink
environment. 3D Animation Viewer ignores BMP files. As a result,
VRML scene textures sometimes display improperly in
Simulink 3D Animation software ensures that the the Simulink 3D Animation Viewer. To display scene
changes made to a virtual world are reflected in the textures properly, replace all BMP texture files in a
MATLAB and Simulink interfaces. If you change the VRML scene with PNG, JPG, or GIF equivalents.
viewpoint in your virtual world, this change occurs in
thevrworld object properties in MATLAB and Simulink
interfaces. 5. METHODOLOGY
To check the capability, it was decided to develop a
The software includes functions for retrieving and demo program using MATLAB’s Simulink GUI. The
changing virtual world properties. objective was to vary speed of helical gears rotating in
two different directions.

4. VRML COMPATIBILITY Below is the screen shot of helical gear assembly model
The Simulink 3D Animation product currently supports viewed in Virtual Environment using BS contact player.
most features of VRML97, with the following
limitations:

Fig1: 3D model of helical gear viewed in BS contact player

We can open the same model in MATLAB’s V- Realm geometrical object contains an independent “geometry”
builder to see various nodes as shown in figure below. In node and “appearance” node. The geometry node
the VRML file format, a 3D virtual world scene is controls the size and shape of each part. Whereas, the
described by a hierarchical tree structure of several appearance node controls the texture and material
objects. These objects are called “nodes”. A node may properties. The “appearance” node specifies the
contain other nodes (child nodes) under it. When a new physical properties such as the color, shininess,
node is created, the required fields are automatically transparency etc. The material properties of each sub-
generated and filled with default values. These fields part can be controlled independently. However, for
hold the data for each node. In VRML, every grouping the parts which have the same material
Dipak Vinayak Shirbhate and Dilip Sahebrao Ingole VSRDIJMCAPE, Vol. VII (IX) September 2017 / 243

properties the VRML “USE” node is used. The “USE” Emissive color is useful for displaying radiosity based
node repeats the same material properties on any other models.
object in the model. It is better to set some materials at
the start and then use these as and when required. The (d) Shininess. The “shininess” specifies how well a
following are the material fields used in VRML. surface is polished. Shininess values range from 0.0 for
dull surface to 1.0 for a highly polished surface.
(a) Ambient Intensity. The “ambient Intensity” specifies
the amount of ambient light the surface should reflect. (e) Specular Colour. The “specular Color” represents
Ambient intensity can be represented as any scalar value the colour of the highlights on a highly reflected object.
between 0.0 to 1.0 both inclusive. The higher the value This is the colour of the light that reflects directly back
the higher the reflection. to the viewer.

(b) Diffused Colour. The “diffuse Color” field indicates (f) Transparency. The “transparency” field specifies the
more or less the color of light that reflects/scatters most transmittance of an object, ranging from 0.0 for
from the object. The diffused color is specified in RGB completely opaque to 1.0 for a completely clear surface.
(red, green and blue) colour. Any value in between may represent a semi-transparent
object.
(c) Emissive Colour. The “emissive Color” field
specifies the light produced by a glowing object.

Fig. 2: Helical gears models code opened in MATLAB’s V-Realm Builder


to see various nodes available in model

The entire MATLAB code to control helical gears model parameters is as follows

6. GRAPHIC USER INTERFACE 1 (GUI1)


function gui1()

global tv1 ;
tv1 = 0 ;

global flg_light ;
flg_light = 0 ;
Dipak Vinayak Shirbhate and Dilip Sahebrao Ingole VSRDIJMCAPE, Vol. VII (IX) September 2017 / 244

global flg_hlight ;
flg_hlight = 0 ;

hFig = figure('Toolbar','none','Menubar', 'none',...


'Name','gui1','Resize','off','CloseRequestFcn',{@my_closereq},...
'Position',[800 400 400 300],'Color',[0.6 0.6 0.6]);

s1 = uicontrol('Style','slider','Callback', {@s1_callback},'FontSize',14,...
'Units','normalized','Position',[0.1 0.8 0.5 .08],'Max',15,...
'Min',0,'SliderStep',[0.01 0.10]);

sv1 = uicontrol(gcf,'Style','edit','FontSize',12,'String','',...
'Units','normalized','Position',[0.6 0.8 0.2 .09],'BackgroundColor','w');

sv1l = uicontrol(gcf,'Style','text','FontSize',12,'String','speed w1',...


'Units','normalized','Position',[0.8 0.8 0.2 .09]);

s2 = uicontrol('Style','slider','Callback', {@s2_callback},'FontSize',14,...
'Units','normalized','Position',[0.1 0.7 0.5 .08],'Max',15,...
'Min',0,'SliderStep',[0.01 0.10]);

sv2 = uicontrol(gcf,'Style','edit','FontSize',12,'String','',...
'Units','normalized','Position',[0.6 0.7 0.2 .09],'BackgroundColor','w');

sv2l = uicontrol(gcf,'Style','text','FontSize',12,'String','speed w2',...


'Units','normalized','Position',[0.8 0.7 0.2 .09]);

s3 = uicontrol('Style','slider','Callback', {@s3_callback},'FontSize',14,...
'Units','normalized','Position',[0.1 0.6 0.5 .08],'Max',10,...
'Min',0,'SliderStep',[0.01 0.10]);

sv3 = uicontrol(gcf,'Style','edit','FontSize',12,'String','',...
'Units','normalized','Position',[0.6 0.6 0.2 .09],'BackgroundColor','w');

sv3l = uicontrol(gcf,'Style','text','FontSize',12,'String','',...
'Units','normalized','Position',[0.8 0.6 0.2 .09]);

s4 = uicontrol('Style','slider','Callback', {@s4_callback},'FontSize',14,...
'Units','normalized','Position',[0.1 0.5 0.5 .08],'Max',1,...
'Min',0,'SliderStep',[0.01 0.10]);

sv4 = uicontrol(gcf,'Style','edit','FontSize',12,'String','',...
'Units','normalized','Position',[0.6 0.5 0.2 .09],'BackgroundColor','w');

sv4l = uicontrol(gcf,'Style','text','FontSize',12,'String','transp-cy',...
'Units','normalized','Position',[0.8 0.5 0.2 .09]);

s5 = uicontrol('Style','slider','Callback', {@s5_callback},'FontSize',14,...
'Units','normalized','Position',[0.1 0.4 0.5 .08],'Max',10,...
'Min',0,'SliderStep',[0.01 0.10]);

sv5 = uicontrol(gcf,'Style','edit','FontSize',12,'String','',...
'Units','normalized','Position',[0.6 0.4 0.2 .09],'BackgroundColor','w');

sv5l = uicontrol(gcf,'Style','text','FontSize',12,'String','light int',...


'Units','normalized','Position',[0.8 0.4 0.2 .09]);

s6 = uicontrol('Style','slider','Callback', {@s6_callback},'FontSize',14,...
Dipak Vinayak Shirbhate and Dilip Sahebrao Ingole VSRDIJMCAPE, Vol. VII (IX) September 2017 / 245

'Units','normalized','Position',[0.1 0.3 0.5 .08],'Max',10,...


'Min',0,'SliderStep',[0.01 0.10]);

sv6 = uicontrol(gcf,'Style','edit','FontSize',12,'String','',...
'Units','normalized','Position',[0.6 0.3 0.2 .09],'BackgroundColor','w');

sv6l = uicontrol(gcf,'Style','text','FontSize',12,'String','sun int',...


'Units','normalized','Position',[0.8 0.3 0.2 .09]);

start_wrl = uicontrol('String','start','Callback',
{@start_wrl_callback},'FontSize',14,...
'Units','normalized','Position',[0.1 0.18 0.15 .1]);

stop_wrl = uicontrol('String','stop','Callback',
{@stop_wrl_callback},'FontSize',14,...
'Units','normalized','Position',[0.1 0.06 0.15 .1]);

light_wrl = uicontrol('String','light','Callback',
{@light_wrl_callback},'FontSize',14,...
'Units','normalized','Position',[0.3 0.18 0.15 .1]);

hlight_wrl = uicontrol('String','hlight','Callback',
{@hlight_wrl_callback},'FontSize',14,...
'Units','normalized','Position',[0.3 0.06 0.15 .1]);

t = timer('period',0.02);
set(t,'ExecutionMode','fixedrate','StartDelay',0.5);
set(t,'timerfcn',@mytimer_callback);
% start(t);

myw = vrworld('HELICAL GEAR .wrl');


open(myw)
f = vrfigure(myw);

tg41 = vrnode(myw,'group04-TIMER');
tg51 = vrnode(myw,'group05-TIMER');

light1 = vrnode(myw,'Light');
sun1 = vrnode(myw,'sun');

axis off;

% [X> B^ W H]
function s1_callback(hObject,eventdata)

T1=get(s1,'value');
set(sv1,'string',15-T1)
tg51.cycleInterval = T1;

end
function s2_callback(hObject,eventdata)

T1=get(s2,'value');
set(sv2,'string',15-T1)
tg41.cycleInterval = T1;
% myw = vrworld('HELICAL GEAR .wrl');
% open(myw)
% view(myw)
Dipak Vinayak Shirbhate and Dilip Sahebrao Ingole VSRDIJMCAPE, Vol. VII (IX) September 2017 / 246

end
function s3_callback(hObject,eventdata)

T1=get(s3,'value');
set(sv3,'string',T1)
% myw = vrworld('HELICAL GEAR .wrl');
% open(myw)
% view(myw)
end

function s4_callback(hObject,eventdata)

T1=get(s4,'value');
set(sv4,'string',T1)

myw.VIFS476.children.appearance.material.transparency=T1

end
function s5_callback(hObject,eventdata)

T1=get(s5,'value');
set(sv5,'string',T1)
light1.intensity = T1;

end

function s6_callback(hObject,eventdata)

T1=get(s6,'value');
set(sv6,'string',T1)
sun1.intensity = T1;
% myw = vrworld('HELICAL GEAR .wrl');
% open(myw)
% view(myw)
end

function start_wrl_callback(hObject,eventdata)

start(t);

end
function stop_wrl_callback(hObject,eventdata)

stop(t);

end
function light_wrl_callback(hObject,eventdata)

if (flg_light == 0)
set(f,'Lighting','off')
flg_light = 1 ;
else
set(f,'Lighting','on')
flg_light = 0 ;
end

end
function hlight_wrl_callback(hObject,eventdata)
Dipak Vinayak Shirbhate and Dilip Sahebrao Ingole VSRDIJMCAPE, Vol. VII (IX) September 2017 / 247

if (flg_hlight == 0)
set(f,'Headlight','off')
flg_hlight = 1 ;
else
set(f,'Headlight','on')
flg_hlight = 0 ;
end

%%

end

function mytimer_callback(hObject,eventdata)

tv1 = tv1 + 0.01 ;


set(myw,'Time', tv1);
% vrdrawnow;

end
%%
function my_closereq(hObject,eventdata)
delete(timerfind)
close(myw);
delete(myw);
delete(gcf);
end
end

7. GRAPHICAL USER INTERFACE


A Graphical User Interface (GUI) is made to create an easy way to set simulation parameters. In this GUI the user can
select which parameter is to be simulated. In the GUI the user can choose following parameters

(1) Speed (w1), (2) Speed (w2) (3) Transparency (4) Light Intensity (5) Sun Light Intensity
Fig 3. Graphic user interface 1 to control VRML helical gears model parameters using Simulink
Dipak Vinayak Shirbhate and Dilip Sahebrao Ingole VSRDIJMCAPE, Vol. VII (IX) September 2017 / 248

8. GRAPHIC USER INTERFACE 2 (GUI2)


The entire MATLAB code to control Grain cleaning system parameters is as follows :

Fig 4. Graphic user interface 2 to control VRML grain cleaning system parameters using Simulink

function gui2()
clc
global tv1 ;
tv1 = 0 ;

global flg_light ;
flg_light = 0 ;

global flg_hlight ;
flg_hlight = 0 ;
Dipak Vinayak Shirbhate and Dilip Sahebrao Ingole VSRDIJMCAPE, Vol. VII (IX) September 2017 / 249

hFig = figure('Toolbar','none','Menubar', 'none',...


'Name','gui1','Resize','off','CloseRequestFcn',{@my_closereq},...
'Position',[800 400 400 300],'Color',[0.6 0.6 0.6]);

s1 = uicontrol('Style','slider','Callback', {@s1_callback},'FontSize',14,...
'Units','normalized','Position',[0.1 0.8 0.5 .08],'Max',10,...
'Min',0,'SliderStep',[0.01 0.10]);

sv1 = uicontrol(gcf,'Style','edit','FontSize',12,'String','',...
'Units','normalized','Position',[0.6 0.8 0.2 .09],'BackgroundColor','w');

sv1l = uicontrol(gcf,'Style','text','FontSize',12,'String','speed',...
'Units','normalized','Position',[0.8 0.8 0.2 .09]);

s2 = uicontrol('Style','slider','Callback', {@s2_callback},'FontSize',14,...
'Units','normalized','Position',[0.1 0.7 0.5 .08],'Max',10,...
'Min',0,'SliderStep',[0.01 0.10]);

sv2 = uicontrol(gcf,'Style','edit','FontSize',12,'String','',...
'Units','normalized','Position',[0.6 0.7 0.2 .09],'BackgroundColor','w');

sv2l = uicontrol(gcf,'Style','text','FontSize',12,'String','',...
'Units','normalized','Position',[0.8 0.7 0.2 .09]);

s3 = uicontrol('Style','slider','Callback', {@s3_callback},'FontSize',14,...
'Units','normalized','Position',[0.1 0.6 0.5 .08],'Max',10,...
'Min',0,'SliderStep',[0.01 0.10]);

sv3 = uicontrol(gcf,'Style','edit','FontSize',12,'String','',...
'Units','normalized','Position',[0.6 0.6 0.2 .09],'BackgroundColor','w');

sv3l = uicontrol(gcf,'Style','text','FontSize',12,'String','',...
'Units','normalized','Position',[0.8 0.6 0.2 .09]);

s4 = uicontrol('Style','slider','Callback', {@s4_callback},'FontSize',14,...
'Units','normalized','Position',[0.1 0.5 0.5 .08],'Max',1,...
'Min',0,'SliderStep',[0.01 0.10]);

sv4 = uicontrol(gcf,'Style','edit','FontSize',12,'String','',...
'Units','normalized','Position',[0.6 0.5 0.2 .09],'BackgroundColor','w');

sv4l = uicontrol(gcf,'Style','text','FontSize',12,'String','transp-cy',...
'Units','normalized','Position',[0.8 0.5 0.2 .09]);

s5 = uicontrol('Style','slider','Callback', {@s5_callback},'FontSize',14,...
'Units','normalized','Position',[0.1 0.4 0.5 .08],'Max',10,...
'Min',0,'SliderStep',[0.01 0.10]);

sv5 = uicontrol(gcf,'Style','edit','FontSize',12,'String','',...
'Units','normalized','Position',[0.6 0.4 0.2 .09],'BackgroundColor','w');

sv5l = uicontrol(gcf,'Style','text','FontSize',12,'String','light int',...


'Units','normalized','Position',[0.8 0.4 0.2 .09]);

s6 = uicontrol('Style','slider','Callback', {@s6_callback},'FontSize',14,...
'Units','normalized','Position',[0.1 0.3 0.5 .08],'Max',10,...
'Min',0,'SliderStep',[0.01 0.10]);

sv6 = uicontrol(gcf,'Style','edit','FontSize',12,'String','',...
Dipak Vinayak Shirbhate and Dilip Sahebrao Ingole VSRDIJMCAPE, Vol. VII (IX) September 2017 / 250

'Units','normalized','Position',[0.6 0.3 0.2 .09],'BackgroundColor','w');

sv6l = uicontrol(gcf,'Style','text','FontSize',12,'String','sun int',...


'Units','normalized','Position',[0.8 0.3 0.2 .09]);

start_wrl = uicontrol('String','start','Callback',
{@start_wrl_callback},'FontSize',14,...
'Units','normalized','Position',[0.1 0.18 0.15 .1]);

stop_wrl = uicontrol('String','stop','Callback',
{@stop_wrl_callback},'FontSize',14,...
'Units','normalized','Position',[0.1 0.06 0.15 .1]);

light_wrl = uicontrol('String','light','Callback',
{@light_wrl_callback},'FontSize',14,...
'Units','normalized','Position',[0.3 0.18 0.15 .1]);

hlight_wrl = uicontrol('String','hlight','Callback',
{@hlight_wrl_callback},'FontSize',14,...
'Units','normalized','Position',[0.3 0.06 0.15 .1]);

t = timer('period',0.02);
set(t,'ExecutionMode','fixedrate','StartDelay',0.5);
set(t,'timerfcn',@mytimer_callback);
% start(t);

myw = vrworld('FC1.wrl');
% myw = vrworld('HELICAL GEAR .wrl');

open(myw)
f = vrfigure(myw);

% tg41 = vrnode(myw,'group04-TIMER');
% tg51 = vrnode(myw,'group05-TIMER');

light1 = vrnode(myw,'light');
sun1 = vrnode(myw,'sun');

axis off;

% [X> B^ W H]
function s1_callback(hObject,eventdata)

T1=get(s1,'value');
set(sv1,'string',T1)
tg41.cycleInterval = T1;

end
function s2_callback(hObject,eventdata)

T1=get(s2,'value');
set(sv2,'string',T1)
tg51.cycleInterval = T1;

end
function s3_callback(hObject,eventdata)
Dipak Vinayak Shirbhate and Dilip Sahebrao Ingole VSRDIJMCAPE, Vol. VII (IX) September 2017 / 251

T1=get(s3,'value');
set(sv3,'string',T1)

end

function s4_callback(hObject,eventdata)

T1=get(s4,'value');
set(sv4,'string',T1)
myw.Elev_box_01.children.appearance.material.transparency=T1;
myw.Elev_box_0.children.appearance.material.transparency=T1;
myw.Elev_box.children.appearance.material.transparency=T1;

end
function s5_callback(hObject,eventdata)

T1=get(s5,'value');
set(sv5,'string',T1)
light1.intensity = T1;

end

function s6_callback(hObject,eventdata)

T1=get(s6,'value');
set(sv6,'string',T1)
sun1.intensity = T1;

end

function start_wrl_callback(hObject,eventdata)

start(t);

end
function stop_wrl_callback(hObject,eventdata)

stop(t);

end
function light_wrl_callback(hObject,eventdata)

if (flg_light == 0)
set(f,'Lighting','off')
flg_light = 1 ;
else
set(f,'Lighting','on')
flg_light = 0 ;
end

end
function hlight_wrl_callback(hObject,eventdata)

if (flg_hlight == 0)
set(f,'Headlight','off')
flg_hlight = 1 ;
else
set(f,'Headlight','on')
flg_hlight = 0 ;
Dipak Vinayak Shirbhate and Dilip Sahebrao Ingole VSRDIJMCAPE, Vol. VII (IX) September 2017 / 252

end

%%

end

function mytimer_callback(hObject,eventdata)

tv1 = tv1 + 0.01 ;


set(myw,'Time', tv1);
% vrdrawnow;

end
%%
function my_closereq(hObject,eventdata)
delete(timerfind)
close(myw);
delete(myw);
delete(gcf);
end
end

9. GRAPHIC USER INTERFACE 3 (GUI3)


The entire MATLAB code to control Grain cleaning system parameters is as follows:

Fig 5. Graphic user interface 3 to control VRML grain cleaning system parameters using Simulink (with GUI
extended to control color RGB values)
Dipak Vinayak Shirbhate and Dilip Sahebrao Ingole VSRDIJMCAPE, Vol. VII (IX) September 2017 / 253

function gui3()
clc
global tv1 ;
tv1 = 0 ;

global flg_light ;
flg_light = 0 ;

global flg_hlight ;
flg_hlight = 0 ;

global a11;
global b11;

hFig = figure('Toolbar','none','Menubar', 'none',...


'Name','gui1','Resize','off','CloseRequestFcn',{@my_closereq},...
'Position',[750 40 400 300],'Color',[0.6 0.6 0.6]);

s0 = uicontrol('Style','slider','Callback', {@s0_callback},'FontSize',14,...
'Units','normalized','Position',[0.1 0.9 0.5 .08],'Max',10,...
'Min',0,'SliderStep',[0.01 0.10]);

sv0 = uicontrol(gcf,'Style','edit','FontSize',12,'String','',...
'Units','normalized','Position',[0.6 0.9 0.2 .09],'BackgroundColor','w');

sv00 = uicontrol(gcf,'Style','text','FontSize',12,'String','speed',...
'Units','normalized','Position',[0.8 0.9 0.2 .09]);

s1 = uicontrol('Style','slider','Callback', {@s1_callback},'FontSize',14,...
'Units','normalized','Position',[0.1 0.8 0.5 .08],'Max',10,...
'Min',0,'SliderStep',[0.01 0.10]);

sv1 = uicontrol(gcf,'Style','edit','FontSize',12,'String','',...
'Units','normalized','Position',[0.6 0.8 0.2 .09],'BackgroundColor','w');

sv1l = uicontrol(gcf,'Style','text','FontSize',10,'String','S01-TIMER',...
'Units','normalized','Position',[0.8 0.8 0.2 .09]);
Dipak Vinayak Shirbhate and Dilip Sahebrao Ingole VSRDIJMCAPE, Vol. VII (IX) September 2017 / 254

s2 = uicontrol('Style','slider','Callback', {@s2_callback},'FontSize',14,...
'Units','normalized','Position',[0.1 0.7 0.5 .08],'Max',10,...
'Min',0,'SliderStep',[0.01 0.10]);

sv2 = uicontrol(gcf,'Style','edit','FontSize',12,'String','',...
'Units','normalized','Position',[0.6 0.7 0.2 .09],'BackgroundColor','w');

sv2l = uicontrol(gcf,'Style','text','FontSize',10,'String','Dis01-TIMER',...
'Units','normalized','Position',[0.8 0.7 0.2 .09]);

s3 = uicontrol('Style','slider','Callback', {@s3_callback},'FontSize',14,...
'Units','normalized','Position',[0.1 0.6 0.5 .08],'Max',10,...
'Min',0,'SliderStep',[0.01 0.10]);

sv3 = uicontrol(gcf,'Style','edit','FontSize',12,'String','',...
'Units','normalized','Position',[0.6 0.6 0.2 .09],'BackgroundColor','w');

sv3l = uicontrol(gcf,'Style','text','FontSize',10,'String','belt-TIMER',...
'Units','normalized','Position',[0.8 0.6 0.2 .09]);

s4 = uicontrol('Style','slider','Callback', {@s4_callback},'FontSize',14,...
'Units','normalized','Position',[0.1 0.5 0.5 .08],'Max',1,...
'Min',0,'SliderStep',[0.01 0.10]);

sv4 = uicontrol(gcf,'Style','edit','FontSize',12,'String','',...
'Units','normalized','Position',[0.6 0.5 0.2 .09],'BackgroundColor','w');

sv4l = uicontrol(gcf,'Style','text','FontSize',12,'String','transp-cy',...
'Units','normalized','Position',[0.8 0.5 0.2 .09]);

s5 = uicontrol('Style','slider','Callback', {@s5_callback},'FontSize',14,...
'Units','normalized','Position',[0.1 0.4 0.5 .08],'Max',10,...
'Min',0,'SliderStep',[0.01 0.10]);

sv5 = uicontrol(gcf,'Style','edit','FontSize',12,'String','',...
'Units','normalized','Position',[0.6 0.4 0.2 .09],'BackgroundColor','w');

sv5l = uicontrol(gcf,'Style','text','FontSize',12,'String','light int',...


'Units','normalized','Position',[0.8 0.4 0.2 .09]);

s6 = uicontrol('Style','slider','Callback', {@s6_callback},'FontSize',14,...
'Units','normalized','Position',[0.1 0.3 0.5 .08],'Max',10,...
'Min',0,'SliderStep',[0.01 0.10]);

sv6 = uicontrol(gcf,'Style','edit','FontSize',12,'String','',...
'Units','normalized','Position',[0.6 0.3 0.2 .09],'BackgroundColor','w');

sv6l = uicontrol(gcf,'Style','text','FontSize',12,'String','sun int',...


'Units','normalized','Position',[0.8 0.3 0.2 .09]);

start_wrl = uicontrol('String','start','Callback',
{@start_wrl_callback},'FontSize',14,...
'Units','normalized','Position',[0.1 0.18 0.15 .1]);

stop_wrl = uicontrol('String','stop','Callback',
{@stop_wrl_callback},'FontSize',14,...
'Units','normalized','Position',[0.1 0.06 0.15 .1]);
Dipak Vinayak Shirbhate and Dilip Sahebrao Ingole VSRDIJMCAPE, Vol. VII (IX) September 2017 / 255

light_wrl = uicontrol('String','light','Callback',
{@light_wrl_callback},'FontSize',14,...
'Units','normalized','Position',[0.3 0.18 0.15 .1]);

hlight_wrl = uicontrol('String','hlight','Callback',
{@hlight_wrl_callback},'FontSize',14,...
'Units','normalized','Position',[0.3 0.06 0.15 .1]);

r1 = uicontrol('Style','slider','Callback', {@rgb_callback},'FontSize',14,...
'Units','normalized','Position',[0.6 0.2 0.4 .08],'Max',1,...
'Min',0,'SliderStep',[0.01 0.10]);

r1l = uicontrol(gcf,'Style','text','FontSize',12,'String','R',...
'Units','normalized','Position',[0.53 0.215 0.06 .06]);

g1 = uicontrol('Style','slider','Callback', {@rgb_callback},'FontSize',14,...
'Units','normalized','Position',[0.6 0.11 0.4 .08],'Max',1,...
'Min',0,'SliderStep',[0.01 0.10]);
g1l = uicontrol(gcf,'Style','text','FontSize',12,'String','G',...
'Units','normalized','Position',[0.53 0.118 0.06 .06]);

b1 = uicontrol('Style','slider','Callback', {@rgb_callback},'FontSize',14,...
'Units','normalized','Position',[0.6 0.01 0.4 .08],'Max',1,...
'Min',0,'SliderStep',[0.01 0.10]);
b1l = uicontrol(gcf,'Style','text','FontSize',12,'String','B',...
'Units','normalized','Position',[0.53 0.018 0.06 .06]);

t = timer('period',0.02);
set(t,'ExecutionMode','fixedrate','StartDelay',0.5);
set(t,'timerfcn',@mytimer_callback);
% start(t);
flg=1;
if (flg==1)

myw = vrworld('FF1.wrl');
% myw = vrworld('HELICAL GEAR .wrl');

open(myw)
f = vrfigure(myw);

tg1 = vrnode(myw,'Seprator01-TIMER');
tg2 = vrnode(myw,'Distoner01-TIMER');
tg3 = vrnode(myw,'belt_conveyer-TIMER');
tg4 = vrnode(myw,'belt_conveyer_0-TIMER');

% Seprator01-TIMER (TimeSensor) []
% Distoner01-TIMER (TimeSensor) []
% belt_conveyer-TIMER (TimeSensor) []
% belt_conveyer_0-TIMER (Transform) []

light1 = vrnode(myw,'light');
sun1 = vrnode(myw,'sun');

t2=vrnode(myw,'Layer:BRUSH');
r4=t2.children;
q11=r4(1,2).appearance(1,1);
a11=q11.material(1,1);
Dipak Vinayak Shirbhate and Dilip Sahebrao Ingole VSRDIJMCAPE, Vol. VII (IX) September 2017 / 256

% a11(1,1).transparency=0.8
% a11(1,1).transparency=0.0
w2=vrnode(myw,'machine');
ww4=w2.children;
we=ww4(1,1).appearance(1,1);
b11=we.material(1,1);
% b11(1,1).transparency=0.1
end
axis off;

% [X> B^ W H]

function s0_callback(hObject,eventdata)

T1=get(s0,'value');
set(sv0,'string',T1)
tg1.cycleInterval = T1;

end

function s1_callback(hObject,eventdata)

T1=get(s1,'value');
set(sv1,'string',T1)
tg2.cycleInterval = T1;

end
function s2_callback(hObject,eventdata)

T1=get(s2,'value');
set(sv2,'string',T1)
tg3.cycleInterval = T1;

end
function s3_callback(hObject,eventdata)

T1=get(s3,'value');
set(sv3,'string',T1)
tg4.cycleInterval = T1;

end

function s4_callback(hObject,eventdata)

T1=get(s4,'value');
set(sv4,'string',T1)
% myw.Elev_box_01.children.appearance.material.transparency=T1;

sa1=vrnode(myw,'Elev_box_01');
sa2=sa1.children;
sa3=sa2(1,1).appearance(1,1);
sa4=sa3.material(1,1);
sa4(1,1).transparency=T1;

sa1=vrnode(myw,'Elev_box_0');
sa2=sa1.children;
sa3=sa2(1,1).appearance(1,1);
sa4=sa3.material(1,1);
Dipak Vinayak Shirbhate and Dilip Sahebrao Ingole VSRDIJMCAPE, Vol. VII (IX) September 2017 / 257

sa4(1,1).transparency=T1;

sa1=vrnode(myw,'Elev_box');
sa2=sa1.children;
sa3=sa2(1,1).appearance(1,1);
sa4=sa3.material(1,1);
sa4(1,1).transparency=T1;

% myw.Elev_box_0.children.appearance.material.transparency=T1;
% myw.Elev_box.children.appearance.material.transparency=T1;

a11(1,1).transparency=T1;
b11(1,1).transparency=T1;

end
function s5_callback(hObject,eventdata)

T1=get(s5,'value');
set(sv5,'string',T1)
light1.intensity = T1;

end

function s6_callback(hObject,eventdata)

T1=get(s6,'value');
set(sv6,'string',T1)
sun1.intensity = T1;

end

function start_wrl_callback(hObject,eventdata)

start(t);

end
function stop_wrl_callback(hObject,eventdata)

stop(t);

end
function light_wrl_callback(hObject,eventdata)

if (flg_light == 0)
set(f,'Lighting','off')
flg_light = 1 ;
else
set(f,'Lighting','on')
flg_light = 0 ;
end

end
function hlight_wrl_callback(hObject,eventdata)

if (flg_hlight == 0)
set(f,'Headlight','off')
flg_hlight = 1 ;
else
set(f,'Headlight','on')
flg_hlight = 0 ;
Dipak Vinayak Shirbhate and Dilip Sahebrao Ingole VSRDIJMCAPE, Vol. VII (IX) September 2017 / 258

end

end

function mytimer_callback(hObject,eventdata)

tv1 = tv1 + 0.01 ;


set(myw,'Time', tv1);
% vrdrawnow;

end

function rgb_callback(hObject,eventdata)

r11=get(r1,'value');
g11=get(g1,'value');
b11=get(b1,'value');

a11(1,1).diffuseColor=[r11 g11 b11];

end

%%
function my_closereq(hObject,eventdata)
delete(timerfind)
if(flg==1)
close(myw);
% delete(myw);
end
delete(gcf);
end
end

10.CONCLUSION AND FUTURE WORK


The GUI developed with Matlab’s Simulink controlled following parameters of VR world
 Light intensity
 Speed of rotation
 Color
 Transparency
 Sun Light Intensity

In future rotation of objects (about X, Y and Z axis) and their relative positions can be controlled if required. A GUI can
be developed to control complex VRML world objects build by calling objects sequentially in a scene.

11.REFERENCES
[1] Virtual Reality tool box for use with for Use with MATLAB® and Simulink® developed by Math Work User’s Guide Version 4
[2] Virtual Laboratories Using Simulink: A Pilot Study by Dr. Mark David Bedillion, South Dakota School of Mines and Technology
and Mr. Mohamed Hakeem Mohamed Nizar, South Dakota School of Mines & Technology: Department of Mechanical
Engineering, 122nd ASEE Annual Conference and Exposition, June 14-17, 2015
[3] Using DIS (Distributed Interactive Simulation) for linking Simulation and Animation in Simulink and VRML


Você também pode gostar