AmbientLight & C++

Hi, how are you doing?
I’m kinda new at Panda3D and I still testing it trying to do a chessgame not in python but in Visual Studio
I could do most of major graphical things (I load the models, show them on screen and I could set the pieces in the correct squares), however there is a think I could not set yet and this is lightening. I’m following the chess sample in python that came with Panda3D, however there seems to be some differences…
When I try to use AmbientLight and DirectionalLight I get the following error
error C2514: ‘AmbientLight’ : class has no constructor
error C2514: ‘DirectionalLight’ : class has no constructor

This is the source code, so if you can give me a hand it would be great :slight_smile:

void cWorld::SetupLights (void)
{
	cWorld::m_oWindow->set_lighting(true);
	PT(AmbientLight) ambientLight = new AmbientLight("ambientLight");
	PT(DirectionalLight) directionalLight = new DirectionalLight("directionalLight");

	ambientLight->set_color(LVecBase4f(.8, .8, .8, 1));
	NodePath pambient = cWorld::m_oWindow->get_render().attach_new_node((PandaNode *)ambientLight->upcast_to_panda_node());
	cWorld::m_oWindow->set_light(pdambient, 0);

	directionalLight->set_direction(LVecBase3f(0, 45, -45));
	directionalLight->set_color(LVecBase4f(.2, .2, .2, 1));

	NodePath pdirectional = cWorld::m_oWindow->get_render().attach_new_node((PandaNode *)directionalLight->upcast_to_panda_node());
	cWorld::m_oWindow->get_render().set_light(pdirectional, 0);
}

The error occurrs at the very begining of the code when I declare PT(AmbientLight) ambientLight = new AmbientLight(“ambientLight”); and
PT(DirectionalLight) directionalLight = new DirectionalLight(“directionalLight”);

Thanks in advance.

i think lights are attributes and require a make() funciton … i think it follows the singeltron pattern or some thing. Then they are attached to the nodes.

And, sorry to ask, but I’m pretty noob with Panda3D yet, so how could that be doing? I mean, could you give me some sample?
Thanks

sorry i don’t use the old lighting system - i use shaders and i dont use c++.

Actually, AmbientLight and DirectionalLight inherit from PandaNode, so it is legal (and correct) to create them directly. Treeform is thinking of LightAttrib, which you don’t create directly.

Your problem is a basic C++ problem: you need to #include “ambientLight.h” and “directionalLight.h” in order to get the definitions for these classes.

David

You were right, I made a very n00b mistake about this… I couldn’t use it but at least I didn’t have any compilation error… By now it’s not necessary for me, but as long as I can have more research time I’ll go back to this :slight_smile: