I have a quick question before I commit to a major learning curve on this library. I wish to do a more realistic render (maybe at least 60-80% of Blender’s quality) to render objects.
Can I know is it possible to create the 3D objects totally from code? These are mainly simple cuboids (some with one open face and hollow inside) or cylinders with one end open (and hollow inside). I want to create these objects totally from code,
and then apply a texture to it from code too, and also lighting from code.
In other words, I want to skip the CGE studio, and just be able to do this from Delphi pascal code entirely. Is it possible?
If someone happens to have a small code sample to share, would deeply appreciate it. I’ll be using Delphi 12 with FMX.
PS: the \examples\viewport_and_scenes\build_3d_object_by_code\ is missing the *_standalone.dpr files
You can build everything in code. You can use the CGE geometric primitives or go below them to to build x3d nodes. Then you use TTriangleSetNode or TIndexedSetNode or TTriangleStripNode or TIndexedTriangleStripNode or other primitives. You add a TPhysicalMaterialNode to the set properties like the texture and shininess. And then can load your your model into a TCastleScene. Blender has more material properties, but you should still be able to get results that meets your goal.
I find it helpful to made a ‘builder’ class that will build the rootnode for the x3dscene and encapsulate complexities.
Look for my icosphere code on the CGE site. It is an example of building this way.
ok thanks so much. will digest it. I’m new to 3D, so many terms are really alien. hoping to find a really simple example on how to build a cube or rectangular block (with a hollow) to start with.
I will still absolutely recommend to go through the manual and use CGE editor, play with it, design some 3D stuff there If you really need to use X3D nodes, then also see about writing your own X3D files, you can load them into TCastleScene (see docs above). In most practical cases, you want to do some stuff from code, but still some stuff in the editor, so combine their strengths And even for cases when you really need to generate something from code, it is often nice to experiment first – before writing Pascal code, it’s often nice to first play with components in CGE editor or X3D nodes in X3D files, and see can you “do by hand” the thing that you will later want to automate.
Geometry3D component | Castle Game Engine Section 3 is the example code I found simplest starting point to figuring out how build x3d scenes. A box with faces and a texture.
From that face demo, I got to here with my parametric buildings in about 1.5 years (after implementing drawable roads, flowing water and growing trees). This building made of 4 ‘blocks’ is all built in code into one scene using the x3d nodes. I plan to then have each face be able to be built with varying level of paramtric detail (this would be the lowest).