View unanswered posts | View active topics It is currently Sun Sep 15, 2019 8:35 am



Reply to topic  [ 9 posts ] 
 move world and axis 
Author Message

Joined: Fri Nov 11, 2011 11:19 am
Posts: 2
Post move world and axis
Hi.

i have the following problem. I load a model, in this case an obj, and every time it load it put in he position 0,0,0. however i want to make this position dinamic. i want to be able to put it everywhere in the screen and then rotate it and this rotation has to be on this new point.. not 0,0,0.

i already seen some posts in the forum.
i try the following code for moving the world but it does not work. if i use it in a simple object as in this thread(viewtopic.php?f=4&t=121) it works.
however i want to avoid going through the hole world and translate every object.

GLC_StructOccurence* pOccurence= m_World.rootOccurence();

GLC_StructInstance* pInstance= pOccurence->structInstance();

GLC_Matrix4x4 myMatrix;
myMatrix.setMatTranslate(300.0, 0.0, -23.5);
pInstance->move(myMatrix);

pOccurence->updateChildrenAbsoluteMatrix();

Can some one help me? thanks.


Fri Nov 11, 2011 11:29 am
Profile

Joined: Fri Oct 21, 2011 1:32 pm
Posts: 3
Post Re: move world and axis
Hello!

I use this piece of code to move, resize and rotate an object called Plate (which is actially a glc_rectangle)
Code:
void QScene::updatePlate(SegmentPlate* plate)
{
    GLC_StructOccurence* structOccurence = m_World.occurence(plate->getId());

    GLC_Matrix4x4 scaleMatrix = GLC_Matrix4x4();
    scaleMatrix.setMatScaling(plate->getHeightRatio(), plate->getWidthRatio(),0);
    GLC_Matrix4x4 rotationMatrix(glc::X_AXIS, plate->getRotAngle());
    GLC_Matrix4x4 positionMatrix(plate->getPlaneCenter());

    structOccurence->structInstance()->setMatrix(positionMatrix * rotationMatrix  * scaleMatrix);

    //Do updates
    structOccurence->updateChildrenAbsoluteMatrix();
    updateGL();
}


and i also have this less functional code, but it moves an obj model
Code:
void QScene::updateModel()
{
    GLC_StructOccurence* pRoot= m_World.rootOccurence();

    GLC_Matrix4x4 positionMatrix(GLC_Vector3d(0, 0, 0));
    GLC_Matrix4x4 rotationMatrix(glc::Z_AXIS, m_skeleton->getModelAng());
    pRoot->children().at(0)->structInstance()->setMatrix(positionMatrix * rotationMatrix);

    //Do updates
    pRoot->updateChildrenAbsoluteMatrix();
    updateGL();
}


Tue Nov 15, 2011 6:03 pm
Profile

Joined: Mon Mar 12, 2012 5:49 am
Posts: 8
Post Re: move world and axis
Hello.
Tried this code in a simple test (GLC Example 7) and it really works nicely.

Now, I am loading a model with several children nodes and would like to select one of them to perform position and rotation changes on it.

What could be a way to get the structOcurrence while performing the selection of an object/children?

Thanks.


Mon Jul 07, 2014 3:14 am
Profile
Site Admin

Joined: Sun Jan 03, 2010 4:27 pm
Posts: 390
Post Re: move world and axis
Hi,
guillermoe wrote:
Hello.
Tried this code in a simple test (GLC Example 7) and it really works nicely.

Now, I am loading a model with several children nodes and would like to select one of them to perform position and rotation changes on it.

What could be a way to get the structOcurrence while performing the selection of an object/children?

Thanks.


Could you be more explicit ? I'm not sure to understand your need.

A+


Wed Jul 16, 2014 9:40 pm
Profile

Joined: Mon Mar 12, 2012 5:49 am
Posts: 8
Post Re: move world and axis
Sorry for my ambiguous question. :oops:
Let me explain myself.

Been trying to understand the logic required to move objects inside a scene. Was able to perform this in the GLC example #7 (the flying plaque), making it move and rotate by its own axis using the code while moving and rotating the world with mouse events as normal.

