Skip to content

Commit

Permalink
Refactor|Resources: Revised Material resource model
Browse files Browse the repository at this point in the history
Implemented a MaterialAnimator concept and revised the old context
"variant" stuff accordingly. The idea is that each material usage
context (map surface, UI, etc...) has it's own client-side Animator
which is responsible for animating an instance of the base Material
resource.

Each MaterialAnimator is configured with a MaterialVariantSpec. This
specification allows for context-specific customization of how the
Material (and any dependent resources) is interpreted.

Material layers and decorations are now modeled with an extensible
object-oriented framework for future enhancement.
  • Loading branch information
danij-deng committed Dec 15, 2014
1 parent 7827244 commit d2342ac
Show file tree
Hide file tree
Showing 72 changed files with 3,642 additions and 3,687 deletions.
16 changes: 11 additions & 5 deletions doomsday/client/client.pro
Expand Up @@ -154,11 +154,11 @@ DENG_CONVENIENCE_HEADERS += \
include/MapElement \
include/MapObject \
include/Material \
include/MaterialAnimator \
include/MaterialArchive \
include/MaterialContext \
include/MaterialManifest \
include/MaterialScheme \
include/MaterialSnapshot \
include/MaterialVariantSpec \
include/Mesh \
include/Model \
Expand Down Expand Up @@ -330,10 +330,14 @@ DENG_HEADERS += \
include/resource/manifest.h \
include/resource/mapdef.h \
include/resource/material.h \
include/resource/materialanimator.h \
include/resource/materialarchive.h \
include/resource/materialdetailtexturelayer.h \
include/resource/materiallightdecoration.h \
include/resource/materialmanifest.h \
include/resource/materialscheme.h \
include/resource/materialsnapshot.h \
include/resource/materialshinelayer.h \
include/resource/materialtexturelayer.h \
include/resource/materialvariantspec.h \
include/resource/model.h \
include/resource/modeldef.h \
Expand Down Expand Up @@ -660,12 +664,14 @@ SOURCES += \
src/resource/manifest.cpp \
src/resource/mapdef.cpp \
src/resource/material.cpp \
src/resource/materialanimation.cpp \
src/resource/materialanimator.cpp \
src/resource/materialarchive.cpp \
src/resource/materialdetailtexturelayer.cpp \
src/resource/materiallightdecoration.cpp \
src/resource/materialmanifest.cpp \
src/resource/materialscheme.cpp \
src/resource/materialsnapshot.cpp \
src/resource/materialvariant.cpp \
src/resource/materialshinelayer.cpp \
src/resource/materialtexturelayer.cpp \
src/resource/model.cpp \
src/resource/patch.cpp \
src/resource/patchname.cpp \
Expand Down
1 change: 1 addition & 0 deletions doomsday/client/include/MaterialAnimator
@@ -0,0 +1 @@
#include "resource/materialanimator.h"
1 change: 0 additions & 1 deletion doomsday/client/include/MaterialSnapshot

This file was deleted.

1 change: 0 additions & 1 deletion doomsday/client/include/de_resource.h
Expand Up @@ -29,7 +29,6 @@
#include "resource/sprite.h"

#ifdef __CLIENT__
# include "resource/materialsnapshot.h"
# include "resource/materialvariantspec.h"
#endif

Expand Down
8 changes: 3 additions & 5 deletions doomsday/client/include/def_main.h
Expand Up @@ -24,6 +24,8 @@
#define LIBDENG_DEFINITIONS_MAIN_H

#include <vector>
#include <doomsday/defs/ded.h>
#include <doomsday/defs/dedtypes.h>
#include <de/stringarray.h>
#include "Material"

Expand Down Expand Up @@ -178,10 +180,6 @@ ded_value_t *Def_GetValueByUri(Uri const *uri);
ded_material_t *Def_GetMaterial(char const *uri);
ded_compositefont_t *Def_GetCompositeFont(char const *uri);
ded_light_t *Def_GetLightDef(int spr, int frame);
/// @todo $revise-texture-animation
ded_decor_t *Def_GetDecoration(Uri const *uri, /*bool hasExternal,*/ bool isCustom);
ded_reflection_t *Def_GetReflection(Uri const *uri, /*bool hasExternal,*/ bool isCustom);
ded_detailtexture_t *Def_GetDetailTex(Uri const *uri, /*bool hasExternal,*/ bool isCustom);

