#2033 closed enhancement (fixed)
[PATCH] Adjustable props to the terrain profile
Reported by: | sanderd17 | Owned by: | leper |
---|---|---|---|
Priority: | Nice to Have | Milestone: | Alpha 14 |
Component: | Core engine | Keywords: | patch |
Cc: | Patch: |
Description
By having props height adjusted to the terrain profile, artists have better tools to avoid dangling props.
The prop real-world coordinates are set in graphics.Model.cpp (around line 400). There you have two matrices, m_Transform and proptransform that have as translation component resp. the real world position of the root object and the real world position of the prop.
So to adjust the height, you just need to translate it with the height difference minus the existing difference (to keep the relative height).
All this fix needs is the implementation of an attribute in the actor XML files, and a way to access the terrain height from Model.cpp.
Attachments (1)
Change History (10)
comment:1 by , 11 years ago
comment:2 by , 11 years ago
In the new patch, only the props that have a maxheight or minheight attribute set will be aligned to the terrain.
As there was a concern that a prop could stick through the roof, this is also solved now. You can simply set the maxheight so that it can never touch the roof. When the ground becomes higher than the maxheight, the prop will stay at the maxheight and sink in the ground. If you don't set the maxheight, the prop will never be placed higher, but can only drop when the ground is lower.
The reverse is true for minheight.
The patch isn't cleaned up yet, I would like to hear some opinions on it (if the xml flags are good enough ...)
by , 11 years ago
Attachment: | prop_alignment.diff added |
---|
comment:3 by , 11 years ago
Keywords: | patch review added |
---|---|
Summary: | Adjustable props to the terrain profile → [PATCH] Adjustable props to the terrain profile |
Cleaned up the patch and edited the persion stables actor file as example. That makes it ready for inclusion.
comment:5 by , 11 years ago
Keywords: | review removed |
---|---|
Milestone: | Backlog → Alpha 14 |
Thanks for the patch.
comment:7 by , 11 years ago
There are build warnings on MSVC due to the patch:
2>E:\devel\ps\source\graphics/ObjectEntry.h(84): warning C4512: 'CObjectEntry' : assignment operator could not be generated 2> E:\devel\ps\source\graphics/ObjectEntry.h(39) : see declaration of 'CObjectEntry'
because of the new CSimulation2& m_Simulation;
member variable. Making the class NONCOPYABLE
fixes the warning.
I added a small patch that alters all props to the terrain. This is not for direct inclusion in the game, just a proof of concept. It will break things like garrison flags on non-flat terrain.
I also edited the carthagian dae file as part of the proof of concept to add a bone on which the palm trees are anchored. As you see on the screenshot, the palm trees do follow the terrain more or less (as they're both on a single bone, they don't follow it exactly, and my bone placement is done via manual editing, so not perfect).
I haven't yet succeeded in adding a flag to the XML so it only affects selected bones.