Extensions introduced in Castle Game Engine related to 3D geometry.
See also documentaton of supported nodes of the Geometry3D component and X3D specification of the Geometry3D component.
Contents:
Sphere
, Cone
, Cylinder
, Box
, Circle2D
)
![]() |
We add some fields to primitive geometry nodes to control their triangulation:
Box { ... SFInt32 [in,out] divisions -1 # [-1, infinity) }
Cone { ... SFInt32 [in,out] slices -1 # {-1} + [3, infinity) SFInt32 [in,out] stacks -1 # {-1} + [2, infinity) }
Cylinder { ... SFInt32 [in,out] slices -1 # {-1} + [3, infinity) SFInt32 [in,out] stacks -1 # {-1} + [2, infinity) }
Sphere { ... SFInt32 [in,out] slices -1 # {-1} + [3, infinity) SFInt32 [in,out] stacks -1 # {-1} + [2, infinity) }
Circle2D { ... SFInt32 [in,out] slices -1 # {-1} + [3, infinity) }
For spheres, cones and cylinders you can set how many slices (like slices of a pizza) and how many stacks (like stacks of a tower) to create. For boxes, you can set how to triangulate faces of cubes.
You can easily test the effects of these fields
by investigating your models in view3dscene.
You can view in Wireframe mode to see the triangulation.
You can try it on our test file:
see our VRML/X3D demo models, file
x3d/castle_extensions/triangulation.x3dv
.
Note that our programs do two different variants of triangulation, and they automatically decide which variant to use in each case:
In this variant we do a little more triangulation. In particular, we divide cones and cylinders into stacks, and we divide cube faces. For collision detection, this additional triangulation is useless (as it doesn't give any better approximation of an object). But it improves how objects look with Gouraud shading.
Special value -1 for any of these fields means that we use some default, sensible value.
Generally, triangulate more if the object is large or you want to see light effects (like light spot) looking good. If the object is small you can triangulate less, to get better rendering time.
Box.ccw
)We add Box.ccw
field.
The default TRUE
means that box is visible only from the outside.
You can specify FALSE
to make it visible only from the inside.
Note that you can also use solid FALSE
to make it visible from both sides.
Box { ... SFBool [] ccw TRUE }
Copyright Michalis Kamburelis and Castle Game Engine Contributors.
This webpage is also open-source and we welcome pull requests to improve it.
We use cookies for analytics. See our privacy policy.