#ifdef __cplusplus
} // extern "C"
Expand Down Expand Up @@ -236,7 +234,7 @@ StringArray *Def_ListStateIDs(void);
/**
* Returns @c true iff @a def is compatible with the specified context.
*/
bool Def_IsAllowedDecoration(ded_decor_t const *def, /*bool hasExternal,*/ bool isCustom);
bool Def_IsAllowedDecoration(ded_decoration_t const *def, /*bool hasExternal,*/ bool isCustom);

/**
* Returns @c true iff @a def is compatible with the specified context.
Expand Down
30 changes: 28 additions & 2 deletions doomsday/client/include/r_util.h
Expand Up @@ -20,11 +20,37 @@
#ifndef DENG_REFRESH_UTIL_H
#define DENG_REFRESH_UTIL_H

#include "api_gl.h"

#include <de/Matrix>
#include <de/String>
#include <de/Vector>

#include "api_gl.h"

#ifdef __CLIENT__
#undef min
#undef max

/**
* Description of an inclusive..inclusive light intensity range.
*
* @ingroup data
*/
struct LightRange
{
float min;
float max;

LightRange(float _min = 0, float _max = 0) : min(_min), max(_max) {}
LightRange(float const minMax[2]) : min(minMax[0]), max(minMax[1]) {}
LightRange(LightRange const &other) : min(other.min), max(other.max) {}

/// Returns a textual representation of the lightlevels.
de::String asText() const {
return de::String("(min: %1 max: %2)").arg(min, 0, 'f', 2).arg(max, 0, 'f', 2);
}
};
#endif

float R_MovementYaw(float const mom[2]);
float R_MovementXYYaw(float momx, float momy);

Expand Down
19 changes: 10 additions & 9 deletions doomsday/client/include/render/billboard.h
Expand Up @@ -25,6 +25,7 @@

#include "dd_types.h"
#include "Material"
#include "MaterialAnimator"
#include "MaterialVariantSpec"

class BspLeaf;
Expand All @@ -37,19 +38,19 @@ class BspLeaf;
*/
struct drawmaskedwallparams_t
{
void *material; /// MaterialVariant
blendmode_t blendMode; ///< Blendmode to be used when drawing
/// (two sided mid textures only)
MaterialAnimator *animator;
blendmode_t blendMode; ///< Blendmode to be used when drawing (two sided mid textures only)

struct wall_vertex_s {
float pos[3]; ///< x y and z coordinates.
float pos[3]; ///< x y and z coordinates.
float color[4];
} vertices[4];

double texOffset[2];
float texCoord[2][2]; ///< u and v coordinates.
float texCoord[2][2]; ///< u and v coordinates.

DGLuint modTex; ///< Texture to modulate with.
float modTexCoord[2][2]; ///< [top-left, bottom-right][x, y]
DGLuint modTex; ///< Texture to modulate with.
float modTexCoord[2][2]; ///< [top-left, bottom-right][x, y]
float modColor[4];
};

Expand Down Expand Up @@ -89,8 +90,8 @@ struct drawspriteparams_t
blendmode_t blendMode;

// Material:
void *material; /// MaterialVariant
dd_bool matFlip[2]; // [S, T] Flip along the specified axis.
MaterialAnimator *matAnimator;
dd_bool matFlip[2]; ///< [S, T] Flip along the specified axis.

// Lighting/color:
//float ambientColor[4];
Expand Down
23 changes: 9 additions & 14 deletions doomsday/client/include/render/decoration.h
@@ -1,7 +1,7 @@
/** @file decoration.h World surface decoration.
/** @file decoration.h World surface decoration.
*
* @authors Copyright © 2003-2013 Jaakko Keränen <jaakko.keranen@iki.fi>
* @authors Copyright © 2006-2013 Daniel Swanson <danij@dengine.net>
* @authors Copyright © 2006-2014 Daniel Swanson <danij@dengine.net>
*
* @par License
* GPL: http://www.gnu.org/licenses/gpl.html
Expand All @@ -18,14 +18,14 @@
* 02110-1301 USA</small>
*/

#ifndef DENG_CLIENT_RENDER_DECORATION_H
#define DENG_CLIENT_RENDER_DECORATION_H
#ifndef CLIENT_RENDER_DECORATION_H
#define CLIENT_RENDER_DECORATION_H

#include <de/Error>
#include <de/Vector>

#include "MapObject"
#include "MaterialSnapshot"
#include "MaterialAnimator"

