material - how to use with PB 5.31Final x64

Everything related to 3D programming
marc_256
Addict
Addict
Posts: 859
Joined: Thu May 06, 2010 10:16 am
Location: Belgium
Contact:

material - how to use with PB 5.31Final x64

Post by marc_256 »

Hi,

I exported a mesh with BLENDER 2.66
and as always I integrated the mesh (ogre) data to my program.
But for the first time I exported also the material.

Code: Select all

// Material1 generated by blender2ogre 0.6.0

material Material1 
{
    receive_shadows on 

    technique
    {
        pass Material1
        {
            ambient 1.0 0.0 0.0 1.0
            diffuse 0.800000011920929 0.0 0.0 1.0
            specular 0.5 0.5 0.5 1.0 2.5
            emissive 0.0 0.0 0.0 1.0

            alpha_to_coverage off
            colour_write on
            cull_hardware clockwise
            depth_check on
            depth_func less_equal
            depth_write on
            illumination_stage 
            light_clip_planes off
            light_scissor off
            lighting on
            normalise_normals off
            polygon_mode solid
            scene_blend one zero
            scene_blend_op add
            shading gouraud
            transparent_sorting on

        }
    }
}
How can this be integrated in PB ?
Is this possible to use this directly ?

thanks,
marc
- every professional was once an amateur - greetings from Pajottenland - Belgium -
PS: sorry for my english I speak flemish ...
User avatar
Samuel
Enthusiast
Enthusiast
Posts: 756
Joined: Sun Jul 29, 2012 10:33 pm
Location: United States

Re: material - how to use with PB 5.31Final x64

Post by Samuel »

Here's an example of how to load a material script. You just need to set Add3DArchive's Path$ to your script location.

Code: Select all

InitEngine3D()
InitSprite()
InitKeyboard()

WinW = 800
WinH = 600

If OpenWindow(0, 0, 0, WinW, WinH, "Material Script", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)

  OpenWindowedScreen(WindowID(0), 0, 0, WinW, WinH)

  Add3DArchive("C:\MaterialScriptLocation", #PB_3DArchive_FileSystem)
  Parse3DScripts()
  
  GetScriptMaterial(0, "Material1")

  CreateSphere(0, 1)
  CreateEntity(0, MeshID(0), MaterialID(0))
  
  CreateLight(0, RGB(255,255,255), 50, 50, 50)

  CreateCamera(0, 0, 0, 100, 100)
  MoveCamera(0, 0, 0, 5)
  CameraLookAt(0, 0, 0, 0)
  CameraBackColor(0, RGB(20,20,20))
  
  Repeat
    
    Repeat
      Event = WindowEvent()
    
      Select Event
          
        Case #PB_Event_CloseWindow
          Quit = 1
        
      EndSelect
      
    Until Event = 0 
    
    RenderWorld()
    FlipBuffers()

  Until Quit = 1
  
EndIf
End
marc_256
Addict
Addict
Posts: 859
Joined: Thu May 06, 2010 10:16 am
Location: Belgium
Contact:

Re: material - how to use with PB 5.31Final x64

Post by marc_256 »

Hi Samuel,

thanks, it works very well.
blender exported the correct material code.

marc,
- every professional was once an amateur - greetings from Pajottenland - Belgium -
PS: sorry for my english I speak flemish ...
Post Reply