Some problems

All about the core api and animation, input, sound, effect, collision and physics engines.
You can also post here your feature requests.

Moderator: Brume Dev Team

Some problems

Postby Gero on Sat Dec 08, 2007 4:59 am

Hi,

when I add a childobject to an existing object, the childobject sets its size to the parent ones.
Is this behavior intended?
Is it possible that the scenegraph created with AddChild() has a corrupt worldrotation?
I found out that sometimes X, Y and Z coordinates are randomly interchanged. :(
The worldposition sometimes is weird too :( some objects are translated stranged their origin when I use Obj.Pos.Reset()
What do XSize, YSize and ZSize do? They had no effect when I changed them

Greetings
-- Gero
User avatar
Gero
Brume user
 
Posts: 27
Joined: Thu Dec 06, 2007 10:11 pm

Re: Some problems

Postby Silmaryls on Wed Dec 12, 2007 8:29 pm

Hello,

Well, yes the transformations of objects are done by adding all parent transforms.
So if a parent is scaled, the child will have the parent scale + his own scale.
This is the default and normal behaviour (the fact that translation changes may be a rotation)
This may be really usefull if you want to scale an entire level in the scene graph.

You can disable this using the BrumeObject.ComputeParentTransformation property. If true the BrumeObject.WorldTranformation will be equal to BrumeObject.LocalTranformation


XSize, YSize and ZSize must be used with BrumeObject.HasGlobalSize = false and are used for non uniform scale.
User avatar
Silmaryls
Brume Team Member
 
Posts: 340
Joined: Tue Feb 21, 2006 10:09 pm
Location: Paris - France

Re: Some problems

Postby Gero on Mon Dec 17, 2007 2:04 pm

Silmaryls wrote:Hello,

Hi, it's me again ;)
Well, yes the transformations of objects are done by adding all parent transforms.
So if a parent is scaled, the child will have the parent scale + his own scale.

There is definitely some sort of bug in the scenegraph transformation code,
the scaling seems totally wrong or I am simply too stupid to use it.
When I add some objects to a parent object, I do this normally to the skybox to show that
the object is in the room, otherwise it doesn't get rendered (why not?), the objects
are ok. This time I had an object which was slightly too big. I scaled it a bit down in 3DMax and now it
was extremely small... 1 pixel only. I tested it some more and when I attach the object to another
object it grows huge and renders over the whole screen.

In my own engine I use following code:
Code: Select all
        private bool UpdateWorld()
        {
            if (m_WorldUpdate)
            {
                if (Parent != null)
                {
                    Vector3 ParentWorldScaling = Parent.WorldScaling;

                    m_WorldRotation = Parent.WorldRotation * m_Rotation;
                    m_WorldScaling = ParentWorldScaling * m_Scaling;
                    m_WorldTranslation = Parent.WorldTranslation + ((Parent.WorldRotation * m_Translation) * ParentWorldScaling);
                }
                else
                {
                    m_WorldTranslation = m_Translation;
                    m_WorldRotation = m_Rotation;
                    m_WorldScaling = m_Scaling;
                }

                m_WorldTransform.Translation = m_WorldTranslation;
                m_WorldTransform.Scale = m_WorldScaling;

                m_InverseWorldTransform = m_WorldTransform.Transpose();

                m_InverseWorldTransform.m30 = m_InverseWorldTransform.m31 = m_InverseWorldTransform.m32 = 0.0f;

                m_InverseWorldTransform.Translation = m_InverseWorldTransform * (-m_WorldTranslation);

                m_WorldUpdate = false;

                return true;
            }

            return false;
        }

This code was ported from my old C++ engine, which was tested in some scenarios.
There is no doubt that your code is tested too, but how it can be that the objects have
such confusing behaviour?

Something other I encountered:
BrumeObject.cs says on line 819:
Code: Select all
        public void AddChild(BrumeObject child)
        {
           this.brume.RemoveObject(child);
           Childs.Add(child);
           child.Parent = this;
           //E3D_E3D_STATS_INC(nbrObjects)
        }

Shouldn't it be:
Code: Select all
        public void AddChild(BrumeObject child)
        {
                if( child == null )
                     return;

                if( child.Parent != null)
                     child.Parent.RemoveObject(child);
          
           Childs.Add(child);
           child.Parent = this;
           //E3D_E3D_STATS_INC(nbrObjects)
        }

I had to remove the object from the parent every time I changed the location in the scene graph.

This is the default and normal behaviour (the fact that translation changes may be a rotation)

You mean rotation is a translation?

This may be really usefull if you want to scale an entire level in the scene graph.

That's the meaning of a scene graph.

You can disable this using the BrumeObject.ComputeParentTransformation property. If true the BrumeObject.WorldTranformation will be equal to BrumeObject.LocalTranformation

Disableing the scenegraph is not really an option for me. only using own scale would be better.
Maybe you could create properties for UseParentRotation, UseParentScale and UseParentTranslation?

XSize, YSize and ZSize must be used with BrumeObject.HasGlobalSize = false and are used for non uniform scale.

I suggest a change of one of these properties sets HasGlobalSize = true automaticly
or a better solution would be Size sets all of these to the same value and HasGlobalSize is always true.
User avatar
Gero
Brume user
 
Posts: 27
Joined: Thu Dec 06, 2007 10:11 pm

Re: Some problems

Postby Silmaryls on Tue Jan 08, 2008 9:18 pm

Hi,


For the scaling problem : there is definitively no problem for me.
Can you make a test : launch Brume Demo and look at the room, table chair mesh (Game.TestCollisionsOnTriMesh() method).
I used this to be sure that transformations are not broken.
This mesh was exported with Blender (not 3DS) and I am sure about it's properties. The room is scaled in blender and the chair is scaled and rotated in Brume. You can even play with it with the debug console : select the room and scale/rotate it -> the objects scale/rotate accordingly. the same for the table and the chair (notice that room is parent of table that is parent of chair.)
I think that your problem may be adding the objects to the skybox. In fact I never tried that but skybox is really a special case so avoid that.
Your objects should be visible without an attachment (just like in the demo). Just ensure that you place the sky box first (I have a bug with skybox sorting that may be your problem, hiding other objects).



Gero wrote:Something other I encountered:
BrumeObject.cs says on line 819:
Code: Select all
        public void AddChild(BrumeObject child)
        {
           this.brume.RemoveObject(child);
           Childs.Add(child);
           child.Parent = this;
           //E3D_E3D_STATS_INC(nbrObjects)
        }

Shouldn't it be:
Code: Select all
        public void AddChild(BrumeObject child)
        {
                if( child == null )
                     return;

                if( child.Parent != null)
                     child.Parent.RemoveObject(child);
          
           Childs.Add(child);
           child.Parent = this;
           //E3D_E3D_STATS_INC(nbrObjects)
        }

I had to remove the object from the parent every time I changed the location in the scene graph.


You're right ! And in fact the right method should be :

Code: Select all
        public void AddChild(BrumeObject child)
        {
                if( child == null )
                     return;

                if( child.Parent != null)
                     child.Parent.RemoveObject(child);
                else
                     this.brume.RemoveObject(child);
         
           Childs.Add(child);
           child.Parent = this;
           //E3D_E3D_STATS_INC(nbrObjects)
        }



Thanks for that one !


You mean rotation is a translation?

Nope :wink: I just said that a rotation may change child's position.


Disableing the scenegraph is not really an option for me. only using own scale would be better.
Maybe you could create properties for UseParentRotation, UseParentScale and UseParentTranslation?

Well I'm not sure about this one...Can't you just override the transform in the move method and do what you want ? (using the parent properties for example)


I suggest a change of one of these properties sets HasGlobalSize = true automaticly
or a better solution would be Size sets all of these to the same value and HasGlobalSize is always true.


You're TOTALLY right ! I changed that for next release.

Silmaryls
User avatar
Silmaryls
Brume Team Member
 
Posts: 340
Joined: Tue Feb 21, 2006 10:09 pm
Location: Paris - France


Return to Technical discussion

Who is online

Users browsing this forum: No registered users and 1 guest

cron