Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#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)

prop_alignment.diff (10.8 KB ) - added by sanderd17 11 years ago.

Download all attachments as: .zip

Change History (10)

comment:1 by sanderd17, 11 years ago

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.

http://i42.tinypic.com/n4uqyw.png

comment:2 by sanderd17, 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 ...)

Last edited 11 years ago by sanderd17 (previous) (diff)

by sanderd17, 11 years ago

Attachment: prop_alignment.diff added

comment:3 by sanderd17, 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:4 by leper, 11 years ago

Owner: set to leper
Resolution: fixed
Status: newclosed

In 13549:

Allow terrain aligned props. Patch by sanderd17. Fixes #2033.

comment:5 by leper, 11 years ago

Keywords: review removed
Milestone: BacklogAlpha 14

Thanks for the patch.

comment:6 by ben, 11 years ago

In 13551:

Fixes prop bugs due to uninitialized variables on MSVC build, refs #2033

comment:7 by historic_bruno, 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.

comment:8 by ben, 11 years ago

In 13552:

Fixes assignment operator warning on MSVC by making CObjectEntry NONCOPYABLE, refs #2033

comment:9 by sanderd17, 11 years ago

Sorry for the MS VS bugs, it initialised fine when compiled with GCC.

Note: See TracTickets for help on using tickets.