Calimero, why do you use a pointer variable for the texture filename?
I don't understand at all why pointers are used so much...
I don't see anything about texture filename in calimero's code, just a pointer to an already loaded texture.
Pointers are sued because it's way way way faster than passing a whole structure to a function (though might make less difference for inline functions, i'm not sure about that)
You do a lot of programming? Really? I try to get some in, but the debugging keeps me pretty busy.
thank a lot electron for doing all the stuff I was too lazy to do myself !!
I apreciate your change !! For the stuff added in the Cscenemanager.cpp you forgot to retire the texture parameter.
As I am lazy I put directly the material and the texture in the node. it may be more "irrlicht" standard to retire material initialisation too.
Has someone made tries with the node attached to another node (like a rotating one) because I think it may behave strangely!
I think this node will be soon ready to be put in the CVS repository
for Venex : I use a lot of pointers because of a heavy C background, some people prefer to use references in C++. but as you don't seem to know what exactly a structure is I advise you to get some simple C / C++ tutorials or a simply a good book to teach yourself bases of the language.
Everybody here had to learn a little bit before writing some right stuff. You don't have to be ashamed of your knowledge. Look at my level in english for example
I make a new version of the node which behave more as expected if attached to a parent different from rootscenenode.
I just give you the code of the render function (it's the only change)
for electron : sorry I haven't merge for now your modifications but I will highly appreciate if you put the new code in your version. (I think you'll have to do a cut paste and change "largeur" to "width" )
I add a few comments for people interested in understanding - modifying - improving the code
void CAxialBBNode::render()
{
// ok in this function is the interesting stuff
// jfh "calimero" 11august2004 nice france
// the axial billboard has two end, the first is the position of the node
// the other is given by orientation in LOCAL coordinates.
// for node attached to rootscenenode it behaves like the previous version
// in this version orientation is expressed in local coordinates of the node
// I think it's more interesting because it gives a more standard behaviour
// if the node is attached to a parent different from rootscenenode
// you can also attach animator to the node (like rotation)
// and I hope it will behave like you expect
//
// known problem : node disappears if position gets too near of the camera
vector3df orientationglobal; // to store the end of the billboard in world coordinates
matrix4 mat; // to get an identity matrix for final render
matrix4 matnode = getAbsoluteTransformation(); // get the transformation of the node
ISceneNode* camera = SceneManager->getActiveCamera();
IVideoDriver* driver = SceneManager->getVideoDriver();
vector3df pos = getAbsolutePosition();
vector3df campos = camera->getAbsolutePosition();
matnode.transformVect(orientation,orientationglobal);
vector3df perp = (orientationglobal-pos).crossProduct(campos - pos);
// perhaps here I should test if perp is null before normalize it ?
// it doesn't seem to be necessary --> to investigate
perp.normalize();
perp *= largeur;
// here I update the coordinates of the billboard in GLOBAL space
vertices[0].Pos = pos - perp;
vertices[1].Pos = pos + perp;
vertices[2].Pos = orientationglobal + perp ;
vertices[3].Pos = orientationglobal - perp;
driver->setMaterial(Material);
// doesn't seem to be necessary probably the default constructor
// build the identity matrix
//mat.makeIdentity();
driver->setTransform(video::ETS_WORLD, mat);
// finally I draw it
driver->drawIndexedTriangleList(vertices, 4, indices, 2);
}
jean-francois "calimero"
p.s. I found a nice page that deals with billboards : http://www.flipcode.com/articles/articl ... ards.shtml
for people who are interested in them (how are they constructed and what you can do with them).
my axialbillboard is "viewport" aligned using their terminology.
Does someone know a good tutorial about using pointers at:
Set a class to a pointer and what the functions change on the pointer
My problem is pointers in combination with functions
Visit my website @ www.venex.be
Plethora project will be added to the site
AMD AthlonXP 2600+, 512MB DDR, Radeon M10 (mobile 9600) PRO 64MB, WinXP
@calimero Thanks for pointing out my mistake of leaving the texture parameter in CSceneManager.cpp. I had changed that in the code I actually compiled but messed it up here. I just edited my previous post to fix that, as anyone trying to compile it would get errors that way.
I will put your new render code in my version and edit my previous post again.
You do a lot of programming? Really? I try to get some in, but the debugging keeps me pretty busy.
hello,
I don't know if you've seen that saigumi put (will put ?) our code in irrlichtnx. I like this kind of cooperative work.
just a remark on your last edit : you make a predeclaration of a class IAxialbillboard, doesn't have to be class IAxialbillboardSceneNode ?
sorry not very sure about that because I don't make a lot of C++ code and I'm not familiar with the interface class concept.
Thanks for pointing out my errors. I do things like that correctly in my code, but when documenting them I make stupid little errors. I also realized I forgot to add the core:: and video: scope operators to your new function. My first post up above will be edited yet again.
I know about Saigumi. He sent me a private message earlier asking for my files because something wasn't compiling right. Probably another stupid error in my documentation .I'm going to send him the files in just a minute
You do a lot of programming? Really? I try to get some in, but the debugging keeps me pretty busy.
sorry, but if i test its vice versa to your test:
i can only see the ray in the near. i test your code in the movement-example and try with root-node, the woman and the moving box.
my english isnt the best, too, so we meet in the middle of the bridge:
I try again.
I tested your code in the movement-example of irrlicht.
In the movement example is a moving box and the woman Sydney who runs in front of the camera. If i use your old or new code, if i use it on root-node, box or Sydney:
The result is, that i see the billboard only in the near (if i take a virtual metering rule, i would say ~1 virtual meter ;-) - in a distance more than ~1 virtual meter the billboard isnt visible)
ok I understand, the behaviour is very curious and I never experiment a thing like that. Can you try with a full white texture for example to be sure if there is not a transparency pb or thing like that ? Perhaps the pb is related to the normals which are not set toady (I'm working on it).
I have a working (I hope) node with normals locally but I have problemes to recompile irrlichtnx and I prefer to put my new version directly in the irrlichtnx version but as a try if you have little time you can try this stuff in the render method :
(depending of the version you have replace largeur by width)
// ok in this function is the interesting stuff
// jfh "calimero" 11august2004 nice france
// the axial billboard has two end, the first is the position of the node
// the other is given by orientation in LOCAL coordinates.
// for node attached to rootscenenode it behaves like the previous version
// in this version orientation is expressed in local coordinates of the node
// I think it's more interesting because it gives a more standard behaviour
// if the node is attached to a parent different from rootscenenode
// you can also attach animator to the node (like rotation)
// and I hope it will behave like you expect
//
// known problem : node disappears if position gets too near of the camera
vector3df orientationglobal; // to store the end of the billboard in world coordinates
matrix4 mat; // to get an identity matrix for final render
matrix4 matnode = getAbsoluteTransformation(); // get the transformation of the node
ISceneNode* camera = SceneManager->getActiveCamera();
IVideoDriver* driver = SceneManager->getVideoDriver();
vector3df pos = getAbsolutePosition();
vector3df campos = camera->getAbsolutePosition();
matnode.transformVect(orientation,orientationglobal);
vector3df vtemp = orientationglobal-pos;
vector3df perp = vtemp.crossProduct(campos - pos);
// perhaps here I should test if perp is null before normalize it ?
// it doesn't seem to be necessary --> to investigate
//perp.normalize();
//perp *= largeur;
perp.setLength(largeur);
// here I update the coordinates of the billboard in GLOBAL space
vertices[0].Pos = pos - perp;
vertices[1].Pos = pos + perp;
vertices[2].Pos = orientationglobal + perp ;
vertices[3].Pos = orientationglobal - perp;
vector3df norm = (perp).crossProduct(vtemp);
norm.normalize();
vertices[0].Normal = norm;
vertices[1].Normal = norm;
vertices[2].Normal = norm;
vertices[3].Normal = norm;
driver->setMaterial(Material);
// doesn't seem to be necessary probably the default constructor
// build the identity matrix
//mat.makeIdentity();
driver->setTransform(video::ETS_WORLD, mat);
// finally I draw it
driver->drawIndexedTriangleList(vertices, 4, indices, 2);
p.s. to you know if there is a tutorial for building irrlichtnx with cvs ?
it's an improvment because it (re)calculates normals of the vertices. So you can use a material that is sensible to lights (for making trees for examples)
if you just want to make a laser ray it changes nothing. But be conscious it's just a sort of alpha version and I post it just to making tests (for knightoflight), not releasing it.
another improvment I want to make too is to add methods to set and retrieve width and orientation so people can manipulate them at runtime.
another idea is to make another constructor with an interface like 3dline. But for now I'm stuck with irrlichtnx compil pb. It seems to be an issue with the last version for devcpp.