S3Dvertex
S3Dvertex
i am using decalSceneNode
gr8
but i have problemm with vertex-es on backround:
(there is no problem with alpha, see second image with another vertex color)
and my question is: how to hide vertex on the backround?
gr8
but i have problemm with vertex-es on backround:
(there is no problem with alpha, see second image with another vertex color)
and my question is: how to hide vertex on the backround?
programmer is bad designer
designer is bad programmer
designer is bad programmer
You can't use the vertex alpha as that will make the entire image transparent, you'd probably be better off using a texture which has transparent sections that you don't want rendered and then using EMT_ALPHA_CHANNEL as the material type. So make the white bits in your decal texture there transparent.
my code is:
IRRLICHT 1.41
decalscenenode.h
decalscenenode.cpp
IRRLICHT 1.41
decalscenenode.h
Code: Select all
#include <irrlicht.h>
#include <time.h>
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
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,float size);
vector3df pointA;
vector3df pointB;
vector3df pointC;
float posA;
float posB;
float posC;
vector3df trinormal;
float basesize;
IVideoDriver* driver;
line3d<f32> line1;
vector3df v1;
vector3df v2;
line3d<f32> line2;
vector3df v3;
vector3df squarepA;
vector3df squarepB;
vector3df squarepC;
vector3df squarepD;
time_t c_time;
time_t d_time;
double lifeSpan;
void setLifeSpan(double seconds);
void OnRegisterSceneNode();
void render();
const core::aabbox3d<f32>& getBoundingBox() const;
};
Code: Select all
#include <irrlicht.h>
#include "decalscenenode.h"
#include "time.h"
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
DecalSceneNode::DecalSceneNode(ISceneNode* parent, ISceneManager* mgr, triangle3df tri, vector3df intersection, ITexture* image, float size): ISceneNode(parent, mgr, 0)
{
IVideoDriver* driver = SceneManager->getVideoDriver();
basesize=size/2;
time(&c_time);
lifeSpan=0;
Material.Wireframe = false;
Material.Lighting = false;
Material.setTexture(0, image);
SColor color(255,255,255,255);
pointA=tri.pointA;
pointB=tri.pointB;
pointC=tri.pointC;
posA=intersection.X;
posB=intersection.Y;
posC=intersection.Z;
trinormal=tri.getNormal();
trinormal=trinormal.normalize();
line3d<f32> line1(pointA, pointB);
vector3df v1 = line1.getVector().normalize();
vector3df v2 = line1.getClosestPoint( pointC );
line3d<f32> line2(v2,pointC);
vector3df v3 = line2.getVector().normalize();
vector3df squarepA=(v1*-basesize)+trinormal*1+(v3*-basesize);
vector3df squarepB=squarepA+(v1*basesize*2);
vector3df squarepC=squarepA+(v1*basesize*2)+(v3*basesize*2);
vector3df squarepD=squarepA+(v3*basesize*2);
squarepA=squarepA+vector3df(posA,posB,posC);
squarepB=squarepB+vector3df(posA,posB,posC);
squarepC=squarepC+vector3df(posA,posB,posC);
squarepD=squarepD+vector3df(posA,posB,posC);
Vertices[0] = S3DVertex(squarepA.X,squarepA.Y,squarepA.Z, 1,0,0,color,1,0);
Vertices[1] = S3DVertex(squarepB.X,squarepB.Y,squarepB.Z, 1,0,0,color,1,1);
Vertices[2] = S3DVertex(squarepC.X,squarepC.Y,squarepC.Z, 1,0,0,color,0,1);
Vertices[3] = S3DVertex(squarepD.X,squarepD.Y,squarepD.Z, 1,0,0,color,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;
}
void DecalSceneNode::OnRegisterSceneNode()
{
if(lifeSpan>0)
{
if(difftime(time(NULL),c_time) > lifeSpan)
SceneManager->addToDeletionQueue(this);
}
if (IsVisible)
SceneManager->registerNodeForRendering(this);
ISceneNode::OnRegisterSceneNode();
}
void DecalSceneNode::render()
{
u16 indices[] = { 0,1,2, 0,2,3};
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;
}
programmer is bad designer
designer is bad programmer
designer is bad programmer
Code: Select all
// assuming texture has transparency data (alhpa channel)
decal->setMaterialType(video::EMT_TRANSPARENT_ALPHA_CHANNEL);
Code: Select all
this->setMaterialType(EMT_TRANSPARENT_ALPHA_CHANNEL);
background have the same color as vertex.
programmer is bad designer
designer is bad programmer
designer is bad programmer
a solved my problemm
I use for material, not for sceneNode this:
but always is something wrong:
see the different dots:
when I near to the wall, dots are black, else are normal.
I using ATMOsphere project (with ambient lights)
but I using also Lighting - false in decalscenenode...
I use for material, not for sceneNode this:
Code: Select all
Material.MaterialType = EMT_TRANSPARENT_ALPHA_CHANNEL;
see the different dots:
when I near to the wall, dots are black, else are normal.
I using ATMOsphere project (with ambient lights)
but I using also Lighting - false in decalscenenode...
programmer is bad designer
designer is bad programmer
designer is bad programmer
yes, when I remove ATMOsphere (so that lighting)
decal is black ( SColor color(255,255,255,255); )
but I set lighting to false:
I HAVE:
AND I WANT:
please help me
decal is black ( SColor color(255,255,255,255); )
but I set lighting to false:
Code: Select all
setMaterialFlag(video::EMF_LIGHTING, false);
Material.Lighting = false;
AND I WANT:
please help me
programmer is bad designer
designer is bad programmer
designer is bad programmer
Live long and phosphor!
-- https://github.com/netpipe/Luna Game Engine Status 95%
-- https://github.com/netpipe/Luna Game Engine Status 95%