class Surface;

Expand All @@ -49,7 +49,7 @@ class Decoration : public de::MapObject
* @param source Source of the decoration (a material).
* @param origin Origin of the decoration in map space.
*/
Decoration(de::MaterialSnapshotDecoration &source,
Decoration(MaterialAnimator::Decoration const &source,
de::Vector3d const &origin = de::Vector3d());
virtual ~Decoration();

Expand All @@ -58,10 +58,7 @@ class Decoration : public de::MapObject
*
* @see hasSource(), setSource()
*/
de::MaterialSnapshotDecoration &source();

/// @copydoc source()
de::MaterialSnapshotDecoration const &source() const;
MaterialAnimator::Decoration const &source() const;

/**
* Returns @c true iff a surface is attributed for the decoration.
Expand All @@ -73,9 +70,7 @@ class Decoration : public de::MapObject
/**
* Convenient method which returns the surface owner of the decoration.
*/
Surface &surface();

/// @copydoc surface()
Surface &surface();
Surface const &surface() const;

/**
Expand All @@ -89,4 +84,4 @@ class Decoration : public de::MapObject
DENG2_PRIVATE(d)
};

#endif // DENG_CLIENT_RENDER_DECORATION_H
#endif // CLIENT_RENDER_DECORATION_H
12 changes: 6 additions & 6 deletions doomsday/client/include/render/lightdecoration.h
@@ -1,7 +1,7 @@
/** @file lightdecoration.h World surface light decoration.
/** @file lightdecoration.h World surface light decoration.
*
* @authors Copyright © 2003-2013 Jaakko Keränen <jaakko.keranen@iki.fi>
* @authors Copyright © 2006-2013 Daniel Swanson <danij@dengine.net>
* @authors Copyright © 2006-2014 Daniel Swanson <danij@dengine.net>
*
* @par License
* GPL: http://www.gnu.org/licenses/gpl.html
Expand All @@ -18,8 +18,8 @@
* 02110-1301 USA</small>
*/

#ifndef DENG_CLIENT_RENDER_LIGHTDECORATION_H
#define DENG_CLIENT_RENDER_LIGHTDECORATION_H
#ifndef CLIENT_RENDER_LIGHTDECORATION_H
#define CLIENT_RENDER_LIGHTDECORATION_H

#include "Decoration"
#include "Lumobj"
Expand All @@ -37,7 +37,7 @@ class LightDecoration : public Decoration, public Lumobj::Source
* @param source Source of the decoration (a material).
* @param origin Origin of the decoration in map space.
*/
LightDecoration(de::MaterialSnapshotDecoration &source,
LightDecoration(MaterialAnimator::Decoration const &source,
de::Vector3d const &origin = de::Vector3d());

/**
Expand Down Expand Up @@ -75,4 +75,4 @@ class LightDecoration : public Decoration, public Lumobj::Source
Lumobj *generateLumobj() const;
};

#endif // DENG_CLIENT_RENDER_LIGHTDECORATION_H
#endif // CLIENT_RENDER_LIGHTDECORATION_H
12 changes: 6 additions & 6 deletions doomsday/client/include/render/materialcontext.h
@@ -1,6 +1,6 @@
/** @file render/materialcontext.h Material render-contexts
/** @file materialcontext.h Material render-context identifiers.
*
* @authors Copyright © 2009-2013 Daniel Swanson <danij@dengine.net>
* @authors Copyright © 2009-2014 Daniel Swanson <danij@dengine.net>
*
* @par License
* GPL: http://www.gnu.org/licenses/gpl.html
Expand All @@ -16,11 +16,11 @@
* http://www.gnu.org/licenses</small>
*/

#ifndef LIBDENG_RENDER_MATERIALCONTEXT_H
#define LIBDENG_RENDER_MATERIALCONTEXT_H
#ifndef CLIENT_RENDER_MATERIALCONTEXT_H
#define CLIENT_RENDER_MATERIALCONTEXT_H

/**
* Material render-context identifiers:
* Material render-context identifier.
*
* @ingroup render
*/
Expand All @@ -38,4 +38,4 @@ enum MaterialContextId
LastMaterialContextId = SkySphereContext
};

#endif // LIBDENG_RENDER_MATERIALCONTEXT_H
#endif // CLIENT_RENDER_MATERIALCONTEXT_H

0 comments on commit d2342ac

Please sign in to comment.