[Solved]Any way to tie two objects together?

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
dc740
Posts: 12
Joined: Fri Dec 26, 2014 1:48 am

[Solved]Any way to tie two objects together?

Post by dc740 »

Suppose I have two boxes, the world around is moving and rotating, but the two boxes must stay at a fixed point relatives to each other.

Is there any way to do this?

The truth is I have 4 billboards which should act as a box, rotating and moving around. But it must look like it's only one object. It's basically the same problem as this:
https://www.opengl.org/discussion_board ... s-together

But I have no idea how to do that in irrlicht.

Thanks!
Last edited by dc740 on Thu Jan 29, 2015 3:24 am, edited 1 time in total.
mongoose7
Posts: 1227
Joined: Wed Apr 06, 2011 12:13 pm

Re: Any way to tie two objects together?

Post by mongoose7 »

Create a dummy scene node as parent to the two boxes. Perform all transformations on the dummy node, not on the box nodes. However, using billboards will present difficulties because they always face the camera, so that is a really bad choice. Maybe you could just use planes?
dc740
Posts: 12
Joined: Fri Dec 26, 2014 1:48 am

Re: Any way to tie two objects together?

Post by dc740 »

Thanks! I didn't know that. I'll test it ASAP.

About the billboards:
I implemented my own billboards and texture animations. My billboards have an option to face the camera, or simply not. Now that you mention it... would simple planes accept texture animators? It's not that it took me much time, but it would have been easier

my texture animator is basically the same found in irrlicht, but it also adds support to use a texture matrix.

You can find both here:
https://mega.co.nz/#!sVNEjIjD!A5OH1ktI5 ... HMMneIzhaA

The original post:
http://irrlicht.sourceforge.net/forum/v ... =1&t=50480
mongoose7
Posts: 1227
Joined: Wed Apr 06, 2011 12:13 pm

Re: Any way to tie two objects together?

Post by mongoose7 »

Someone else will have to answer this as I have no experience using texture matrices. However, I believe that Irrlicht actually passes texture matrices to the driver, so you might just try it.
dc740
Posts: 12
Joined: Fri Dec 26, 2014 1:48 am

Re: Any way to tie two objects together?

Post by dc740 »

mongoose7 wrote:Someone else will have to answer this as I have no experience using texture matrices. However, I believe that Irrlicht actually passes texture matrices to the driver, so you might just try it.

How odd that it's not supported by default then. I already have my animations and billboards working as I wanted (with and without matrices), so I won't be testing this in the short term. I haven't tried with the parent node YET, but I'm sure I will in a few days once I get a little time.


Thanks!
dc740
Posts: 12
Joined: Fri Dec 26, 2014 1:48 am

Re: Any way to tie two objects together?

Post by dc740 »

Solved. I was setting the billboard RELATIVE position to itself off from the center instead of setting the billboard absolute position in the world. So the rotation was completely messed up

Now it rotates as expected.

By the way, this is my render method for the multi-purpose billboard (static and follow-camera), please tell me ifyou see anything wrong with it (mainly because I'm a newbie and I want to learn):

Code: Select all

//! render
void StaticBillboardSceneNode::render()
{
    irr::video::IVideoDriver* driver = SceneManager->getVideoDriver();
    irr::scene::ICameraSceneNode* camera = SceneManager->getActiveCamera();
 
    if (!camera || !driver)
        return;
 
    if (followCamera){
        irr::core::vector3df campos = camera->getAbsolutePosition();
        irr::core::vector3df target = camera->getTarget();
        setOrientation(target - campos);
        driver->setTransform(irr::video::ETS_WORLD, irr::core::IdentityMatrix);
    } else {
        driver->setTransform(irr::video::ETS_WORLD, AbsoluteTransformation);
    }
 
    driver->setMaterial(Material);
 
    driver->drawIndexedTriangleList(vertices, 4, indices, 2);
}
 
Post Reply