X3d-nodes-to-pascal on windows?

I want to add topradius and top to the tcastlecone. This looked simple enough, but it uses the TConeNode which is generated by x3d-nodes-to-pascal. I tried to make a bat from the sh script, but the run fails whether I use \ or / paths at generateprocessors.pas line 961 with EFOpenError when it tries to open the wildcard. How can I get this to run on windows? Thanks

  1. As for x3d-nodes-to-pascal:

    In general, you can run our shell scripts using Cygwin on Windows, see also our coding conventions, ā€œUse PowerShell (not BAT files) for Windows scripting; or, in many cases, use bash (from Cygwin or MSYS2)ā€, Coding Conventions | Manual | Castle Game Engine .

    But in this case, the simpler answer is: x3d-nodes-to-pascal should not really need a shell script, it can do everything from Pascal. Done, I removed run.sh there and committed a change to do everything from Pascal ā€“ so just running compiled x3d-nodes-to-pascal (from itā€™s own directory) will do everything it should.

    This is already committed to CGE GitHub master branch. If you use engine binary downloads from Download | Castle Game Engine (recommended), then please observe this page: Comparing snapshot...master Ā· castle-engine/castle-engine Ā· GitHub . When it will no longer show the commit ā€œMove 100% of x3d-nodes-to-pascal work into Pascal, no need for a shelā€¦ā€ then it means this commit is part of the downloads on Download | Castle Game Engine .

  2. Note in case of your modification:

    Better to modify Cylinder X3D node, not Cone. This seems more natural, if you want to also tweak the top radius freely ā€“ the result is no longer a ā€œcut coneā€.

    You want to modify the TCylinderNode.Proxy. It calls CylinderCone_Proxy which already can generate a cylinder with different bottom and top radius (the same routine is used for cone, when top radius is 0).

    It is now used like this:

    CylinderCone_Proxy(IFS.FdCoordIndex.Items,
      CoordNode.FdPoint.Items, NormalNode.FdVector.Items, TexCoords, nil,
      FdRadius.Value, FdRadius.Value, FdHeight.Value,
      FdBottom.Value, FdSide.Value, FdTop.Value,
      CalculateSlices, CalculateStack);
    

    Note that we pass there FdRadius.Value 2 times, for bottom and top radiuses, now.

    I think you can achieve what you need by just exposing a new SFFloat topRadius field on the cylinder X3D node. When 0 (default) ā†’ the top radius should be equal to bottom radius, so itā€™s a regular cylinder.

    The CylinderCone_Proxy should use it then, like

    FinalBottomRadius := Radius;
    FinalTopRadius := TopRadius;
    if FinalTopRadius <= 0 then
      FinalTopRadius := FinalBottomRadius;
    CylinderCone_Proxy(IFS.FdCoordIndex.Items,
      CoordNode.FdPoint.Items, NormalNode.FdVector.Items, TexCoords, nil,
      FinalBottomRadius, FinalTopRadius, FdHeight.Value,
      FdBottom.Value, FdSide.Value, FdTop.Value,
      CalculateSlices, CalculateStack);
    

    Note that above I just write Radius instead of FdRadius.Value, most such field access can be simplified now.

    Then TCastleCylinder could use it, exposing TopRadius: Single property.

You are a hero. Thanks.

1 Like

It seemed like adding this to the cylinder resisted my efforts. I have top radius working on the cone. It makes my procedural trees a more natural looking to have taper. The actual class used is abstracted away, so if you want to add this to the cylinder, it will be easy for me to change. I donā€™t want to have to maintain my own changes to cge so am hoping you will add this in a future release. Ideally you would expose all features offered for a shape. For example controlling stacks and slices would help me control level of detail.
Thanks again for all you do.

They arenā€™t very natural yetā€¦ but all the elements are working together. I have to set more realistic parameters, but these are for testing, so I can see ā€˜nucklesā€™ between the segments.

Sorry for long silence!

  • Iā€™ll see to expose the TopRadius at TCylinderNode.

  • As for exposing stacks and slices: they should be already exposed in both TCylinderNode and TConeNode. Or do you need them to be exposed also at TCastleCylinder and TCastleCone? It would make sense, and also something I could do :slight_smile:

Iā€™ll get back to this and post here :slight_smile: