Panda3d Issues

Hi, I’m a fair noob with Panda3d, but I have some experience with c++. Recently I’ve been trying to get Panda3d to work with my windows computer, but I am not having very much luck. So first, I tried running the hello world code provided in the manual.

#include "pandaFramework.h"
#include "pandaSystem.h"
 
PandaFramework framework;
 
int main(int argc, char *argv[]) {
    //open a new window framework
  framework.open_framework(argc, argv);
    //set the window title to My Panda3D Window
  framework.set_window_title("My Panda3D Window");
    //open the window
  WindowFramework *window = framework.open_window();
 
  //here is room for your own code
 
    //do the main loop, equal to run() in python
  framework.main_loop();
    //close the window framework
  framework.close_framework();
  return (0);
}

When I run this eclipse is unable to resolve the panda header files, even though I have the Panda folders in my PATH.
I tried replacing them with the exact file paths, but now I get these errors
Any help would be greatly appreciated!!!
EDIT:Maybe I posted this in the wrong forum

.

Hi, I tried that, but I’m still receiving the make errors and the fatal python file not found error. But shouldn’t just putting “pandaFramework.h” work in the include section? I’ve put the panda folders into my path.

.

18:08:29 **** Incremental Build of configuration Build (GNU) for project PandaTest ****
make all
Making all in src
make[1]: Entering directory /c/Users/AntiAmoeba/Desktop/3D/PandaTest/src' g++ -DPACKAGE_NAME="PandaTest" -DPACKAGE_TARNAME="pandatest" -DPACKAGE_VERSION="1.0" -DPACKAGE_STRING="PandaTest\ 1.0" -DPACKAGE_BUGREPORT="" -DPACKAGE_URL="" -DPACKAGE="pandatest" -DVERSION="1.0" -I. -I/C/Users/AntiAmoeba/Desktop/3D/PandaTest/src -g -O2 -MT PandaTest.o -MD -MP -MF .deps/PandaTest.Tpo -c -o PandaTest.o PandaTest.cpp In file included from C:\Panda3D-1.7.2\include\pandabase.h:22:0, from C:\Panda3D-1.7.2\include\pandaFramework.h:18, from PandaTest.cpp:1: C:\Panda3D-1.7.2\include\dtoolbase.h:109:22: fatal error: pyconfig.h: No such file or directory make[1]: Leaving directory /c/Users/AntiAmoeba/Desktop/3D/PandaTest/src’
compilation terminated.
make[1]: *** [PandaTest.o] Error 1
make: *** [all-recursive] Error 1

.

So basically I just have to add the path of Python? Also, I’ve heard a lot about compiling panda3d but I’m not exactly sure what that’s supposed to mean. Like, I downloaded and installed the sdk, ran wxpython, but I never had to do any compiling of any sort.

.

Alright, so I tried including the python directory. It fixed the pyconfig error, but now it is unable to find pandaSystem.h, even if I specify the file path and include the panda3d directory. I think I’ll be switching over to something like Visual C++ or Netbeans that’s less unreliable.
EDIT: And I still receive these make errors.

.

I managed to fix the problem of eclipse not being able to find pandaSystem.h by changing the file to a cxx file from a cpp file. However, now I get this error message:

