About Store Forum Documentation Contact



Post Reply 
DrawGroup and DrawMask Problem
Author Message
ronghester Offline
Member

Post: #1
DrawGroup and DrawMask Problem
I created two meshes from the same obj file. when I am applying a drawgroup to a meshpart of one mesh (and then setting the drawmask for that draw group) the same meshpart of the other mesh is also getting affected. Now if I create other meshes using the same mesh file their meshpart also get affected in the similar way.

Here is a code...
Code:
In Init :
Mesh     *mesh1;
Mesh     *mesh2;
mesh1=Meshes   ("obj/chr/human/0.mesh");
mesh2=Meshes   ("obj/chr/human/0.mesh");
In Draw :
Matrix  mesh1mat;  mesh1mat.setTransformAtPos(Vec(0, 0, 0), Matrix3().setRotateX( 0));
    Matrix  mesh2mat;  mesh2mat.setTransformAtPos(Vec(1, 0, 1), Matrix3().setRotateX( 1));
   mesh1->draw(mesh1mat);
   mesh2->draw(mesh2mat);
On press of a key:
if(Kb.bp(KB_O))
{
   mesh1->parts[1].setDrawGroup(HIDE_PART);
}

I think it has to do something with the way meshes are being created. Is there a way to create mesh such that its drawgroup will not affect the other meshes created from the same mesh file.
08-24-2013 04:07 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #2
RE: DrawGroup and DrawMask Problem
Hi,

You're operating on two Mesh* (mesh pointers) which point to the same mesh in the memory.
08-24-2013 11:36 PM
Find all posts by this user Quote this message in a reply
ronghester Offline
Member

Post: #3
RE: DrawGroup and DrawMask Problem
okay So how to create meshes that returns a unique pointers.
08-25-2013 07:23 AM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #4
RE: DrawGroup and DrawMask Problem
Hi,

Could you please explain what would you like to achieve as the final result?
Like a description with a screenshot would be great.

Quote:okay So how to create meshes that returns a unique pointers.
I don't recommend doing that because using 2 meshes you use 2x more memory.
But you can do:
MeshPtr original;
Mesh copy; // here this is not a pointer, but an actual mesh object
original=UID(..);
copy.create(*original); // something like that
08-26-2013 02:30 AM
Find all posts by this user Quote this message in a reply
ronghester Offline
Member

Post: #5
RE: DrawGroup and DrawMask Problem
It is related to armour hiding and showing in a multiplayer scenario. I don't have much to show at this moment, but I have the rpg test sample in the showcase. Nothing special wink
I am trying to learn every aspect of this engine in the coming few weeks, so I am trying many things. I might ask few more questions in near future as I am finding my way through this engine. and I appreciate the support so far I am getting here.

regarding the solution you have provided it actually works as expected.

Thanks
08-26-2013 10:17 PM
Find all posts by this user Quote this message in a reply
Rubeus Offline
Member

Post: #6
RE: DrawGroup and DrawMask Problem
Keep in mind that if you don't want to use the extra memory, you can extend the base class and make a custom draw function such as:
Code:
UInt extended::drawPrepare(  )
{
   if( drawMe )
      return super.drawPrepare(  );
   return 0;
}
So you could potentially turn drawing on and off by changing 'drawMe'.
08-26-2013 11:49 PM
Find all posts by this user Quote this message in a reply
ronghester Offline
Member

Post: #7
RE: DrawGroup and DrawMask Problem
Hi Rubeus,

The drawmask does that exactly for you, doesn't it?
without having the extra overhead of all these tiny objects hierarchy.
08-27-2013 07:54 AM
Find all posts by this user Quote this message in a reply
Rubeus Offline
Member

Post: #8
RE: DrawGroup and DrawMask Problem
The draw mask is part of the model itself. If you have only 1 instance of the model loaded, you draw it according to the specific objects requirements.
If you modify the mask, any object that uses that model will be affected- unless you have a copy of the model loaded for each object. Let's use Esenthel's example. If you have a armor hat who's model takes up 1mb of memory, pre-copy, you are using 1mb even if 1,000 players wear the same hat. If you copy like Esenthel posted, 1,000 players would use 1GB of memory JUST for the hats.
So the ideal solution would be to extend the engine code to either draw/don't draw object like I posted, or possibly draw with a mask, but after the draw reset the mask. (I haven't played much with this, so this last one is a guess.) Doing things this way does create overhead, but not as much as copying objects
08-27-2013 03:48 PM
Find all posts by this user Quote this message in a reply
ronghester Offline
Member

Post: #9
RE: DrawGroup and DrawMask Problem
Hi,

We are taking the same route of drawmask as everyone believe that is best optimized for rendering (one more link : http://www.esenthel.com/community/showth...p?tid=5965)

But I didn't quite understand what you are proposing here. So you are saying that we should have two classes with individual drawprepare method right? but how you are proposing to address the fundamental problem of mesh creation?

So lets say we create individual class how are you proposing to create the meshes there?

I agree with you technically but if you can clarify a little more with some workable code it could be a another good solution for armour rendering.

I appreciate your help.
08-27-2013 09:45 PM
Find all posts by this user Quote this message in a reply
Rubeus Offline
Member

Post: #10
RE: DrawGroup and DrawMask Problem
I seem to have gotten a little long winded, so let me simplify: the goal is to either
1) call SetDrawMask() (with no argument-sets the mask back to default) directly after rendering the desired instance of the mesh
2) skip drawing the mesh part in the first place.
08-27-2013 11:50 PM
Find all posts by this user Quote this message in a reply
ronghester Offline
Member

Post: #11
RE: DrawGroup and DrawMask Problem
Just trying to understand, so the drawprepare solution won't work?

1. we are already doing that.
2. This i could not understand. Now how to skip drawing the mesh part? is there any other way (other than drawmask?).
08-28-2013 08:51 AM
Find all posts by this user Quote this message in a reply
Post Reply