About Store Forum Documentation Contact



Post Reply 
Rotate individual mesh parts
Author Message
Kevin Offline
Member

Post: #1
Rotate individual mesh parts
Hi,

I have a turret which consists of two mesh parts. A bottom part and a cannon part. Now I want the cannon part to always focus the active target, therefore I have to apply a transformation matrix.

I already calculated the absolute rotation (stored in Orient) and applied it to the whole model, by changing the actors matrix in my game object class:

Code:
matrix(Matrix(Matrix3(_orient), pos()));

But I am looking for a way to only apply the rotation to a single mesh part.
I already thought about overwriting the default draw method and draw each mesh part manually. But maybe there is an easier way?

Furthermore, I would like to know how to access a mesh part only by its name.

Thanks in advance!
07-10-2012 09:40 AM
Find all posts by this user Quote this message in a reply
Harry Offline
Member

Post: #2
RE: Rotate individual mesh parts
(07-10-2012 09:40 AM)Kevin Wrote:  Furthermore, I would like to know how to access a mesh part only by its name.

I think it should work ok:

Code:
MeshPart var;

REPA(mesh->parts) {
    if(mesh->parts[i].name=="Name") {
        var.create(mesh->parts[i]);
        break;
    }
}
(This post was last modified: 07-10-2012 12:20 PM by Harry.)
07-10-2012 12:19 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Kevin Offline
Member

Post: #3
RE: Rotate individual mesh parts
Well thanks, but actually I thought there would be a simple helper function which would do that for me. But it seems like I have to write my own.

I would still like to know how to rotate individual mesh parts. Does nobody have an idea?
07-11-2012 11:25 AM
Find all posts by this user Quote this message in a reply
Harry Offline
Member

Post: #4
RE: Rotate individual mesh parts
There is also Advanced\3 - Mesh, Shaders\Mesh\Separate parts rendering 1.cpp tutorial that shows how apply rotation for a single MeshPart. And you also doesn't need to use REPA to find MeshPart by name.
07-11-2012 12:05 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Kevin Offline
Member

Post: #5
RE: Rotate individual mesh parts
You are awesome. Thank you very much wink

Didn't knew there was a tutorial for that.
07-11-2012 12:40 PM
Find all posts by this user Quote this message in a reply
cat555 Offline
Member

Post: #6
RE: Rotate individual mesh parts
Hi, is there someone who can post the example project - "Advanced\3 - Mesh, Shaders\Mesh\Separate parts rendering 1.cpp".

I believe that's an example from EE 1.0, and it's not present in EE 2.0.

Thanks!
01-15-2014 12:36 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #7
RE: Rotate individual mesh parts
Hi,

In 2.0 the tutorial is under name "mesh part draw group"
01-15-2014 11:19 PM
Find all posts by this user Quote this message in a reply
cat555 Offline
Member

Post: #8
RE: Rotate individual mesh parts
Hi Esenthel, thanks, i already saw that tutorial, but is not what i need then.

I need to get mesh parts (MeshPart) from a Mesh, and then transform them individually. Is it possible?

Picking the "mesh part draw group" tutorial example, how to change it, in such a manner that i can rotate (for example) only the MeshPart related to the head of the warrior?

Thanks!
01-16-2014 01:21 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #9
RE: Rotate individual mesh parts
Hi,

First you select the mask for certain parts. Then you draw this mesh with one matrix.

Then you select the mask for other part and draw the mesh with other matrix.
01-17-2014 12:10 AM
Find all posts by this user Quote this message in a reply
cat555 Offline
Member

Post: #10
RE: Rotate individual mesh parts
Hi Esenthel, many thanks... it works just perfectly smile
01-17-2014 12:49 PM
Find all posts by this user Quote this message in a reply
cat555 Offline
Member

Post: #11
RE: Rotate individual mesh parts
Hi again, sorry for so much doubts!!!

I'm now trying apply this in physics objects in a world.

So, i've created a world with a physics object - a plane.

In render(), i'm already calling Game.World.draw(); so the entire world is rendered here. I can't then use the same technique as in tutorial "mesh part draw group", because it will draw the mesh again, but this last one will not behave in the physics world, like the one that is drawn by Game.World.draw();.

So, my need is just to transform the MeshPart of propeller for instance. I'm trying then to use meshpart.transform(matrix); in the update() method, but with no success.

This was my strategy in other game engines that i've used in the past, that's why i'm trying it here... how can i do this with Esenthel?

Thanks again!!!
01-17-2014 01:53 PM
Find all posts by this user Quote this message in a reply
Rubeus Offline
Member

Post: #12
RE: Rotate individual mesh parts
For physics objects, try to use the physics matrix. You can use joints to hold the objects together instead of mesh parts. For a propeller, you can set the joint and add angular velocity to set it a-spinning. This might be an easier method.
01-17-2014 02:39 PM
Find all posts by this user Quote this message in a reply
cat555 Offline
Member

Post: #13
RE: Rotate individual mesh parts
Hi Rubeus, thanks for your feedback.

My intention was to not break the plane into several objects (applying then the joints you referred), since that will make it more complex to manage the plane as a whole. That's why i've divided plane in several meshparts, allowing me to treat the plane as one object only.

Regarding your suggestion of using the physics matrix, i can use it, but it will be applied to the whole object.
(This post was last modified: 01-17-2014 03:28 PM by cat555.)
01-17-2014 03:17 PM
Find all posts by this user Quote this message in a reply
cat555 Offline
Member

Post: #14
RE: Rotate individual mesh parts
Well, i managed to do this... using physics (actor) matrix (a mix of Rubeus and Esenthel suggestions):

Code:
void Render()
{
   switch(Renderer())
   {
      case RM_PREPARE:
      {
         if(Planes[0].mesh)
         {
            SetDrawMask(IndexToFlag(DG_PLANE));
            
            Matrix m1(MatrixIdentity);
            
            Planes[0].mesh->draw(Planes[0].actor.matrix());

            SetDrawMask(IndexToFlag(DG_PROPELLER));
            
            m1.rotateZ(x);
            
            Planes[0].mesh->draw(m1.mul(Planes[0].actor.matrix()));
            
            SetDrawMask();
         }
      }break;
   }
}

That said, i see that i've to draw each object in the scene, so i cannot use Game.World.draw() no more.

So, if i want to render the terrain individually (and get access to each object in the defined world), how can i get to it to draw it (i've checked Game.World.* but don't see a way)?
01-17-2014 06:06 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #15
RE: Rotate individual mesh parts
Quote:That said, i see that i've to draw each object in the scene, so i cannot use Game.World.draw() no more.
Can you explain what you mean by that?

You can override the virtual draw method of the objects, and do custom drawing there, or don't draw them at all.
01-17-2014 11:04 PM
Find all posts by this user Quote this message in a reply
Post Reply