So i tried to use MeshDrawer, i deduced from the manual
that MeshDrawer draws the particles with respect to
the camera, but in my case it doesn’t really happen.
here is my initial code:
PandaFramework framework;
framework.open_framework(argc, argv);
WindowFramework *window = framework.open_window();
MeshDrawer generator = MeshDrawer();
NodePath genNode = generator.get_root();
genNode.reparent_to(window->get_render());
generator.set_budget(1000);
genNode.set_depth_write(false);
genNode.set_transparency(TransparencyAttrib::M_alpha);
genNode.set_two_sided(true);
genNode.set_texture(TexturePool::load_texture(mydir+"/plate2.png"));
genNode.set_bin(“fixed”,0);
genNode.set_light_off(true);
and here is how i’m using it:
generator.begin(window->get_camera_group(),window->get_render());
int numOfSegs = 5;
LVector3f startPos(98,143,70),
endPos(379,471,80),
advancingVec=(endPos-startPos)/numOfSegs;
for(int i=0; i<10; i++)
generator.cross_segment(startPos,startPos + advancingVec * i,LVector4f((128./2048.)*14.,(128./2048.)*1.,256./2048.,128./2048.),3,LVector4f(1,1,1,0.7));
generator.end();
Only for some positions of the camera i’m able to see
the draw (laser beam).
here is how i’m moving the camera:
NodePath cam = window->get_camera_group();
GraphicsWindow *gwin = window->get_graphics_window();
//Get cursor position
if(gwin){
cursorX = gwin->get_pointer(0).get_x();
cursorY = gwin->get_pointer(0).get_y();
float xsize = (float)window->get_graphics_window()->get_x_size();
float ysize = (float)window->get_graphics_window()->get_y_size();
if(cursorX < 10 )
cam.set_x(cam,-4);
if(cursorX > xsize - 10)
cam.set_x(cam,4);
if(cursorY < 10 )
cam.set_z(cam,4);
if(cursorY > ysize - 10)
cam.set_z(cam,-4);
}
Thank you very much guys.