About Store Forum Documentation Contact



Post Reply 
Create sub objects in editor
Author Message
Harton Offline
Member

Post: #1
Create sub objects in editor
Hello,

I create new object type in editor and I would like join to this object other sub objects from object template.
My two questions:
1. How can I change position sub object when I change position its parent object?
2. How can I create sub object from template. Now I create it like this:
Code:
STRUCT(EditParticles , Edit::ObjClass)
//{
    // ...
};

void EditParticles::create(Game::ObjParams &obj)
{
    for(UInt i=0; i<obj.sub_objs.elms(); ++i)
    {
        Edit::World.objCreate(Vec(0,0,0), &obj.sub_objs[i]);
    }
}
Objects are created but they are empty. Anyone know why?
(This post was last modified: 08-24-2012 05:41 AM by Harton.)
08-24-2012 05:40 AM
Visit this user's website Find all posts by this user Quote this message in a reply
Harton Offline
Member

Post: #2
RE: Create sub objects in editor
Asked are outdated. I worked it out with these problems.
But there was another problem. When I want to move the parent object, its sub objects copy to a new location and I have one parent and a few the same sub object in different positions. How do I move the parent, so that the children remained in the same relationship?
I create sub object in this way:
Code:
void CBaseObjClass::create(Game::ObjParams &obj)
{
    for(UInt i=0; i<obj.sub_objs.elms(); ++i)
    {
        Edit::World.objCreate(obj.matrixFinal().pos, &obj.sub_objs[i]);
    }
}

The second question. Why is not it possible to get an array of objects selected?
At this point, a way to determine which object is selected, it is very brutal.
Code:
    for(int i=0; i<Edit::World.objs(); ++i)
    {
        if(Edit::World.obj(i).selected() == true)
        {
            // actions
        }
    }

Calling the code for every object in every frame is very inefficient. Or maybe there is another way?
08-25-2012 09:27 AM
Visit this user's website Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #3
RE: Create sub objects in editor
Hello,

This is not the right approach to create secondary objects,
as CBaseObjClass::create (in Editor) may be called multiple times, everytime the object has been modified.

I can add accessing selected objects for next SDK

if you don't wish to wait you can add following methods to "Edit/World/WE.h"
Code:
Int  selObjs(     )C {return  _obj_sel.elms();} // get number of selected objects
Obj& selObj (Int i)  {return *_obj_sel[i]    ;} // get i-th      selected object
08-26-2012 02:23 PM
Find all posts by this user Quote this message in a reply
Harton Offline
Member

Post: #4
RE: Create sub objects in editor
Thanks! I'll wait for next SDK and surprise, mentioned in the roadmap. wink This access to selected objects will be better.

But I would like to ask you for help in creating sub objects. Generally, a useful improvement would be a group of objects, but as long as it does not exist, I have to do it another way.
Can you hint, how to create sub objects, that were permanently attached to the parent?
08-26-2012 07:13 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #5
RE: Create sub objects in editor
Hello,

Groupped objects are on the roadmap

My suggestion would be:
use 1 Edit object in the world Editor, however draw that object as multiple objects:
void objDraw()
{
mesh.draw(matrix);
sub_obj_0.draw(matrix1);
sub_obj_1.draw(matrix2);
}

when it comes to Game, then you can use your method of:
Code:
void CBaseObjClass::create(Game::ObjParams &obj)
{
     for(UInt i=0; i<obj.sub_objs.elms(); ++i)
     {
         Edit::World.objCreate(obj.matrixFinal().pos, &obj.sub_objs[i]);
     }
}
09-01-2012 02:18 PM
Find all posts by this user Quote this message in a reply
Post Reply