Hy!
I don’t want to make a “hundred” small “how can I do that, how can I do this” topic, so I make this, and if someone have a beginner problem, he can ask a question here about that.
Soo my actual problem is cell shaders. I started to analising the toon maker sample (I can’t find any tutorial abut that) and every time get error messages.
my code:
#include "pandaSystem.h"
#include "pandaFramework.h"
#include "windowProperties.h"
#include "SpriteParticleRenderer.h"
#include "graphicsStateGuardian.h"
#include "TexturePool.h"
#include "loader.h"
//----------------------------------
#include "cMetaInterval.h"
#include "waitInterval.h"
#include "showInterval.h"
#include "cIntervalManager.h"
#include "cLerpNodePathInterval.h"
#include "control.h"
#include "shaderPool.h"
#include "ambientLight.h"
#include "pointLight.h"
#include "lightRampAttrib.h"
TexturePool* myTexturePool = TexturePool::get_global_ptr();
PT(AsyncTaskManager) taskMgr = AsyncTaskManager::get_global_ptr();
NodePath objNp;
PT(WindowFramework) m_windowFrameworkPtr;
int i=0;
AsyncTask::DoneStatus example_task(GenericAsyncTask* task, void* data){
i=i+10;
//if(i=36000) i=0;
objNp.set_hpr(i/20, 0, 0);
//objNp.set_scale(i/100);
return AsyncTask::DS_cont;
}
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow) {
int argc = 0;
char** argv = NULL;
WindowProperties *props = new WindowProperties();
props->set_size(640,480);
props->set_origin(100,100);
props->set_title("Modelviewer" );
PandaFramework framework; //.set_window_title("yay");
framework.open_framework(argc, argv);
WindowFramework *window = framework.open_window(*props,1);
//cell shader------------------------------------------------------------------------
auto_ptr<CCommonFilters> m_filters;
NodePath tempnode = NodePath(new PandaNode("temp node"));
tempnode.set_attrib(LightRampAttrib::make_single_threshold(0.5, 0.4));
tempnode.set_shader_auto();
window->get_camera(0)->set_initial_state(tempnode.get_state());
m_filters.reset(new CCommonFilters(windowFrameworkPtr->get_graphics_output(),NodePath(window->get_camera(0))));
//--------------------------------------------------------------------------------------------
objNp = window->load_model(framework.get_models(), "model.egg");
objNp.set_pos(0, 200, -20);
objNp.set_bin("unsorted", 0);
objNp.set_depth_test(true);
PT(Texture) texture;
texture = TexturePool::load_texture("textura.png");
PT(TextureStage) ts = new TextureStage("ts");
ts->set_mode(TextureStage::M_modulate);
objNp.set_tex_scale(ts, 0.001, 0.001);
objNp.set_texture(texture);
objNp.reparent_to(window->get_render());
window->enable_keyboard();
PT(GenericAsyncTask) task;
task = new GenericAsyncTask("MyTaskName", &example_task, (void*) NULL);
AsyncTaskManager::get_global_ptr()->add(task);
PT(CLerpNodePathInterval) pandaHprInterval1 ,pandaHprInterval2;
pandaHprInterval1 = new CLerpNodePathInterval("pandaHprInterval1", 6.0,CLerpInterval::BT_no_blend,true, false, objNp, NodePath());
pandaHprInterval1->set_start_hpr(LPoint3f(0, 0, 0));
pandaHprInterval1->set_end_hpr(LPoint3f(359, 0, 0));
PT(CMetaInterval) pandaPace;
pandaPace = new CMetaInterval("pandaPace");
pandaPace->add_c_interval(pandaHprInterval1, 0,CMetaInterval::RS_previous_end);
pandaPace->loop();
Thread *current_thread = Thread::get_current_thread();
while(framework.do_frame(current_thread)) {
CIntervalManager::get_global_ptr()->step();
}
framework.close_framework();
}
this program open a model and a texture and start to rotate the model.
But when I tried to load this command, I get an error:
auto_ptr<CCommonFilters> m_filters;
What is this command ( I can’t find anithing about that)
And how can I make a model cell shade style?
I take from here the toon mker sample what I analising.
Hi.
A new noob question coming:
I tried to make a Mousewacherregion to get the mouse position:
PT(MouseWatcherRegion) r = new MouseWatcherRegion("region", 0, 640, 480, 0);
mouseWatcher->add_region (r);
MouseWatcher::init_type();
r->set_active(true);
mouseWatcher =DCAST(MouseWatcher, window->get_mouse().node());
And when my code was translated, ewery time I get this error:
Unhandled exception at 0x771f8e19 in collisiontest.exe: 0xC0000005: Access violation writing location 0xbaadf015.
The exception thrower always after the “r->set_active(true);” code.
What is the problem? I miss something?