Wenn ich die 2 Dateien include dann kommen folgende 2 Fehler:
Code:
|4|error: redefinition of `class DecalSceneNode'|
|4|error: previous definition of `class DecalSceneNode'|
Ich versteh nicht was das soll ._.
Und die hier werden included:
Decalscenenode.hCode:
#include <irrlicht.h>
#include <time.h>
using namespace irr;
class DecalSceneNode : public scene::ISceneNode
{
protected:
core::aabbox3d<f32> Box;
video::S3DVertex Vertices[4];
video::SMaterial Material;
public:
DecalSceneNode(scene::ISceneNode* parent, scene::ISceneManager* mgr, core::triangle3df tri, core::vector3df intersection, video::ITexture* image);
core::vector3df pointA;
core::vector3df pointB;
core::vector3df pointC;
float posA;
float posB;
float posC;
core::vector3df trinormal;
float basesize;
float dotcorrection;
video::IVideoDriver* driver;
core::line3d<f32> line1;
core::vector3df v1;
core::vector3df v2;
core::line3d<f32> line2;
core::vector3df v3;
core::vector3df squarepA;
core::vector3df squarepB;
core::vector3df squarepC;
core::vector3df squarepD;
time_t c_time;
time_t d_time;
double lifeSpan;
void setLifeSpan(double seconds);
float getSize();
void OnPreRender();
void render();
const core::aabbox3d<f32>& getBoundingBox() const;
virtual s32 getMaterialCount();
virtual video::SMaterial& getMaterial(s32 i);
};
Decalscenenode.cppCode:
/*
bullethole/decal class
by Armen138
before creating an instance of this class, i assume you got:
1. the triangle you hit with your weapon
2. the coordinates(intersection point) you hit the triangle at
3. the texture you want to display on the decal
4. the size you want the bullethole to be(you'll have to experiment a little with this one)
these are the last 4 arguments for the constructor.
this will create a square decal displaying your texture on the wall you hit
with a weapon shooting in a straight line.
*/
#include <irrlicht.h>
#include "decalscenenode.h"
#include "time.h"
using namespace irr;
DecalSceneNode::DecalSceneNode(scene::ISceneNode* parent, scene::ISceneManager* mgr, core::triangle3df tri, core::vector3df intersection, video::ITexture* image, float size): scene::ISceneNode(parent, mgr, 0)
{
time(&c_time);
lifeSpan=0;
pointA=tri.pointA;
pointB=tri.pointB;
pointC=tri.pointC;
posA=intersection.X;
posB=intersection.Y;
posC=intersection.Z;
trinormal=tri.getNormal();
dotcorrection=1;
video::IVideoDriver* driver = SceneManager->getVideoDriver();
Material.Wireframe = false;
Material.Lighting = false;
this->setMaterialType( video::EMT_TRANSPARENT_ALPHA_CHANNEL );
this->setMaterialFlag(video::EMF_LIGHTING, true);
this->setMaterialTexture(0, image );
basesize=size/2;
trinormal=trinormal.normalize();
core::line3d<f32> line1(pointA, pointB);
core::vector3df v1 = line1.getVector().normalize();
core::vector3df v2 = line1.getClosestPoint( pointC );
core::line3d<f32> line2(v2,pointC);
core::vector3df v3 = line2.getVector().normalize();
core::vector3df squarepA=(v1*-basesize)+trinormal*dotcorrection+(v3*-basesize);
core::vector3df squarepB=squarepA+(v1*basesize*2);
core::vector3df squarepC=squarepA+(v1*basesize*2)+(v3*basesize*2);
core::vector3df squarepD=squarepA+(v3*basesize*2);
squarepA=squarepA+core::vector3df(posA,posB,posC);
squarepB=squarepB+core::vector3df(posA,posB,posC);
squarepC=squarepC+core::vector3df(posA,posB,posC);
squarepD=squarepD+core::vector3df(posA,posB,posC);
Vertices[0] = video::S3DVertex(squarepA.X,squarepA.Y,squarepA.Z, 1,0,0,video::SColor(255,255,255,255),1,0);
Vertices[1] = video::S3DVertex(squarepB.X,squarepB.Y,squarepB.Z, 1,0,0,video::SColor(255,255,255,255),1,1);
Vertices[2] = video::S3DVertex(squarepC.X,squarepC.Y,squarepC.Z, 1,0,0,video::SColor(255,255,255,255),0,1);
Vertices[3] = video::S3DVertex(squarepD.X,squarepD.Y,squarepD.Z, 1,0,0,video::SColor(255,255,255,255),0,0);
Box.reset(Vertices[0].Pos);
for (s32 i=1; i<4; ++i)
Box.addInternalPoint(Vertices[i].Pos);
}
void DecalSceneNode::setLifeSpan(double seconds){
lifeSpan=seconds;
}
float DecalSceneNode::getSize(){
return basesize*2;
}
void DecalSceneNode::OnPreRender()
{
if(lifeSpan>0){if(difftime(time(NULL),c_time) > lifeSpan)SceneManager->addToDeletionQueue(this);}
if (IsVisible)
SceneManager->registerNodeForRendering(this);
ISceneNode::OnPreRender();
}
void DecalSceneNode::render()
{
u16 indices[] = { 0,1,2, 0,2,3};
video::IVideoDriver* driver = SceneManager->getVideoDriver();
driver->setMaterial(Material);
driver->setTransform(video::ETS_WORLD, AbsoluteTransformation);
driver->drawIndexedTriangleList(&Vertices[0], 4, &indices[0], 2);
}
const core::aabbox3d<f32>& DecalSceneNode::getBoundingBox() const
{
return Box;
}
s32 DecalSceneNode::getMaterialCount()
{
return 1;
}
video::SMaterial& DecalSceneNode::getMaterial(s32 i)
{
return Material;
}
[EDIT]
Wenn ich die Dateien nirgends Include sondern einfach so mit kompilieren (schreibt man das so?) lasse dann kommt folgender Fehler:
Code:
decalscenenode.cpp|21|error: prototype for `DecalSceneNode::DecalSceneNode(irr::scene::ISceneNode*, irr::scene::ISceneManager*, irr::core::triangle3df, irr::core::vector3df, irr::video::ITexture*, float)' does not match any in class `DecalSceneNode'|