Skip to content
Switch branches/tags
Go to file
Cannot retrieve contributors at this time
type title order
Geometry basics

What is Geometry?

Geometry defines shape of a mesh. To render a mesh, Grimoire require Geometry and Material for each meshes. All vertices in a geometry have vertex attribute variables for each.

For example, if there was 3 vertices and constructing a triangle, 3 position parameters should be available for renderer. vertex attribute variable is not only limited position. Each vertices can have different normal or texture coordinate(A coordinate used for attaching texture).

Vertex attribute variables are not only element of a geometry. Geometry also should have index buffer. Index buffer is defining how to connect each vertices. The easist example is wireframe of a mesh. Renderer should connect 3 points and create a surface when render a mesh as a solid. But, renderer should connect 2 points and create lines for rendering wireframe.

(If you are really good graphics engineer, you might think that 'it is not index buffer, just a topology'. Yes, it is correct. But, in grimoire, "index buffer" is a buffer containing indices defining how to connect each vertices and topology.)

Let's use geometry.

<MeshRenderer> component which is typically contained in <mesh> node have geometry attribute.

<mesh geometry="cube" color="red"/>

You can change shape of meshes by changing geometry attribute. geometry attribute can accept this 2 types of variable.

  • name of geometry
  • geometry instance (from javascript only)

Understanding name of geometry

In tutorial, we didn't care about what geometry is available and how to register a geometry. Let's register some geometries in this section.

  <geometry type="sphere" name="sphere2" divVertical="10" divHorizontal="10"/>
    <mesh geometry="sphere2" color="red"/>

This example is defining a geometry named sphere2. sphere2 is divided 10 by 10.And mesh node refer the geometry.

<geometry> node is register a geometry from construction script. In the example, sphere2 is generated by sphere construction script with arguments divVertical and divHorizontal. In grimoire, there are several geometry construction script already and some of them can accept some arguments to generate various shapes. All arguments should have default values.

This is a list of geometry construction scripts initially implemented.


A simple quad. Only have single surface. If you see this geometry from backward, this object is invisible(If and only culling are enabled).

This construction script is not receiving any arguments.


A simple cube.

This construction script is not receiving any arguments.


A sphere.


  • divHorizontal(Number) ・・・ How many times should the sphere be divided in horizontal direction.(default:50)
  • divVertical(Number) ・・・ How many times should the sphere be divided in vertical direction.(default:50)


A cylinder.


  • divide(Number)・・・How many times should the cylinder be divided in horizontal direction.(default:50)


A cone.


  • divide(Number)・・・How many times should the cylinder be divided in horizontal direction.(default:50)


A plane same as unity.


  • divide(Number)・・・Division count of plane(default:10)

Default registered geometries

Several geometries are already instanciated and registered. Therefore, you didn't need to use geometry tag to use cube. This is a list of geometries registered initially.

  • quad
  • cube
  • sphere

If you need the geometries above, you don't need to regieter. These are always registered in first initialization timing. If you need to rewrite default sphere division parameters, you just need to add geometry tag to register a geometry named sphere. If there was a geometry have same name, grimoire would just simply overwrite last one.

Custom geometries

If you need to create a custom geometries. The easist way is using model file. Model file should contain geometry data and material data. Several file format are supported by grimoire plugins.

But, if you need to create construction script for geometry, grimoire also have great feature to support this needs. To create your own geometry from program, please see Custom geometry(WIP) for more details.