Page 1 of 2

AttachNodeObject() Error

Posted: Sat Feb 16, 2013 12:14 am
by IdeasVacuum
AttachNodeObject(#MyNode, EntityID(#MyEnt))

I'm getting a compiler error: [ERROR] The specified #Entity is not initialised

Is this because FinishMesh() should be #True? Edit: Nope, see notes below!

Example:

Code: Select all

IncludeFile "C:\Program Files\PureBasic510\Examples\3D\Screen3DRequester.pb"

Enumeration
#MyMesh
#MyMatl
#MyEnt
#MyNode
#MyCamera
#MyLight
#MyTexture
EndEnumeration

#CameraSpeed = 2

NewList sgListPts.s()
sgDelim.s = Chr(44)
igFaceCnt.i = 0

Define iKeyX.i, iKeyY.i, iMouseX.i, iMouseY.i

Restore MeshPoints

For i = 1 To 36

      AddElement(sgListPts())
      Read.s sgListPts()

Next i

         If InitEngine3D()

                         InitSprite()
                       InitKeyboard()
                          InitMouse()

                       Add3DArchive("C:\PROJECTS_DrvC\Prof STL To Point Cloud\Scripts", #PB_3DArchive_FileSystem)
                       Add3DArchive("C:\Documents and Settings\ChrisW\Application Data\ProfessorCad\Prof STL To Point Cloud\Texture", #PB_3DArchive_FileSystem)
                     Parse3DScripts()

                If Screen3DRequester()

                            ;CreateTexture(#MyTexture, 16, 16)
                               LoadTexture(#MyTexture, "Blue.png")
                            CreateMaterial(#MyMatl, TextureID(#MyTexture))
                         ;GetScriptMaterial(#MyMatl, "ColorBlue/Blue")
                       MaterialCullingMode(#MyMatl, #PB_Material_NoCulling)
                                CreateMesh(#MyMesh, #PB_Mesh_TriangleList, #PB_Mesh_Static)

                       FirstElement(sgListPts())
                       i = 0

                       Repeat

                                MeshVertexPosition(ValD(StringField(sgListPts(),1,sgDelim)),ValD(StringField(sgListPts(),2,sgDelim)),ValD(StringField(sgListPts(),3,sgDelim)))
                                       NextElement(sgListPts())

                                MeshVertexPosition(ValD(StringField(sgListPts(),1,sgDelim)),ValD(StringField(sgListPts(),2,sgDelim)),ValD(StringField(sgListPts(),3,sgDelim)))
                                       NextElement(sgListPts())

                                MeshVertexPosition(ValD(StringField(sgListPts(),1,sgDelim)),ValD(StringField(sgListPts(),2,sgDelim)),ValD(StringField(sgListPts(),3,sgDelim)))
                                       NextElement(sgListPts())

                                          MeshFace(i, i + 1, i + 2)

                                igFaceCnt = igFaceCnt + 1
                                        i = i + 3

                       Until i > 34

                            FinishMesh(#True)

                       SetMeshMaterial(#MyMesh, MaterialID(#MyMatl))

                          CreateEntity(#MyEnt, MeshID(#MyMesh), MaterialID(#MyMatl), 0, 0, 0)

                            CreateNode(#MyNode)

                      AttachNodeObject(#MyNode, EntityID(#MyEnt))

                      ;Camera
                          CreateCamera(#MyCamera, 0, 0, 100, 100)
                            MoveCamera(#MyCamera,0,0,500, #PB_Absolute)
                          CameraLookAt(#MyCamera, 0, 50, 0)
                    CameraFixedYawAxis(#MyCamera, #True, 0, 1, 0)
                       CameraBackColor(#MyCamera, RGB(35, 35, 35))

                      ;Light
                           CreateLight(#MyLight, RGB(255, 255, 255), 20, 150, 120)
                          AmbientColor(RGB(90, 90, 90))

                      Repeat

                               Screen3DEvents()

                               If ExamineKeyboard()

                                        If KeyboardPushed(#PB_Key_Left)

                                               iKeyX = -#CameraSpeed
 
                                        ElseIf KeyboardPushed(#PB_Key_Right)

                                               iKeyX = #CameraSpeed 
                                        Else
                                               iKeyX = 0
                                        EndIf
                                        
                                        If KeyboardPushed(#PB_Key_Up)

                                               iKeyY = -#CameraSpeed
 
                                        ElseIf KeyboardPushed(#PB_Key_Down) 

                                               iKeyY = #CameraSpeed 
                                        Else
                                               iKeyY = 0
                                        EndIf
                               EndIf

                               If ExamineMouse()
                               
                                        iMouseX = -(MouseDeltaX()/10)
                                        iMouseY = -(MouseDeltaY()/10)
                               EndIf

                                ;MoveCamera(#MyCamera, iKeyX, 0, iKeyY)
                               RotateCamera(#MyCamera, 0, 0.1, 0, #PB_Relative)

                                RenderWorld()
                                FlipBuffers()

                      Until KeyboardPushed(#PB_Key_Escape)

                EndIf
         EndIf
End

DataSection
MeshPoints:
;01
Data$ "50.0000,50.0000,-50.0000"
Data$ "-50.0000,-50.0000,-50.0000"
Data$ "-50.0000,50.0000,-50.0000"
;02
Data$ "50.0000,50.0000,-50.0000"
Data$ "50.0000,-50.0000,-50.0000"
Data$ "-50.0000,-50.0000,-50.0000"
;03
Data$ "50.0000,50.0000,50.0000"
Data$ "-50.0000,50.0000,50.0000"
Data$ "-50.0000,-50.0000,50.0000"
;04
Data$ "50.0000,50.0000,50.0000"
Data$ "-50.0000,-50.0000,50.0000"
Data$ "50.0000,-50.0000,50.0000"
;05
Data$ "50.0000,-50.0000,50.0000"
Data$ "-50.0000,-50.0000,50.0000"
Data$ "-50.0000,-50.0000,-50.0000"
;06
Data$ "50.0000,-50.0000,50.0000"
Data$ "-50.0000,-50.0000,-50.0000"
Data$ "50.0000,-50.0000,-50.0000"
;07
Data$ "50.0000,50.0000,50.0000"
Data$ "50.0000,-50.0000,50.0000"
Data$ "50.0000,-50.0000,-50.0000"
;08
Data$ "50.0000,50.0000,50.0000"
Data$ "50.0000,-50.0000,-50.0000"
Data$ "50.0000,50.0000,-50.0000"
;09
Data$ "-50.0000,50.0000,50.0000"
Data$ "50.0000,50.0000,50.0000"
Data$ "50.0000,50.0000,-50.0000"
;10
Data$ "-50.0000,50.0000,50.0000"
Data$ "50.0000,50.0000,-50.0000"
Data$ "-50.0000,50.0000,-50.0000"
;11
Data$ "-50.0000,-50.0000,50.0000"
Data$ "-50.0000,50.0000,50.0000"
Data$ "-50.0000,50.0000,-50.0000"
;12
Data$ "-50.0000,-50.0000,50.0000"
Data$ "-50.0000,50.0000,-50.0000"
Data$ "-50.0000,-50.0000,-50.0000"
EndDataSection
EDIT: With invaluable help from Thade, I can see I have been flumuxed by the Help description for MeshFace, which is shown as: MeshFace(Vertex1, Vertex2, Vertex3). In fact, they are not Vertex Values (xyz) but the Index numbers identifying pre-defined Vertices. So, modified code above does run without a crash. Can't actually see entity though......

Re: AttachNodeObject() Error

Posted: Sat Feb 16, 2013 9:09 am
by Comtois
you are using #PB_Mesh_TriangleList, so you must define three vertices to create a triangle.

If I take the first 3 vertices of your list, I see that they are all in the same position, so you will not see a triangle.

Code: Select all

   Data $ "50.0000, -50.0000, -50.0000"
   Data $ "50.0000, -50.0000, -50.0000"
   Data $ "50.0000, -50.0000, -50.0000"

Re: AttachNodeObject() Error

Posted: Sat Feb 16, 2013 12:36 pm
by applePi
Hi IdeasVacuum
here is my version , Ogre are too huge, i'm always a beginner level 0. so this is a tutorial for myself, i'm still fuzzy about lighting, materials, shadow, normalization ,physics, etc. if the PB Ogre syntax begins to be stable and fixed like rocks then i'm sure someone will provide a real tutorial which can be usable for a long long long time.
this line of data "Data.f 50,0,0 , 0,0" which are read by
Read.f x : Read.f y : Read.f z
Read.f u: Read.f v
MeshVertexPosition(x*2 , y*2, z*2 )
MeshVertexTextureCoordinate(u, v)

this is for the first vertex multiplied by 2 to make the triangle big, the u,v coordinates (imagine it x,y) here (0,0) is the point in the picture which we want it to project over the first vertex.
remember all the picture coordinates (any picture) are from (0,0),(1,0),(1,1),(0,1)
after completely reading the vertices, it has numbers from 0 to ... , now we can weave the faces from those vertices such as 0,1,2 ie connect the 3 points to form the triangle. this is the role of
Read.w t1 : Read.w t2 : Read.w t3
MeshFace(t1, t2, t3)

the weaving info i put in the Triangles data section
and don't forget the camera, here i put it
MoveCamera(0,0,-60,300,#PB_Absolute) ie 300 units away from the Entity and looking to it 60 units from underground. and we look at point 0,0,0 :CameraLookAt(0, 0,0, 0)
save the code to Examples\3D folder to use the picture in Data\Textures
if you want to use node idea uncomment lines 51, 52, 59, and comment 50.
you should get this rotating figure:
Image

Code: Select all

Enumeration
#MyMesh
#MyMatl
#MyEnt
#MyNode
#Win
EndEnumeration
IncludeFile "Screen3DRequester.pb"
InitEngine3D()
InitSprite()
InitKeyboard()
Add3DArchive("Data/Textures", #PB_3DArchive_FileSystem)
Add3DArchive("Data\Scripts", #PB_3DArchive_FileSystem)
Parse3DScripts()
OpenWindow(#Win,0,0,640,480,"mesh construction from 6 points to build 2 triangles and then texturing it from a picture ...",#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,-60,300,#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)

;GetScriptMaterial(#MyMatl, "Color/Blue")
CreateMaterial(#MyMatl, LoadTexture(0, "MRAMOR6X6.jpg"))
MaterialCullingMode(#MyMatl, #PB_Material_NoCulling)

CreateMesh(#MyMesh,#PB_Mesh_TriangleList, #PB_Mesh_Static)
Restore MeshPoints
For i=0 To 5
    
    Read.f x : Read.f y : Read.f z
    Read.f u: Read.f v
    MeshVertexPosition(x*2 , y*2, z*2 )
    MeshVertexTextureCoordinate(u, v)
    MeshVertexNormal(x, y, z)
    
Next i
NormalizeMesh(#MyMesh)
;reading how to build faces
Restore Triangles
  For i=0 To 1
    Read.w t1 : Read.w t2 : Read.w t3
    MeshFace(t1, t2, t3)
  Next i
  FinishMesh(#True)

SetMeshMaterial(#MyMesh, MaterialID(#MyMatl))

CreateEntity(#MyEnt, MeshID(#MyMesh), MaterialID(#MyMatl), 0, 0, 0)
;CreateNode(#MyNode , 0, 0, 0)
;AttachNodeObject(#MyNode, EntityID(#MyEnt))

Repeat
  Event = WindowEvent()
  ExamineKeyboard()
  yyy+1
  RotateEntity(#MyEnt,0,yyy,0)
  ;RotateNode(#MyNode, rot, 0, 0 )
  rot+1  :  If rot>360 :rot= 1 :EndIf
  RenderWorld()
  FlipBuffers()
Until KeyboardPushed(#PB_Key_Escape) Or Event = #PB_Event_CloseWindow

DataSection
MeshPoints:
Data.f 50,0,0  , 0,0
Data.f -50,0,0 , 1,0 
Data.f 0,60,0  , 1,1
Data.f 0,60,0  ,0,1
Data.f 50,0,-70 ,0,0
Data.f 50,0,0   ,1,0

Triangles:
  Data.w 0,1,2
  Data.w 3,4,5
  
EndDataSection

Re: AttachNodeObject() Error

Posted: Sat Feb 16, 2013 12:54 pm
by Thade
Comtois wrote:you are using #PB_Mesh_TriangleList, so you must define three vertices to create a triangle.

If I take the first 3 vertices of your list, I see that they are all in the same position, so you will not see a triangle.

Code: Select all

   Data $ "50.0000, -50.0000, -50.0000"
   Data $ "50.0000, -50.0000, -50.0000"
   Data $ "50.0000, -50.0000, -50.0000"

I thought the same at first ... but its not true (normaly) ... it should depend on the triangle list. Each corner of a cube is connected to 6 triangles. So there is 6 times the same vertex position in a vertex list ...

Code: Select all

Mesh Box01 {
   24;
   -0.335873;0.333333;-0.334933;,
   -0.335873;-0.333333;-0.334933;,
   0.330793;0.333333;-0.334933;,
   0.330793;-0.333333;-0.334933;,
   0.330793;0.333333;-0.334933;,
   0.330793;-0.333333;-0.334933;,
   0.330793;0.333333;0.331733;,
   0.330793;-0.333333;0.331733;,
   0.330793;0.333333;0.331733;,
   0.330793;-0.333333;0.331733;,
   -0.335873;0.333333;0.331733;,
   -0.335873;-0.333333;0.331733;,
   -0.335873;0.333333;0.331733;,
   -0.335873;-0.333333;0.331733;,
   -0.335873;0.333333;-0.334933;,
   -0.335873;-0.333333;-0.334933;,
   -0.335873;0.333333;-0.334933;,
   0.330793;0.333333;-0.334933;,
   -0.335873;-0.333333;-0.334933;,
   0.330793;-0.333333;-0.334933;,
   0.330793;0.333333;0.331733;,
   0.330793;-0.333333;0.331733;,
   -0.335873;0.333333;0.331733;,
   -0.335873;-0.333333;0.331733;;
   12;
   3;0,2,1;,
   3;1,2,3;,
   3;4,20,5;,
   3;5,20,21;,
   3;8,10,9;,
   3;9,10,11;,
   3;22,14,23;,
   3;23,14,15;,
   3;12,6,16;,
   3;16,6,17;,
   3;18,19,13;,
   3;13,19,7;;
Although you may be right as well ... PB makes everything different from other 3D engines ... especially with Mesh there is a lot of thinking to be done to make it usable for more than simple entities.
:wink:

RGR

PS.: The Game in my Sig is done with Meshcreation and Meshmanipulation on the fly ... no track is loaded as mesh ... to do this with PB would be very hard work at present ...

.

Re: AttachNodeObject() Error

Posted: Sun Feb 17, 2013 12:37 am
by IdeasVacuum
Ah, indeed. The snag there is not that the values do not (eventually) describe a cube, it's that they are in an order that I do not have control of, coming from an external app. Going to need to find a work-around for that, which I think I actually did acheive in an earlier project (abandoned because of the total faces limit at the time).

A cube where 5 triangles share the same vertex:
Image

Re: AttachNodeObject() Error

Posted: Sun Feb 17, 2013 1:24 am
by IdeasVacuum
Ogre are too huge, i'm always a beginner level 0. so this is a tutorial for myself, i'm still fuzzy about lighting, materials, shadow, normalization ,physics, etc. if the PB Ogre syntax begins to be stable and fixed like rocks then i'm sure someone will provide a real tutorial which can be usable for a long long long time.
Hi ApplePi

I agree - there should be some working examples in the Help - and those should not be using 'magic numbers' everywhere as many of the demos do, nor include more functionality than the subject of the function (which just makes things more difficult to follow). I think it's exciting that Comtois is working on the 3D stuff.

The Ogre Manual is comprehensive but lacking examples - material scripts are useful, but there are no guidlines on how to define a colour or colour of a material (e.g. a metal) - I have done this for WaveFront files and the Ogre stuff looks similar, but I had expected to see a huge library of scripts in a download library on the Ogre site, yet there seems to be nothing.

Re: AttachNodeObject() Error

Posted: Sun Feb 17, 2013 2:53 am
by IdeasVacuum
I have re-arranged the Data$ so that it makes sense to PB, my test code above is changed accordingly. That's fine, we can now see the cube.

Issues: The cube is sitting on Global X0,Y0,Z0. I want the camera to rotate around the Global Y axis, i.e. rotate around the cube. I have tried to use CameraFixedYawAxis to do this, but the camera is rotating about it's own Y axis.

Also, I applied a materials script to the mesh/entity - it should be some sort of blue colour but it looks as though the material does not get applied?

Re: AttachNodeObject() Error

Posted: Sun Feb 17, 2013 5:02 am
by Samuel
Hello, IdeasVacuum

First off for your camera issue I don't think I'll be a great help. Because I've always used matrix calculations and CameraLocate for revolving around
objects. So I'm not really familiar with any other Camera commands.
For your material script problem though I might be able to help. The most common problem I've faced is simply a misspelled command or call.
Give this script and code a try and you should see a blue sphere.

Just save this script as ColorBlue.MATERIAL.

Code: Select all

material ColorBlue/Blue
{
    technique
    {
        pass
        {
            ambient 0.1 0.1 0.1
            diffuse 0.1 0.1 0.9
            specular 0.7 0.7 0.7 64
            shading phong
        }
    }
}
Then try this code. Don't forget to set the archive for the script files.

Code: Select all

;*************PRESS ESC to Exit***************
#CameraSpeed = 3
Define.f KeyX, KeyY, MouseX, MouseY

If InitEngine3D()
  ExamineDesktops()
  ;************************ADD PATH TO SCRIPTS************************
  Add3DArchive("/Scripts", #PB_3DArchive_FileSystem)
  ;Add3DArchive("C:/Users/Samuel/Documents/PurebasicScripts", #PB_3DArchive_FileSystem)
  Parse3DScripts()
  
  InitSprite()
  InitKeyboard()
  InitMouse()
  
DeskWid=DesktopWidth(0)
DeskHei=DesktopHeight(0)

  OpenWindow(0, 0, 0, DeskWid, DeskHei, "Script Test", #PB_Window_MinimizeGadget | #PB_Window_ScreenCentered)
  OpenWindowedScreen(WindowID(0), 0, 0, DeskWid, DeskHei, 0, 0, 0)
    
    Blue = GetScriptMaterial(#PB_Any, "ColorBlue/Blue")
    CreateSphere(0, 40, 50, 50)
    CreateEntity(0,MeshID(0), MaterialID(Blue)  ,  0,   0,  0)

    CreateCamera(0, 0, 0, 100, 100)
    CameraBackColor(0, RGB(0,0,0))
    MoveCamera(0,0, 100, 300)
    CameraLookAt(0, 0, 0, 0)
    
    CreateLight(0, $FFFFFF, 1560, 900, 500)
    ;LightColor(0,$FFFFFF,#PB_Light_SpecularColor)
    SetLightColor(0, #PB_Light_SpecularColor, $FFFFFF)
    WorldShadows(#PB_Shadow_Modulative, 6000, RGB(100,100,100))
    
    Repeat
     Event=WaitWindowEvent()
      If ExamineMouse()
        MouseX = -MouseDeltaX() * #CameraSpeed * 0.05
        MouseY = -MouseDeltaY() * #CameraSpeed * 0.05
      EndIf
      
      ExamineKeyboard()
         If KeyboardPushed(#PB_Key_Left)
          KeyX = -#CameraSpeed
        ElseIf KeyboardPushed(#PB_Key_Right)
          KeyX = #CameraSpeed
        Else
          KeyX = 0
        EndIf
        
        If KeyboardPushed(#PB_Key_Up)
          KeyY = -#CameraSpeed
        ElseIf KeyboardPushed(#PB_Key_Down)
          KeyY = #CameraSpeed
        Else
          KeyY = 0
        EndIf    
      
      RotateCamera(0, MouseY, MouseX, 0, #PB_Relative)
      MoveCamera  (0, KeyX, 0, KeyY)
      RenderWorld()
      FlipBuffers()
    Until KeyboardPushed(#PB_Key_Escape)

Else
  MessageRequester("Error", "The 3D Engine can't be initialized",0)
EndIf

End
I hope this helps you with the material script issue.

Re: AttachNodeObject() Error

Posted: Sun Feb 17, 2013 8:06 am
by applePi
i thought first that using something like:
MoveCamera(#MyCamera, 0, 0, -0.05, #PB_Local)
RotateCamera(#MyCamera, 0, -1, 0, #PB_Relative)

will do the job, as it is in my 2 examples here http://www.purebasic.fr/english/viewtop ... 36&t=52091 which are using :
MoveEntity(3, 0, 0, -0.05, #PB_Local)
RotateEntity(3, 0, -1, 0, #PB_Relative)

but no, the best is to use nodes.
position node at 0,0,0 the attach a camera to it
node = CreateNode(#PB_Any, 0,0,0)
AttachNodeObject(node, CameraID(#MyCamera))


then rotate the parent node ,so the child #MyCamera will rotate accordingly:
RotateNode(node, 0, -0.4, 0, #PB_Relative)
you will think that the cube are rotating and not you (#MyCamera) .
i am trying to visualize how the astronauts feeling regarding the directions. and if the rotation in this code are correct or not.
another solution from the StaticGeometry.pb example:
nx.f = 500 * Cos(ElapsedMilliseconds() / 2500)
nz.f = 500 * Sin(ElapsedMilliseconds() / 2500)
MoveCamera(#MyCamera, nx, 100, nz, #PB_Absolute)

save the code to Examples\3D

Code: Select all

IncludeFile "Screen3DRequester.pb"

Enumeration
#MyMesh
#MyMatl
#MyEnt
#MyNode
#MyCamera
#MyLight
#MAT_plane
#TEX_plane
#plane
EndEnumeration

#CameraSpeed = 2

NewList sgListPts.s()
sgDelim.s = Chr(44)
igFaceCnt.i = 0

Define iKeyX.i, iKeyY.i, iMouseX.i, iMouseY.i

Restore MeshPoints

For i = 1 To 36

      AddElement(sgListPts())
      Read.s sgListPts()

Next i

         If InitEngine3D()

                         InitSprite()
                       InitKeyboard()
                          InitMouse()

                          Add3DArchive("Data\Scripts", #PB_3DArchive_FileSystem)
                          Add3DArchive("Data\Textures", #PB_3DArchive_FileSystem)
                          Add3DArchive("Data/Packs/skybox.zip", #PB_3DArchive_Zip)
                          Parse3DScripts()

                If Screen3DRequester()

                         GetScriptMaterial(#MyMatl, "Color/Blue")
                       MaterialCullingMode(#MyMatl, #PB_Material_NoCulling)
                                CreateMesh(#MyMesh, #PB_Mesh_TriangleList, #PB_Mesh_Static)

                       FirstElement(sgListPts())
                       i = 0
                       CreateMaterial(#MAT_plane, LoadTexture(#TEX_plane, "clouds.jpg"))
                        CreatePlane(#plane, 500, 500, 1, 1, 1, 1)
                        CreateEntity (#plane, MeshID(#plane), MaterialID(#MAT_plane))
                        SkyBox("stevecube.jpg")
                       Repeat

                                MeshVertexPosition(ValD(StringField(sgListPts(),1,sgDelim)),ValD(StringField(sgListPts(),2,sgDelim)),ValD(StringField(sgListPts(),3,sgDelim)))
                                       NextElement(sgListPts())

                                MeshVertexPosition(ValD(StringField(sgListPts(),1,sgDelim)),ValD(StringField(sgListPts(),2,sgDelim)),ValD(StringField(sgListPts(),3,sgDelim)))
                                       NextElement(sgListPts())

                                MeshVertexPosition(ValD(StringField(sgListPts(),1,sgDelim)),ValD(StringField(sgListPts(),2,sgDelim)),ValD(StringField(sgListPts(),3,sgDelim)))
                                       NextElement(sgListPts())

                                          MeshFace(i, i + 1, i + 2)

                                igFaceCnt = igFaceCnt + 1
                                        i = i + 3

                       Until i > 34

                            FinishMesh(#True)

                       SetMeshMaterial(#MyMesh, MaterialID(#MyMatl))

                          CreateEntity(#MyEnt, MeshID(#MyMesh), MaterialID(#MyMatl), 0, 0, 0)

                      ;Camera
                          CreateCamera(#MyCamera, 0, 0, 100, 100)
                            MoveCamera(#MyCamera,0,200,500, #PB_Absolute)
                          CameraLookAt(#MyCamera, 0, 0, 0)
                        CameraFixedYawAxis(#MyCamera, #True, 0, 1, 0)
                       CameraBackColor(#MyCamera, RGB(35, 35, 35))
                       ;node
                       node = CreateNode(#PB_Any, 0,0,0)
                       AttachNodeObject(node, CameraID(#MyCamera)) 
                      
                       
                      ;Light
                           CreateLight(#MyLight, RGB(255, 255, 255), 20, 150, 120)
                          AmbientColor(RGB(90, 90, 90))

                      Repeat

                               Screen3DEvents()

                               If ExamineKeyboard()

                                        If KeyboardPushed(#PB_Key_Left)

                                               iKeyX = -#CameraSpeed
 
                                        ElseIf KeyboardPushed(#PB_Key_Right)

                                               iKeyX = #CameraSpeed 
                                        Else
                                               iKeyX = 0
                                        EndIf
                                        
                                        If KeyboardPushed(#PB_Key_Up)

                                               iKeyY = -#CameraSpeed
 
                                        ElseIf KeyboardPushed(#PB_Key_Down) 

                                               iKeyY = #CameraSpeed 
                                        Else
                                               iKeyY = 0
                                        EndIf
                               EndIf

                               If ExamineMouse()
                               
                                        iMouseX = -(MouseDeltaX()/10)
                                        iMouseY = -(MouseDeltaY()/10)
                               EndIf

                                RotateNode(node, 0, -0.4, 0, #PB_Relative)
                                RenderWorld()
                                FlipBuffers()

                      Until KeyboardPushed(#PB_Key_Escape)

                EndIf
         EndIf
End

DataSection
MeshPoints:
;01
Data$ "50.0000,50.0000,-50.0000"
Data$ "-50.0000,-50.0000,-50.0000"
Data$ "-50.0000,50.0000,-50.0000"
;02
Data$ "50.0000,50.0000,-50.0000"
Data$ "50.0000,-50.0000,-50.0000"
Data$ "-50.0000,-50.0000,-50.0000"
;03
Data$ "50.0000,50.0000,50.0000"
Data$ "-50.0000,50.0000,50.0000"
Data$ "-50.0000,-50.0000,50.0000"
;04
Data$ "50.0000,50.0000,50.0000"
Data$ "-50.0000,-50.0000,50.0000"
Data$ "50.0000,-50.0000,50.0000"
;05
Data$ "50.0000,-50.0000,50.0000"
Data$ "-50.0000,-50.0000,50.0000"
Data$ "-50.0000,-50.0000,-50.0000"
;06
Data$ "50.0000,-50.0000,50.0000"
Data$ "-50.0000,-50.0000,-50.0000"
Data$ "50.0000,-50.0000,-50.0000"
;07
Data$ "50.0000,50.0000,50.0000"
Data$ "50.0000,-50.0000,50.0000"
Data$ "50.0000,-50.0000,-50.0000"
;08
Data$ "50.0000,50.0000,50.0000"
Data$ "50.0000,-50.0000,-50.0000"
Data$ "50.0000,50.0000,-50.0000"
;09
Data$ "-50.0000,50.0000,50.0000"
Data$ "50.0000,50.0000,50.0000"
Data$ "50.0000,50.0000,-50.0000"
;10
Data$ "-50.0000,50.0000,50.0000"
Data$ "50.0000,50.0000,-50.0000"
Data$ "-50.0000,50.0000,-50.0000"
;11
Data$ "-50.0000,-50.0000,50.0000"
Data$ "-50.0000,50.0000,50.0000"
Data$ "-50.0000,50.0000,-50.0000"
;12
Data$ "-50.0000,-50.0000,50.0000"
Data$ "-50.0000,50.0000,-50.0000"
Data$ "-50.0000,-50.0000,-50.0000"
EndDataSection

Re: AttachNodeObject() Error

Posted: Sun Feb 17, 2013 9:12 am
by Comtois
or you cans play with NodeAnimation, see NodeAnimation.pv example.

Re: AttachNodeObject() Error

Posted: Sun Feb 17, 2013 9:59 am
by applePi
thank you Comtois for the gorgeous example "NodeAnimation.pb" , i will try to grasp how it works, but i will remember someone told a person who complained that he can't understand windows API: don't try to understand it or to be smart with it, just use it, this is the way the pilot are driving his airplane.

Re: AttachNodeObject() Error

Posted: Sun Feb 17, 2013 2:37 pm
by IdeasVacuum
this is the way the pilot are driving his airplane
There are old Pilots
And there are bold Pilots
But there are no old bold Pilots
:mrgreen:

Re: AttachNodeObject() Error

Posted: Sun Feb 17, 2013 2:40 pm
by IdeasVacuum
Hi Samuel

Well, that has been a great help because the colour script works fine in your test code but has no effect in mine, so I think I was looking in the wrong place and need to pay attention to the lighting. Thanks very much. 8)

Re: AttachNodeObject() Error

Posted: Sun Feb 17, 2013 2:49 pm
by IdeasVacuum
Hi ApplePi

You have given me a lot to work with there, thank you!
i am trying to visualize how the astronauts feeling regarding the directions. and if the rotation in this code are correct or not.
I took a 'ride' in a centrifugal force machine that tests supersonic aircraft pilots to the limit. From this experience I can say nobody is worrying about their direction, they are just trying to keep their internal organs on the inside! :mrgreen:

Re: AttachNodeObject() Error

Posted: Sun Feb 17, 2013 3:11 pm
by applePi
IdeasVacuum , this is the first time i have used material scripts, i have benefited from Samuel too much i'm a 59 y.o man with faulty brain i have settled down finaly with purebasic from a basic interpreter, for a hobby usage only.
the Samuel code works for me , its picture:
Image
just save the script file ColorBlue.MATERIAL in the Data\Scripts folder
and change the Line 8 to:
Add3DArchive("Data/Scripts", #PB_3DArchive_FileSystem)
then save the code to Examples\3D
works with v5.10
PS: OH sorry IdeasVacuum, i understand you now, but i will not delete this post.