I am new to using Panda and have been just messing around with simple things so far using the simple environment shown in the manual. My problem is that I am trying to simply add fog to the manual hello world project. I feel like I’m just missing something very simple. Everything compiles fine… but when I run i get a Runtime error.
#include "stdafx.h"
#include "pandaFramework.h"
#include "pandaSystem.h"
#include "fog.h"
PandaFramework framework;
int _tmain(int argc, char *argv[])
{
framework.open_framework(argc, argv);
framework.set_window_title("My Panda3D Window");
WindowFramework *window = framework.open_window();
NodePath cam = window->get_camera_group();
//load the environment model
NodePath environ = window->load_model(framework.get_models(),"models/environment");
environ.reparent_to(window->get_render());
environ.set_scale(0.25,0.25,0.25);
environ.set_pos(-8,42,0);
PT(Fog) myFog;
myFog = new Fog("Scene Fog");
myFog->set_color(0,0,0);
myFog->set_exp_density(.05);
window->get_render().set_fog(myFog);
//do the main loop:
ClockObject* clock;
clock = ClockObject::get_global_clock();
Thread *current_thread = Thread::get_current_thread();
while(framework.do_frame(current_thread))
{
double time = clock->get_real_time();
double angledegrees = time * 6.0;
double angleradians = angledegrees * (3.14 / 180.0);
cam.set_pos(20*sin(angleradians),-20.0*cos(angleradians),3);
cam.set_hpr(angledegrees, 0, 0); //set the hpr
}
//close the window framework
framework.close_framework();
return (0);
}
Any help would be greatly appreciated. I have found it to be semi-difficult to find any resources/samples for Panda3d in c++ .
I am not completely sure to be honest with you. I get a popup window saying TestPanda.exe has encountered a problem and needs to close. We are sorry for the inconvenience. Then you have the buttons for Debug, Send Error Report, and Don’t Send.
Is there a chance that my configuration properties of my project in visual studio are messed up and could be causing this problem? I have included the following include files:
I don’t see any problem with the code either. Yet it crashes every time. It will load the model and render it. I can see the fog… then a second after it starts running… crash. There has to be something little I am doing wrong. I can easily duplicate the code in python and I have no problems. However, when I create it in c++ I have this crashing problem. I am fairly certain I have everything setup correctly… is there a certain type of project I should create to begin with? I have just been using a Win32 Console Application. Do I need to use something other than that?
I already had that in my preprocessor definitions and I already have the multithreading setup… so still not working. I did find something interesting though. It seems that if I use the setup_trackball mouse settings and just run the main_loop instead of the setup I posted above with the rotating camera… I don’t seem to have any problems.
Note: The rotating camera setup works fine with out the fog added in there.
It really seems like something is corrupt in your build somehow; the sorts of errors you’re describing seem random and unrelated to the particular changes you’re making.
Do you know how to use the Microsoft debugger to view the stack trace at the time of the crash? It might be informative to know what line is actually crashing.
Did you build this Panda yourself, or are you using the supplied build?