About Store Forum Documentation Contact
Donations:
207$/mo



Post Reply 
retrieve mesh from memx/c/b array
Author Message
Zervox Offline
Member

Post: #1
retrieve mesh from memx/c/b array
Trying to load every static object into one mesh.
I only need the pos and geometry.

Code:
Memb<Game::Static> custstatic;
MeshBase custmesh;

FREP(custstatic.elms())
{
     FREPD(j,custstatic[i])
     {
    //custmesh.add(custstatic[i]
                
     }
}
Or if its possible to do something like
Code:
FREP(area::objs)
{
   area::objs.mesh.type(any mesh, type)
}
(This post was last modified: 12-11-2010 09:30 PM by Zervox.)
12-11-2010 09:08 PM
Find all posts by this user Quote this message in a reply
Zervox Offline
Member

Post: #2
RE: retrieve mesh from memx/c/b array
Sorry, i'm not sure if I expressed my question properly previously:

Can you explain how I can retrieve every object within a area with "OBJ_"TYPE"" and then add the meshes of "OBJ_TYPE" to a memb<meshbase>obstacle so that I can use Mesh.add(obstacle[i].meshbase)

I'm not sure how to do this in the engine. Any advice/tips on the matter? Perhaps a snippet of sorts?
(This post was last modified: 12-12-2010 02:30 PM by Zervox.)
12-12-2010 02:29 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #3
RE: retrieve mesh from memx/c/b array
Game::Area::obj,objs this gives you access to objects
Game::Obj::type this gives you access to object type
12-12-2010 02:37 PM
Find all posts by this user Quote this message in a reply
Zervox Offline
Member

Post: #4
RE: retrieve mesh from memx/c/b array
obj which is the objParams link in area.h doesnt give me the objParams right to retrieve its Mesh.
In fact it doesnt even show the mesh at all in VS.
Any ways to work around this?
(This post was last modified: 12-12-2010 02:59 PM by Zervox.)
12-12-2010 02:59 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #5
RE: retrieve mesh from memx/c/b array
Int objs ( ) {return _obj.elms();} // get number of objects in the area
Obj& obj ( Int i ) {return *_obj[i] ;} // get i-th object in the area

its Obj, not ObjParams
then do cast to whatever class you want
copy Mesh, transform it by matrix, and add to your container.
12-12-2010 03:04 PM
Find all posts by this user Quote this message in a reply
Zervox Offline
Member

Post: #6
RE: retrieve mesh from memx/c/b array
Well I also noticed
Memc<ObjParams > obj,const_obj;
Just thought I could extract mesh directly from that, which would have made it shorter somewhat.


->data->data()->obj(0).mesh
->data->data()->obj(0).base
this could work maybe if it had not been delcared private.
(This post was last modified: 12-12-2010 03:20 PM by Zervox.)
12-12-2010 03:11 PM
Find all posts by this user Quote this message in a reply
Zervox Offline
Member

Post: #7
RE: retrieve mesh from memx/c/b array
Ok, so I've tried some different ways this was the last thing I tested.
Could you perhaps show me how to cast them to retrieve the meshr/meshbase/mesh?
Code:
MeshBase obstaclemeshes;
Game::Obj *cust;
FREP(grid1->data->objs())
{
    cust= CAST(Game::Obj,&grid1->data->obj(i));
    obstaclemeshes.add();    
}
12-13-2010 07:26 AM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #8
RE: retrieve mesh from memx/c/b array
if(Game::Static *stat=CAST(Game::Static,...obj(i)))
{
stat->mesh
stat->matrix
}
12-13-2010 11:15 AM
Find all posts by this user Quote this message in a reply
Zervox Offline
Member

Post: #9
RE: retrieve mesh from memx/c/b array
Hmm, have to check it when I get home from work.
12-13-2010 11:23 AM
Find all posts by this user Quote this message in a reply
Zervox Offline
Member

Post: #10
RE: retrieve mesh from memx/c/b array
I tried something like this, but it didnt work. It did however make the exported .obj from 500kb to 3.2MB but with no geometry change.

I notice an increased memory usage as well but it doesn't add anything. Seems like it instead copies and recreates the terrain mesh.
Anything else I might have missed?
Code:
Mesh xt;

FREPD(i,grid1->data->objs())
{
    if(Game::Static *stat=CAST(Game::Static,&grid1->data->obj(i)))
    {

        xt.add(stat->mesh->base(0));
    }
}
(This post was last modified: 12-14-2010 07:53 AM by Zervox.)
12-14-2010 07:52 AM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #11
RE: retrieve mesh from memx/c/b array
you havent transformed the mesh by matrix, and dont use only 0-th part, but all of them
12-14-2010 02:18 PM
Find all posts by this user Quote this message in a reply
Zervox Offline
Member

Post: #12
RE: retrieve mesh from memx/c/b array
Ok, got some progress.
How do I get the xzy scale of the cast mesh?
obstaclemeshes.scale(stat[0].mesh->scale.xzy());
I could do Vec(stat[0].mesh->scale.x,stat[0].mesh->scale.y,stat[0].mesh->scale.z)?
Code:
    FREPD(i,grid1->data->objs())
    {
        if(Game::Static *stat=CAST(Game::Static,&grid1->data->obj(i)))
        {
            FREPD(j,stat[0].mesh->parts())
            {
                obstaclemeshes.create(stat[0].mesh->part(j).render);
                obstaclemeshes.transform(stat[0].matrix());
                //obstaclemeshes.scale(stat[0]);
                xt.add(obstaclemeshes);
            }
        }
    }
(This post was last modified: 12-14-2010 03:56 PM by Zervox.)
12-14-2010 03:46 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #13
RE: retrieve mesh from memx/c/b array
use matrixScaled
12-14-2010 03:57 PM
Find all posts by this user Quote this message in a reply
Zervox Offline
Member

Post: #14
RE: retrieve mesh from memx/c/b array
obstaclemeshes.scale(Vec(stat[0].matrixScaled().x.x,stat[0].matrixScaled().x.y,stat[0].matrixScaled().x.z));

This changes their positons, and strechtes the exported objects.
I've tried different x.x,y.y,z.z combinations all does the same things
12-14-2010 04:09 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #15
RE: retrieve mesh from memx/c/b array
obstaclemeshes.transform(stat[0].matrixScaled());
12-14-2010 04:42 PM
Find all posts by this user Quote this message in a reply
Post Reply