diff --git a/docs/assets/stylesheets/extra.css b/docs/assets/stylesheets/extra.css index 5a6dd193..b286e5e3 100644 --- a/docs/assets/stylesheets/extra.css +++ b/docs/assets/stylesheets/extra.css @@ -17,3 +17,116 @@ .md-typeset :focus-within > .md-annotation__index > ::before { transform: none; } + +.sp-list { + padding: 0 !important; + margin: 0 !important; + list-style-type: none; +} + +.sp-prop { + margin-top: -1em; + margin-bottom: 1em; + font-family: monospace; + font-size: 0.7em; + border: 1px solid #333333; + padding: 5px 0.5rem; +} + +.t-int::before { + content: url("/assets/icons/spacer-int.png"); +} + +.t-float::before { + content: url("/assets/icons/spacer-float.png"); +} + +.t-str::before { + content: url("/assets/icons/spacer-string.png"); +} + +.t-raw::before { + content: url("/assets/icons/spacer-misc.png"); +} + +.t-vec::before { + content: url("/assets/icons/spacer-vec.png"); +} + +.t-bool::before { + content: url("/assets/icons/spacer-bool.png"); +} + +.t-enum::before { + content: url("/assets/icons/spacer-enum.png"); +} + +.sp-folder { + margin-top: 0 !important; + margin-bottom: 0 !important; + list-style-image: url('/assets/icons/spacer-folder.png'); + font-family: monospace; +} + +.sp-type { + margin-top: 0 !important; + margin-bottom: 0 !important; + list-style-image: url('/assets/icons/spacer-type.png'); + font-family: monospace; +} + +.sp-int { + margin-top: 0 !important; + margin-bottom: 0 !important; + list-style-image: url('/assets/icons/spacer-int.png'); + font-family: monospace; +} + +.sp-string { + margin-top: 0 !important; + margin-bottom: 0 !important; + list-style-image: url('/assets/icons/spacer-string.png'); + font-family: monospace; +} + +.sp-misc { + margin-top: 0 !important; + margin-bottom: 0 !important; + list-style-image: url('/assets/icons/spacer-misc.png'); + font-family: monospace; +} + +.sp-bool { + margin-top: 0 !important; + margin-bottom: 0 !important; + list-style-image: url('/assets/icons/spacer-bool.png'); + font-family: monospace; +} + +.sp-enum { + margin-top: 0 !important; + margin-bottom: 0 !important; + list-style-image: url('/assets/icons/spacer-enum.png'); + font-family: monospace; +} + +.sp-vec { + margin-top: 0 !important; + margin-bottom: 0 !important; + list-style-image: url('/assets/icons/spacer-vec.png'); + font-family: monospace; +} + +.sp-float { + margin-top: 0 !important; + margin-bottom: 0 !important; + list-style-image: url('/assets/icons/spacer-float.png'); + font-family: monospace; +} + +.sp-save { + margin-top: 0 !important; + margin-bottom: 0 !important; + list-style-image: url('/assets/icons/spacer-save.png'); + font-family: monospace; +} diff --git a/docs/engine/objects/zCVob.md b/docs/engine/objects/zCVob.md new file mode 100644 index 00000000..90ad2508 --- /dev/null +++ b/docs/engine/objects/zCVob.md @@ -0,0 +1,227 @@ +# zCVob + +!!! abstract inline end "Quick Infos" + **Type:** Virtual Object
+ **Format Name:** ZenGin Archive
+ **File Extension:** `.ZEN`
+ **Class Name:** `zCVob`
+ **Version Identifier:**
+ — Gothic I: `12289`
+ — Gothic II: `52224`
+ **ZenKit Class:** `VirtualObject` + +Represents so-called virtual objects which appear in the game world. `zCVob` is the base class for all virtual +objects which include everything from static models like boxes to interactive elements like doors and chests and +invisible trigger objects. They are also referred to as VObjects in this documentation. + + + +## Properties + + `pack` + +: Internal property which indicates how the data associated with this VObject is stored. Can not be changed in the + Spacer and is inaccessible in *ZenKit*. + + `presetName` + +: The name of the template used to create this VObject in the Spacer. Exposed as a normal field by *ZenKit*. + + + `bbox3DWS` + +: The 3-dimensional bounding box of this VObject to be used for collision detection. This is used in conjunction with + [`cdStatic`](#cdstatic) and [`cdDyn`](#cddyn) to detect whether two VObject are colliding. Depending on the kind of + VObject collision with it may do different things which are documented for each VObject separately. + + The bounding box is described by two opposite diagonal points in 3D world space coordinates. + + `trafoOSToWSRot` + +: The rotation of this VObject in world space, represented by a 3x3 rotation matrix. + + `trafoOSToWSPos` + +: The coordinates of this VObject in world space. + + `vobName` + +: The name of this VObject. VObject names are not necessarily unique but are sometimes helpful for identifying them. + For some VObjects, like [zCVobSpot](zCVobSpot.md) or [zCTrigger](zCTrigger.md) setting the `vobName` is required + + `visual` + +: The name of the visual component associated with this VObject. This is usually the name of a file containing the + data for a visual object. The following file formats are supported: + + * `*.3DS` — Static models + * `*.PFX` — Particle effects + * `*.TGA` — Textures + * `*.MDS`, `.ASC` — Interactive or rigged models + * `*.MMS` — Morph-mesh animated models + + `showVisual` + +: Indicates whether this VObject should display its associated visual. +
`TRUE` — Display the visual. `FALSE` — Hide the visual. + + `visualCamAlign` + +: Indicates how this VObject should be aligned in relation to the camera. This may be used with grass or flowers + which only consist of a 2-dimensional sprite to have it always face the camera, for example. Possible value are + + * `NONE` — The sprite is not affected by the camera's rotation. + * `YAW` — The sprite rotates with the camera's yaw axis. + * `FULL` — The sprite rotates alonside the camera. + + `visualAniMode` + +: The type of wind animation to apply to the VObject. One of + + * `NONE` — No wave animation. + * `WIND` — Indicates that the object should be animated as if shifting in strong wind. Used mostly for animating + grass and other small foliage. + * `WIND2` — Indicates that the object should be animated as if shifting in light wind. Used mostly for animating trees. + + `visualAniModeStrength` + +: Indicates the strength of the animation set through [`visualAniMode`](#visualanimode). This value is ignored if + [`visualAniMode`](#visualanimode) is set to `NONE`. + + `vobFarClipZScale` + +: Indicates the draw distance of this VObject. Its value should be between 0 and 2. 0 Means, that this object is + never drawn on screen but collisions are still calculated. A value of 2 means, that the draw distance of this + VObject is the same as the draw distance specified in the [`zCZoneVobFarPlane`](zCZoneVobFarPlane.md) object. + + `cdStatic` + +: Indicates whether this VObject should collide with other VObjects. This is used for placing the object in the + ZenGin map editor, the *Spacer*, where it will prevent the VObject being placed wither other VObjects. This setting + is irrelevant for runtime collision detection. + + * `TRUE` — Collide with all other VObjects. + * `FALSE` — Don't collide with other static VObjects. + + + `cdDyn` + +: Indicates whether this VObject should collide with dynamic objects. For this purpose, dynamic objects are the + player, NPCs and items. If this flag is set, implementations should apply collision detection to this VObject. + + * `TRUE` — Collide with dynamic VObjects. + * `FALSE` — Don't collide with dynamic VObjects. + + `staticVob` + +: Indicates whether this VObject should be included during static lighting calculations. These lighting calculations + are done at compile-time and will bake VObjects with this flag into the light-maps available from the world mesh. + + * `TRUE` — Exclude this VObject from dynamic lighting calculations. + * `FALSE` — Include this VObject in dynamic lighting calculations. + + `dynShadow` + +: The type of dynamic shadow to be used for this VObject. + + * `DS_NONE` — The VObject does not cast any shadow. + * `DS_BLOB` — The VObject casts a dark circle at its base. + + `zbias` + +: The depth-bias for this VObject. This value is passed directly to Direct3D when rendering the associated visual of + this VObject. Sadly, because documentation is not available for the very old Direct3D version used by the ZenGin, + the exact behavior it would have resulted in are unknown. + + `isAmbient` + +: Indicates that this VObject is *ambient*. It looks like this VObject setting was a system used during development + when access to the game's source code was available. Basically, the global variable `zCWorld::s_bAmbientVobsEnabled` + could be used to hide or show VObjects which have the `isAmbient` flag set. In release builds, this variable is + always set to `true`, thus the `isAmbient` flag does not have any perceivable effect on the game. It follows, that + this field should be ignored by most implementations. + +## Hierarchy + +The following list shows the virtual object class hierarchy. Click on any of the VObjects to see more details. + +* [zCVob](zCVob.md) + * [zCVobSpot](zCVobSpot.md) + * [zCVobStair](zCVobStair.md) + * [zCVobStartpoint](zCVobStartpoint.md) + * [zCVobLevelCompo](zCVobLevelCompo.md) + * [zCCSCamera](zCCSCamera.md) + * [zCCamTrj_KeyFrame](zCCamTrj_KeyFrame.md) + * [zCVobLight](zCVobLight.md) + * [zCVobAnimate](zCVobAnimate.md) + * [oCItem](oCItem.md) + * [zCVobLensFlare](zCVobLensFlare.md) + * [zCPFXController](zCPFXController.md) + * [zCMessageFilter](zCMessageFilter.md) + * [zCCodeMaster](zCCodeMaster.md) + * [zCMoverController](zCMoverController.md) + * [oCTouchDamage](oCTouchDamage.md) + * [zCEarthquake](zCEarthquake.md) + * [oCNpc](oCNpc.md) + * [zCVobScreenFX](zCVobScreenFX.md) + * [oCMOB](oCMOB.md) + * [oCMobInter](oCMobInter.md) + * [oCMobFire](oCMobFire.md) + * [oCMobContainer](oCMobContainer.md) + * [oCMobDoor](oCMobDoor.md) + * [oCMobLadder](oCMobLadder.md) + * [oCMobSwitch](oCMobSwitch.md) + * [oCMobWheel](oCMobWheel.md) + * [oCMobBed](oCMobBed.md) + * [zCVobSound](zCVobSound.md) + * [zCVobSoundDaytime](zCVobSoundDaytime.md) + * [zCTrigger](zCTrigger.md) + * [oCCSTrigger](oCCSTrigger.md) + * [zCMover](zCMover.md) + * [zCTriggerList](zCTriggerList.md) + * [oCTriggerScript](oCTriggerScript.md) + * [oCTriggerChangeLevel](oCTriggerChangeLevel.md) + * [zCTriggerWorldStart](zCTriggerWorldStart.md) + * [zCTriggerUntouch](zCTriggerUntouch.md) + * [oCZoneMusic](oCZoneMusic.md) + * [oCZoneMusicDefault](oCZoneMusicDefault.md) + * [zCZoneVobFarPlane](zCZoneVobFarPlane.md) + * [zCZoneVobFarPlaneDefault](zCZoneVobFarPlaneDefault.md) + * [zCZoneZFog](zCZoneZFog.md) + * [zCZoneZFogDefault](zCZoneZFogDefault.md) diff --git a/docs/library/overview.md b/docs/library/overview.md index 2e5e2a2d..e2e9014c 100644 --- a/docs/library/overview.md +++ b/docs/library/overview.md @@ -5,7 +5,7 @@ hide: # Library Reference -![](/assets/logo.png) +![](../assets/logo.png) Welcome to the *ZenKit* reference documentation. This page contains information about how to use *ZenKit*, a C++-library for parsing file formats used by the *ZenGin*, an early 2000's game engine developed by diff --git a/include/zenkit/vobs/MovableObject.hh b/include/zenkit/vobs/MovableObject.hh index 5871aabe..ce50f3bc 100644 --- a/include/zenkit/vobs/MovableObject.hh +++ b/include/zenkit/vobs/MovableObject.hh @@ -31,6 +31,8 @@ namespace zenkit { }; struct VMovableObject : VirtualObject { + ZK_OBJECT(ObjectType::oCMOB); + std::string name; std::int32_t hp; std::int32_t damage; @@ -57,6 +59,8 @@ namespace zenkit { }; struct VInteractiveObject : VMovableObject { + ZK_OBJECT(ObjectType::oCMobInter); + std::int32_t state; std::string target; std::string item; @@ -80,6 +84,8 @@ namespace zenkit { /// \brief A VOb representing a campfire. struct VFire : VInteractiveObject { + ZK_OBJECT(ObjectType::oCMobFire); + std::string slot; std::string vob_tree; @@ -98,6 +104,8 @@ namespace zenkit { /// \brief A VOb representing a container. struct VContainer : VInteractiveObject { + ZK_OBJECT(ObjectType::oCMobContainer); + bool locked; std::string key; std::string pick_string; @@ -122,6 +130,8 @@ namespace zenkit { /// \brief A VOb representing a door. struct VDoor : VInteractiveObject { + ZK_OBJECT(ObjectType::oCMobDoor); + bool locked; std::string key; std::string pick_string; @@ -140,11 +150,21 @@ namespace zenkit { [[nodiscard]] ZKAPI uint16_t get_version_identifier(GameVersion game) const override; }; - struct VLadder : VInteractiveObject {}; - struct VSwitch : VInteractiveObject {}; - struct VWheel : VInteractiveObject {}; + struct VLadder : VInteractiveObject { + ZK_OBJECT(ObjectType::oCMobLadder); + }; + + struct VSwitch : VInteractiveObject { + ZK_OBJECT(ObjectType::oCMobSwitch); + }; + + struct VWheel : VInteractiveObject { + ZK_OBJECT(ObjectType::oCMobWheel); + }; struct VBed : VInteractiveObject { + ZK_OBJECT(ObjectType::oCMobBed); + [[nodiscard]] ZKAPI uint16_t get_version_identifier(GameVersion game) const override; }; } // namespace zenkit diff --git a/include/zenkit/vobs/VirtualObject.hh b/include/zenkit/vobs/VirtualObject.hh index aa51ee01..34f4fa8d 100644 --- a/include/zenkit/vobs/VirtualObject.hh +++ b/include/zenkit/vobs/VirtualObject.hh @@ -58,7 +58,7 @@ namespace zenkit { enum class SpriteAlignment : std::uint8_t { NONE = 0, ///< The sprite is not affected by the camera's rotation. YAW = 1, ///< The sprite rotates with the camera's yaw axis. - FULL = 2, ///< The sprite rotates with camera fully. + FULL = 2, ///< The sprite rotates alonside the camera. // Deprecated entries. none ZKREM("renamed to SpriteAlignment::NONE") = NONE, @@ -70,20 +70,16 @@ namespace zenkit { enum class AnimationType : std::uint8_t { NONE = 0, ///< No wave animation. - /// \brief String wind animation. + /// \brief Strong wind animation. /// ///

Indicates that the object should be animated as if shifting in strong wind. Used mostly for /// animating grass and other small foliage.

- /// - /// \see http://www.gothic-library.ru/publ/class_zcvob/1-1-0-467#visualAniMode WIND = 1, /// \brief Light wind animation. /// ///

Indicates that the object should be animated as if shifting in light wind. Used mostly for /// animating trees.

- /// - /// \see http://www.gothic-library.ru/publ/class_zcvob/1-1-0-467#visualAniMode WIND_ALT = 2, // Deprecated entries. @@ -100,6 +96,8 @@ namespace zenkit { /// ///

This field conains the name of the source file of the visual. A mesh visual, for example, will end in /// `.3DS` since that is the original file format of the mesh.

+ /// + /// \see https://zk.gothickit.dev/engine/objects/zCVob/#visual std::string name; }; @@ -272,6 +270,7 @@ namespace zenkit { /// /// \note Virtual objects should not be loaded manually. They are embedded into world archives and are automatically /// loaded when the world is loaded. + /// \see https://zk.gothickit.dev/engine/objects/zCVob/ struct VirtualObject : Object { ZK_OBJECT(ObjectType::zCVob); @@ -303,15 +302,19 @@ namespace zenkit { uint32_t id ZKREM("scheduled for removal; refer to documentation") = 0; /// \brief The bounding box of this VObject. + /// \see https://zk.gothickit.dev/engine/objects/zCVob/#bbox3dws AxisAlignedBoundingBox bbox = AxisAlignedBoundingBox::zero(); /// \brief The position of this VObject in virtual space. + /// \see https://zk.gothickit.dev/engine/objects/zCVob/#trafoostowspos glm::vec3 position = glm::vec3 {0}; /// \brief The rotation of this VObject in virtual space. + /// \see https://zk.gothickit.dev/engine/objects/zCVob/#trafoostowsrot glm::mat3x3 rotation = glm::identity(); - /// \brief Indicates whether this VObject has should display its associated visual. + /// \brief Indicates whether this VObject should display its associated visual. + /// \see https://zk.gothickit.dev/engine/objects/zCVob/#showvisual bool show_visual = false; /// \brief Indicates how this VObject should be aligned in relation to the camera. @@ -319,6 +322,8 @@ namespace zenkit { ///

The value of this field indicates, if and how this VObject should align itself with the camera. This may /// be used with grass or flowers which only consist of a 2-dimensional sprite to have it always face the /// camera, for example. See zenkit::SpriteAlignment for additional details.

+ /// + /// \see https://zk.gothickit.dev/engine/objects/zCVob/#visualcamalign SpriteAlignment sprite_camera_facing_mode = SpriteAlignment::NONE; /// \brief Indicates whether this VObject should collide with other VObjects. @@ -326,12 +331,16 @@ namespace zenkit { ///

This is used for placing the object in the ZenGin map editor, the Spacer, where it will prevent /// the VObject being placed wither other VObjects. This setting is irrelevant for runtime collision /// detection

+ /// + /// \see https://zk.gothickit.dev/engine/objects/zCVob/#cdstatic bool cd_static = true; /// \brief Indicates whether this VObject should collide with dynamic objects. /// ///

For this purpose, dynamic objects are the player, NPCs and items. If this flag is set, implementations /// should apply collision detection to this VObject.

+ /// + /// \see https://zk.gothickit.dev/engine/objects/zCVob/#cddyn bool cd_dynamic = true; /// \brief Indicates whether this VObject should be included during static lighting calculations. @@ -339,11 +348,15 @@ namespace zenkit { ///

These lighting calculations are done at compile-time and will bake VObjects with this flag into the /// light-maps available from the world mesh. If set to `true`, this VObject may be excluded from dynamic /// lighting if the light-maps are used.

+ /// + /// \see https://zk.gothickit.dev/engine/objects/zCVob/#vobstatic bool vob_static = false; /// \brief The type of dynamic shadow to be used. /// ///

See zenkit::ShadowType for information about available shadow types.

+ /// + /// \see https://zk.gothickit.dev/engine/objects/zCVob/#dynShadow ShadowType dynamic_shadows = ShadowType::NONE; /// \brief Indicates whether this VObject has enabled physics. @@ -351,40 +364,59 @@ namespace zenkit { ///

This field represents internal state of the ZenGin which is written to disk only for a certain world /// format type. It is not possible to set this field ZenGin's world editor, the Spacer, for example. /// This makes this field unreliable, since it is only available for some VObjects.

- bool physics_enabled = true; + ZKREM("Unreliable. No alternative available yet.") bool physics_enabled = true; /// \brief The type of wind animation to apply to the VObject. + /// \see https://zk.gothickit.dev/engine/objects/zCVob/#visualanimode AnimationType anim_mode = AnimationType::NONE; /// \brief The depth-bias for this VObject. /// ///

This value is passed directly to Direct3D when rendering the associated visual of this VObject. Sadly, - /// because documentation is not really available for the very old Direct3D version used by the ZenGin, the + /// because documentation is not available for the very old Direct3D version used by the ZenGin, the /// exact behavior it would have resulted in are unknown.

+ /// + /// \see https://zk.gothickit.dev/engine/objects/zCVob/#zbias std::int32_t bias = 0; /// \brief Indicates that this VObject is ambient. /// - ///

It looks like this VObject setting was a system used duing development when access to the game's source + ///

It looks like this VObject setting was a system used during development when access to the game's source /// code was available. Basically, the global variable `zCWorld::s_bAmbientVobsEnabled` could be used to hide or /// show VObjects which have the `isAmbient` flag set. In release builds, this variable is always set to `true`, - /// thus the `isAmbient` flag does not have any percievable effect on the game.

+ /// thus the `isAmbient` flag does not have any perceivable effect on the game.

///

It follows, that this field should be ignored by most implementations.

+ /// + /// \see https://zk.gothickit.dev/engine/objects/zCVob/#isambient bool ambient = false; /// \brief Indicates the strength of the animation set through #anim_mode. /// ///

Essentialy, this controls the strength of the wind to be animated using the given #anim_mode. This value /// is ignored if #anim_mode is AnimationType::NONE

+ /// + /// \see https://zk.gothickit.dev/engine/objects/zCVob/#visualanimodestrength float anim_strength = 0; + + /// \brief Indicates the draw distance of this VObject. + /// + ///

Its value should be between 0 and 2. 0 Means, that this object is never drawn on screen but collisions + /// are still calculated. A value of 2 means, that the the draw distance of this VObject is the same as the draw + /// distance specified in the zenkit::VZoneFarPlane object

+ /// + /// \see https://zk.gothickit.dev/engine/objects/zCVob/#vobfarclipzscale float far_clip_scale = 2.0; + /// \brief The name of the template used to create this VObject in the Spacer. + /// \see https://zk.gothickit.dev/engine/objects/zCVob/#presetname std::string preset_name; /// \brief The name of this VObject. /// - ///

The name of this VObject. VObject names are not necessarily unique but are sometimes helpful for + ///

VObject names are not necessarily unique but are sometimes helpful for /// identfying them in ZenGin's original map editor, the Spacer.

+ /// + /// \see https://zk.gothickit.dev/engine/objects/zCVob/#vobname std::string vob_name; std::string visual_name ZKREM("use VirtualObject::visual::name instead") {}; @@ -394,7 +426,7 @@ namespace zenkit { /// \brief The visual data associated with this VObject. /// ///

All supported visuals except the zenkit::VisualDecal do not contain any additional information. To - /// determine the type of attached visual, simply access zenkit::VisualDecal::type

+ /// determine the type of attached visual, check zenkit::VisualDecal::type

std::shared_ptr visual = nullptr; std::shared_ptr ai = nullptr; diff --git a/mkdocs.yml b/mkdocs.yml index 36014798..251b3746 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -36,6 +36,8 @@ nav: - 'ZenGin Texture': 'engine/formats/texture.md' - 'ZenGin Virtual File System': 'engine/formats/vdf.md' - 'ZenGin Archive': 'engine/formats/archive.md' + - 'Objects': + - 'zCVob': 'engine/objects/zCVob.md' - 'Encodings': - 'Binary': 'engine/encodings/binary.md' - 'Binary, Chunked': 'engine/encodings/binary-chunked.md' @@ -73,9 +75,7 @@ markdown_extensions: - pymdownx.highlight: anchor_linenums: true auto_title: true - - pymdownx.emoji: - emoji_index: !!python/name:materialx.emoji.twemoji - emoji_generator: !!python/name:materialx.emoji.to_svg + - pymdownx.emoji - pymdownx.tabbed: alternate_style: true - pymdownx.arithmatex: @@ -88,3 +88,4 @@ markdown_extensions: - 'pymdownx.inlinehilite' - 'md_in_html' - 'pymdownx.details' + - 'def_list'