Get/SetMeshData and the color

Everything related to 3D programming
applePi
Addict
Addict
Posts: 1404
Joined: Sun Jun 25, 2006 7:28 pm

Get/SetMeshData and the color

Post by applePi »

is this a bug or i miss something ?
MeshVertexColor(RGB(255,255,0)) ; yellow color
gives yellow color correctly
but if we copied the mesh contents to an array with GetMeshData and we want to check if this vertex have yellow color we must do this
If MeshData(i)\Color = RGB(0,255,255)
and not what is supposed for the yellow color:
If MeshData(i)\Color = RGB(255,255,0)

bigpoint.material save it to the same folder of the code

Code: Select all

material Big_Point
{
   technique
   {
      pass
      {
         point_size 10
       }
   }
}
press space to move only the yellow colored vertex by checking If MeshData(i)\Color = RGB(0,255,255)

Code: Select all

Global Dim MeshData.PB_MeshVertex(0)

ExamineDesktops()
If OpenWindow(0, 0, 0, DesktopWidth(0), DesktopHeight(0), " press space to move only the yellow color vertex", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)

InitEngine3D()
InitSprite()
OpenWindowedScreen(WindowID(0), 0, 0, DesktopWidth(0), DesktopHeight(0)-10, 0, 0, 0)

InitKeyboard()
SetFrameRate(60)

Add3DArchive(".", #PB_3DArchive_FileSystem)
Parse3DScripts()

CreateCamera(0, 0, 0, 100, 100)
MoveCamera(0, 0, 5, 20)
CameraLookAt(0, 0, 2, 0)

RotateCamera(0, -15, 0, 0)
EndIf

CreateMesh(0, #PB_Mesh_PointList, #PB_Mesh_Dynamic )

GetScriptMaterial(0, "Big_Point")

MeshVertexPosition(-1,0,1)
MeshVertexColor(RGB(0,255,0)) ;green
MeshVertexPosition(-0.5,0,-0.5)
MeshVertexColor(RGB(255,255,0)); yellow
MeshVertexPosition(0.5,-2,0)
MeshVertexColor(RGB(255,0,0)) ; red
MeshVertexPosition(0,0.5,-1)
MeshVertexColor(RGB(0,0,255)) ;blue

FinishMesh(#True)
SetMeshMaterial(0, MaterialID(0))
DisableMaterialLighting(0, #True)
CreateEntity(0, MeshID(0), #PB_Material_None, 0,0,0)

Repeat
  ExamineKeyboard()
  
  Repeat
      Event = WindowEvent()
  Until Event = 0 Or Event = #PB_Event_CloseWindow
  
  If KeyboardReleased(#PB_Key_Space)
    GetMeshData(0,0, MeshData(), #PB_Mesh_Vertex | #PB_Mesh_Color, 0, MeshVertexCount(0)-1)
    For i=0 To 3
      If MeshData(i)\Color = RGB(0,255,255) 
        MeshData(i)\y + 0.3
      EndIf
      
    Next
    ;MeshData(1)\Color = RGB(0,255,255)
    SetMeshData(0,0, MeshData(), #PB_Mesh_Vertex | #PB_Mesh_Color, 0, MeshVertexCount(0)-1)
  EndIf

   RotateEntity(0, 0, 1, 0, #PB_Relative)
   
   RenderWorld()
   FlipBuffers()

     
  Until KeyboardPushed(#PB_Key_Escape) Or Event = #PB_Event_CloseWindow