This PDF describes code for displaying jzy3d OpenGL-based 3D graphics in MATLAB. Jzy3d is an open-source 3D graphics library. See http://www.jzy3d.org/
Code to run these demos is available as a Java jar file at
http://sourceforge.net/projects/waterloo/files/
(N.B. All dependencies are either distributed as standard with MATLAB or included in this jar).
jzy3d uses the JOGL Java bindings to the OpenGL API to generate 3D graphics in Java. These graphics are easily generated in MATLAB and can readily be added to MATLAB figures. For the sphere in the illustration:
>> import kcl.waterloo.graphics3D.jzy3d.Factory.*
>> [x,y,z]=sphere(32);
>> gr=createSurface(x,y,z);
>> f = figure;
>> [comp, container] = javacomponent(gr);
>> set(container,'Units', 'normalized','Position', [0 0 1 1]);
Malcolm Lidierth (2021). OpenGL 3D graphics in MATLAB using jzy3d - a demo (https://www.mathworks.com/matlabcentral/fileexchange/35026-opengl-3d-graphics-in-matlab-using-jzy3d-a-demo), MATLAB Central File Exchange. Retrieved .
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Create scripts with code, output, and formatted text in a single executable document.
@Jan
You need to add 'waterloo-jzy3d-demo.jar' using javaaddpath, not jzy3d.
But,
I do not know if this will work with the related jars shipped with R2013a and on the static path. It does not with R2013b. It does on a Mac with R2010a.
You may need to edit and recompile the source code to work with the shipped versions of other jars. The source code is at
http://sourceforge.net/projects/waterloo/files/Waterloo%20jzy3d%20in%20MATLAB%20Demo/
This was posted simply as an illustration/experiment in using jzy3d (which has also developed a lot since I posted it). It was never intended for serious use, and as each of JOGL/jzy3d/MATLAB are changing I have not kept to up-to-date.
Hi,
I tried to execute it, but failed. My machine runs on MacOsX 10.7.5 and MATLAB 2013a.
I downloaded all files:
gluegen-rt.jar
jogl.jar
jzy3d-api-0.9.1.jar
libgluegen-rt.jnilib
libjogl.jnilib
libjogl_awt.jnilib
libjogl_cg.jnilib
opencsv-2.1.jar
org.convexhull.jar
org.jzy3d-0.8.4.jar
swt-debug.jar
swt.jar
and typed the following commands:
javaaddpath('org.jzy3d-0.8.4.jar');
import kcl.waterloo.graphics3D.jzy3d.Factory.*
No error until here. But createMesh and createSurface can not be found:
gr=createMesh(Z);
Undefined function 'createMesh' for input arguments of type 'double'.
I would be very grateful to get a hint what I am doing wrong.
Best, Jan
Hi,
I'm trying to learn Waterloo and jzy3d for Matlab.
Do you have code for the demo .jar?
It would help a lot, thanks.
I've posted on the sf forum as well.
Ivan