mirror of
https://github.com/projectM-visualizer/projectm.git
synced 2026-02-06 09:25:49 +00:00
Milkdrop Preset Factory partially implemented
git-svn-id: https://projectm.svn.sourceforge.net/svnroot/projectm/personal/carm/represet@1138 6778bc44-b910-0410-a7a0-be141de4315d
This commit is contained in:
@ -33,7 +33,7 @@ Func.cpp Eval.cpp PerFrameEqn.cpp PerPointEqn.cpp fftsg.cpp KeyHandler.cpp
|
||||
timer.cpp wipemalloc.cpp BuiltinFuncs.cpp BuiltinParams.cpp Renderer.cpp
|
||||
PresetLoader.cpp PresetChooser.cpp PresetFrameIO.cpp PresetMerge.cpp PipelineContext.cpp
|
||||
ConfigFile.cpp IdlePreset.cpp TextureManager.cpp TimeKeeper.cpp Filters.cpp Renderable.cpp Pipeline.cpp PerPixelMesh.cpp
|
||||
MilkdropWaveform.cpp Waveform.cpp VideoEcho.cpp Shader.cpp PerlinNoise.cpp UserTexture.cpp ShaderEngine.cpp Common.cpp ${GLEW_SOURCES})
|
||||
MilkdropWaveform.cpp Waveform.cpp VideoEcho.cpp Shader.cpp PerlinNoise.cpp UserTexture.cpp ShaderEngine.cpp MilkdropPreset.cpp MilkdropPresetFactory.cpp ${GLEW_SOURCES})
|
||||
|
||||
if (USE_DEVIL)
|
||||
SET (projectM_SOURCES ${projectM_SOURCES})
|
||||
|
||||
@ -39,37 +39,42 @@
|
||||
|
||||
|
||||
MilkdropPreset::MilkdropPreset(std::istream & in, const std::string & presetName, PresetInputs & presetInputs, PresetOutputs & presetOutputs):
|
||||
Preset(presetName, ""),
|
||||
Preset(presetName),
|
||||
builtinParams(presetInputs, presetOutputs),
|
||||
m_presetName(presetName),
|
||||
m_presetOutputs(presetOutputs),
|
||||
presetInputs(presetInputs)
|
||||
_presetOutputs(presetOutputs),
|
||||
_presetInputs(presetInputs)
|
||||
{
|
||||
|
||||
m_presetOutputs.customWaves.clear();
|
||||
m_presetOutputs.customShapes.clear();
|
||||
_presetOutputs.customWaves.clear();
|
||||
_presetOutputs.customShapes.clear();
|
||||
|
||||
initialize(in);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param absoluteFilePath
|
||||
* @param presetName
|
||||
* @param presetInputs
|
||||
* @param presetOutputs
|
||||
*/
|
||||
MilkdropPreset::MilkdropPreset(const std::string & absoluteFilePath, const std::string & presetName, PresetInputs & presetInputs, PresetOutputs & presetOutputs):
|
||||
builtinParams(presetInputs, presetOutputs),
|
||||
m_absoluteFilePath(absoluteFilePath),
|
||||
m_presetName(presetName),
|
||||
m_presetOutputs(presetOutputs),
|
||||
presetInputs(presetInputs)
|
||||
_absoluteFilePath(absoluteFilePath),
|
||||
_presetOutputs(presetOutputs),
|
||||
_presetInputs(presetInputs)
|
||||
{
|
||||
|
||||
m_presetOutputs.customWaves.clear();
|
||||
m_presetOutputs.customShapes.clear();
|
||||
_presetOutputs.customWaves.clear();
|
||||
_presetOutputs.customShapes.clear();
|
||||
|
||||
initialize(absoluteFilePath);
|
||||
|
||||
}
|
||||
|
||||
Preset::~MilkdropPreset()
|
||||
MilkdropPreset::~MilkdropPreset()
|
||||
{
|
||||
|
||||
Algorithms::traverse<Algorithms::TraverseFunctors::DeleteFunctor<InitCond> >(init_cond_tree);
|
||||
@ -272,18 +277,24 @@ void MilkdropPreset::postloadInitialize() {
|
||||
|
||||
}
|
||||
|
||||
void MilkdropPreset::Render(const BeatDetect &music, const PipelineContext &context)
|
||||
{
|
||||
// set stuff here
|
||||
this->evaluateFrame();
|
||||
}
|
||||
|
||||
void MilkdropPreset::initialize(const std::string & pathname)
|
||||
{
|
||||
int retval;
|
||||
|
||||
preloadInitialize();
|
||||
|
||||
if (PRESET_DEBUG)
|
||||
if (MILKDROP_PRESET_DEBUG)
|
||||
std::cerr << "[Preset] loading file \"" << pathname << "\"..." << std::endl;
|
||||
|
||||
if ((retval = loadPresetFile(pathname)) < 0)
|
||||
{
|
||||
if (PRESET_DEBUG)
|
||||
if (MILKDROP_PRESET_DEBUG)
|
||||
std::cerr << "[Preset] failed to load file \"" <<
|
||||
pathname << "\"!" << std::endl;
|
||||
|
||||
@ -303,7 +314,7 @@ void MilkdropPreset::initialize(std::istream & in)
|
||||
if ((retval = readIn(in)) < 0)
|
||||
{
|
||||
|
||||
if (PRESET_DEBUG)
|
||||
if (MILKDROP_PRESET_DEBUG)
|
||||
std::cerr << "[Preset] failed to load from stream " << std::endl;
|
||||
|
||||
/// @bug how should we handle this problem? a well define exception?
|
||||
@ -370,8 +381,8 @@ void MilkdropPreset::evaluateFrame()
|
||||
|
||||
// Setup pointers of the custom waves and shapes to the preset outputs instance
|
||||
/// @slow an extra O(N) per frame, could do this during eval
|
||||
m_presetOutputs.customWaves = PresetOutputs::cwave_container(customWaves);
|
||||
m_presetOutputs.customShapes = PresetOutputs::cshape_container(customShapes);
|
||||
_presetOutputs.customWaves = PresetOutputs::cwave_container(customWaves);
|
||||
_presetOutputs.customShapes = PresetOutputs::cshape_container(customShapes);
|
||||
|
||||
}
|
||||
|
||||
@ -379,74 +390,74 @@ void MilkdropPreset::initialize_PerPixelMeshes()
|
||||
{
|
||||
|
||||
int x,y;
|
||||
for (x=0;x<presetInputs.gx;x++){
|
||||
for(y=0;y<presetInputs.gy;y++){
|
||||
m_presetOutputs.cx_mesh[x][y]=m_presetOutputs.cx;
|
||||
for (x=0;x<presetInputs().gx;x++){
|
||||
for(y=0;y<presetInputs().gy;y++){
|
||||
_presetOutputs.cx_mesh[x][y]=presetOutputs().cx;
|
||||
}}
|
||||
|
||||
|
||||
|
||||
|
||||
for (x=0;x<presetInputs.gx;x++){
|
||||
for(y=0;y<presetInputs.gy;y++){
|
||||
m_presetOutputs.cy_mesh[x][y]=m_presetOutputs.cy;
|
||||
for (x=0;x<presetInputs().gx;x++){
|
||||
for(y=0;y<presetInputs().gy;y++){
|
||||
_presetOutputs.cy_mesh[x][y]=presetOutputs().cy;
|
||||
}}
|
||||
|
||||
|
||||
|
||||
for (x=0;x<presetInputs.gx;x++){
|
||||
for(y=0;y<presetInputs.gy;y++){
|
||||
m_presetOutputs.sx_mesh[x][y]=m_presetOutputs.sx;
|
||||
for (x=0;x<presetInputs().gx;x++){
|
||||
for(y=0;y<presetInputs().gy;y++){
|
||||
_presetOutputs.sx_mesh[x][y]=presetOutputs().sx;
|
||||
}}
|
||||
|
||||
|
||||
|
||||
|
||||
for (x=0;x<presetInputs.gx;x++){
|
||||
for(y=0;y<presetInputs.gy;y++){
|
||||
m_presetOutputs.sy_mesh[x][y]=m_presetOutputs.sy;
|
||||
for (x=0;x<presetInputs().gx;x++){
|
||||
for(y=0;y<presetInputs().gy;y++){
|
||||
_presetOutputs.sy_mesh[x][y]=presetOutputs().sy;
|
||||
}}
|
||||
|
||||
|
||||
|
||||
for (x=0;x<presetInputs.gx;x++){
|
||||
for(y=0;y<presetInputs.gy;y++){
|
||||
m_presetOutputs.dx_mesh[x][y]=m_presetOutputs.dx;
|
||||
for (x=0;x<presetInputs().gx;x++){
|
||||
for(y=0;y<presetInputs().gy;y++){
|
||||
_presetOutputs.dx_mesh[x][y]=presetOutputs().dx;
|
||||
}}
|
||||
|
||||
|
||||
|
||||
for (x=0;x<presetInputs.gx;x++){
|
||||
for(y=0;y<presetInputs.gy;y++){
|
||||
m_presetOutputs.dy_mesh[x][y]=m_presetOutputs.dy;
|
||||
for (x=0;x<presetInputs().gx;x++){
|
||||
for(y=0;y<presetInputs().gy;y++){
|
||||
_presetOutputs.dy_mesh[x][y]=presetOutputs().dy;
|
||||
}}
|
||||
|
||||
|
||||
|
||||
for (x=0;x<presetInputs.gx;x++){
|
||||
for(y=0;y<presetInputs.gy;y++){
|
||||
m_presetOutputs.zoom_mesh[x][y]=m_presetOutputs.zoom;
|
||||
for (x=0;x<presetInputs().gx;x++){
|
||||
for(y=0;y<presetInputs().gy;y++){
|
||||
_presetOutputs.zoom_mesh[x][y]=presetOutputs().zoom;
|
||||
}}
|
||||
|
||||
|
||||
|
||||
|
||||
for (x=0;x<presetInputs.gx;x++){
|
||||
for(y=0;y<presetInputs.gy;y++){
|
||||
m_presetOutputs.zoomexp_mesh[x][y]=m_presetOutputs.zoomexp;
|
||||
for (x=0;x<presetInputs().gx;x++){
|
||||
for(y=0;y<presetInputs().gy;y++){
|
||||
_presetOutputs.zoomexp_mesh[x][y]=presetOutputs().zoomexp;
|
||||
}}
|
||||
|
||||
|
||||
|
||||
for (x=0;x<presetInputs.gx;x++){
|
||||
for(y=0;y<presetInputs.gy;y++){
|
||||
m_presetOutputs.rot_mesh[x][y]=m_presetOutputs.rot;
|
||||
for (x=0;x<presetInputs().gx;x++){
|
||||
for(y=0;y<presetInputs().gy;y++){
|
||||
_presetOutputs.rot_mesh[x][y]=presetOutputs().rot;
|
||||
}}
|
||||
|
||||
|
||||
for (x=0;x<presetInputs.gx;x++){
|
||||
for(y=0;y<presetInputs.gy;y++){
|
||||
m_presetOutputs.warp_mesh[x][y]=m_presetOutputs.warp;
|
||||
for (x=0;x<presetInputs().gx;x++){
|
||||
for(y=0;y<presetInputs().gy;y++){
|
||||
_presetOutputs.warp_mesh[x][y]=presetOutputs().warp;
|
||||
}}
|
||||
|
||||
|
||||
@ -457,8 +468,8 @@ void MilkdropPreset::evalPerPixelEqns()
|
||||
{
|
||||
|
||||
/* Evaluate all per pixel equations in the tree datastructure */
|
||||
for (int mesh_x = 0; mesh_x < presetInputs.gx; mesh_x++)
|
||||
for (int mesh_y = 0; mesh_y < presetInputs.gy; mesh_y++)
|
||||
for (int mesh_x = 0; mesh_x < presetInputs().gx; mesh_x++)
|
||||
for (int mesh_y = 0; mesh_y < presetInputs().gy; mesh_y++)
|
||||
for (std::map<int, PerPixelEqn*>::iterator pos = per_pixel_eqn_tree.begin();
|
||||
pos != per_pixel_eqn_tree.end(); ++pos)
|
||||
pos->second->evaluate(mesh_x, mesh_y);
|
||||
@ -474,7 +485,7 @@ int MilkdropPreset::readIn(std::istream & fs) {
|
||||
/* Parse any comments */
|
||||
if (Parser::parse_top_comment(fs) < 0)
|
||||
{
|
||||
if (PRESET_DEBUG)
|
||||
if (MILKDROP_PRESET_DEBUG)
|
||||
std::cerr << "[Preset::readIn] no left bracket found..." << std::endl;
|
||||
return PROJECTM_FAILURE;
|
||||
}
|
||||
@ -520,7 +531,7 @@ int MilkdropPreset::loadPresetFile(const std::string & pathname)
|
||||
/* Open the file corresponding to pathname */
|
||||
std::ifstream fs(pathname.c_str());
|
||||
if (!fs || fs.eof()) {
|
||||
if (PRESET_DEBUG)
|
||||
if (MILKDROP_PRESET_DEBUG)
|
||||
std::cerr << "loadPresetFile: loading of file \"" << pathname << "\" failed!\n";
|
||||
return PROJECTM_ERROR;
|
||||
}
|
||||
|
||||
@ -35,7 +35,7 @@
|
||||
#include <cassert>
|
||||
#include <map>
|
||||
|
||||
#define MilkdropPreset_DEBUG 0 /* 0 for no debugging, 1 for normal, 2 for insane */
|
||||
#define MILKDROP_PRESET_DEBUG 0 /* 0 for no debugging, 1 for normal, 2 for insane */
|
||||
|
||||
#include "CustomShape.hpp"
|
||||
#include "CustomWave.hpp"
|
||||
@ -120,7 +120,8 @@ public:
|
||||
return _presetInputs;
|
||||
}
|
||||
|
||||
/// @bug encapsulate
|
||||
|
||||
// @bug encapsulate
|
||||
|
||||
PresetOutputs::cwave_container customWaves;
|
||||
PresetOutputs::cshape_container customShapes;
|
||||
@ -134,7 +135,7 @@ public:
|
||||
std::map<std::string,Param*> user_param_tree; /* user parameter splay tree */
|
||||
|
||||
|
||||
const Pipeline & pipeline() { return _presetOutputs; }
|
||||
const Pipeline & pipeline() const { return _presetOutputs; }
|
||||
|
||||
void Render(const BeatDetect &music, const PipelineContext &context);
|
||||
|
||||
|
||||
33
src/libprojectM/MilkdropPresetFactory.cpp
Normal file
33
src/libprojectM/MilkdropPresetFactory.cpp
Normal file
@ -0,0 +1,33 @@
|
||||
//
|
||||
// C++ Implementation: MilkdropPresetFactory
|
||||
//
|
||||
// Description:
|
||||
//
|
||||
//
|
||||
// Author: Carmelo Piccione <carmelo.piccione@gmail.com>, (C) 2008
|
||||
//
|
||||
// Copyright: See COPYING file that comes with this distribution
|
||||
//
|
||||
//
|
||||
//
|
||||
// C++ Interface: PresetFactory
|
||||
//
|
||||
// Description:
|
||||
//
|
||||
//
|
||||
// Author: Carmelo Piccione <carmelo.piccione@gmail.com>, (C) 2008
|
||||
//
|
||||
// Copyright: See COPYING file that comes with this distribution
|
||||
//
|
||||
//
|
||||
|
||||
#include "MilkdropPresetFactory.hpp"
|
||||
|
||||
|
||||
MilkdropPresetFactory::MilkdropPresetFactory() {}
|
||||
|
||||
MilkdropPresetFactory::~MilkdropPresetFactory() {}
|
||||
|
||||
std::auto_ptr<Preset> MilkdropPresetFactory::allocate(const std::string & url, const std::string & name, const std::string & author) {
|
||||
return std::auto_ptr<Preset>(new MilkdropPreset(url, name, _presetInputs, _presetOutputs));
|
||||
}
|
||||
36
src/libprojectM/MilkdropPresetFactory.hpp
Normal file
36
src/libprojectM/MilkdropPresetFactory.hpp
Normal file
@ -0,0 +1,36 @@
|
||||
//
|
||||
// C++ Interface: PresetFactory
|
||||
//
|
||||
// Description:
|
||||
//
|
||||
//
|
||||
// Author: Carmelo Piccione <carmelo.piccione@gmail.com>, (C) 2008
|
||||
//
|
||||
// Copyright: See COPYING file that comes with this distribution
|
||||
//
|
||||
//
|
||||
|
||||
#ifndef __MILKDROP_PRESET_FACTORY_HPP
|
||||
#define __MILKDROP_PRESET_FACTORY_HPP
|
||||
|
||||
#include "MilkdropPreset.hpp"
|
||||
#include <memory>
|
||||
#include "PresetFactory.hpp"
|
||||
|
||||
class MilkdropPresetFactory : public PresetFactory {
|
||||
|
||||
public:
|
||||
|
||||
|
||||
MilkdropPresetFactory();
|
||||
|
||||
virtual ~MilkdropPresetFactory();
|
||||
|
||||
std::auto_ptr<Preset> allocate(const std::string & url, const std::string & name = std::string(), const std::string & author = std::string());
|
||||
|
||||
private:
|
||||
PresetOutputs _presetOutputs;
|
||||
PresetInputs _presetInputs;
|
||||
};
|
||||
|
||||
#endif
|
||||
@ -8,3 +8,4 @@
|
||||
#include "PipelineContext.hpp"
|
||||
|
||||
PipelineContext::PipelineContext() {}
|
||||
PipelineContext::~PipelineContext() {}
|
||||
|
||||
@ -7,8 +7,6 @@
|
||||
|
||||
#include "Preset.hpp"
|
||||
|
||||
Preset::Preset() {}
|
||||
|
||||
Preset::~Preset() {}
|
||||
|
||||
Preset::Preset(const std::string & presetName, const std::string & presetAuthor):
|
||||
|
||||
@ -17,8 +17,8 @@
|
||||
class Preset {
|
||||
public:
|
||||
|
||||
Preset();
|
||||
Preset(const std::string & name, const std::string & author);
|
||||
|
||||
Preset(const std::string & name=std::string(), const std::string & author = std::string());
|
||||
virtual ~Preset();
|
||||
|
||||
void setName(const std::string & value);
|
||||
|
||||
@ -21,14 +21,17 @@ class PresetFactory {
|
||||
public:
|
||||
|
||||
|
||||
PresetFactory() {}
|
||||
inline PresetFactory() {}
|
||||
|
||||
virtual ~PresetFactory() {}
|
||||
inline virtual ~PresetFactory() {}
|
||||
|
||||
/// Constructs a new preset given an url
|
||||
/// \param url a locational identifier referencing the preset
|
||||
/// \returns a valid preset object- otherwise
|
||||
virtual std::auto_ptr<Preset> allocate(std::string url, std::string name);
|
||||
/// \param name the preset name
|
||||
/// \param author the preset author
|
||||
/// \returns a valid preset object
|
||||
virtual std::auto_ptr<Preset> allocate(const std::string & url, const std::string & name=std::string(),
|
||||
const std::string & author=std::string()) = 0;
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user