Page 1 of 2
#Entity is not initialized
Posted: Tue Jul 23, 2013 9:28 am
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!
Re: #Entity is not initialized
Posted: Tue Jul 23, 2013 9:44 am
by applePi
Hi Lexicon
you write FinishMesh(#False), to create entity the FinishMesh should be true. FinishMesh(#True)
Re: #Entity is not initialized
Posted: Tue Jul 23, 2013 10:10 am
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.

Re: #Entity is not initialized
Posted: Tue Jul 23, 2013 10:28 am
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
Re: #Entity is not initialized
Posted: Tue Jul 23, 2013 11:34 am
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.
Re: #Entity is not initialized
Posted: Tue Jul 23, 2013 11:37 am
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
Re: #Entity is not initialized
Posted: Tue Jul 23, 2013 12:52 pm
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!

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?
Re: #Entity is not initialized
Posted: Tue Jul 23, 2013 2:09 pm
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.
Re: #Entity is not initialized
Posted: Tue Jul 23, 2013 3:32 pm
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).
Please sheck program code your master eye. May be something wrong or absent.

Re: #Entity is not initialized
Posted: Tue Jul 23, 2013 3:40 pm
by Lexicon
Oh! I forgot!
When FinishMesh(#False) and AttachNodeObject(11, MeshID(11)) everything looks good.
Re: #Entity is not initialized
Posted: Tue Jul 23, 2013 3:50 pm
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)
Re: #Entity is not initialized
Posted: Tue Jul 23, 2013 3:55 pm
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!!
THANKS!
Re: #Entity is not initialized
Posted: Wed Jul 24, 2013 5:08 am
by Lexicon
Now under sky!
Please look at 720p and full screen
www.youtube.com/watch?v=9bCbB1GE2BE

Re: #Entity is not initialized
Posted: Wed Jul 24, 2013 7:20 am
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
Re: #Entity is not initialized
Posted: Wed Jul 24, 2013 12:01 pm
by Fred
Just wondering, why not using a skybox for the sky ?