Manual Object Diagram

A place for users of OGRE to discuss ideas and experiences of utilitising OGRE in their games / demos / applications.
nebulism
Gnoblar
Posts: 4
Joined: Fri Jan 07, 2022 5:05 pm

Manual Object Diagram

Post by nebulism »

Hi All,

I'm playing with ManualObject and have a few questions after crawling the forums searching for an answer or two.

So my question is:
Does anyone have a diagram/description as to the normal/textureCoord/colour/triangle with respect to the vertex that the api has described?
For each vertex, call position(), normal(), textureCoord(), colour() to define your vertex data. Note that each time you call position() you start a new vertex. Note that the first vertex defines the components of the vertex - you can't add more after that. For example if you didn't call normal() in the first vertex, you cannot call it in any others. You ought to call the same combination of methods per vertex.
I looked up some diagrams online and referenced open-gl, but it still was not quite clear as to what the methodology was expressing. I understand the vertex locations, but it's not quite clear how a vertex normal applies to an object (at least compared to the normal of a surface bounded by several vertices). I do believe that I understand that all visual faces need to be expressed as a collection of triangles (so I think that makes sense).

If I want to represent a cube, for example, I understand that I would start with 8 vertices, but I've seen examples that leverage many more. Is that for the purpose of creating overlapping vertices in order to define triangles that share a common point with normals for each component of the triangle's
3 vertices?

Thank you!
Neb
nebulism
Gnoblar
Posts: 4
Joined: Fri Jan 07, 2022 5:05 pm

Re: Manual Object Diagram

Post by nebulism »

After a bit more digging, it does appear now to make sense to require vertices that are duplicated per shared face. Thus a vertex is connected to 3 faces in a cube, and so we would expect to have 3 (faces) x 8 (vertices/cube) resulting in a total of 24 vertices, each having defined elements associated with normal, textureCoord, and so on. I'll keep adding to this thread as I learn more (or respond to others).

This thread: viewtopic.php?t=43030, appears to have some good discussion.

An example, from me, where I define a plane using the the prescription set up here https://ogrecave.github.io/ogre/api/1.1 ... ation.html:

Code: Select all

Ogre::ManualObject* Introduction::CreatePlaneMesh(Ogre::String name, Ogre::String matName, float planeSize) {

    Ogre::ManualObject* plane = new Ogre::ManualObject(name);
    plane->begin(matName);

	plane->position(-planeSize, planeSize, 0);
	plane->normal(0, 0, 1);
	plane->textureCoord(0, 0);

	plane->position(-planeSize, -planeSize, 0);
	plane->normal(0, 0, 1);
	plane->textureCoord(0, 1);

	plane->position(planeSize, -planeSize, 0);
	plane->normal(0, 0, 1);
	plane->textureCoord(1, 1);

	plane->position(planeSize, planeSize, 0);
	plane->normal(0, 0, 1);
	plane->textureCoord(1, 0);

	//Autodefine quad
	plane->quad(0, 1, 2, 3);

    plane->end();

    return plane;

}
This makes sense from a 2D perspective, presumably, this has to be repeated 6 times for a cube (or something like that). When I tinker with a cube, I'll post an update.