Initial commit
This commit is contained in:
164
Include/ZRendererUtil/ZFontRenderer.hpp
Normal file
164
Include/ZRendererUtil/ZFontRenderer.hpp
Normal file
@@ -0,0 +1,164 @@
|
||||
/*
|
||||
ZFontRenderer.h
|
||||
Author: Patrick Baggett <ptbaggett@762studios.com>
|
||||
|
||||
Purpose: TODO
|
||||
|
||||
Changelog
|
||||
2011/09/18 - creation (ptbaggett)
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef _ZFONTRENDERER_HPP
|
||||
#define _ZFONTRENDERER_HPP
|
||||
|
||||
#include <SST/SST_Mat44.h>
|
||||
|
||||
#include <ZRenderer/ZRenderer.hpp>
|
||||
|
||||
//Font Face
|
||||
typedef void* ZFontFace;
|
||||
|
||||
//ZFontBounds struct, used as such
|
||||
// top --- right
|
||||
// | |
|
||||
// left --- bottom
|
||||
struct ZFontBounds
|
||||
{
|
||||
//ZFontBounds of a rectangle (lower-left orientation)
|
||||
int left, bottom, right, top;
|
||||
};
|
||||
|
||||
class ZFontRenderer
|
||||
{
|
||||
protected:
|
||||
//Protected Constructor
|
||||
ZFontRenderer() { }
|
||||
|
||||
public:
|
||||
//Virtual Destructor
|
||||
virtual ~ZFontRenderer() { }
|
||||
|
||||
/*
|
||||
virtual public ZFontRenderer::createFontFace
|
||||
|
||||
Creates a font face from a memory image of a font file.
|
||||
|
||||
@param _pixelSize - The pixel size of a character. To use point size (ala MS Word), use (point size / 72.0) * DPI.
|
||||
@param _fontData - The font file's data
|
||||
@param _dataSize - The size in bytes of the file data.
|
||||
@return (ZFontFace)
|
||||
@context (all)
|
||||
*/
|
||||
virtual ZFontFace CreateFontFace(int _pixelSize, const void* _fontData, unsigned int _dataSize) = 0;
|
||||
|
||||
/*
|
||||
virtual public ZFontRenderer::deleteFontFace
|
||||
|
||||
Deletes a font face. If this face is the currently active face, then the active face is set to NULL.
|
||||
|
||||
@param face - The font face to delete.
|
||||
@return (void)
|
||||
@context (all)
|
||||
*/
|
||||
virtual void DeleteFontFace(ZFontFace face) = 0;
|
||||
|
||||
/*
|
||||
virtual public ZFontRenderer::beginText
|
||||
|
||||
Sets up render state to begin drawing text. The only legal functions to call between beginText(),
|
||||
and endText() are renderText(), computeBounds(), and setColor().
|
||||
|
||||
@param _ctx - The ZFrameContext for this frame
|
||||
@param _xform - The transformation
|
||||
@return (void)
|
||||
@context (all)
|
||||
*/
|
||||
virtual void BeginText(ZFrameContext _ctx, const SST_Mat44f& _xform) = 0;
|
||||
|
||||
/*
|
||||
virtual public ZFontRenderer::endText
|
||||
|
||||
Restores render state when done drawing text, flushes any buffered text.
|
||||
|
||||
@return (void)
|
||||
@context (all)
|
||||
*/
|
||||
virtual void EndText() = 0;
|
||||
|
||||
/*
|
||||
virtual public ZFontRenderer::renderText
|
||||
|
||||
Renders text at the given XY location
|
||||
|
||||
@param x - The left edge of the text
|
||||
@param y - The bottom edge of the text
|
||||
@param text - Some letters render below this line (e.g. the letter g's "tail").
|
||||
@return (void)
|
||||
@context (all)
|
||||
*/
|
||||
virtual void RenderText(int x, int y, const char* text) = 0;
|
||||
|
||||
/*
|
||||
virtual public ZFontRenderer::computeBounds
|
||||
|
||||
Computes the bounding box for text, as if it was placed at the origin.
|
||||
|
||||
@param text - The text to compute a bounding box for.
|
||||
@param bounds - Pointer to where the computed boundaries are stored.
|
||||
@return (void)
|
||||
@context (all)
|
||||
*/
|
||||
virtual void ComputeBounds(const char* text, ZFontBounds* bounds) = 0;
|
||||
|
||||
/*
|
||||
virtual public ZFontRenderer::setColor
|
||||
|
||||
Sets the color of the text. Requires that there is a current font face, set with setFontFace().
|
||||
|
||||
@param r - The red component in the range of [0,1]
|
||||
@param g - The green component in the range of [0,1]
|
||||
@param b - The blue component in the range of [0,1]
|
||||
@param a - The alpha (transparency) component in the range of [0,1]
|
||||
@return (void)
|
||||
@context (all)
|
||||
*/
|
||||
virtual void SetColor(float r, float g, float b, float a) = 0;
|
||||
|
||||
/*
|
||||
virtual public ZFontRenderer::setColor
|
||||
|
||||
Sets a color with a packed 32-bit integer, converting to 4x32-bit floats first. Due to
|
||||
endian-ness differences, don't typecast an char[4] to int* and then dereference it!
|
||||
|
||||
@param rgba - The RGBA color stored as (hex) 0xRRGGBBAA
|
||||
@return (void)
|
||||
@context (all)
|
||||
*/
|
||||
virtual void SetColor(unsigned int rgba) = 0;
|
||||
|
||||
/*
|
||||
public ZFontRenderer::setFontFace
|
||||
|
||||
Sets the current font face.
|
||||
|
||||
@param face - The face to make current
|
||||
@return (void)
|
||||
@context (all)
|
||||
*/
|
||||
virtual void SetFontFace(ZFontFace face) = 0;
|
||||
|
||||
/*
|
||||
public ZFontRenderer::getFontFace
|
||||
|
||||
Gets the current font face.
|
||||
|
||||
@return (ZFontFace) - Handle to the current font face. It is not reference counted.
|
||||
@context (all)
|
||||
*/
|
||||
virtual ZFontFace GetFontFace() = 0;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
67
Include/ZRendererUtil/ZFontRendererBase.hpp
Normal file
67
Include/ZRendererUtil/ZFontRendererBase.hpp
Normal file
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
ZFontRendererBase.h
|
||||
Author: James Russell <jcrussell@762studios.com>
|
||||
|
||||
Purpose: TODO
|
||||
|
||||
Changelog
|
||||
2011/09/18 - creation (jcrussell)
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef _ZFONTRENDERERBASE_HPP
|
||||
#define _ZFONTRENDERERBASE_HPP
|
||||
|
||||
#include <ZRendererUtil/ZFontRenderer.hpp>
|
||||
|
||||
class ZFontRendererBase : public ZFontRenderer
|
||||
{
|
||||
protected:
|
||||
//Our current font face
|
||||
ZFontFace currentFace;
|
||||
|
||||
public:
|
||||
/*
|
||||
Default Constructor.
|
||||
*/
|
||||
ZFontRendererBase();
|
||||
|
||||
/*
|
||||
Destructor.
|
||||
*/
|
||||
virtual ~ZFontRendererBase();
|
||||
|
||||
//Subclass Implementation
|
||||
virtual ZFontFace GetFontFace();
|
||||
|
||||
//Subclass Implementation
|
||||
virtual void SetColor(unsigned int rgba);
|
||||
|
||||
//Subclass Implementation
|
||||
virtual void SetFontFace(ZFontFace face);
|
||||
|
||||
//Not Implemented
|
||||
virtual ZFontFace CreateFontFace( int PixelSize, const void* fontData, unsigned int dataSize ) = 0;
|
||||
|
||||
//Not Implemented
|
||||
virtual void DeleteFontFace( ZFontFace face ) = 0;
|
||||
|
||||
//Not Implemented
|
||||
virtual void BeginText( ZFrameContext _ctx, const SST_Mat44f& _xform ) = 0;
|
||||
|
||||
//Not Implemented
|
||||
virtual void EndText() = 0;
|
||||
|
||||
//Not Implemented
|
||||
virtual void RenderText( int x, int y, const char* text ) = 0;
|
||||
|
||||
//Not Implemented
|
||||
virtual void ComputeBounds( const char* text, ZFontBounds* bounds ) = 0;
|
||||
|
||||
//Not Implemented
|
||||
virtual void SetColor( float r, float g, float b, float a ) = 0;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
126
Include/ZRendererUtil/ZOutlineEvaluator.hpp
Normal file
126
Include/ZRendererUtil/ZOutlineEvaluator.hpp
Normal file
@@ -0,0 +1,126 @@
|
||||
/*
|
||||
ZOutlineEvaluator.h
|
||||
Author: Patrick Baggett <ptbaggett@762studios.com>
|
||||
|
||||
Purpose: TODO
|
||||
|
||||
Changelog
|
||||
2011/09/18 - creation (ptbaggett)
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef _ZOUTLINEEVALUATOR_H
|
||||
#define _ZOUTLINEEVALUATOR_H
|
||||
|
||||
#include <ZUtil/ZUtil.hpp>
|
||||
#include <SST/SST_Vec2.h>
|
||||
|
||||
#include <vector>
|
||||
#include <ft2build.h>
|
||||
#include FT_FREETYPE_H
|
||||
|
||||
class ZOutlineEvaluator
|
||||
{
|
||||
private:
|
||||
FT_Outline* outline;
|
||||
int detail;
|
||||
int curContour;
|
||||
int* bounds;
|
||||
std::vector<SST_Vec2f> pts;
|
||||
|
||||
//Process a curve
|
||||
int processCurve(int contour, int curveStart);
|
||||
|
||||
//Evaluate a line segment
|
||||
void evalLinear(FT_Vector* p0, FT_Vector* p1);
|
||||
|
||||
//Evaluate a quadric path (called conic)
|
||||
void evalQuadratic(FT_Vector* p0, FT_Vector* p1, FT_Vector* p2);
|
||||
|
||||
//Evaluate a cubic path
|
||||
void evalCubic(FT_Vector* p0, FT_Vector* p1, FT_Vector* p2, FT_Vector* p3);
|
||||
|
||||
//Adds a point
|
||||
void addPoint(const FT_Vector* pt);
|
||||
|
||||
public:
|
||||
/*
|
||||
Constructor.
|
||||
|
||||
@param _outline -
|
||||
@param _detail -
|
||||
*/
|
||||
ZOutlineEvaluator(FT_Outline* _outline, int _detail);
|
||||
|
||||
/*
|
||||
Destructor.
|
||||
*/
|
||||
~ZOutlineEvaluator();
|
||||
|
||||
/*
|
||||
public ZOutlineEvaluator::evaluate
|
||||
|
||||
TODO
|
||||
|
||||
@return (void)
|
||||
@context (all)
|
||||
*/
|
||||
void evaluate();
|
||||
|
||||
/*
|
||||
public ZOutlineEvaluator::getContourCount
|
||||
|
||||
TODO
|
||||
|
||||
@return (int)
|
||||
@context (all)
|
||||
*/
|
||||
int getContourCount() const;
|
||||
|
||||
/*
|
||||
public ZOutlineEvaluator::getContourStart
|
||||
|
||||
TODO
|
||||
|
||||
@param contour -
|
||||
@return (int)
|
||||
@context (all)
|
||||
*/
|
||||
int getContourStart(int contour) const;
|
||||
|
||||
/*
|
||||
public ZOutlineEvaluator::getContourEnd
|
||||
|
||||
TODO
|
||||
|
||||
@param contour -
|
||||
@return (int)
|
||||
@context (all)
|
||||
*/
|
||||
int getContourEnd(int contour) const;
|
||||
|
||||
/*
|
||||
public ZOutlineEvaluator::getPoint
|
||||
|
||||
TODO
|
||||
|
||||
@param pt -
|
||||
@return (const SST_Vec2f*)
|
||||
@context (all)
|
||||
*/
|
||||
const SST_Vec2f* getPoint(int pt) const;
|
||||
|
||||
/*
|
||||
public ZOutlineEvaluator::printContourPoints
|
||||
|
||||
TODO
|
||||
|
||||
@param contour -
|
||||
@return (void)
|
||||
@context (all)
|
||||
*/
|
||||
void printContourPoints(int contour);
|
||||
};
|
||||
|
||||
#endif
|
||||
140
Include/ZRendererUtil/ZParticleEffect.h
Normal file
140
Include/ZRendererUtil/ZParticleEffect.h
Normal file
@@ -0,0 +1,140 @@
|
||||
/*
|
||||
ZParticleEffect.h
|
||||
Author: James Russell <jcrussell@762studios.com>
|
||||
|
||||
Purpose: A particle effect class which maintains a set of particle emitters.
|
||||
|
||||
Changelog
|
||||
2011/08/28 - creation (jcrussell)
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef _ZPARTICLEEFFECT_H
|
||||
#define _ZPARTICLEEFFECT_H
|
||||
|
||||
#include <ZRenderer/ZRenderer.hpp>
|
||||
#include <ZRendererUtil/ZParticleEmitter.h>
|
||||
|
||||
class ZParticleEffect
|
||||
{
|
||||
private:
|
||||
//The name of this particle effect
|
||||
ZString Name;
|
||||
|
||||
//Boolean indicating this particle effect has completed
|
||||
bool bIsFinished;
|
||||
|
||||
//The emitters attached to this particle effect
|
||||
ZArray< ZSmartPointer<ZParticleEmitter> > Emitters;
|
||||
|
||||
public:
|
||||
/*
|
||||
Default Constructor.
|
||||
*/
|
||||
ZParticleEffect();
|
||||
|
||||
/*
|
||||
Parameterized Constructor.
|
||||
|
||||
@param _name - the name of this particle effect
|
||||
*/
|
||||
ZParticleEffect(const ZString& _name);
|
||||
|
||||
/*
|
||||
Destructor.
|
||||
*/
|
||||
~ZParticleEffect();
|
||||
|
||||
/*
|
||||
public ZParticleEffect::AddEmitter
|
||||
|
||||
Adds an emitter to this particle effect. The emitter will be updated and rendered when the
|
||||
effect is.
|
||||
|
||||
@param _emitter - the emitter to add
|
||||
@return (void)
|
||||
@context (all)
|
||||
*/
|
||||
void AddEmitter(ZPtr<ZParticleEmitter> _emitter);
|
||||
|
||||
/*
|
||||
public ZParticleEffect::GetName
|
||||
|
||||
Gets the name of this particle effect.
|
||||
|
||||
@return (ZString) - the name of this effect
|
||||
@context (all)
|
||||
*/
|
||||
ZString GetName();
|
||||
|
||||
/*
|
||||
public ZParticleEffect::IsFinished
|
||||
|
||||
Returns true if this particle effect is finished.
|
||||
|
||||
@return (bool) - true if completed, false otherwise
|
||||
@context (all)
|
||||
*/
|
||||
bool IsFinished();
|
||||
|
||||
/*
|
||||
public ZParticleEffect::RemoveEmitter
|
||||
|
||||
Removes an emitter from this particle effect.
|
||||
|
||||
@param _emitter - the particle effect
|
||||
@return (bool) - true if the emitter was contained, false otherwise
|
||||
@context (all)
|
||||
*/
|
||||
bool RemoveEmitter(ZPtr<ZParticleEmitter> _emitter);
|
||||
|
||||
/*
|
||||
public ZParticleEffect::Render
|
||||
|
||||
Renders this particle effect using the provided renderer.
|
||||
|
||||
@param _renderer - the renderer to use
|
||||
@param _frameContext - the frame context to render with
|
||||
@param _drawGroup - the draw group to render in
|
||||
@return (void)
|
||||
@context (all)
|
||||
*/
|
||||
void Render(ZRenderer* _renderer, ZFrameContext _frameContext, int _drawGroup = 0);
|
||||
|
||||
/*
|
||||
public ZParticleEffect::SetFinished
|
||||
|
||||
Sets completion status of this effect to the provided value.
|
||||
|
||||
@param _status - completion status (true if finished, false otherwise)
|
||||
@return (void)
|
||||
@context (all)
|
||||
*/
|
||||
void SetFinished(bool _status);
|
||||
|
||||
/*
|
||||
public ZParticleEffect::SetName
|
||||
|
||||
Sets the name of this particle effect.
|
||||
|
||||
@param _name - the name of this particle effect
|
||||
@return (void)
|
||||
@context (all)
|
||||
*/
|
||||
void SetName(const ZString& _name);
|
||||
|
||||
/*
|
||||
public ZParticleEffect::Update
|
||||
|
||||
Updates this particle effect with the provided delta time since last call to update.
|
||||
|
||||
@param _dt - the time (in milliseconds) since the last call to Update
|
||||
@return (void)
|
||||
@context (all)
|
||||
*/
|
||||
void Update(size_t _dt);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
200
Include/ZRendererUtil/ZParticleEmitter.h
Normal file
200
Include/ZRendererUtil/ZParticleEmitter.h
Normal file
@@ -0,0 +1,200 @@
|
||||
/*
|
||||
ZParticleEmitter.h
|
||||
Author: James Russell <jcrussell@762studios.com>
|
||||
|
||||
Purpose: Particle emitter class, which maintains a set of strategies used to store, create, update, and render
|
||||
particles.
|
||||
|
||||
Changelog
|
||||
2011/08/28 - creation (jcrussell)
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef _ZPARTICLEEMITTER_H
|
||||
#define _ZPARTICLEEMITTER_H
|
||||
|
||||
#include <ZRenderer/ZRenderer.hpp>
|
||||
#include <ZRendererUtil/ZParticleStorageAllocator.h>
|
||||
#include <ZRendererUtil/ZParticleSpawnStrategy.h>
|
||||
#include <ZRendererUtil/ZParticleUpdateStrategy.h>
|
||||
#include <ZRendererUtil/ZParticleRenderStrategy.h>
|
||||
|
||||
//Forward Declaration
|
||||
class ZParticleEffect;
|
||||
|
||||
class ZParticleEmitter
|
||||
{
|
||||
protected:
|
||||
//Number of particles at a time this emitter supports
|
||||
size_t MaxParticles;
|
||||
|
||||
//Boolean indicating this emitter is complete (no longer emits particles)
|
||||
bool bIsFinished;
|
||||
|
||||
//The transform for the particle emitter
|
||||
ZMatrix44f Transform;
|
||||
|
||||
//Particle Generator
|
||||
ZPtr<ZParticleStorageAllocator> StorageAllocator;
|
||||
|
||||
//Particle Spawn Strategy
|
||||
ZPtr<ZParticleSpawnStrategy> SpawnStrategy;
|
||||
|
||||
//Particle Update Strategy
|
||||
ZPtr<ZParticleUpdateStrategy> UpdateStrategy;
|
||||
|
||||
//Particle Render Strategy
|
||||
ZPtr<ZParticleRenderStrategy> RenderStrategy;
|
||||
|
||||
public:
|
||||
/*
|
||||
Default Constructor.
|
||||
*/
|
||||
ZParticleEmitter();
|
||||
|
||||
/*
|
||||
Destructor.
|
||||
*/
|
||||
~ZParticleEmitter();
|
||||
|
||||
/*
|
||||
public ZParticleEmitter::GetMaxParticles
|
||||
|
||||
Returns the current amount of max particles this particle emitter supports.
|
||||
|
||||
@return (size_t)
|
||||
@context (all)
|
||||
*/
|
||||
size_t GetMaxParticles();
|
||||
|
||||
/*
|
||||
public ZParticleEmitter::GetTransform
|
||||
|
||||
Gets the local transform for this particle emitter.
|
||||
|
||||
@return (ZMatrix44f) - local transform for this emitter
|
||||
@context (all)
|
||||
*/
|
||||
ZMatrix44f GetTransform();
|
||||
|
||||
/*
|
||||
public ZParticleEmitter::IsFinished
|
||||
|
||||
Returns true if this particle emitter will no longer emit particles.
|
||||
|
||||
@return (bool) - true if finished, false otherwise
|
||||
@context (all)
|
||||
*/
|
||||
bool IsFinished();
|
||||
|
||||
/*
|
||||
public ZParticleEmitter::Render
|
||||
|
||||
Renders the contained particles using the provided render strategy.
|
||||
|
||||
@param _particleEffect - the parent particle effect
|
||||
@param _renderer - the renderer to use
|
||||
@param _context - frame context to render with
|
||||
@param _drawGroup - the draw group to render with
|
||||
@return (void)
|
||||
@context (all)
|
||||
*/
|
||||
void Render(ZParticleEffect* _particleEffect, ZRenderer* _renderer, ZFrameContext _context, int _drawGroup);
|
||||
|
||||
/*
|
||||
public ZParticleEmitter::SetMaxParticles
|
||||
|
||||
Sets the maximum number of particles this emitter supports.
|
||||
|
||||
@param _maxParticles - the maximum particle count
|
||||
@return (void)
|
||||
@context (all)
|
||||
*/
|
||||
void SetMaxParticles(size_t _maxParticles);
|
||||
|
||||
/*
|
||||
public ZParticleEmitter::SetFinished
|
||||
|
||||
Sets completion status of this emitter to the provided value.
|
||||
|
||||
@param _status - completion status (true if finished, false otherwise)
|
||||
@return (void)
|
||||
@context (all)
|
||||
*/
|
||||
void SetFinished(bool _status);
|
||||
|
||||
/*
|
||||
public ZParticleEmitter::SetParticleStorageAllocator
|
||||
|
||||
Sets the particle storage allocator for this particle emitter. This will call
|
||||
ZParticleStorageAllocator::AllocateParticleStorage.
|
||||
|
||||
@param _allocator - the allocator to use
|
||||
@param _maxParticles - the number of particles to allocate storage for
|
||||
@return (ZPtr<ZParticleStorageAllocator>) - the storage allocator that was previously attached
|
||||
@context (all)
|
||||
*/
|
||||
ZPtr<ZParticleStorageAllocator> SetParticleStorageAllocator(ZPtr<ZParticleStorageAllocator> _allocator, size_t _maxParticles);
|
||||
|
||||
/*
|
||||
public ZParticleEmitter::SetParticleSpawnStrategy
|
||||
|
||||
Sets the particle span strategy for this particle emitter.
|
||||
|
||||
@param _spawnStrategy - the spawn strategy to use
|
||||
@return (ZPtr<ZParticleSpawnStrategy>) - the spawn strategy that was previously attached
|
||||
@context (all)
|
||||
*/
|
||||
ZPtr<ZParticleSpawnStrategy> SetParticleSpawnStrategy(ZPtr<ZParticleSpawnStrategy> _spawnStrategy);
|
||||
|
||||
/*
|
||||
public ZParticleEmitter::SetParticleUpdateStrategy
|
||||
|
||||
Sets the particle update strategy for this particle emitter.
|
||||
|
||||
@param _updateStrategy - the particle update strategy to use
|
||||
@return (ZPtr<ZParticleUpdateStrategy>) - the update strategy that was previously attached
|
||||
@context (all)
|
||||
*/
|
||||
ZPtr<ZParticleUpdateStrategy> SetParticleUpdateStrategy(ZPtr<ZParticleUpdateStrategy> _updateStrategy);
|
||||
|
||||
/*
|
||||
public ZParticleEmitter::SetParticleRenderStrategy
|
||||
|
||||
Sets the render strategy for this particle emitter. This will call AllocateBuffers on the render strategy.
|
||||
|
||||
@param _renderStrategy - the render strategy to use
|
||||
@param _renderer - the renderer to allocate buffers from
|
||||
@return (ZPtr<ZParticleRenderStrategy>) - the render strategy that was previously attached
|
||||
@context (all)
|
||||
*/
|
||||
ZPtr<ZParticleRenderStrategy> SetParticleRenderStrategy(ZPtr<ZParticleRenderStrategy> _renderStrategy, ZRenderer *_renderer);
|
||||
|
||||
/*
|
||||
public ZParticleEmitter::SetTransform
|
||||
|
||||
Sets the transform for this particle emitter.
|
||||
|
||||
@param _transform - the transform to use
|
||||
@return (void)
|
||||
@context (all)
|
||||
*/
|
||||
void SetTransform(ZMatrix44f _transform);
|
||||
|
||||
/*
|
||||
public ZParticleEmitter::Update
|
||||
|
||||
Runs through the various installed strategies, which can will both create new particles (as dictated by strategy)
|
||||
and update existing ones.
|
||||
|
||||
@param _particleEffect - the parent particle effect
|
||||
@param _dt - the time (in milliseconds) since last update
|
||||
@return (void)
|
||||
@context (all)
|
||||
*/
|
||||
void Update(ZParticleEffect* _particleEffect, size_t _dt);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
80
Include/ZRendererUtil/ZParticleRenderStrategy.h
Normal file
80
Include/ZRendererUtil/ZParticleRenderStrategy.h
Normal file
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
ZParticleRenderStrategy.h
|
||||
Author: James Russell <jcrussell@762studios.com>
|
||||
|
||||
Purpose: TODO
|
||||
|
||||
Changelog
|
||||
2011/08/28 - creation (jcrussell)
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef _ZPARTICLERENDERSTRATEGY_H
|
||||
#define _ZPARTICLERENDERSTRATEGY_H
|
||||
|
||||
#include <ZUtil/ZUtil.hpp>
|
||||
#include <ZRenderer/ZRenderer.hpp>
|
||||
#include <ZRendererUtil/ZParticleStorageAllocator.h>
|
||||
|
||||
//Forward Declarations
|
||||
class ZParticleEffect;
|
||||
class ZParticleEmitter;
|
||||
class ZParticleStorageAllocator;
|
||||
|
||||
class ZParticleRenderStrategy
|
||||
{
|
||||
public:
|
||||
//Virtual Destructor
|
||||
~ZParticleRenderStrategy() { }
|
||||
|
||||
/*
|
||||
public ZParticleRenderStrategy::AllocateBuffers
|
||||
|
||||
Called when the particle render strategy needs to allocate buffers from the renderer
|
||||
for particle data.
|
||||
|
||||
@param _maxParticles - the number of particles to allocate buffer space for
|
||||
@param _renderer - the renderer to allocate buffers from
|
||||
@return (void)
|
||||
@context (all)
|
||||
*/
|
||||
virtual void AllocateBuffers(size_t _maxParticles, ZRenderer *_renderer) = 0;
|
||||
|
||||
/*
|
||||
virtual public ZParticleRenderStrategy::CheckParticleFormat
|
||||
|
||||
Checks to see if this render strategy can render the provided particle format.
|
||||
|
||||
@param _format - string description of the particle format
|
||||
@return (bool) - true if this render strategy can handle it, false otherwise
|
||||
@context (all)
|
||||
*/
|
||||
virtual bool CheckParticleFormat(const ZString& _format) = 0;
|
||||
|
||||
/*
|
||||
virtual public ZParticleUpdateStrategy::RenderParticles
|
||||
|
||||
Renders the particle data present in particle storage.
|
||||
|
||||
@param _particleEffect - the emitter's parent particle effect
|
||||
@param _particleEmitter - the parent emitter
|
||||
@param _storageAllocator - the particle data storage
|
||||
@param _renderer - the renderer to render to
|
||||
@param _frameContext - the frame context to render with
|
||||
@return (void)
|
||||
@context (all)
|
||||
*/
|
||||
virtual void RenderParticles(ZParticleEffect* _particleEffect,
|
||||
ZParticleEmitter* _particleEmitter,
|
||||
ZParticleStorageAllocator* _storageAllocator,
|
||||
ZRenderer* _renderer,
|
||||
ZFrameContext _frameContext,
|
||||
const ZMatrix44f& _transform,
|
||||
int _drawGroup
|
||||
) = 0;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
61
Include/ZRendererUtil/ZParticleSpawnStrategy.h
Normal file
61
Include/ZRendererUtil/ZParticleSpawnStrategy.h
Normal file
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
ZParticleSpawnStrategy.h
|
||||
Author: James Russell <jcrussell@762studios.com>
|
||||
|
||||
Purpose: TODO
|
||||
|
||||
Changelog
|
||||
2011/08/28 - creation (jcrussell)
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef _ZPARTICLESPAWNSTRATEGY_H
|
||||
#define _ZPARTICLESPAWNSTRATEGY_H
|
||||
|
||||
#include <ZUtil/ZUtil.hpp>
|
||||
|
||||
//Forward Declarations
|
||||
class ZParticleEffect;
|
||||
class ZParticleEmitter;
|
||||
class ZParticleStorageAllocator;
|
||||
|
||||
class ZParticleSpawnStrategy
|
||||
{
|
||||
public:
|
||||
//Virtual Destructor
|
||||
~ZParticleSpawnStrategy() { }
|
||||
|
||||
/*
|
||||
virtual public ZParticleSpawnStrategy::CheckParticleFormat
|
||||
|
||||
Checks to see if this spawn strategy can spawn the provided particle format.
|
||||
|
||||
@param _format - string description of the particle format
|
||||
@return (bool) - true if this spawn strategy can handle it, false otherwise
|
||||
@context (all)
|
||||
*/
|
||||
virtual bool CheckParticleFormat(const ZString& _format) = 0;
|
||||
|
||||
/*
|
||||
virtual public ZParticleSpawnStrategy::UpdateSpawn
|
||||
|
||||
An update call to the spawn strategy that determines if more particles should be created. If so, the new particle data
|
||||
can be placed directly into particle storage.
|
||||
|
||||
@param _particleEffect - the emitter's parent particle effect
|
||||
@param _particleEmitter - the parent emitter
|
||||
@param _storageAllocator - particle storage used by this particle effect
|
||||
@param _dt - the time (in milliseconds) since last update
|
||||
@return (void)
|
||||
@context (all)
|
||||
*/
|
||||
virtual void UpdateSpawn(ZParticleEffect* _particleEffect,
|
||||
ZParticleEmitter* _particleEmitter,
|
||||
ZParticleStorageAllocator* _storageAllocator,
|
||||
size_t _dt
|
||||
) = 0;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
82
Include/ZRendererUtil/ZParticleStorageAllocator.h
Normal file
82
Include/ZRendererUtil/ZParticleStorageAllocator.h
Normal file
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
ZParticleGenerator.h
|
||||
Author: James Russell <jcrussell@762studios.com>
|
||||
|
||||
Purpose: The particle generator is responsible for generating / allocating the particle data
|
||||
and storing it for the duration the particle emitter is alive.
|
||||
|
||||
Also responsible for cleanup.
|
||||
|
||||
Changelog
|
||||
2011/08/28 - creation (jcrussell)
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef _ZPARTICLESTORAGEALLOCATOR_H
|
||||
#define _ZPARTICLESTORAGEALLOCATOR_H
|
||||
|
||||
#include <ZUtil/ZUtil.hpp>
|
||||
|
||||
//Forward Declaration
|
||||
class ZParticleEffect;
|
||||
class ZParticleEmitter;
|
||||
|
||||
class ZParticleStorageAllocator
|
||||
{
|
||||
public:
|
||||
//Virtual Destructor
|
||||
virtual ~ZParticleStorageAllocator() { }
|
||||
|
||||
/*
|
||||
virtual public ZParticleGenerator::AllocateParticleStorage
|
||||
|
||||
Allocates particle storage for this particle emitter.
|
||||
|
||||
@param _emitter - the emitter we are creating storage for
|
||||
@param _maxParticles - the number of particles we allocate storage for
|
||||
@return (void)
|
||||
@context (all)
|
||||
*/
|
||||
virtual void AllocateParticleStorage(ZParticleEmitter* _emitter, size_t _maxParticles) = 0;
|
||||
|
||||
/*
|
||||
virtual public ZParticleGenerator::DeallocateParticleStorage
|
||||
|
||||
Deallocates storage previously allocated with AllocateParticleStorage.
|
||||
|
||||
@return (void)
|
||||
@context (all)
|
||||
*/
|
||||
virtual void DeallocateParticleStorage() = 0;
|
||||
|
||||
/*
|
||||
virtual public ZParticleStorageAllocator::GetParticleFormat
|
||||
|
||||
Returns a string 'type' indicating the type of particle storage used by this allocator. Checked
|
||||
against the other strategies to ensure compatibility.
|
||||
|
||||
@return (ZString)
|
||||
@context (all)
|
||||
*/
|
||||
virtual ZString GetParticleFormat() = 0;
|
||||
|
||||
/*
|
||||
virtual public ZParticleStorageAllocator::Update
|
||||
|
||||
Updates the storage allocator, indicating another frame has passed.
|
||||
|
||||
@param _effect - the particle effect
|
||||
@param _emitter - the particle emitter
|
||||
@param _dt - amount of time passed (in ms)
|
||||
@return (void)
|
||||
@context (all)
|
||||
*/
|
||||
virtual void Update(ZParticleEffect *_effect,
|
||||
ZParticleEmitter *_emitter,
|
||||
size_t _dt
|
||||
) = 0;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
60
Include/ZRendererUtil/ZParticleUpdateStrategy.h
Normal file
60
Include/ZRendererUtil/ZParticleUpdateStrategy.h
Normal file
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
ZParticleUpdateStrategy.h
|
||||
Author: James Russell <jcrussell@762studios.com>
|
||||
|
||||
Purpose: TODO
|
||||
|
||||
Changelog
|
||||
2011/08/28 - creation (jcrussell)
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef _ZPARTICLEUPDATESTRATEGY_H
|
||||
#define _ZPARTICLEUPDATESTRATEGY_H
|
||||
|
||||
#include <ZUtil/ZUtil.hpp>
|
||||
|
||||
//Forward Declarations
|
||||
class ZParticleEffect;
|
||||
class ZParticleEmitter;
|
||||
class ZParticleStorageAllocator;
|
||||
|
||||
class ZParticleUpdateStrategy
|
||||
{
|
||||
public:
|
||||
//Virtual Destructor
|
||||
~ZParticleUpdateStrategy() { }
|
||||
|
||||
/*
|
||||
virtual public ZParticleUpdateStrategy::CheckParticleFormat
|
||||
|
||||
Checks to see if this update strategy can update the provided particle format.
|
||||
|
||||
@param _format - string description of the particle format
|
||||
@return (bool) - true if this udpate strategy can handle it, false otherwise
|
||||
@context (all)
|
||||
*/
|
||||
virtual bool CheckParticleFormat(const ZString& _format) = 0;
|
||||
|
||||
/*
|
||||
virtual public ZParticleUpdateStrategy::UpdateParticles
|
||||
|
||||
Updates the particle data present in particle storage.
|
||||
|
||||
@param _particleEffect - the emitter's parent particle effect
|
||||
@param _particleEmitter - the parent emitter
|
||||
@param _storageAllocator - the particle data storage
|
||||
@param _dt - the time (in millisecond) since last update
|
||||
@return (void)
|
||||
@context (all)
|
||||
*/
|
||||
virtual void UpdateParticles(ZParticleEffect* _particleEffect,
|
||||
ZParticleEmitter* _particleEmitter,
|
||||
ZParticleStorageAllocator* _storageAllocator,
|
||||
size_t _dt
|
||||
) = 0;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
145
Include/ZRendererUtil/ZPerspectiveCamera.hpp
Normal file
145
Include/ZRendererUtil/ZPerspectiveCamera.hpp
Normal file
@@ -0,0 +1,145 @@
|
||||
#include <SST/SST_Math.h>
|
||||
|
||||
//Perspective Camera Class, Used to compute camera transforms
|
||||
class ZPerspectiveCamera
|
||||
{
|
||||
protected:
|
||||
bool transformDirty; //Dirty flag for computing camera transform
|
||||
|
||||
SST_Mat44f CameraTransform;
|
||||
|
||||
SST_Vec3f EyePoint;
|
||||
SST_Vec3f ForwardVec;
|
||||
SST_Vec3f UpVec;
|
||||
SST_Vec3f RightVec;
|
||||
|
||||
float NearClip;
|
||||
float FarClip;
|
||||
float XFov;
|
||||
float AspectRatio;
|
||||
|
||||
void ComputeCameraTransform()
|
||||
{
|
||||
SST_Mat44f perspectiveMatrix;
|
||||
SST_Mat44f viewMatrix;
|
||||
SST_Vec3f target = {ForwardVec.x + EyePoint.x,
|
||||
ForwardVec.y + EyePoint.y,
|
||||
ForwardVec.z + EyePoint.z};
|
||||
|
||||
SST_Math_Mat44fCreatePerspective(&perspectiveMatrix, this->XFov, this->AspectRatio, this->NearClip, this->FarClip);
|
||||
SST_Math_Mat44fCreateLookAt(&viewMatrix, &this->EyePoint, &target, &this->UpVec);
|
||||
SST_Math_Mat44fMultiplyMatrix(&perspectiveMatrix, &viewMatrix, &this->CameraTransform);
|
||||
|
||||
this->transformDirty = false;
|
||||
}
|
||||
|
||||
//Flags the transform as 'dirty'
|
||||
void FlagTransforms()
|
||||
{
|
||||
this->transformDirty = true;
|
||||
}
|
||||
|
||||
public:
|
||||
ZPerspectiveCamera()
|
||||
{
|
||||
SST_Vec3f eye = { 0, 0, 0 };
|
||||
SST_Vec3f forward = { 0, 1, 0 };
|
||||
SST_Vec3f up = { 0, 0, 1 };
|
||||
SST_Vec3f right = { 1, 0, 1 };
|
||||
|
||||
SetEyePoint(&eye);
|
||||
SetForwardVec(&forward);
|
||||
SetUpVec(&up);
|
||||
SetRightVec(&right);
|
||||
|
||||
NearClip = 1.0f;
|
||||
FarClip = 10000.0f;
|
||||
XFov = 90.0f;
|
||||
AspectRatio = 1.0f;
|
||||
|
||||
this->transformDirty = true;
|
||||
}
|
||||
|
||||
//Getters for camera data
|
||||
const SST_Vec3f* GetEyePoint() { return &EyePoint; }
|
||||
const SST_Vec3f* GetForwardVec() { return &ForwardVec; }
|
||||
const SST_Vec3f* GetUpVec() { return &UpVec; }
|
||||
const SST_Vec3f* GetRightVec() { return &RightVec; }
|
||||
float GetNearClip() { return NearClip; }
|
||||
float GetFarClip() { return FarClip; }
|
||||
float GetXFov() { return XFov; }
|
||||
float GetAspectRatio() { return AspectRatio; }
|
||||
|
||||
//Setters for camera data. Will flag the transform as 'dirty'
|
||||
void SetEyePoint(const SST_Vec3f* _eye) { EyePoint = *_eye; FlagTransforms(); }
|
||||
void SetForwardVec(const SST_Vec3f* _forward) { ForwardVec = *_forward; FlagTransforms(); }
|
||||
void SetUpVec(const SST_Vec3f* _up) { UpVec = *_up; FlagTransforms(); }
|
||||
void SetRightVec(const SST_Vec3f* _right) { RightVec = *_right; FlagTransforms(); }
|
||||
|
||||
void SetNearClip(float _nearClip) { NearClip = _nearClip; FlagTransforms(); }
|
||||
void SetFarClip(float _farClip) { FarClip = _farClip; FlagTransforms(); }
|
||||
void SetXFov(float _xFov) { XFov = _xFov; FlagTransforms(); }
|
||||
void SetAspectRatio(float _ratio) { AspectRatio = _ratio; FlagTransforms(); }
|
||||
|
||||
//Movement methods, which move the camera in the direction if it's basis vectors by a factor
|
||||
void MoveForward(float t)
|
||||
{
|
||||
SST_Vec3f tmp;
|
||||
|
||||
SST_Math_Vec3fScale(&ForwardVec, t, &tmp);
|
||||
SST_Math_Vec3fAddLocal(&EyePoint, &tmp);
|
||||
|
||||
FlagTransforms();
|
||||
}
|
||||
|
||||
void MoveUp(float t)
|
||||
{
|
||||
SST_Vec3f tmp;
|
||||
|
||||
SST_Math_Vec3fScale(&UpVec, t, &tmp);
|
||||
SST_Math_Vec3fAddLocal(&EyePoint, &tmp);
|
||||
|
||||
FlagTransforms();
|
||||
}
|
||||
|
||||
void MoveRight(float t)
|
||||
{
|
||||
SST_Vec3f tmp;
|
||||
|
||||
SST_Math_Vec3fScale(&RightVec, t, &tmp);
|
||||
SST_Math_Vec3fAddLocal(&EyePoint, &tmp);
|
||||
FlagTransforms();
|
||||
}
|
||||
|
||||
//Rotation Methods, which rotate the camera about it's basis vectors
|
||||
void RotateUp(float t)
|
||||
{
|
||||
SST_Math_Vec3fRotateAboutLocal(&this->ForwardVec, &this->RightVec, t);
|
||||
SST_Math_Vec3fRotateAboutLocal(&this->UpVec, &this->RightVec, t);
|
||||
FlagTransforms();
|
||||
}
|
||||
|
||||
void RotateRight(float t)
|
||||
{
|
||||
SST_Math_Vec3fRotateAboutLocal(&this->ForwardVec, &this->UpVec, t);
|
||||
SST_Math_Vec3fRotateAboutLocal(&this->RightVec, &this->UpVec, t);
|
||||
FlagTransforms();
|
||||
}
|
||||
|
||||
void RotateClockwise(float t)
|
||||
{
|
||||
SST_Math_Vec3fRotateAboutLocal(&this->UpVec, &this->ForwardVec, t);
|
||||
SST_Math_Vec3fRotateAboutLocal(&this->RightVec, &this->ForwardVec, t);
|
||||
FlagTransforms();
|
||||
}
|
||||
|
||||
//Camera transform getters, which will trigger a recompute of the transform matrix if need be
|
||||
const SST_Mat44f* GetCameraTransform()
|
||||
{
|
||||
if (this->transformDirty)
|
||||
{
|
||||
this->ComputeCameraTransform();
|
||||
}
|
||||
return &this->CameraTransform;
|
||||
}
|
||||
};
|
||||
84
Include/ZRendererUtil/ZSolidFontFace.hpp
Normal file
84
Include/ZRendererUtil/ZSolidFontFace.hpp
Normal file
@@ -0,0 +1,84 @@
|
||||
/*
|
||||
ZSolidFontFace.hpp
|
||||
Author: Patrick Baggett <ptbaggett@762studios.com>
|
||||
|
||||
Purpose: TODO
|
||||
|
||||
Changelog
|
||||
2011/09/18 - creation (ptbaggett)
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef _ZSOLIDFONTFACE_HPP
|
||||
#define _ZSOLIDFONTFACE_HPP
|
||||
|
||||
#include <SST/SST_Vec2.h>
|
||||
|
||||
#include <ZRendererUtil/ZFontRenderer.hpp> //Need ZFontBounds structure
|
||||
|
||||
//#include <vector>
|
||||
#include <ft2build.h>
|
||||
#include FT_FREETYPE_H
|
||||
#include FT_GLYPH_H
|
||||
|
||||
//Needed for friend class definition
|
||||
class ZSolidFontRenderer;
|
||||
|
||||
// Structure representing glyph information for use in solid font rendering
|
||||
struct ZSolidGlyphInfo
|
||||
{
|
||||
FT_UInt glyphId; // Glyph ID, as read from the font
|
||||
ZArray<SST_Vec2f> verts; // Vertex data, every 3 vertices makes a triangle
|
||||
int advancex; // Amount along X axis to advance pen by, in pixels
|
||||
int advancey; // Amount along Y axis to advance pen by, in pixels
|
||||
ZFontBounds bbox; // Bounding box of this glyph, in pixels
|
||||
};
|
||||
|
||||
//Class representing a font face created by a SolidFontRenderer
|
||||
class ZSolidFontFace
|
||||
{
|
||||
friend class ZSolidFontRenderer;
|
||||
private:
|
||||
FT_Face face;
|
||||
char* fontData;
|
||||
int hasKerning;
|
||||
|
||||
ZHashMap<unsigned int, ZSolidGlyphInfo> glyphCache;
|
||||
|
||||
public:
|
||||
|
||||
/*
|
||||
Default Constructor.
|
||||
*/
|
||||
ZSolidFontFace();
|
||||
|
||||
/*
|
||||
Destructor.
|
||||
*/
|
||||
~ZSolidFontFace();
|
||||
|
||||
/*
|
||||
public ZSolidFontFace::cacheGlyph
|
||||
|
||||
Caches a glyph, given a UTF-32 character code. The glyph must not already be loaded.
|
||||
|
||||
@param charCode - The UTF-32 character code for this glyph
|
||||
@return (const ZSolidGlyphInfo&) - Reference to the glyph information.
|
||||
@context (all)
|
||||
*/
|
||||
const ZSolidGlyphInfo& CacheGlyph(unsigned int charCode);
|
||||
|
||||
/*
|
||||
public ZSolidFontFace::getGlyph
|
||||
|
||||
Gets a glyph from the cache, or loads it if necessary.
|
||||
|
||||
@param charCode -
|
||||
@return (const ZSolidGlyphInfo*)
|
||||
@context (all)
|
||||
*/
|
||||
const ZSolidGlyphInfo* GetGlyph(unsigned int charCode);
|
||||
};
|
||||
|
||||
#endif
|
||||
101
Include/ZRendererUtil/ZSolidFontRenderer.hpp
Normal file
101
Include/ZRendererUtil/ZSolidFontRenderer.hpp
Normal file
@@ -0,0 +1,101 @@
|
||||
/*
|
||||
ZSolidFontRenderer.hpp
|
||||
Author: Patrick Baggett <ptbaggett@762studios.com>
|
||||
|
||||
Purpose: TODO
|
||||
|
||||
Changelog
|
||||
2011/09/18 - creation (ptbaggett)
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef _ZSOLIDFONTRENDERER_H
|
||||
#define _ZSOLIDFONTRENDERER_H
|
||||
|
||||
#include <SST/SST_Mat44.h>
|
||||
|
||||
#include <ZRenderer/ZRenderer.hpp>
|
||||
#include <ZRenderer/ZDataBuffer.hpp>
|
||||
#include <ZRendererUtil/ZFontRendererBase.hpp>
|
||||
#include <ZRendererUtil/ZSolidFontFace.hpp>
|
||||
|
||||
#include <ft2build.h>
|
||||
#include FT_FREETYPE_H
|
||||
|
||||
#define TRICACHE_SIZE (8*1024) //Cache up to 8K polygons before drawing
|
||||
|
||||
class ZSolidFontRenderer : public ZFontRendererBase
|
||||
{
|
||||
protected:
|
||||
ZRenderer* renderer;
|
||||
ZPtr<ZDataBuffer> tricache;
|
||||
|
||||
const ZDataBufferStream* posstream;
|
||||
const ZDataBufferStream* colorstream;
|
||||
const ZDataBufferBlock* matrixBlock;
|
||||
const ZDataBufferBlock* indexBlock;
|
||||
|
||||
ZPtr<ZShaderProgram> shaderprogram;
|
||||
ZPtr<ZShaderParams> shaderparams;
|
||||
ZPtr<ZIndexParams> indexparams;
|
||||
ZPtr<ZVertexParams> vertexparams;
|
||||
|
||||
ZPtr<ZDataBuffer> uniforms;
|
||||
ZPtr<ZDataBuffer> indexes;
|
||||
|
||||
ZFrameContext ctx;
|
||||
SST_Mat44f xform;
|
||||
|
||||
//Internal used struct for vertex / color pairing
|
||||
struct SolidVertex
|
||||
{
|
||||
float x, y;
|
||||
float rgba[4];
|
||||
};
|
||||
|
||||
SolidVertex* vtx_dma;
|
||||
FT_Library library;
|
||||
float color[4];
|
||||
size_t nrTrisWritten;
|
||||
bool inRendering;
|
||||
|
||||
void flushTriCache();
|
||||
|
||||
public:
|
||||
|
||||
/*
|
||||
Constructor.
|
||||
|
||||
@param _renderer - the current renderer instance.
|
||||
*/
|
||||
ZSolidFontRenderer(ZRenderer* _renderer);
|
||||
|
||||
/*
|
||||
Destructor.
|
||||
*/
|
||||
virtual ~ZSolidFontRenderer();
|
||||
|
||||
//Subclass Implementation
|
||||
virtual ZFontFace CreateFontFace(int pixelSize, const void* fontData, unsigned int dataSize);
|
||||
|
||||
//Subclass Implementation
|
||||
virtual void DeleteFontFace(ZFontFace face);
|
||||
|
||||
//Subclass Implementation
|
||||
virtual void BeginText(ZFrameContext _ctx, const SST_Mat44f& _xform);
|
||||
|
||||
//Subclass Implementation
|
||||
virtual void EndText();
|
||||
|
||||
//Subclass Implementation
|
||||
virtual void RenderText(int x, int y, const char* text);
|
||||
|
||||
//Subclass Implementation
|
||||
virtual void ComputeBounds(const char* text, ZFontBounds* bounds);
|
||||
|
||||
//Subclass Implementation
|
||||
virtual void SetColor(float r, float g, float b, float a);
|
||||
};
|
||||
|
||||
#endif
|
||||
105
Include/ZRendererUtil/ZStandardParticleRenderStrategy.h
Normal file
105
Include/ZRendererUtil/ZStandardParticleRenderStrategy.h
Normal file
@@ -0,0 +1,105 @@
|
||||
/*
|
||||
ZStandardParticleRenderStrategy.h
|
||||
Author: James Russell <jcrussell@762studios.com>
|
||||
|
||||
Purpose: TODO
|
||||
|
||||
Changelog
|
||||
2011/09/11 - creation (jcrussell)
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef _ZSTANDARDPARTICLERENDERSTRATEGY_H
|
||||
#define _ZSTANDARDPARTICLERENDERSTRATEGY_H
|
||||
|
||||
#include <ZRendererUtil/ZParticleRenderStrategy.h>
|
||||
#include <ZRendererUtil/ZStandardParticleStorageAllocator.h>
|
||||
|
||||
class ZStandardParticleRenderStrategy : public ZParticleRenderStrategy
|
||||
{
|
||||
protected:
|
||||
//Vertex buffer
|
||||
ZPtr<ZDataBuffer> VertexBuffer;
|
||||
|
||||
//Index buffer
|
||||
ZPtr<ZDataBuffer> IndexBuffer;
|
||||
|
||||
//Material we use
|
||||
ZPtr<ZMaterialSurface> ParticleMaterial;
|
||||
|
||||
//Texture we'll be using
|
||||
ZPtr<ZTexture2D> ParticleTexture;
|
||||
|
||||
//Our render state
|
||||
ZRenderState RenderState;
|
||||
|
||||
//Our UV coordinates (per vertex)
|
||||
float UVs[8];
|
||||
|
||||
public:
|
||||
/*
|
||||
Constructor.
|
||||
|
||||
@param _maxParticles - maximum number of particles we will use
|
||||
@param _renderer - the renderer instance
|
||||
*/
|
||||
ZStandardParticleRenderStrategy();
|
||||
|
||||
/*
|
||||
Destructor.
|
||||
*/
|
||||
~ZStandardParticleRenderStrategy();
|
||||
|
||||
/*
|
||||
public ZStandardParticleRenderStrategy::SetParticleTexture
|
||||
|
||||
TODO
|
||||
|
||||
@param _texture -
|
||||
@return (void)
|
||||
@context (all)
|
||||
*/
|
||||
void SetParticleTexture(ZPtr<ZTexture2D> _texture);
|
||||
|
||||
/*
|
||||
public ZStandardParticleRenderStrategy::SetParticleTextureUVs
|
||||
|
||||
TODO
|
||||
|
||||
@param _uvs - uv coordinate array (size 8)
|
||||
@return (void)
|
||||
@context (all)
|
||||
*/
|
||||
void SetParticleTextureUVs(float *_uvs);
|
||||
|
||||
/*
|
||||
public ZStandardParticleRenderStrategy::SetRenderState
|
||||
|
||||
TODO
|
||||
|
||||
@param _state -
|
||||
@return (void)
|
||||
@context (all)
|
||||
*/
|
||||
void SetRenderState(ZRenderState _state);
|
||||
|
||||
//Subclass Override
|
||||
void AllocateBuffers(size_t _maxParticles, ZRenderer *_renderer);
|
||||
|
||||
//Subclass Override
|
||||
virtual bool CheckParticleFormat( const ZString& _format );
|
||||
|
||||
//Subclass Override
|
||||
virtual void RenderParticles(ZParticleEffect* _particleEffect,
|
||||
ZParticleEmitter* _particleEmitter,
|
||||
ZParticleStorageAllocator* _storageAllocator,
|
||||
ZRenderer* _renderer,
|
||||
ZFrameContext _frameContext,
|
||||
const ZMatrix44f& _transform,
|
||||
int _drawGroup );
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
218
Include/ZRendererUtil/ZStandardParticleSpawnStrategy.h
Normal file
218
Include/ZRendererUtil/ZStandardParticleSpawnStrategy.h
Normal file
@@ -0,0 +1,218 @@
|
||||
/*
|
||||
ZStandardParticleSpawnStrategy.h
|
||||
Author: James Russell <jcrussell@762studios.com>
|
||||
|
||||
Purpose: TODO
|
||||
|
||||
Changelog
|
||||
2011/09/11 - creation (jcrussell)
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef _ZSTANDARDPARTICLESPAWNSTRATEGY_H
|
||||
#define _ZSTANDARDPARTICLESPAWNSTRATEGY_H
|
||||
|
||||
#define ZSP_DEFAULT_SPAWN_MASS (1)
|
||||
|
||||
#define ZSP_DEFAULT_SPAWN_ENERGY (1000)
|
||||
|
||||
#define ZSP_DEFAULT_SPAWN_VELOCITY_X (0.0f)
|
||||
#define ZSP_DEFAULT_SPAWN_VELOCITY_Y (0.0f)
|
||||
#define ZSP_DEFAULT_SPAWN_VELOCITY_Z (0.0f)
|
||||
|
||||
#define ZSP_DEFAULT_SPAWN_FACING_X (0.0f)
|
||||
#define ZSP_DEFAULT_SPAWN_FACING_Y (0.0f)
|
||||
#define ZSP_DEFAULT_SPAWN_FACING_Z (1.0f)
|
||||
|
||||
#define ZSP_DEFAULT_SPAWN_SCALE_X (1.0f)
|
||||
#define ZSP_DEFAULT_SPAWN_SCALE_Y (1.0f)
|
||||
|
||||
#define ZSP_DEFAULT_SPAWN_COLOR_R (1.0f)
|
||||
#define ZSP_DEFAULT_SPAWN_COLOR_G (1.0f)
|
||||
#define ZSP_DEFAULT_SPAWN_COLOR_B (1.0f)
|
||||
#define ZSP_DEFAULT_SPAWN_COLOR_A (1.0f)
|
||||
|
||||
#define ZSP_DEFAULT_TEXTURE_U (0.0f)
|
||||
#define ZSP_DEFAULT_TEXTURE_V (0.0f)
|
||||
#define ZSP_DEFAULT_TEXTURE_OFFSET (1.0f)
|
||||
|
||||
#define ZSP_DEFAULT_SPAWN_INTERVAL (100)
|
||||
#define ZSP_DEFAULT_SPAWN_ANGLE (0.0f)
|
||||
#define ZSP_DEFAULT_SPAWN_COUNT_MIN (0)
|
||||
#define ZSP_DEFAULT_SPAWN_COUNT_MAX (1)
|
||||
|
||||
#include <ZRendererUtil/ZStandardParticleStorageAllocator.h>
|
||||
#include <ZRendererUtil/ZParticleSpawnStrategy.h>
|
||||
|
||||
class ZStandardParticleSpawnStrategy : public ZParticleSpawnStrategy
|
||||
{
|
||||
private:
|
||||
//The time until our next spawn
|
||||
int NextSpawn;
|
||||
|
||||
//Our current spawn group
|
||||
size_t CurrentSpawnGroup;
|
||||
|
||||
protected:
|
||||
//Template for the particle we will be spawning with
|
||||
ZStandardParticle TemplateParticle;
|
||||
|
||||
//The span between particle spawns
|
||||
size_t SpawnInterval;
|
||||
|
||||
//The half-angle we deviate within when spawning a particle [0.0 - pi]
|
||||
float SpawnAngle;
|
||||
|
||||
//The particle count spawn range (lower, upper)
|
||||
ZPair<size_t, size_t> SpawnCountRange;
|
||||
|
||||
public:
|
||||
/*
|
||||
Default Constructor.
|
||||
*/
|
||||
ZStandardParticleSpawnStrategy();
|
||||
|
||||
/*
|
||||
Destructor.
|
||||
*/
|
||||
virtual ~ZStandardParticleSpawnStrategy();
|
||||
|
||||
//Subclass Override
|
||||
virtual bool CheckParticleFormat( const ZString& _format );
|
||||
|
||||
//Subclass Override
|
||||
virtual void UpdateSpawn(ZParticleEffect* _particleEffect,
|
||||
ZParticleEmitter* _particleEmitter,
|
||||
ZParticleStorageAllocator* _storageAllocator,
|
||||
size_t _dt );
|
||||
|
||||
/*
|
||||
public ZStandardParticleSpawnStrategy::GetSpawnAngle
|
||||
|
||||
TODO
|
||||
|
||||
@return (float)
|
||||
@context (all)
|
||||
*/
|
||||
float GetSpawnAngle();
|
||||
|
||||
/*
|
||||
public ZStandardParticleSpawnStrategy::GetSpawnColor
|
||||
|
||||
TODO
|
||||
|
||||
@return (const ZVector4f&)
|
||||
@context (all)
|
||||
*/
|
||||
const ZVector4f& GetSpawnColor();
|
||||
|
||||
/*
|
||||
public ZStandardParticleSpawnStrategy::GetSpawnEnergy
|
||||
|
||||
TODO
|
||||
|
||||
@return (size_t)
|
||||
@context (all)
|
||||
*/
|
||||
size_t GetSpawnEnergy();
|
||||
|
||||
/*
|
||||
public ZStandardParticleSpawnStrategy::GetSpawnInterval
|
||||
|
||||
TODO
|
||||
|
||||
@return (size_t)
|
||||
@context (all)
|
||||
*/
|
||||
size_t GetSpawnInterval();
|
||||
|
||||
/*
|
||||
public ZStandardParticleSpawnStrategy::GetSpawnScale
|
||||
|
||||
TODO
|
||||
|
||||
@return (const ZVector2f&)
|
||||
@context (all)
|
||||
*/
|
||||
const ZVector2f& GetSpawnScale();
|
||||
|
||||
/*
|
||||
public ZStandardParticleSpawnStrategy::GetSpawnVelocity
|
||||
|
||||
TODO
|
||||
|
||||
@return (const ZVector3f&)
|
||||
@context (all)
|
||||
*/
|
||||
const ZVector3f& GetSpawnVelocity();
|
||||
|
||||
/*
|
||||
public ZStandardParticleSpawnStrategy::SetSpawnAngle
|
||||
|
||||
TODO
|
||||
|
||||
@param _angle -
|
||||
@return (void)
|
||||
@context (all)
|
||||
*/
|
||||
void SetSpawnAngle(float _angle);
|
||||
|
||||
/*
|
||||
public ZStandardParticleSpawnStrategy::SetSpawnColor
|
||||
|
||||
TODO
|
||||
|
||||
@param _color -
|
||||
@return (void)
|
||||
@context (all)
|
||||
*/
|
||||
void SetSpawnColor(const ZVector4f& _color);
|
||||
|
||||
/*
|
||||
public ZStandardParticleSpawnStrategy::SetSpawnEnergy
|
||||
|
||||
TODO
|
||||
|
||||
@param _energy -
|
||||
@return (void)
|
||||
@context (all)
|
||||
*/
|
||||
void SetSpawnEnergy(size_t _energy);
|
||||
|
||||
/*
|
||||
public ZStandardParticleSpawnStrategy::SetSpawnInterval
|
||||
|
||||
TODO
|
||||
|
||||
@param _interval -
|
||||
@return (void)
|
||||
@context (all)
|
||||
*/
|
||||
void SetSpawnInterval(size_t _interval);
|
||||
|
||||
/*
|
||||
public ZStandardParticleSpawnStrategy::SetSpawnScale
|
||||
|
||||
TODO
|
||||
|
||||
@param _scale -
|
||||
@return (void)
|
||||
@context (all)
|
||||
*/
|
||||
void SetSpawnScale(const ZVector2f& _scale);
|
||||
|
||||
/*
|
||||
public ZStandardParticleSpawnStrategy::SetDirection
|
||||
|
||||
TODO
|
||||
|
||||
@param _direction -
|
||||
@return (void)
|
||||
@context (all)
|
||||
*/
|
||||
void SetSpawnVelocity(const ZVector3f& _velocity);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
167
Include/ZRendererUtil/ZStandardParticleStorageAllocator.h
Normal file
167
Include/ZRendererUtil/ZStandardParticleStorageAllocator.h
Normal file
@@ -0,0 +1,167 @@
|
||||
/*
|
||||
ZStandardParticleStorageAllocator.h
|
||||
Author: James Russell <jcrussell@762studios.com>
|
||||
|
||||
Purpose: Standard particle type allocator. Stores particle data as an array of structs containing particle data.
|
||||
|
||||
Changelog
|
||||
2011/09/11 - creation (jcrussell)
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef _ZSTANDARDPARTICLESTORAGEALLOCATOR_H
|
||||
#define _ZSTANDARDPARTICLESTORAGEALLOCATOR_H
|
||||
|
||||
#include <ZRendererUtil/ZParticleStorageAllocator.h>
|
||||
|
||||
//Struct containing our per-particle data
|
||||
struct ZStandardParticle
|
||||
{
|
||||
//Particle mass (sign indicates charge)
|
||||
int Mass;
|
||||
|
||||
//Particle Energy (when zero or less, dead)
|
||||
int Energy;
|
||||
|
||||
//Particle Position (offset from emitter transform)
|
||||
ZVector3f Position;
|
||||
|
||||
//Particle Facing (only matters if not billboarding)
|
||||
ZVector3f Facing;
|
||||
|
||||
//Particle Velocity
|
||||
ZVector3f Velocity;
|
||||
|
||||
//Particle Scaling
|
||||
ZVector2f Scale;
|
||||
|
||||
//Particle Color (per vertex, includes alpha)
|
||||
// 3 --- 2
|
||||
// | |
|
||||
// 0 --- 1
|
||||
ZVector4f Color[4];
|
||||
|
||||
//Texture data (U, V, texture width and height)
|
||||
ZVector3f TextureData;
|
||||
|
||||
//Particle Id
|
||||
size_t Id;
|
||||
|
||||
//Default Constructor
|
||||
ZStandardParticle()
|
||||
: Mass(1), Energy(0),
|
||||
Position(0, 0, 0), Facing(0, 0, 0),
|
||||
Velocity(0, 0, 0), Scale(0, 0),
|
||||
TextureData(0, 0, 0), Id(0)
|
||||
{
|
||||
for (int i = 0; i < 4; ++i)
|
||||
{
|
||||
Color[i].Data[0] = 0;
|
||||
Color[i].Data[1] = 0;
|
||||
Color[i].Data[2] = 0;
|
||||
Color[i].Data[3] = 0;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
class ZStandardParticleStorageAllocator : public ZParticleStorageAllocator
|
||||
{
|
||||
protected:
|
||||
//The next inactive particle
|
||||
int NextInactive;
|
||||
|
||||
//The current particle group
|
||||
size_t CurrentGroup;
|
||||
|
||||
//The current particle within the current group
|
||||
size_t CurrentParticle;
|
||||
|
||||
//Array containing particle storage
|
||||
ZArray<ZStandardParticle> ParticleData;
|
||||
|
||||
//Array containing indices for particles that have been activated (must be cleared manually)
|
||||
ZArray<int> NewParticles;
|
||||
|
||||
public:
|
||||
/*
|
||||
Constructor.
|
||||
*/
|
||||
ZStandardParticleStorageAllocator();
|
||||
|
||||
/*
|
||||
Destructor.
|
||||
*/
|
||||
virtual ~ZStandardParticleStorageAllocator();
|
||||
|
||||
/*
|
||||
public ZStandardParticleStorageAllocator::ActivateParticle
|
||||
|
||||
Activates a particle contained in storage and returns the index of the activated particle. This
|
||||
sets the particle id.
|
||||
|
||||
@param _group - the group number this particle is being activated with
|
||||
@return (int) - index to the activated particle
|
||||
@context (all)
|
||||
*/
|
||||
int ActivateParticle(size_t _group);
|
||||
|
||||
/*
|
||||
public ZStandardParticleStorageAllocator::DeactivateParticle
|
||||
|
||||
Deactivates a particle given the index to the particle in storage.
|
||||
|
||||
@param _index - index to the particle in storage
|
||||
@return (void)
|
||||
@context (all)
|
||||
*/
|
||||
void DeactivateParticle(size_t _index);
|
||||
|
||||
/*
|
||||
public ZStandardParticleStorageAllocator::GetActiveParticleCount
|
||||
|
||||
Gets the number of currently active particles. So long as only the methods
|
||||
ActivateParticle and DeactivateParticle have been used, they are guaranteed
|
||||
to be sequential in the ParticleData array and starting at index 0.
|
||||
|
||||
@return (int) - number of active particles
|
||||
@context (all)
|
||||
*/
|
||||
int GetActiveParticleCount();
|
||||
|
||||
/*
|
||||
public ZStandardParticleStorageAllocator::GetParticleData
|
||||
|
||||
Gets a reference to the array containing particle data.
|
||||
|
||||
@return (ZArray<ZStandardParticle>&) - the particle data array
|
||||
@context (all)
|
||||
*/
|
||||
ZArray<ZStandardParticle>& GetParticleData();
|
||||
|
||||
/*
|
||||
public ZStandardParticleStorageAllocator::GetNewParticles
|
||||
|
||||
Gets an array containing indices that correspond to newly activated particles. Should be
|
||||
cleared by the spawn strategy when updated.
|
||||
|
||||
@return (ZArray<int>&) - list of indices to particles that have been activated
|
||||
@context (all)
|
||||
*/
|
||||
ZArray<int>& GetNewParticles();
|
||||
|
||||
//Subclass Override
|
||||
virtual void AllocateParticleStorage( ZParticleEmitter* _emitter, size_t _maxParticles );
|
||||
|
||||
//Subclass Override
|
||||
virtual void DeallocateParticleStorage();
|
||||
|
||||
//Subclass Override
|
||||
virtual ZString GetParticleFormat();
|
||||
|
||||
//Subclass Override
|
||||
virtual void Update(ZParticleEffect *_effect, ZParticleEmitter *_emitter, size_t _dt);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
97
Include/ZRendererUtil/ZStandardParticleUpdateStrategy.h
Normal file
97
Include/ZRendererUtil/ZStandardParticleUpdateStrategy.h
Normal file
@@ -0,0 +1,97 @@
|
||||
/*
|
||||
ZStandardParticleUpdateStrategy.h
|
||||
Author: James Russell <jcrussell@762studios.com>
|
||||
|
||||
Purpose: TODO
|
||||
|
||||
Changelog
|
||||
2011/09/11 - creation (jcrussell)
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef _ZSTANDARDPARTICLEUPDATESTRATEGY_H
|
||||
#define _ZSTANDARDPARTICLEUPDATESTRATEGY_H
|
||||
|
||||
#include <ZRendererUtil/ZParticleUpdateStrategy.h>
|
||||
|
||||
#define ZSP_DEFAULT_ENERGY_BLEED (1)
|
||||
#define ZSP_DEFAULT_ACCELERATION_X (0.0f)
|
||||
#define ZSP_DEFAULT_ACCELERATION_Y (0.0f)
|
||||
#define ZSP_DEFAULT_ACCELERATION_Z (0.5f)
|
||||
|
||||
class ZStandardParticleUpdateStrategy : public ZParticleUpdateStrategy
|
||||
{
|
||||
protected:
|
||||
//Acceleration Vector
|
||||
ZVector3f ParticleAcceleration;
|
||||
|
||||
//Energy drop per ms
|
||||
size_t EnergyBleed;
|
||||
|
||||
public:
|
||||
/*
|
||||
Default Constructor.
|
||||
*/
|
||||
ZStandardParticleUpdateStrategy();
|
||||
|
||||
/*
|
||||
Destructor.
|
||||
*/
|
||||
~ZStandardParticleUpdateStrategy();
|
||||
|
||||
/*
|
||||
public ZStandardParticleUpdateStrategy::GetEnergyBleed
|
||||
|
||||
TODO
|
||||
|
||||
@return (const size_t)
|
||||
@context (all)
|
||||
*/
|
||||
const size_t GetEnergyBleed();
|
||||
|
||||
/*
|
||||
public ZStandardParticleUpdateStrategy::GetParticleAcceleration
|
||||
|
||||
TODO
|
||||
|
||||
@return (const ZVector3f)
|
||||
@context (all)
|
||||
*/
|
||||
const ZVector3f GetParticleAcceleration();
|
||||
|
||||
/*
|
||||
public ZStandardParticleUpdateStrategy::SetEnergyBleed
|
||||
|
||||
TODO
|
||||
|
||||
@param _bleedRate -
|
||||
@return (void)
|
||||
@context (all)
|
||||
*/
|
||||
void SetEnergyBleed(size_t _bleedRate);
|
||||
|
||||
/*
|
||||
public ZStandardParticleUpdateStrategy::SetParticleAcceleration
|
||||
|
||||
TODO
|
||||
|
||||
@param _accel -
|
||||
@return (void)
|
||||
@context (all)
|
||||
*/
|
||||
void SetParticleAcceleration(const ZVector3f& _accel);
|
||||
|
||||
//Subclass Implementation
|
||||
virtual bool CheckParticleFormat( const ZString& _format );
|
||||
|
||||
//Subclass Implementation
|
||||
virtual void UpdateParticles(ZParticleEffect* _particleEffect,
|
||||
ZParticleEmitter* _particleEmitter,
|
||||
ZParticleStorageAllocator* _storageAllocator,
|
||||
size_t _dt );
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
134
Include/ZRendererUtil/ZStaticMesh.hpp
Normal file
134
Include/ZRendererUtil/ZStaticMesh.hpp
Normal file
@@ -0,0 +1,134 @@
|
||||
/*
|
||||
ZStaticMesh.h
|
||||
Author: Chris Ertel <crertel@762studios.com>
|
||||
|
||||
Purpose: Classes for holding static mesh data.
|
||||
|
||||
Changelog
|
||||
2011/09/18 - creation (crertel)
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef _ZSTATICMESH_H
|
||||
#define _ZSTATICMESH_H
|
||||
|
||||
#include <ZUtil/ZSmartPointer.hpp>
|
||||
#include <ZSTL/ZArray.hpp>
|
||||
#include <ZSTL/ZString.hpp>
|
||||
|
||||
typedef uint32_t ZSMFaceIndex;
|
||||
|
||||
typedef enum ZSMChannelType
|
||||
{
|
||||
ZSMCT_UNKNOWN = 0,
|
||||
|
||||
ZSMCT_BOOL = 0x11,
|
||||
ZSMCT_BOOL_VEC2 = 0x12,
|
||||
ZSMCT_BOOL_VEC3 = 0x13,
|
||||
ZSMCT_BOOL_VEC4 = 0x14,
|
||||
|
||||
ZSMCT_INT = 0x21,
|
||||
ZSMCT_INT_VEC2 = 0x22,
|
||||
ZSMCT_INT_VEC3 = 0x23,
|
||||
ZSMCT_INT_VEC4 = 0x24,
|
||||
|
||||
ZSMCT_UINT = 0x31,
|
||||
ZSMCT_UINT_VEC2 = 0x32,
|
||||
ZSMCT_UINT_VEC3 = 0x33,
|
||||
ZSMCT_UINT_VEC4 = 0x34,
|
||||
|
||||
ZSMCT_FLOAT = 0x41,
|
||||
ZSMCT_FLOAT_VEC2 = 0x42,
|
||||
ZSMCT_FLOAT_VEC3 = 0x43,
|
||||
ZSMCT_FLOAT_VEC4 = 0x44
|
||||
};
|
||||
|
||||
class ZSMChannelDefinition
|
||||
{
|
||||
protected:
|
||||
ZString Name;
|
||||
ZSMChannelType Datatype;
|
||||
uint32_t StartOffset;
|
||||
uint32_t Stride;
|
||||
|
||||
public:
|
||||
ZSMChannelDefinition( ZString _name, ZSMChannelType _datatype, uint32_t _offset, uint32_t _stride)
|
||||
: Name(_name), Datatype(_datatype), StartOffset(_offset), Stride(_stride)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
class ZStaticMeshMaterial
|
||||
{
|
||||
protected:
|
||||
ZString Name;
|
||||
ZArray< ZSMFaceIndex > FaceIndices;
|
||||
ZArray< ZPtr<ZSMChannelDefinition> > ChannelDefinitions;
|
||||
|
||||
public:
|
||||
ZStaticMeshMaterial(ZString _name, ZArray< ZSMFaceIndex> _faceIndices, ZArray< ZPtr<ZSMChannelDefinition> > _channelDefinitions)
|
||||
: Name(_name), FaceIndices(_faceIndices), ChannelDefinitions(_channelDefinitions)
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
public ZStaticMeshMaterial::GetName
|
||||
|
||||
Function to get the name of the material.
|
||||
|
||||
@return (ZString) - Name of the material.
|
||||
*/
|
||||
inline ZString GetName() { return this->Name; }
|
||||
|
||||
/*
|
||||
public ZStaticMeshMaterial::GetFaceIndices
|
||||
|
||||
Function to get the face indices for a material.
|
||||
|
||||
@return (ZArray<ZSMFaceIndex>) - Array of the face indices.
|
||||
*/
|
||||
inline ZArray<ZSMFaceIndex> GetFaceIndices() { return this->FaceIndices; }
|
||||
|
||||
/*
|
||||
public ZStaticMeshMaterial::GetChannelDefinitions
|
||||
|
||||
Function to get the vertex channel definiitions for this material.
|
||||
|
||||
@return (ZArray<ZSMChannelDefinition>) - Array of vertex channel definitions.
|
||||
*/
|
||||
inline ZArray< ZPtr<ZSMChannelDefinition> > GetChannelDefinitions() { return this->ChannelDefinitions; }
|
||||
};
|
||||
|
||||
class ZStaticMesh
|
||||
{
|
||||
protected:
|
||||
ZArray< ZPtr<ZStaticMeshMaterial> > MaterialGroups;
|
||||
ZPtr< ZArray< char > > VertexData;
|
||||
|
||||
public:
|
||||
ZStaticMesh(ZArray< ZPtr<ZStaticMeshMaterial> > _groups, ZPtr< ZArray< char > > _vertexData)
|
||||
: MaterialGroups(_groups), VertexData(_vertexData)
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
public ZStaticMesh::GetMaterialGroups
|
||||
|
||||
Function to get the material groups.
|
||||
|
||||
@return (ZArray<ZStaticMeshMaterialGroup>) - Material groups that make up the mesh.
|
||||
*/
|
||||
inline ZArray< ZPtr<ZStaticMeshMaterial> > GetMaterialGroups() { return this->MaterialGroups; }
|
||||
|
||||
/*
|
||||
public ZStaticMesh::GetVertexData
|
||||
|
||||
Function to get the vertex data.
|
||||
|
||||
@return (ZPtr< ZArray< char > >) - Vertex data for the mesh.
|
||||
*/
|
||||
inline ZPtr< ZArray< char > > GetVertexData() { return this->VertexData; }
|
||||
};
|
||||
|
||||
#endif
|
||||
27
Include/ZRendererUtil/ZStaticMeshLoader.hpp
Normal file
27
Include/ZRendererUtil/ZStaticMeshLoader.hpp
Normal file
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
ZStaticMeshLoader.h
|
||||
Author: Chris Ertel <crertel@762studios.com>
|
||||
|
||||
Purpose: File for loading ZStaticMeshes
|
||||
|
||||
Changelog
|
||||
2013/02/24 - Removed dependency on renderer.
|
||||
2011/09/25 - creation (crertel)
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef _ZSTATICMESHLOADER_H
|
||||
#define _ZSTATICMESHLOADER_H
|
||||
|
||||
#include <ZUtil/ZSmartPointer.hpp>
|
||||
#define ZSM_CURRENT_VERSION (4)
|
||||
|
||||
class ZStaticMesh;
|
||||
class ZStaticMeshLoader
|
||||
{
|
||||
public:
|
||||
static ZPtr<ZStaticMesh> loadFromMemory(const void* _memory, size_t _sizeInMemory);
|
||||
};
|
||||
|
||||
#endif
|
||||
100
Include/ZRendererUtil/ZTessellator.hpp
Normal file
100
Include/ZRendererUtil/ZTessellator.hpp
Normal file
@@ -0,0 +1,100 @@
|
||||
/*
|
||||
ZTessellator.h
|
||||
Author: Patrick Baggett <ptbaggett@762studios.com>
|
||||
|
||||
Purpose: Header for tessellator interface. (currently requires GLU)
|
||||
|
||||
Changelog
|
||||
2011/09/18 - creation (ptbaggett)
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef _ZTESSELLATOR_HPP
|
||||
#define _ZTESSELLATOR_HPP
|
||||
|
||||
#include <ZRendererUtil/ZOutlineEvaluator.hpp>
|
||||
|
||||
//Types of tessellations we can handle
|
||||
enum ZTesselatorPolyType
|
||||
{
|
||||
ZTPT_POLY_TRIANGLES,
|
||||
ZTPT_POLY_TRIFAN,
|
||||
ZTPT_POLY_TRISTRIP
|
||||
};
|
||||
|
||||
class ZTessellator
|
||||
{
|
||||
protected:
|
||||
//Protected Constructor
|
||||
ZTessellator() { }
|
||||
|
||||
public:
|
||||
//Virtual Destructor
|
||||
virtual ~ZTessellator() { }
|
||||
|
||||
/*
|
||||
virtual public ZTessellator::BeginPoly
|
||||
|
||||
TODO
|
||||
|
||||
@param type -
|
||||
@return (void)
|
||||
@context (all)
|
||||
*/
|
||||
virtual void BeginPoly(ZTesselatorPolyType type) = 0;
|
||||
|
||||
/*
|
||||
virtual public ZTessellator::BeginTessellate
|
||||
|
||||
TODO
|
||||
|
||||
@return (void)
|
||||
@context (all)
|
||||
*/
|
||||
virtual void BeginTessellate() = 0;
|
||||
|
||||
/*
|
||||
virtual public ZTessellator::EndPoly
|
||||
|
||||
TODO
|
||||
|
||||
@return (void)
|
||||
@context (all)
|
||||
*/
|
||||
virtual void EndPoly() = 0;
|
||||
|
||||
/*
|
||||
virtual public ZTessellator::EndTessellate
|
||||
|
||||
TODO
|
||||
|
||||
@return (void)
|
||||
@context (all)
|
||||
*/
|
||||
virtual void EndTessellate() = 0;
|
||||
|
||||
/*
|
||||
virtual public ZTessellator::Tessellate
|
||||
|
||||
TODO
|
||||
|
||||
@return (void)
|
||||
@context (all)
|
||||
*/
|
||||
virtual void Tesselate() = 0;
|
||||
|
||||
/*
|
||||
virtual public ZTessellator::Vertex
|
||||
|
||||
TODO
|
||||
|
||||
@param p -
|
||||
@return (void)
|
||||
@context (all)
|
||||
*/
|
||||
virtual void Vertex(SST_Vec2f* p) = 0;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
64
Include/ZRendererUtil/ZTessellatorBase.hpp
Normal file
64
Include/ZRendererUtil/ZTessellatorBase.hpp
Normal file
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
ZTessellatorBase.h
|
||||
Author: James Russell <jcrussell@762studios.com>
|
||||
|
||||
Purpose: TODO
|
||||
|
||||
Changelog
|
||||
2011/09/18 - creation (jcrussell)
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef _ZTESSELLATORBASE_HPP
|
||||
#define _ZTESSELLATORBASE_HPP
|
||||
|
||||
#include <ZRendererUtil/ZTessellator.hpp>
|
||||
|
||||
//#if WINDOWS
|
||||
#include <windows.h>
|
||||
//#endif
|
||||
|
||||
#include <GL/glu.h> //TODO: remove dependency on GLU for tessellation
|
||||
|
||||
class ZTessellatorBase : public ZTessellator
|
||||
{
|
||||
protected:
|
||||
//Outline Evaluator to use
|
||||
ZOutlineEvaluator* Evaluator;
|
||||
|
||||
//Tessellator (TODO: remove dependency on GLU)
|
||||
GLUtesselator *Tessellator;
|
||||
|
||||
public:
|
||||
/*
|
||||
Default Constructor.
|
||||
*/
|
||||
ZTessellatorBase(ZOutlineEvaluator* _eval);
|
||||
|
||||
/*
|
||||
Destructor.
|
||||
*/
|
||||
virtual ~ZTessellatorBase();
|
||||
|
||||
//Subclass Implementation
|
||||
virtual void Tesselate();
|
||||
|
||||
//Not Implemented
|
||||
virtual void BeginTessellate() = 0;
|
||||
|
||||
//Not Implemented
|
||||
virtual void EndTessellate() = 0;
|
||||
|
||||
//Not Implemented
|
||||
virtual void BeginPoly( ZTesselatorPolyType type ) = 0;
|
||||
|
||||
//Not Implemented
|
||||
virtual void EndPoly() = 0;
|
||||
|
||||
//Not Implemented
|
||||
virtual void Vertex( SST_Vec2f* p ) = 0;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
37
Include/ZRendererUtil/ZTransformHierarchy.hpp
Normal file
37
Include/ZRendererUtil/ZTransformHierarchy.hpp
Normal file
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
ZTransformHierarchy.h
|
||||
Author: Chris Ertel <crertel@762studios.com>
|
||||
|
||||
Purpose: Helper classes to setup a simple transform hierarchy.
|
||||
|
||||
Changelog
|
||||
2011/09/20 - creation (crertel)
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef _ZTRANSFORMHIERARCHY_H
|
||||
#define _ZTRANSFORMHIERARCHY_H
|
||||
|
||||
#include <ZUtil/ZSmartPointer.hpp>
|
||||
#include <ZSTL/ZArray.hpp>
|
||||
#include <ZUtil/ZMath.h>
|
||||
|
||||
class ZTransformHierarchy
|
||||
{
|
||||
protected:
|
||||
ZMatrix44f Transform;
|
||||
ZString Name;
|
||||
|
||||
ZArray Children;
|
||||
|
||||
public:
|
||||
ZTransformHierarchy();
|
||||
~ZTransformHierarchy();
|
||||
|
||||
|
||||
void Render(ZPtr<ZRenderer> _renderer, ZFrameContext _context, int _drawgroup, ZMatrix44f _transform, ZRenderState _renderState);
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
55
Include/ZRendererUtil/ZTriTessellator.hpp
Normal file
55
Include/ZRendererUtil/ZTriTessellator.hpp
Normal file
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
ZTriTessellator.h
|
||||
Author: Patrick Baggett <ptbaggett@762studios.com>
|
||||
Chris Ertel <crertel@762studios.com>
|
||||
|
||||
Purpose: Implementation of tessellator interface that tessellates into lists of triangles (unindexed)
|
||||
|
||||
Changelog
|
||||
2011/09/18 - creation (ptbaggett)
|
||||
2012/08/05 - Updated to use new SST functions.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef _ZTRITESSELLATOR_HPP
|
||||
#define _ZTRITESSELLATOR_HPP
|
||||
|
||||
#include <SST/SST_Vec2.h>
|
||||
|
||||
#include <ZRendererUtil/ZTessellatorBase.hpp>
|
||||
|
||||
class ZTriTessellator : public ZTessellatorBase
|
||||
{
|
||||
protected:
|
||||
//Our set of vertices
|
||||
ZArray<SST_Vec2f>& Vertices;
|
||||
|
||||
//Temporary use array
|
||||
ZArray<SST_Vec2f> Temp;
|
||||
|
||||
//Tessellation poly type
|
||||
ZTesselatorPolyType PolyType;
|
||||
|
||||
public:
|
||||
//Dumps a list of vertices into 'verts' when complete
|
||||
ZTriTessellator(ZOutlineEvaluator* _eval, ZArray<SST_Vec2f>& _verts);
|
||||
|
||||
//Subclass Implementation
|
||||
virtual void BeginTessellate();
|
||||
|
||||
//Subclass Implementation
|
||||
virtual void EndTessellate();
|
||||
|
||||
//Subclass Implementation
|
||||
virtual void BeginPoly(ZTesselatorPolyType _type);
|
||||
|
||||
//Subclass Implementation
|
||||
virtual void EndPoly();
|
||||
|
||||
//Subclass Implementation
|
||||
virtual void Vertex(SST_Vec2f* _p);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user