MeshVertexPosition - What am I doing wrong?

Everything related to 3D programming
User avatar
Lexicon
User
User
Posts: 98
Joined: Mon Jul 22, 2013 6:16 am
Contact:

MeshVertexPosition - What am I doing wrong?

Post by Lexicon »

Hi guys,
I can't understand why the 2 and 3 textures looks inside the mesh. Please explain me. :(

Code: Select all

CreateMesh(22, #PB_Mesh_TriangleList, #PB_Mesh_Dynamic)

MeshVertexPosition(0, 0, 0)
MeshVertexTextureCoordinate(0, 0)
MeshVertexPosition(1, 0, 0)
MeshVertexTextureCoordinate(0.1, 0)
MeshVertexPosition(0, 0, 20)
MeshVertexTextureCoordinate(0, 2)
MeshVertexPosition(1, 0, 20)
MeshVertexTextureCoordinate(0.1, 2)
MeshFace(0, 1, 3)
MeshFace(3, 2, 0)

MeshVertexPosition(0, 0, 0)
MeshVertexTextureCoordinate(0, 0)
MeshVertexPosition(0, 2, 0)
MeshVertexTextureCoordinate(0.2, 0)
MeshVertexPosition(0, 0, 20)
MeshVertexTextureCoordinate(0, 2)
MeshVertexPosition(0, 2, 20)
MeshVertexTextureCoordinate(0.2, 2)

MeshFace(4, 5, 7)
MeshFace(7, 6, 4)

MeshVertexPosition(0, 2, 0)
MeshVertexTextureCoordinate(0.2, 0)
MeshVertexPosition(1, 2, 0)
MeshVertexTextureCoordinate(0.3, 0)
MeshVertexPosition(0, 2, 20)
MeshVertexTextureCoordinate(0.2, 2)
MeshVertexPosition(1, 2, 20)
MeshVertexTextureCoordinate(0.3, 2)
MeshFace(11, 10, 8)
MeshFace(8, 9, 11)

MeshVertexPosition(1, 2, 0)
MeshVertexTextureCoordinate(0.4, 0)
MeshVertexPosition(1, 0, 0)
MeshVertexTextureCoordinate(0.6, 0)
MeshVertexPosition(1, 2, 20)
MeshVertexTextureCoordinate(0.4, 2)
MeshVertexPosition(1, 0, 20)
MeshVertexTextureCoordinate(0.6, 2)
MeshFace(15, 13, 12)
MeshFace(12, 14, 15)

FinishMesh(#True)
NormalizeMesh(22)

CreateEntity(22, MeshID(22), MaterialID(20), 5230, 50, 5169)
PureBasic 5.11 | WinXP | 2GB RAM | GForce GT240
User avatar
Olliv
Enthusiast
Enthusiast
Posts: 542
Joined: Tue Sep 22, 2009 10:41 pm

Re: MeshVertexPosition - What am I doing wrong?

Post by Olliv »

Within Meshface() arguments.
Interchange 2 of the 3 arguments in the matching MeshFace functions.
User avatar
Olliv
Enthusiast
Enthusiast
Posts: 542
Joined: Tue Sep 22, 2009 10:41 pm

Re: MeshVertexPosition - What am I doing wrong?

Post by Olliv »

Please explain me
An aircraft goes forward because its propeller turns one way.
If the propeller turns opposite way, the same aircraft goes backward!

On spatial rendering, the three vertices of a face (triangular) seem to turn around a fictive center, from the first vertex, through the second one, to the third one.

According to this rotation way, the face will be visible either before or behind, propeller effect akin.

Nota: interchange (or "exchange" I do not know the right word) 2 vertices in the "MeshFace" function has as result to invert the turning way, and so swaps the visible side!
User avatar
Lexicon
User
User
Posts: 98
Joined: Mon Jul 22, 2013 6:16 am
Contact:

Re: MeshVertexPosition - What am I doing wrong?

Post by Lexicon »

Olliv wrote:
Please explain me
Nota: interchange (or "exchange" I do not know the right word) 2 vertices in the "MeshFace" function has as result to invert the turning way, and so swaps the visible side!
Thanks. I did it. Now I have some black artefacts on the opposite side of box. :(
I will try again bit later.
PureBasic 5.11 | WinXP | 2GB RAM | GForce GT240
User avatar
Olliv
Enthusiast
Enthusiast
Posts: 542
Joined: Tue Sep 22, 2009 10:41 pm

Re: MeshVertexPosition - What am I doing wrong?

Post by Olliv »

Do not worry.

In the current life, we could see lots of artefacts. What is necessary is keep stand up and keep a little place for the coffee.
User avatar
Olliv
Enthusiast
Enthusiast
Posts: 542
Joined: Tue Sep 22, 2009 10:41 pm

Re: MeshVertexPosition - What am I doing wrong?

Post by Olliv »

Do not worry... EXCEPTED if these artifacts are aligned and seem to be black right-angle triangles.
Do not they do?
User avatar
Lexicon
User
User
Posts: 98
Joined: Mon Jul 22, 2013 6:16 am
Contact:

Re: MeshVertexPosition - What am I doing wrong?

Post by Lexicon »

Olliv wrote:Do not worry... EXCEPTED if these artifacts are aligned and seem to be black right-angle triangles.
Do not they do?
Yes. I compiled my 1st cube correctly. Thanks. :D

Code: Select all


CreateMesh(30, #PB_Mesh_TriangleList, #PB_Mesh_Static) ; FileCustomMesh$

MeshVertexPosition(1.000000, -1.000000, -1.000000)
MeshVertexPosition(1.000000, -1.000000, 1.000000)
MeshVertexPosition(-1.000000, -1.000000, 1.000000)
MeshVertexPosition(-1.000000, -1.000000, -1.000000)
MeshVertexPosition(1.000000, 1.000000, -1.000000)
MeshVertexPosition(1.000000, 1.000000, 1.000001)
MeshVertexPosition(-1.000000, 1.000000, 1.000000)
MeshVertexPosition(-1.000000, 1.000000, -1.000000)

MeshFace(0,1,2)
MeshFace(2,3,0)

MeshFace(4,7,6)
MeshFace(6,5,4)

MeshFace(0,4,5)
MeshFace(5,1,0)

MeshFace(1,5,6)
MeshFace(6,2,1)

MeshFace(2,6,7)
MeshFace(7,3,2)

MeshFace(4,0,3)
MeshFace(3,7,4)

FinishMesh(#True)
NormalizeMesh(30)

CreateEntity(30, MeshID(30), MaterialID(21), 10180, 120, 6112)

PureBasic 5.11 | WinXP | 2GB RAM | GForce GT240
User avatar
Lexicon
User
User
Posts: 98
Joined: Mon Jul 22, 2013 6:16 am
Contact:

Re: MeshVertexPosition - What am I doing wrong?

Post by Lexicon »

Hi mates!
I did it! :D
My 3D Engine that programming via PB 5.11!
Full terrain have this resolution: 30x30km.
The tree "betula" (classical russian tree) have from 16 000 polygones to 56 000 polygons and 5-6 meters in height. On the left statistic window you can see xCam and zCam. This is meters on the map of terrain.

https://www.youtube.com/watch?v=IrsZfVgVbkc

Please look and comments. Oh, and as you see my engine supports 2 500 000 polygons without freeze. :wink:
PS. Please pay attention! Each trees's leaf is a separate object in the trees's structure. No sprites as branch and leafs! NumTri is the current number of polygons.

Thanks for your criticism.
All this is PB 5.11! :D
PureBasic 5.11 | WinXP | 2GB RAM | GForce GT240
Fred
Administrator
Administrator
Posts: 18384
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: MeshVertexPosition - What am I doing wrong?

Post by Fred »

Looks good !!
User avatar
Lexicon
User
User
Posts: 98
Joined: Mon Jul 22, 2013 6:16 am
Contact:

Re: MeshVertexPosition - What am I doing wrong?

Post by Lexicon »

Fred wrote:Looks good !!
Thanks Fred.
PureBasic 5.11 | WinXP | 2GB RAM | GForce GT240
User avatar
Samuel
Enthusiast
Enthusiast
Posts: 756
Joined: Sun Jul 29, 2012 10:33 pm
Location: United States

Re: MeshVertexPosition - What am I doing wrong?

Post by Samuel »

Lexicon wrote: Please look and comments. Oh, and as you see my engine supports 2 500 000 polygons without freeze. :wink:
PS. Please pay attention! Each trees's leaf is a separate object in the trees's structure. No sprites as branch and leafs! NumTri is the current number of polygons.
Looks good, but if you don't mind me asking what are your computer specs? Just curious if it runs well on lower and higher end computers.
User avatar
Lexicon
User
User
Posts: 98
Joined: Mon Jul 22, 2013 6:16 am
Contact:

Re: MeshVertexPosition - What am I doing wrong?

Post by Lexicon »

Samuel wrote:Looks good, but if you don't mind me asking what are your computer specs? Just curious if it runs well on lower and higher end computers.
Processor - i3, GeForce GT240 1Gb, RAM - 2Gb, WinXP SP3 32Bit. Not very high parameters. :wink:
PureBasic 5.11 | WinXP | 2GB RAM | GForce GT240
applePi
Addict
Addict
Posts: 1404
Joined: Sun Jun 25, 2006 7:28 pm

Re: MeshVertexPosition - What am I doing wrong?

Post by applePi »

nice tour and good performance, is your terrain and trees have physics properties?. if not i suggest to have a look at the nice game hoveracer by Kelebrindae http://www.purebasic.fr/english/viewtop ... hovercraft its latest version for pb 5.10 and it works okay for pb 5.11, it has large terrain, trees, explosions, the cars can collide with the trees. and much more. the source code with media files available there.
User avatar
Lexicon
User
User
Posts: 98
Joined: Mon Jul 22, 2013 6:16 am
Contact:

Re: MeshVertexPosition - What am I doing wrong?

Post by Lexicon »

applePi wrote:nice tour and good performance, is your terrain and trees have physics properties?. if not i suggest to have a look at the nice game hoveracer by Kelebrindae http://www.purebasic.fr/english/viewtop ... hovercraft its latest version for pb 5.10 and it works okay for pb 5.11, it has large terrain, trees, explosions, the cars can collide with the trees. and much more. the source code with media files available there.
Thanks applePi, very nice! :)
PureBasic 5.11 | WinXP | 2GB RAM | GForce GT240
User avatar
Lexicon
User
User
Posts: 98
Joined: Mon Jul 22, 2013 6:16 am
Contact:

Re: MeshVertexPosition - What am I doing wrong?

Post by Lexicon »

oops... :(

Ogre.log
18:14:19: Warning: shadow index buffer size to small. Auto increasing buffer size to380880

And stop program.
This warning was after set BuildMeshShadowVolume on the tree model. Why it happens?
PureBasic 5.11 | WinXP | 2GB RAM | GForce GT240
Post Reply