Then I tried to perform this inside GLC Player but found objects were not able to be selected after moving them. Then, you provided me the answer to this. By updating the objects' octrees after movement was finished, they could be selected as normal by clicking on them.

Now I need to understand how the model/world structure is managed by GLC lib to perform the following: Would like to write a function to select the children objects of a model by a consecutive increment of the parent node level of the selected children's branch... don't know if i am explaining it clearly :|
See... I want to double click a child object and then all other children sharing the same "1st level" parent also get selected.
Then the same object is double clicked again and now all the children of the "2nd level" parent are selected while others get deselected.
We can then continue performing this until we get just one selected object: The object we kept double clicking all this time, the only child of the "last level" parent from this branch of the structure.

Could you provide me a hint on how to perform this? Been playing with the different world.collection, struct and occurence parent/child managing capabilities but haven't been able to get the hang of it.
Also, this is my first coding project after years of not being able to do so (job). I have the feeling I am missing some basic knowledge on the way GLC lib defines and manages the glc_view world structure. Is there any resource available you can suggest me to obtain to learn more about this?

Thank you :mrgreen:


Sat Jul 26, 2014 9:02 am
Profile
Site Admin

Joined: Sun Jan 03, 2010 4:27 pm
Posts: 390
Post Re: move world and axis
Sorry It's not clear for me… :roll:
Can you send me a picture of a sample structure, And step by step the double clicked object and the selected objects.

So, to navigate into structure see these class :
GLC_World
GLC_StructOccurence

@+


Sat Jul 26, 2014 4:03 pm
Profile
User avatar

Joined: Sat Feb 06, 2010 7:28 am
Posts: 11
Location: Paris - France
Post Re: move world and axis
My understanding of Guillermoe's question : selection interaction like in PDF3D viewer

First time you click a 3D object, you select it.
Its depth in the tree is n.
Then, each time you click it again, you'll select the parent occurence ( depth = n-1 )
Finally, after "depth" clicks, the root is selected

Is it right ?


Sun Jul 27, 2014 1:06 am
Profile

Joined: Mon Mar 12, 2012 5:49 am
Posts: 8
Post Re: move world and axis
Hi lolobobo :)

Well, it is required to work in actually the opposite way.

After an object is clicked the function must find the depth=1 parent under root node and select all children objects of this node.
Next time it is clicked it must look for its depth=2 parent under root, unselect all and select the children object of this 2nd node.
If we continue doing so we will reach depth=n, selecting the clicked object only.

Using the structure shown in the attached image, if we continue clicking object #6 objects 1 to 8 will be selected first, then just children 5 to 8 and finally only object #6 will be selected.


Attachments:
structure.JPG
structure.JPG [ 23.72 KiB | Viewed 10950 times ]
Sun Jul 27, 2014 7:32 am
Profile

Joined: Mon Mar 12, 2012 5:49 am
Posts: 8
Post Re: move world and axis
Well... it seems I could not explain it correctly.

Lets say... I open a car 3D model in the player. I am looking for is to be abe to select this car's parts by "categories" or "areas", following the structure tree.
Lets say we click on a tire. The tire is part of the "powerdrive" node of the structure (a children of root node) so all objects that belong to this node are selected and then we make unselected objects invisible.
Now we have the car's powerdrive on the screen, which is divided in other nodes such as "engine", "transmission", "driveshaft" and "axles".
If we click on the tire again and, being part of the "axles" node (root's 2nd level child), all children objects of this node will be selected.
At last (in this example), we have the 2 axle and 4 tire objects. If we click on the tire, it will be selected while others get invisible.

Thats the behaviour I want to reproduce in the select function.
To know what is the actual parent node to use I can get the selected object ID, make a loop to get all parent IDs until root is reached and place them in a Qlist. Then, actual parent is selected according to the current selection depth level.

What I still cant understand is how to make the function to traverse all the children object of the actual parent node and select them. Not all tree structures will be symetrical and nodes will have different quantities of children objects.

Could somebody provide me with a hint on how to perform this?

Thanks.


Fri Aug 08, 2014 3:59 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 9 posts ] 

Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.