Graphics in Julia: Difference between revisions

Created page with "A guide on making graphics visualizations in Julia ===MeshCat=== MeshCat is a Julia wrapper around three.js. It creates its own server and opens a webpage to access the serve..."
 
No edit summary
Line 2: Line 2:


===MeshCat===
===MeshCat===
MeshCat is a Julia wrapper around three.js. It creates its own server and opens a webpage to access the server.
MeshCat.jl is a Julia wrapper around three.js. It creates its own server and opens a webpage to access the server.




Line 11: Line 11:


===Geometry===
===Geometry===
MeshCat.jl and GeometryTypes.jl both come with a variety of basic geometries such as <code>HyperRectangle</code> and <code>PointCloud</code>.<br>
You can also create your own geometry by calling the HomogenousMesh function with your own vertices, normals, triangles/faces, and uvs/texturecoordinates.<br>
====Creating Geometry====
Example of how to create a quad:
<syntaxhighlight lang="julia>
<syntaxhighlight lang="julia>
using GeometryTypes
using GeometryTypes
Line 35: Line 40:
# Set the position
# Set the position
settransform!(vis["myquad"], Translation(0.5, -0.5, 0.5))
settransform!(vis["myquad"], Translation(0.5, -0.5, 0.5))
</syntaxhighlight>
====Loading Geometry====
<syntaxhighlight lang="julia>
using GeometryTypes: GLUVMesh # we need a mesh type that stores texture coordinates
image = PngImage(joinpath(@__DIR__, "..", "data", "HeadTextureMultisense.png"))
texture = Texture(image=image)
material = MeshLambertMaterial(map=texture)
geometry = load(joinpath(MeshCat.VIEWER_ROOT, "..", "data", "head_multisense.obj"), GLUVMesh)
setobject!(vis["robots", "valkyrie", "head"], geometry, material)
settransform!(vis["robots", "valkyrie"], Translation(0.5, -0.5, 0.5))
</syntaxhighlight>
</syntaxhighlight>