make all 
Making all in src
make[1]: Entering directory `/c/Users/AntiAmoeba/Desktop/3D/Testing/src'
make[1]: *** No rule to make target `Testing.o', needed by `a.out.exe'.  Stop.
make[1]: Leaving directory `/c/Users/AntiAmoeba/Desktop/3D/Testing/src'
make: *** [all-recursive] Error 1

From what I know a .o file is generated by the compiler to make the .exe file, so why isn’t eclipse doing that?

.

Oh wow. Well thanks for the help atari!
EDIT: Also, is netbeans a valid option for an IDE? I like it better than visual studio.

.

.

Alright, so I decided to use Visual Studio. Now, my problem is that my framerate goes down a lot when I start firing bullets using the code below. I don’t know what I’m doing wrong. Any help please? There are some functions from other classes I made…

#include "LevelOneState.h"
#include "../core/DMAGame.h"
#include "../core/DBGR.h"

#define _USE_MATH_DEFINES
// Panda3D stuff.
#include "auto_bind.h"
#include "audioManager.h"
#include "executionEnvironment.h"
#include "filename.h"
#include "AnimControlCollection.h"
#include "collisionHandlerPusher.h"
#include "collisionTraverser.h"
#include "collisionNode.h"
#include "collisionSphere.h"
#include "collisionInvSphere.h"
#include "pandaFramework.h"
#include "clockObject.h"
// C++ stuff.
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <cstdlib>
#include <sstream>
#include <list>
#include <stdio.h>
#include <time.h>



LevelOneState::LevelOneState() {
}

LevelOneState::~LevelOneState() {
}

void LevelOneState::init (PlayerStats *ps) {
	counter = new TextNP ("counter", intToString(moneyBallHealth));
	counter->set_x (-1.3);
	counter->set_z (-0.95);
	counter->set_scale (0.2);
	moneyBallHealth=10;
	bulletsC=0;
	easyBotsC=0;
	// Get the location of the executable file I'm running.
	mydir = ExecutionEnvironment::get_binary_name();
	mydir = mydir.get_dirname();

	//window=DMAGame::getWindow();
	// Load the environment model and display it.
	NodePath environ = LoadModelAndDisplay (mydir+"/models/Ground2/Ground2");
	environ.set_scale (1, 1, 1);
    // The environment's 3D model center is not in the middle of the grassfield, so we move the
    // model so that the grassfield is approximately at (0,0,0) of render's coord system.
    environ.set_pos (0, 0, 0);

    moneyBall = LoadModelAndDisplay(mydir+"/models/alice-shapes--sphere/sphere");
    moneyBall.set_color(0.5, 0, 0, 0);
    moneyBall.set_scale(10);
    moneyBall.set_pos(0,0,20);
    collision.addCollisionSphere(moneyBall, "moneyBall", false, Point(0, 0, 0), 4);

    player = LoadModelAndDisplay ("panda-model");
    player.set_scale (0.03);  // player model is large, so have to scale it down quite a bit
   	player.set_pos (100, 100, 0);
   	player.set_hpr (90, 0, 0);
   	player.reparent_to (RENDER);
   	cNode=new CollisionNode("player");
   	cNode->add_solid(new CollisionSphere(0,0,0,600));
   	playerC=player.attach_new_node(cNode);


    sky = LoadModelAndDisplay(mydir + "/models/happysky/happysky");
    sky.set_scale(0.78, 0.78, 2);
    sky.set_pos(0,0,0);
    /*cNode = new CollisionNode("sky");
    cNode->add_solid(new CollisionInvSphere(0,0,0,725));
    skyC=sky.attach_new_node(cNode);*/

    //bullets = LoadModelAndDisplay(mydir + "/../models/fire (1)/fire");
    //bullets.set_scale(0.03);
	// Load our player (main actor, currently a panda), centering it in the environment.

	//collision.addCollisionSphere(player, "player", true, Point(0, 0, 0), 600);
	collision.addCollisionInvSphere(sky, "sky", false, Point(0,0,0), 725);
	CollisionHandlerPusher* wall = new CollisionHandlerPusher;
	traverser=new CollisionTraverser();
	wall->add_collider(playerC, player);
	traverser->add_collider(playerC, wall);

	camera = WINDOW->get_camera_group();
	camera.reparent_to (RENDER);
	camera.set_pos (0, 400/0.03, 200/0.03);
	//camera.set_pos(0, 0, 2000);
	camera.look_at (player.get_pos());
	easyBot();
	fire();
}

void LevelOneState::deinit() {
}
void LevelOneState::fire()
{
	bulletsc=LoadModelAndDisplay(mydir+"/models/fire (1)/fire");
	bulletsc.set_hpr(player.get_h()+90, 0, 90);
	bulletsc.set_scale(0.03);
	bulletsc.set_pos(player, Point(0, -1000, 100));
	//bullets[bulletsC].reparent_to (RENDER);
	//bulletsX[bulletsC]=player.get_x();
	//bulletsY[bulletsC]=player.get_y();
	collision.addCollisionSphere(bulletsc, "bullets", false, Point(0,0,0), 100);
	//bulletsX.push_back(player.get_x());
	//bulletsY.push_back(player.get_y());
	bullets.push_back(bulletsc);
	DUMP("FIRED");
}
void LevelOneState::easyBot()
{
	lastTime=ClockObject::get_global_clock()->get_real_time();
	srand (time (NULL));
	
	int maxNum = 1450;
	double randomX = rand() % 725;
	if(rand()%2==0)
	{
		randomX=-randomX;
	}
	double randomY = sqrt(725*725-randomX*randomX);
	if(rand()%2==0)
	{
		randomY = -randomY;
	}
	easyBotsc=LoadModelAndDisplay(mydir+"/models/bvw-f2004--evilaibo/evilaibodog");
	//easyBots[easyBotsC].look_at(moneyBall);
	//easyBots[easyBotsC].set_pos(randomX, randomY, 0);
	//easyBots[easyBotsC].set_pos(100, 725, 0);
	easyBotsc.set_pos(randomX, randomY, 0);
	int angle=90-(atan(abs(easyBotsc.get_x()/easyBotsc.get_y()))*180/M_PI);
	if((easyBotsc.get_x()>=0&&easyBotsc.get_y()<0))
	{
		angle=-angle;
	}
	if(easyBotsc.get_x()<0&&easyBotsc.get_y()>0)
	{
		angle=180-angle;
	}
	if(easyBotsc.get_x()<0&&easyBotsc.get_y()<=0)
	{
		angle=180+angle;
	}
	easyBotsc.set_h(angle);
	easyBotsc.set_scale(10);
	collision.addCollisionSphere(easyBotsc, "easyBots", false, Point(0,0,0), 2);
	//easyBotHealth[easyBotsC]=10;
	//easyBots[easyBotsC].reparent_to (RENDER);
	easyBots.push_back(easyBotsc);
	DUMP("Dog LOADED");
}
void LevelOneState::logic(void) {
	if(KPM->isKeyPressed("q"))
	{
		FRAMEWORK->close_framework();
	}
	if(moneyBallHealth>0)
	{
	if(KPM->isKeyPressed("arrow_up"))
	{
		player.set_y(player, -20);
		/*if (KPM->timeSinceKeyPress ("arrow_up") > 0.5) {
			fire();
			KPM->resetKeyPressTimer("arrow_up");
		}*/
	}
	else if(KPM->isKeyPressed("arrow_down"))
	{
		player.set_y(player, 20);
	}
	if(KPM->isKeyPressed("arrow_left"))
	{
		player.set_h(player.get_h() + 2);
	}
	else if(KPM->isKeyPressed("arrow_right"))
	{
		player.set_h(player.get_h() - 2);
	}
	if(KPM->isKeyPressed("a"))
	{
		if (KPM->timeSinceKeyPress ("a") > 0.2) {
				fire();
				KPM->resetKeyPressTimer("a");
		}
	}
	double currTime    = ClockObject::get_global_clock()->get_real_time();
	if((currTime-lastTime)>2)
	{
		easyBot();
	}
	camera.set_pos (player, Point(0, 400/0.03, 200/0.03));
	camera.look_at(player.get_pos());
	//camera.set_pos (player, Point(0, 150/0.03, 1000));
	if(KPM->isKeyPressed("space"))
	{
		if(!KPM->isKeyProcessed("space"))
		{
			if(jumping==false)
			{
				zspeed=5;
				jumping=true;
			}
			KPM->setKeyProcessed("space");
		}
	}
	if(jumping==true)
	{
		player.set_z(player.get_z()+zspeed);
		zspeed=zspeed-0.1;
	}
	if((player.get_z()<=0)&&(jumping=true))
	{
		zspeed=0;
		player.set_z(0);
		jumping=false;
	}
	traverser->traverse(RENDER);
	/*list<NodePath>::iterator it;
	for(it = bullets.begin(); it != bullets.end(); it++)
	{
		it->set_pos(*it, Point(0, 0, -200));
		if(collision.collide(*it, sky)){
			NodePath destructor = *it;
			destructor.remove_node();
		}
	}*/
	list<NodePath>::iterator its;
	list<NodePath>::iterator itc;
	for(its = easyBots.begin(); its != easyBots.end(); its++)
	{
		its->set_pos(*its, Point(-0.1, 0, 0));
		if(collision.collide(*its, moneyBall)){
			NodePath destructor = *its;
			destructor.remove_node();
			//moneyBallHealth--;
		}
		for(itc = bullets.begin(); itc != bullets.end(); itc++)
		{
			itc->set_pos(*itc, Point(0,0,-20));
			if(collision.collide(*its, *itc)){
				NodePath destructor = *itc;
				destructor.remove_node();
				NodePath cdestructor = *its;
				cdestructor.remove_node();
			}
			if(collision.collide(*itc, sky)){
				NodePath destructor = *itc;
				destructor.remove_node();
			}
			if(collision.collide(*itc, moneyBall)){
				NodePath destructor = *itc;
				destructor.remove_node();
			}
		}
	}
	its = easyBots.begin();
	while( its != easyBots.end())
	{
		if(its->is_empty())
		{
			easyBots.remove(*its);
			easyBots.erase(its);
		}
		its++;
	}
	its = bullets.begin();
	while( its != bullets.end())
	{
		if(its->is_empty())
		{
			bullets.remove(*its);
			bullets.erase(its);
		}
		its++;
	}
	counter->SetText(intToString(moneyBallHealth));
	counter->set_x (-1.3);
	counter->set_z (-0.95);
	counter->set_scale (0.2);
	}
	else
	{
		TextNP* loser = new TextNP ("loser", "You Lose!!!");
		loser->set_x (-1.5);
		loser->set_scale(0.5);
	}

}


.

.

For the record, there’s no point in calling detach_node before remove_node whatsoever. remove_node internally also detaches the node.