AddMaterialLayer()

Everything related to 3D programming
User avatar
Distorted Pixel
Enthusiast
Enthusiast
Posts: 303
Joined: Sun Aug 29, 2021 4:34 am

Re: AddMaterialLayer()

Post by Distorted Pixel »

miso wrote: Wed Jul 02, 2025 5:50 pm There is no main mesh. A mesh is composed of submeshes, and it has at least 1. All the 31 item is a submesh in your model. Some of them are textured, some of them are not. (but they have color in their mesh data, and they are visible. Those just do not need a textured material.)

The material name should not concern you when using pb.

Case 1 is the 2'nd in the material file. Case 4 is the 5'th. (I did not recheck, but if you find something off with the cases, it might be because I made a mistake somewhere, that isn't visible)

Case default is everything else that is not presented.
Probably as you posted this I think I figured out that the case numbers where according to certain entries in the material file. I will study this information you have taught me and keep studying the material file to further understand it.

Thank you very much for your time miso, I'm sorry if I drove you nuts. There are a lot of people out there that would explain some things in a way not easily understood and when you ask them to explain, they just don't say anything and the person trying to learn is stuck trying to figure it out themselves. I have studied hard to learn PB over the years to learn it. I have come a long way, but still have a long way to go. I have stayed away from the 3D part of PB because it scares me seeing all this that I have to learn even though it is the part of PB that I want to use most.

Thank you for taking the time to explain things over numerous posts and not giving up on me. Thank you for your time. I will study this hard.
To be popular is way to much work. I just want to be me, myself and I. Oh no, does that mean I'm bipolar? :shock:

No one cares how much you know until they know how much you care
miso
Enthusiast
Enthusiast
Posts: 407
Joined: Sat Oct 21, 2023 4:06 pm
Location: Hungary

Re: AddMaterialLayer()

Post by miso »

Don't mention it, your welcome. I'm glad if I was able to help a little. I'm learning also with these.
User avatar
Distorted Pixel
Enthusiast
Enthusiast
Posts: 303
Joined: Sun Aug 29, 2021 4:34 am

Re: AddMaterialLayer()

Post by Distorted Pixel »

miso wrote: Wed Jul 02, 2025 6:24 pm Don't mention it, your welcome. I'm glad if I was able to help a little. I'm learning also with these.
Just thought I'd post this short video I made last night. I recorded it with an old version of Movavi and my screen refresh rate is 144 fps lol. So it is crappy recording lol. I will learn a lot from this project.
https://drive.proton.me/urls/W26NCXSR9C#HHZ7Mveowit2

I got the keyboard controls from this thread here:
viewtopic.php?t=78124
The keyboard code here is pretty easy to understand for me.

Code: Select all

#MOVEMENT_SPEED = 0.1

Global MouseXRotation.f,MouseYRotation.f,KeyX.f,KeyZ.f

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


OpenWindow(0, 0, 0, 1200, 800, "European Football Simulator", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
OpenWindowedScreen(WindowID(0), 0, 0, 1200, 800, 0, 0, #PB_Screen_WaitSynchronization)
Add3DArchive("C:\Users\Brian\Documents\PUREBASIC PROJECTS\3D Programs\3Dfield\Media", #PB_3DArchive_FileSystem)

Parse3DScripts()
CreateLight(0,RGB(55, 55, 55), 0, 400, -10, #PB_Light_Directional)
LoadTexture(0, "Stadium_blue.png") 
LoadTexture(1, "Stadium_field.png")

bluemat=CreateMaterial(#PB_Any,TextureID(0))
fieldmat=CreateMaterial(#PB_Any,TextureID(1))
defmat = CreateMaterial(#PB_Any,0)

LoadMesh(0, "StadiumNew_obj.mesh")

CreateEntity(0, MeshID(0), #PB_Material_None)

For x = 0 To 30
  Select x
    Case 1
      tmat = fieldmat
    Case 4
      tmat = defmat
    Case 5
      tmat = defmat
    Case 9
      tmat = defmat
    Case 10
      tmat = defmat
    Case 11
      tmat = defmat
    Case 12
      tmat = defmat
    Default
      tmat = bluemat
  EndSelect
  SetEntityMaterial(0,MaterialID(tmat),x)
Next x

RotateEntity(0, 6, 45, 0, #PB_Absolute)

CreateCamera(0, 0, 0, 100, 100)
MoveCamera(0, 0, 20, 40, #PB_Absolute | #PB_Local) ; absolute + local positive Z coordinate moves camera backwards
CameraRange(0,0.1, 1000)
CameraLookAt(0, 0, 0, 0)
Repeat
  Repeat : event=WindowEvent() : If event = #PB_Event_CloseWindow : End : EndIf :Until Not event
  If ExamineMouse()
    MouseYRotation = -MouseDeltaX() / 10
    MouseXRotation = -MouseDeltaY() / 10
  EndIf
  RotateCamera(0, MouseXRotation, MouseYRotation, 0, #PB_Relative)
  ;Update Key Presses and position the Camera accordingly
  If ExamineKeyboard()
    If KeyboardPushed(#PB_Key_Left) : KeyX = -#MOVEMENT_SPEED : EndIf
    If KeyboardPushed(#PB_Key_Right) : KeyX = #MOVEMENT_SPEED : EndIf
    If KeyboardPushed(#PB_Key_Up) : KeyZ = -#MOVEMENT_SPEED : EndIf
    If KeyboardPushed(#PB_Key_Down) : KeyZ = #MOVEMENT_SPEED : EndIf
    If KeyboardPushed(#PB_Key_Escape) : ReleaseMouse(#True) : EndIf
    MoveCamera(0, KeyX, 0, KeyZ)
    KeyX = 0
    KeyZ = 0
  EndIf
  RenderWorld()
  FlipBuffers()
  Delay(1)
ForEver
To be popular is way to much work. I just want to be me, myself and I. Oh no, does that mean I'm bipolar? :shock:

No one cares how much you know until they know how much you care
Post Reply