billboard scene node : constant size ?
Like i said before...
Code: Select all
create a scenenode.
create a meshbuffer holding a unit quad(easy scaling)
on render
save the current projection and view matrix
set a projection, view, and model to Identity
project the 3d position of the billboard to the screen
if billboard on screen
render the quad at this position with desired size (can be done with a simple world matrix)
restore view and projection matrix
We're programmers. Programmers are, in their hearts, architects, and the first thing they want to do when they get to a site is to bulldoze the place flat and build something grand. We're not excited by renovation:tinkering,improving,planting flower beds.
Sudi wrote:Like i said before...Code: Select all
create a scenenode. create a meshbuffer holding a unit quad(easy scaling) on render save the current projection and view matrix set a projection, view, and model to Identity project the 3d position of the billboard to the screen if billboard on screen render the quad at this position with desired size (can be done with a simple world matrix) restore view and projection matrix
You've already lost me there, so...set a projection, view, and model to Identity
Nvidia has excellent docs. It's what I learned on, and I plan on continuing to write in Cg.serengeor wrote:I taught that you might know some starter friendly tutorials, but eh, I will google them up when I need, its not like it would be hard for me
Also, I use cgc to compile them to whatever I need, thus there's no Cg dep on my final app. It can compile to almost any profile, glsl, hlsl, ARB assembly etc.
I'm only interested in GLSL for now.hendu wrote:Nvidia has excellent docs. It's what I learned on, and I plan on continuing to write in Cg.serengeor wrote:I taught that you might know some starter friendly tutorials, but eh, I will google them up when I need, its not like it would be hard for me
Also, I use cgc to compile them to whatever I need, thus there's no Cg dep on my final app. It can compile to almost any profile, glsl, hlsl, ARB assembly etc.
Edit: I think this would be a good place to start.
Working on game: Marrbles (Currently stopped).
I looked at the billboard scene node draw function. Perhaps I could add something after "driver->setTransform(video::ETS_WORLD, core::IdentityMatrix);" to set the transformation such that the node is a constant size? Any ideas?
Code: Select all
void CBillboardSceneNode::render()
{
video::IVideoDriver* driver = SceneManager->getVideoDriver();
ICameraSceneNode* camera = SceneManager->getActiveCamera();
if (!camera || !driver)
return;
// make billboard look to camera
core::vector3df pos = getAbsolutePosition();
core::vector3df campos = camera->getAbsolutePosition();
core::vector3df target = camera->getTarget();
core::vector3df up = camera->getUpVector();
core::vector3df view = target - campos;
view.normalize();
core::vector3df horizontal = up.crossProduct(view);
if ( horizontal.getLength() == 0 )
{
horizontal.set(up.Y,up.X,up.Z);
}
horizontal.normalize();
horizontal *= 0.5f * Size.Width;
core::vector3df vertical = horizontal.crossProduct(view);
vertical.normalize();
vertical *= 0.5f * Size.Height;
view *= -1.0f;
for (s32 i=0; i<4; ++i)
vertices[i].Normal = view;
vertices[0].Pos = pos + horizontal + vertical;
vertices[1].Pos = pos + horizontal - vertical;
vertices[2].Pos = pos - horizontal - vertical;
vertices[3].Pos = pos - horizontal + vertical;
// draw
if ( DebugDataVisible & scene::EDS_BBOX )
{
driver->setTransform(video::ETS_WORLD, AbsoluteTransformation);
video::SMaterial m;
m.Lighting = false;
driver->setMaterial(m);
driver->draw3DBox(BBox, video::SColor(0,208,195,152));
}
driver->setTransform(video::ETS_WORLD, core::IdentityMatrix);
driver->setMaterial(Material);
driver->drawIndexedTriangleList(vertices, 4, indices, 2);
}
Well if you want to change the Billboard scenenode then just set the Projection matrix to orthogonal before rendering the billboard. But don't forget to change it back after rendering the billboard
We're programmers. Programmers are, in their hearts, architects, and the first thing they want to do when they get to a site is to bulldoze the place flat and build something grand. We're not excited by renovation:tinkering,improving,planting flower beds.
Actually all those transformation operations are done per vertex by your graphics card.
If i remember right opengl has two matrix slots one for the projection view and one for the model matrix. normally you only change the model matrix per node which makes sense since every model probably has a different location in the 3d world. The other matrix is only reset if you change the transform of view or projection...
btw i am probably wrong about the matrix slots^^
If i remember right opengl has two matrix slots one for the projection view and one for the model matrix. normally you only change the model matrix per node which makes sense since every model probably has a different location in the 3d world. The other matrix is only reset if you change the transform of view or projection...
btw i am probably wrong about the matrix slots^^
We're programmers. Programmers are, in their hearts, architects, and the first thing they want to do when they get to a site is to bulldoze the place flat and build something grand. We're not excited by renovation:tinkering,improving,planting flower beds.