#Entity is not initialized

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

#Entity is not initialized

Post by Lexicon »

Guys! I need help again for another problem. :)

Code: Select all

CreateMesh(11, #PB_Mesh_TriangleList, #PB_Mesh_Dynamic)

MeshVertexPosition(0, 0, 0)
MeshVertexTextureCoordinate(0, 1)
MeshVertexPosition(0, 5000, 0)
MeshVertexTextureCoordinate(0, 0)
MeshVertexPosition(5000, 5000, 0)
MeshVertexTextureCoordinate(1, 0)
MeshVertexPosition(5000, 0, 0)
MeshVertexTextureCoordinate(1, 1)

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

FinishMesh(#False)
NormalizeMesh(11)

CreateNode(11)
AttachNodeObject(11, MeshID(11))
ScaleNode(11, 1, 1, 1)

CreateMaterial(11, LoadTexture(11, "sky_up.dds"))
DisableMaterialLighting(11, #True)
MaterialShadingMode(11, #PB_Material_Solid)
MaterialCullingMode(11, #PB_Material_NoCulling)
SetMeshMaterial(11, MaterialID(11), 0)

Result = CreateEntity(11, MeshID(11), MaterialID(11))
I see this mesh with texture but Result = 0 and entity was not created.
Why? Please help!
PureBasic 5.11 | WinXP | 2GB RAM | GForce GT240
applePi
Addict
Addict
Posts: 1404
Joined: Sun Jun 25, 2006 7:28 pm

Re: #Entity is not initialized

Post by applePi »

Hi Lexicon
you write FinishMesh(#False), to create entity the FinishMesh should be true. FinishMesh(#True)
User avatar
Lexicon
User
User
Posts: 98
Joined: Mon Jul 22, 2013 6:16 am
Contact:

Re: #Entity is not initialized

Post by Lexicon »

applePi wrote:Hi Lexicon
you write FinishMesh(#False), to create entity the FinishMesh should be true. FinishMesh(#True)
Hi applePi and thanks!
But after

AttachNodeObject(11, MeshID(11))

string I have error message 'Invalid memory access... etc'. When I remove strings about nodes, Result > 0 but I can't see the mesh. :(
PureBasic 5.11 | WinXP | 2GB RAM | GForce GT240
applePi
Addict
Addict
Posts: 1404
Joined: Sun Jun 25, 2006 7:28 pm

Re: #Entity is not initialized

Post by applePi »

in the Docs of AttachNodeObject() there is no MeshId but EntityID()
here is an approximate of your example

Code: Select all

Enumeration
#MyMatl
#Win
EndEnumeration

InitEngine3D()
InitSprite()
InitKeyboard()
Add3DArchive(#PB_Compiler_Home + "Examples/3D/Data/Textures", #PB_3DArchive_FileSystem)
Add3DArchive(#PB_Compiler_Home + "Examples/Sources\Data", #PB_3DArchive_FileSystem)
Add3DArchive("/", #PB_3DArchive_FileSystem)

OpenWindow(#Win,0,0,640,480,"..",#PB_Window_SystemMenu | #PB_Window_ScreenCentered)
OpenWindowedScreen(WindowID(#Win),0,0,640,400,1,0,0)
CreateCamera(0, 0, 0, 100, 100)
MoveCamera(0,0,200,5000,#PB_Absolute)
CameraLookAt(0, 0,0, 0)
CameraBackColor(0,RGB(77,160,100))
CreateLight(1,RGB(255,255,255),0,0,100)
LightDirection(1, 0, 0, 0)

CreateMaterial(#MyMatl, LoadTexture(0, "MRAMOR6X6.jpg"))
MaterialCullingMode(#MyMatl, #PB_Material_NoCulling)
;MaterialShadingMode(#MyMatl, #PB_Material_Wireframe)
MaterialShadingMode(#MyMatl, #PB_Material_Solid )   
;CreateMesh(#MyMesh,#PB_Mesh_TriangleList, #PB_Mesh_Static)
CreateMesh(11, #PB_Mesh_TriangleList, #PB_Mesh_Dynamic)
MeshVertexPosition(0, 0, 0)
MeshVertexTextureCoordinate(0, 1)
MeshVertexPosition(0, 5000, 0)
MeshVertexTextureCoordinate(0, 0)
MeshVertexPosition(5000, 5000, 0)
MeshVertexTextureCoordinate(1, 0)
MeshVertexPosition(5000, 0, 0)
MeshVertexTextureCoordinate(1, 1)

MeshFace(0, 1, 2)
MeshFace(0, 3, 2)
NormalizeMesh(11)
;reading how to build faces

FinishMesh(#True)

CreateEntity(11, MeshID(11), MaterialID(#MyMatl), 0, 0, 0)
ScaleEntity(11, 0.4,0.4,0.4)
MoveEntity(11, 0, -1000,0)
CreateNode(11)
AttachNodeObject(11, EntityID(11))
ScaleNode(11, 1, 1, 1)
Repeat
  Event = WindowEvent()
  ExamineKeyboard()
  
  RenderWorld()
  FlipBuffers()
Until KeyboardPushed(#PB_Key_Escape) Or Event = #PB_Event_CloseWindow

User avatar
Comtois
Addict
Addict
Posts: 1432
Joined: Tue Aug 19, 2003 11:36 am
Location: Doubs - France

Re: #Entity is not initialized

Post by Comtois »

There are two types of mesh.

An instantiable type
, it may be used to create the entities based on the same geometry. FinishMesh(#True) creates this type of mesh.
You can only use this constant for this type
#PB_Mesh_TriangleList: the mesh Will Be Composed of a list of triangles (default).


A non-instantiable type, it can not be used to create entities.FinishMesh (# False) creates this kind of mesh.

You can use all constants for this type

#PB_Mesh_TriangleList: the mesh Will Be Composed of a list of triangles (default).
#PB_Mesh_TriangleStrip: the mesh Will Be Composed of a list of connected triangles (vertices are shared).
#PB_Mesh_TriangleFan: the mesh Will Be Composed of a list of triangles sharing the same central vertex points.
#PB_Mesh_PointList: the mesh Will Be Composed of a list of points.
#PB_Mesh_LineList: the mesh Will Be Composed of a list of lines.
#PB_Mesh_LineStrip: the mesh Will Be Composed of a list of connected lines (vertices are shared).

This type of mesh can be changed with the UpdateMesh() command. To be used it must be attached to a node.
Please correct my english
http://purebasic.developpez.com/
User avatar
Comtois
Addict
Addict
Posts: 1432
Joined: Tue Aug 19, 2003 11:36 am
Location: Doubs - France

Re: #Entity is not initialized

Post by Comtois »

applePi's example with non-instantiable mesh

Code: Select all

Enumeration
#MyMatl
#Win
EndEnumeration

InitEngine3D()
InitSprite()
InitKeyboard()
Add3DArchive(#PB_Compiler_Home + "Examples/3D/Data/Textures", #PB_3DArchive_FileSystem)
Add3DArchive(#PB_Compiler_Home + "Examples/Sources\Data", #PB_3DArchive_FileSystem)
Add3DArchive("/", #PB_3DArchive_FileSystem)

OpenWindow(#Win,0,0,640,480,"..",#PB_Window_SystemMenu | #PB_Window_ScreenCentered)
OpenWindowedScreen(WindowID(#Win),0,0,640,400,1,0,0)
CreateCamera(0, 0, 0, 100, 100)
MoveCamera(0,0,200,5000,#PB_Absolute)
CameraLookAt(0, 0,0, 0)
CameraBackColor(0,RGB(77,160,100))
CreateLight(1,RGB(255,255,255),0,0,100)
LightDirection(1, 0, 0, 0)

CreateMaterial(#MyMatl, LoadTexture(0, "MRAMOR6X6.jpg"))
MaterialCullingMode(#MyMatl, #PB_Material_NoCulling)
;MaterialShadingMode(#MyMatl, #PB_Material_Wireframe)
MaterialShadingMode(#MyMatl, #PB_Material_Solid )   
;CreateMesh(#MyMesh,#PB_Mesh_TriangleList, #PB_Mesh_Static)
CreateMesh(11, #PB_Mesh_TriangleList, #PB_Mesh_Static)
MeshVertexPosition(0, 0, 0)
MeshVertexTextureCoordinate(0, 1)
MeshVertexPosition(0, 5000, 0)
MeshVertexTextureCoordinate(0, 0)
MeshVertexPosition(5000, 5000, 0)
MeshVertexTextureCoordinate(1, 0)
MeshVertexPosition(5000, 0, 0)
MeshVertexTextureCoordinate(1, 1)

MeshFace(0, 1, 2)
MeshFace(0, 3, 2)
NormalizeMesh(11)
;reading how to build faces

FinishMesh(#False)
SetMeshMaterial(11, MaterialID(#MyMatl))
CreateNode(0)
AttachNodeObject(0, MeshID(11))
ScaleNode(0, 0.4, 0.4, 0.4)
MoveNode(0, 0, -1000,0)

Repeat
  Event = WindowEvent()
  ExamineKeyboard()
 
  RenderWorld()
  FlipBuffers()
Until KeyboardPushed(#PB_Key_Escape) Or Event = #PB_Event_CloseWindow
Please correct my english
http://purebasic.developpez.com/
User avatar
Lexicon
User
User
Posts: 98
Joined: Mon Jul 22, 2013 6:16 am
Contact:

Re: #Entity is not initialized

Post by Lexicon »

applePi wrote:in the Docs of AttachNodeObject() there is no MeshId but EntityID()
here is an approximate of your example
Yes! Thanks-Thanks! :D But bugs again...

Code: Select all

CreateMesh(11, #PB_Mesh_TriangleList, #PB_Mesh_Dynamic)

SkyH = 3000: SkyL = 5000

MeshVertexPosition(0, SkyH, 0)
MeshVertexTextureCoordinate(0, 0)
MeshVertexPosition(SkyL, SkyH, 0)
MeshVertexTextureCoordinate(1, 0)
MeshVertexPosition(0, SkyH, SkyL)
MeshVertexTextureCoordinate(0, 1)
MeshVertexPosition(SkyL, SkyH, SkyL)
MeshVertexTextureCoordinate(1, 1)

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

FinishMesh(#True)
NormalizeMesh(11)

CreateMaterial(11, LoadTexture(11, "sky_up.dds"))
DisableMaterialLighting(11, #True)
MaterialShadingMode(11, #PB_Material_Solid)
MaterialShininess(11, 0)
MaterialCullingMode(11, #PB_Material_NoCulling)
SetMeshMaterial(11, MaterialID(11), 0)

CreateEntity(11, MeshID(11), MaterialID(11))
RotateEntity(11, 0, 0, 0)
MoveEntity(11, 2500, SkyH, 2500)

CreateNode(11)
AttachNodeObject(11, EntityID(11))
ScaleNode(11, 1, 1, 1)
Now I see

bottom view: http://stalkerfangroup.ru/Stalker_2/sho ... -13-10.jpg
Top view: http://stalkerfangroup.ru/Stalker_2/sho ... -51-31.jpg

After RotateEntity(11, 180, 0, 0) no effect. Any ideas?
PureBasic 5.11 | WinXP | 2GB RAM | GForce GT240
applePi
Addict
Addict
Posts: 1404
Joined: Sun Jun 25, 2006 7:28 pm

Re: #Entity is not initialized

Post by applePi »

i can't replicate the problem, i have used clouds.jpg which are on my purebasic folder and rotating it in every directions its appearance are the same. try to convert the .dds to png just a random guess.
if there is a full working example showing the problem will be better for more users to test it on the fly and to suggest solutions.
User avatar
Lexicon
User
User
Posts: 98
Joined: Mon Jul 22, 2013 6:16 am
Contact:

Re: #Entity is not initialized

Post by Lexicon »

applePi wrote:i can't replicate the problem, i have used clouds.jpg which are on my purebasic folder and rotating it in every directions its appearance are the same. try to convert the .dds to png just a random guess.
if there is a full working example showing the problem will be better for more users to test it on the fly and to suggest solutions.
Thanks applePi anyway!

This is light or face (vertex) error I think. Look at the screen.

http://stalkerfangroup.ru/Stalker_2/sho ... -15-25.jpg

The dark triangle have shadow on the terrain (red arrow). Light triangle have no shadow (green arrow). :wink:
Please sheck program code your master eye. May be something wrong or absent. :|
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: #Entity is not initialized

Post by Lexicon »

Oh! I forgot!

When FinishMesh(#False) and AttachNodeObject(11, MeshID(11)) everything looks good.
PureBasic 5.11 | WinXP | 2GB RAM | GForce GT240
User avatar
Comtois
Addict
Addict
Posts: 1432
Joined: Tue Aug 19, 2003 11:36 am
Location: Doubs - France

Re: #Entity is not initialized

Post by Comtois »

when you create a mesh does not use # PB_Material_NoCulling, this way you can see if your faces are correct, Try this :

Code: Select all

MeshFace(0, 1, 3)
MeshFace(3, 2, 0)
Please correct my english
http://purebasic.developpez.com/
User avatar
Lexicon
User
User
Posts: 98
Joined: Mon Jul 22, 2013 6:16 am
Contact:

Re: #Entity is not initialized

Post by Lexicon »

Comtois wrote:when you create a mesh does not use # PB_Material_NoCulling, this way you can see if your faces are correct, Try this :

Code: Select all

MeshFace(0, 1, 3)
MeshFace(3, 2, 0)
Yes! This works RIGHT!! :D :D :D

THANKS!
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: #Entity is not initialized

Post by Lexicon »

Now under sky! :D

Please look at 720p and full screen

www.youtube.com/watch?v=9bCbB1GE2BE

:wink:
PureBasic 5.11 | WinXP | 2GB RAM | GForce GT240
applePi
Addict
Addict
Posts: 1404
Joined: Sun Jun 25, 2006 7:28 pm

Re: #Entity is not initialized

Post by applePi »

@Lexicon now i know why you are using very big dimensions. great realistic scene.
@Comtois thanks for the comments, i have not noticed it, the differentiation between instantiable type and non-instantiable type meshes, and that the non-instantiable to be used it must be attached to a node. that makes more roots to the subject so
if FinishMesh(#False) then we can AttachNodeObject(node, MeshID(..))
and if FinishMesh(#True) then we can't do AttachNodeObject(node, MeshID(..)) because it is now attached to entity so we should use AttachNodeObject(node, EntityID(..))
the instantiable type and non-instantiable terms can be added to the Docs/Mesh
thanks
Fred
Administrator
Administrator
Posts: 18384
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: #Entity is not initialized

Post by Fred »

Just wondering, why not using a skybox for the sky ?
Post Reply