I do not work GetScriptMaterial

Just starting out? Need help? Post your questions and find answers here.
User avatar
Johny8
User
User
Posts: 10
Joined: Sun Jan 25, 2015 1:40 am
Location: Bogotá -Colombia-
Contact:

I do not work GetScriptMaterial

Post by Johny8 »

I'm learning process with PureBasic, but not that I'm doing wrong.

Any suggestions.
[19:23:27] The Program was killed.
[19:23:30] Waiting for executable to start...
[19:23:30] Executable type: Windows - x86 (32bit, Unicode)
[19:23:30] Executable started.
[19:23:31] [ERROR] Pawn.pb (Line: 48)
[19:23:31] [ERROR] The specified #Material is not initialised.

Code: Select all

IncludePath  "Includes I\"
XIncludeFile "Variables.pb"
XIncludeFile "Procedimientos.pb"

Define eventosWindow.i, initSistemaMotor3D.i 

If InitSistemas()
  


  
  idVetana.i  = OpenWindow(#PB_Any, 0, 0, 800,600, tituloAPP.s, #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  SetWindowColor(idVetana.i, RGB(0,0,0))
  idLienzo.i  = OpenWindowedScreen(WindowID(idVetana.i),0,0,800,600)

  ; - Objetos Escena.
  Add3DArchive("Data\Sky.iso", #PB_3DArchive_Zip)
  Add3DArchive("Data\Texturas.zip",#PB_3DArchive_Zip)
  Add3DArchive("Data\M\", #PB_3DArchive_FileSystem)
  
 
  Camara = CreateCamera(#PB_Any,0,0,100,100)
  CameraLookAt(Camara,0,0,0)
  RotateCamera(Camara,0,180,0,#PB_Absolute)
  MoveCamera(Camara,0,1,0, #PB_Absolute)
  
  
  ;texturaCaja = LoadTexture(#PB_Any,"Caja.jpg")
  ;materialCaja.i =  CreateMaterial(#PB_Any,TextureID(texturaCaja))
  
  Parse3DScripts()
  materialcaja = GetScriptMaterial(#PB_Any,"Color\Red")
  
  Cubo = CreateCube(#PB_Any,1)
  mallaCubo = CreateEntity(#PB_Any,MeshID(Cubo),MaterialID(materialCaja),0,0,5)
  RotateEntity(mallaCubo,0,45,0, #PB_Absolute)
  
  
  
  
  
  
  Luz.i = CreateLight(#PB_Any,RGB(255,255,255),0,0,0,#PB_Light_Directional )
  RotateLight( Luz,-90,0,0,#PB_Absolute)
  
  SkyBox("sky2.jpg")
  ; - Bucle Principales.
  Repeat 
    
    eventosWindow = WindowEvent()
   

    
    RenderWorld()
    FlipBuffers()
    
   
    
    
    ExamineKeyboard()
  
    
  Until eventosWindow =   #PB_Event_CloseWindow Or KeyboardReleased(#PB_Key_Escape)
  
  
EndIf 
Iris3D -Games Studios- http://www.iris3dgames.com
User avatar
falsam
Enthusiast
Enthusiast
Posts: 632
Joined: Wed Sep 21, 2011 9:11 am
Location: France
Contact:

Re: I do not work GetScriptMaterial

Post by falsam »

Hi Johny8.
[19:23:31] [ERROR] The specified #Material is not initialised.
■ An example of script material contained in the installation folder of PureBasic.

Code: Select all

material Color/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
        }
    }
}

material Color/Red
{
    technique
    {
        pass
        {
            ambient 0.05 0.05 0.05
            diffuse 0.9 0.1 0.1
            specular 1 1 1 20         
            shading phong
        }             
    }
}

material Color/Yellow
{
    technique
    {
        pass
        {
            ambient 0.05 0.05 0.05
            diffuse 1.0 1.0 0.0
            specular 1 1 1 20         
            shading phong
        }             
    }
}

material Color/Green
{
    technique
    {
        pass
        {
            ambient 0.05 0.05 0.05
            diffuse 0.1 0.9 0.1
            specular 1 1 1 20         
            shading phong
        }             
    }
}
■ I will display a colorful cube with the Color/Blue.

Code: Select all

Enumeration
  #Mainform
EndEnumeration

InitEngine3D()
InitKeyboard()
InitSprite()
InitMouse()

ExamineDesktops()

OpenWindow(#Mainform,0, 0, 1024, 768, "Load Material", #PB_Window_SystemMenu)
OpenWindowedScreen(WindowID(#Mainform), 0, 0, 1024, 768, 0, 0, 0)

Add3DArchive(#PB_Compiler_Home + "Examples/3D/Data/Packs/skybox.zip", #PB_3DArchive_Zip)
Add3DArchive(#PB_Compiler_Home + "Examples/3D/Data/Scripts", #PB_3DArchive_FileSystem)

;Parses ALL the .materials OGRE scripts found in the paths set With Add3DArchive(). 
Parse3DScripts()

KeyboardMode(#PB_Keyboard_International)

;SkyBox
SkyBox("stevecube.jpg")

;Light & Shadow
AmbientColor(RGB(127, 127, 127))
CreateLight(#PB_Any,RGB(151, 251, 151), 50, 200, 50)
WorldShadows(#PB_Shadow_Additive)

;Camera 
Camera = CreateCamera(#PB_Any, 0, 0, 100, 100)
MoveCamera(Camera, 2, 5, 100, #PB_Absolute)  
CameraLookAt(Camera, 0,0,0)   

;Get a material defined in an OGRE script file.
;The name of the material is in the script files (Example : Color/Blue)
Material = GetScriptMaterial(#PB_Any,"Color/Blue")

Mesh = CreateCube(#PB_Any, 20)
Entity = CreateEntity(#PB_Any, MeshID(Mesh), MaterialID(Material))

Repeat ;Event 3D
  
  Repeat ;Event Window (Important)
    Event  = WindowEvent()
    Select Event
      Case #PB_Event_CloseWindow
        End
        
    EndSelect
  Until Event = 0
  
  If ExamineKeyboard()  
    If KeyboardPushed (#PB_Key_Escape)
      Break
    EndIf
  EndIf
  
  RotateEntity(Entity, 0.5, 0.5, 0.5, #PB_Relative)
  
  RenderWorld(80)
  FlipBuffers()  
  
ForEver
PS : Nice website :)

➽ Windows 11 64-bit - PB 6.21 x64 - AMD Ryzen 7 - NVIDIA GeForce GTX 1650 Ti

Sorry for my bad english and the Dunning–Kruger effect 🤪
User avatar
Johny8
User
User
Posts: 10
Joined: Sun Jan 25, 2015 1:40 am
Location: Bogotá -Colombia-
Contact:

Re: I do not work GetScriptMaterial

Post by Johny8 »

Thanks You :D
Now I have something to put on my website tomorrow speak sombre materials.

My website is just a hobby, I am learning what I learn PureBasic and put it on the site, it is a way of learning.

Another question, you know of any guide to get started in the Shaders? CG, GLS, HGLS


Image

Code: Select all

IncludePath "Includes I\"
XIncludeFile "Procedimientos.pb"
XIncludeFile "Variables.pb"



Enumeration Elementos
  #ID_VentanaPrincipal
  #ID_Cubo
  #ID_Caja
  #ID_Camara
  #ID_MaterialCaja
EndEnumeration

If InitSistemas()



OpenWindow(#ID_VentanaPrincipal,0, 0, 800, 600, "Load Material", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
OpenWindowedScreen(WindowID(#ID_VentanaPrincipal), 0, 0, 800,600, 0, 0, 0)

Add3DArchive("Data\Sky.iso", #PB_3DArchive_Zip)
Add3DArchive( "M", #PB_3DArchive_FileSystem)
Parse3DScripts()




SkyBox("Sky2.jpg")


CreateLight(#PB_Any,RGB(151, 251, 151), 50, 200, 50)


 
CreateCamera(#ID_Camara, 0, 0, 100, 100)

MoveCamera(#ID_Camara, 2, 5, 100, #PB_Absolute)  
;CameraLookAt(Camara, 0,0,0)   




CreateCube(#ID_Cubo, 20)
GetScriptMaterial(#ID_MaterialCaja,"Template/texture_map")
CreateEntity(#ID_Caja, MeshID(#ID_Cubo), MaterialID(#ID_MaterialCaja))



Repeat 
  
  eventosVentana = WindowEvent()  
  
  RotateEntity(#ID_Caja, 0.5, 0.5, 0.5, #PB_Relative)
  
  RenderWorld()
  FlipBuffers()  
  
Until eventosVentana = #PB_Event_CloseWindow 

EndIf 
material Template/texture_map
{
technique
{
pass
{
texture_unit
{
texture Caja.jpg
// scale 0.1 0.1
// this means that the texture will be tiled 10 times (1/10 = 0.1)
}
}
}
}
Iris3D -Games Studios- http://www.iris3dgames.com
User avatar
Samuel
Enthusiast
Enthusiast
Posts: 755
Joined: Sun Jul 29, 2012 10:33 pm
Location: United States

Re: I do not work GetScriptMaterial

Post by Samuel »

The Ogre wiki has a section on shaders that might interest you.
http://www.ogre3d.org/tikiwiki/shaders
User avatar
Johny8
User
User
Posts: 10
Joined: Sun Jan 25, 2015 1:40 am
Location: Bogotá -Colombia-
Contact:

Re: I do not work GetScriptMaterial

Post by Johny8 »

Samuel wrote:The Ogre wiki has a section on shaders that might interest you.
http://www.ogre3d.org/tikiwiki/shaders

Thanks You :)
Iris3D -Games Studios- http://www.iris3dgames.com
Post Reply