Page 1 of 1

WorldShadows TextureAdditive help

Posted: Mon Jan 28, 2013 8:16 pm
by Samuel
I can't get TextureAdditive to display any shadows. I know they can work because the Character demo has them and they work fine.
I'm thinking that I might have to do something extra with the texture, but that's just a guess.


Code: Select all

;*******************Press Escape To Exit**********************
#CameraSpeed=1
If InitEngine3D()
  InitSprite()
  InitKeyboard()
  InitMouse()


 OpenWindow(0, 0, 0, 1000, 800, "Texture Additive Test", #PB_Window_MinimizeGadget | #PB_Window_ScreenCentered)
 OpenWindowedScreen(WindowID(0), 0, 0, 1000, 800, 0, 0, 0)


Define.d KeyX, KeyY, MouseX, MouseY

    
    CreateTexture(0, 32, 32)
     StartDrawing(TextureOutput(0))
       Box(0, 0, 32, 32 ,RGB(150,150,150))
     StopDrawing()
    
    CreateMaterial(0, TextureID(0))
    
    CreateCube(0,50)
    CreatePlane(1, 1000, 1000, 10, 10, 10, 10)
    
    CreateEntity(0, MeshID(0), MaterialID(0),0,0,0)
    CreateEntity(1,MeshID(1),MaterialID(0), 0, -100, 0)
   
    CreateLight(0, RGB(0, 55, 155), 200, 400 , 1000)
    CreateCamera(0, 0, 0, 100, 100)
    ;CameraLocate(0, 0, 0, 400)
    MoveCamera(0,0,0,400,#PB_Absolute)
    
    WorldShadows(#PB_Shadow_TextureAdditive , 0, 0, 512)
    ;WorldShadows(#PB_Shadow_Additive , 0, 0)
    Repeat

      
      If ExamineMouse()
        MouseX = -MouseDeltaX() * #CameraSpeed * 0.05
        MouseY = -MouseDeltaY() * #CameraSpeed * 0.05
      EndIf
      
      If 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    
        
      EndIf
      

      RotateEntity(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

Re: WorldShadows TextureAdditive help

Posted: Mon Jan 28, 2013 10:12 pm
by Comtois
add this line

Code: Select all

   EntityRenderMode(1,0)

Re: WorldShadows TextureAdditive help

Posted: Mon Jan 28, 2013 10:18 pm
by Samuel
Thank you for the help Comtois. That took care of the problem.

Re: WorldShadows TextureAdditive help

Posted: Mon Jan 28, 2013 10:41 pm
by Olby
Comtois wrote:add this line

Code: Select all

   EntityRenderMode(1,0)
Can you please explain what you did? 0 does not correspond to any of the accepted constants, so you just "switch off" extra rendering modes. But how come additive shadows work without #PB_Entity_CastShadow ?
Thanks.

Re: WorldShadows TextureAdditive help

Posted: Mon Jan 28, 2013 11:06 pm
by Comtois
Here is a tutorial that explains this better than I ever could.

http://www.ogre3d.org/tikiwiki/Basic+Tu ... e_Supports

Extract :
Neat huh? There are two more things we need to do with our ground before we are finished with it. The first is to tell the SceneManager that we don't want it to cast shadows since it is what's being used for shadows to project on.

Code: Select all

entGround->setCastShadows(false);

Re: WorldShadows TextureAdditive help

Posted: Tue Jan 29, 2013 8:10 pm
by Olby
Makes sense. Thanks!