What is S3DVertex2TCoords and how it works ?

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
Rayshader
Posts: 21
Joined: Tue Mar 28, 2017 1:18 pm

What is S3DVertex2TCoords and how it works ?

Post by Rayshader »

Hello !
I'm using simple S3DVertex to build my custom scene node... And when looking to Irrlicht's API, I fall on this class.
As the documentation specify, the constructor looks like:

Code: Select all

 
S3DVertex2TCoords(const core::vector3df& pos, const core::vector3df& normal, const SColor& color, const core::vector2d<f32>& tcoords, const core::vector2d<f32>& tcoords2);
 
From what I read, the constructor expect two 2D vectors for the texture. I'm not sure how this two vectors are used: how does they apply from the texture to the vertex ?
I'm wondering if the following image describe how moving from S3DVertex to S3DVertex2TCoords could be used:
Image
In this case: C and E have the same world positions but not the same texture positions, idem for D and F.
But I think I might be wrong, so what it is for ?
Thanks for you answer !
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: What is S3DVertex2TCoords and how it works ?

Post by CuteAlien »

No - you need really 8 vertices for this case because you have different uv's per vertex.
The S3DVertex2TCoords is when you want a second texture on top of it. For example to add details. Then that can have a different set of uv-coordinates.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Mel
Competition winner
Posts: 2292
Joined: Wed May 07, 2008 11:40 am
Location: Granada, Spain

Re: What is S3DVertex2TCoords and how it works ?

Post by Mel »

The S3DVertex2TCoords is a vertex type composed of:

-A Position 3D Vector
-A Normal 3D Vector
-A Color which is a 32 bit unsigned integer
-A first Set of texture coordinates as a 2D Vector, TC0
-A second Set of texture coordinates as a 2D Vector, TC1

It adds a second set of texture coordinates so you can have 2 sets of independent texture coordinates at any given time. This second set of texture coordinates is used on the follwing materials, besides the shaders. IN these cases, the texture1 uses the second set of texture coordinates

EMT_LIGHTMAP : the textures 0 and 1 are multiplied
EMT_LIGHTMAP_ADD :the textures 0 and 1 are added
EMT_LIGHTMAP_M2 : the texture 0 is multiplied by 2*texture1
EMT_LIGHTMAP_M4 : the texture 0 is multiplied by 4*texture1
EMT_LIGHTMAP_LIGHTING : Same as EMT_LIGHTMAP, but adds dynamic lighting
EMT_LIGHTMAP_LIGHTING_M2 : Same as EMT_LIGHTMAP_M2, but adds dynamic lighting
EMT_LIGHTMAP_LIGHTING_M4 : Same as EMT_LIGHTMAP_M4, but adds dynamic lighting.
EMT_DETAIL_MAP : the textures 0 and 1 blended, and the TC1 is a multiply of TC0 so large that produces good detail on terrains when the original texture starts to be too blurry, it is the material used in the terrain example

And you can convert directly from a standard vertex type to a 2TCoords mesh using the mesh manipulator utility of the scene manager.

Their utility is just to provide another set of texture coordinates, which is mainly used to do lightmapping techniques, present on the Quake III levels, for example, although they aren't necesarily used for that. It's all about texture coordinates, not world positions, To build the faces, you need the triangles whose vertices are represented by the world positions, but with this type of vertex, it can contain aditional info
"There is nothing truly useless, it always serves as a bad example". Arthur A. Schmitt
Rayshader
Posts: 21
Joined: Tue Mar 28, 2017 1:18 pm

Re: What is S3DVertex2TCoords and how it works ?

Post by Rayshader »

Ok not a potential solution for what I was looking for... No optimization for me.
Thanks for the explanation, I'll definitively use this soon.
Post Reply