Menu

ShadowVolume - what am I doing wrong?

Help
2015-09-18
2016-01-02
  • Sergey Plesnetsov

    Hello everyone! I am really desperate, so I am with all possible humbleness asking for help (

    I seem to be positively unable to use ShadowVolume for some reason :( I just can't get it working in my app - while demo works perfectly and, as it seems to me, I'm doing everything exactly like in the demo...

    So, I have a scene:

    Root
    - mcam <-camera
    - dcmaingame
    - -dcgame
    - --playerlight <-lightsource
    - --shadowz <-glshadowvolume
    - ---dcgameb
    - ---- (all gameworld objects)
    - (other dummies mostly related to UI)

    ShadowVolume parameters are:

    object shadowz: TGLShadowVolume
    ObjectsSorting = osNone
    Active = False //this one is activated in forms OnCreate
    Lights = <
    item
    LightSource = playerlight
    end>
    Occluders = <>
    Options = [svoScissorClips, svoDesignVisible]
    Mode = svmDarkening
    end
    end

    This code is supposed to periodically process casters to refress current surroundings:

    procedure TForm1.HandleShadows;
    var i,j,k:integer;
    begin
      //processing shadows
    
      with shadowz do
      begin
        try Occluders.Clear; except end; //clearing all occluders
    
        //plx,ply - player coords on the grid 
    
       for i:=(plx-1) to (plx+1) do //picking up all surrounding walls 
                                             //(also there are ceils and floors,
                                             //but i'm sticking to walls now)
        for j:=(ply-1) to (ply+1) do
        begin
    
          if (i>=0) and (j>=0) and (i<=dw) and (j<=dh) then //making sure that cell is inbound
          begin
    
              if (cells[i,j].wall=true) or (cells[i,j].fwm=true) then  //checks if there IS a wall here
                try Occluders.AddCaster(wall[i,j], 0, scmParentVisible); except end;
    
          end;
    
        end;
    
      end;
    end;
    

    Whenever this procedure is used I receive memory errors as soon as caters are added... What am I doing wrong? T___T

    Late edit:
    Discovered that error appears to happen at GLVectorGeometry.pas on the first line of assembler code:

    // VectorSubtract (proc, affine)
    //
    procedure VectorSubtract(const v1, v2 : TAffineVector; var result : TAffineVector);
    // EAX contains address of V1
    // EDX contains address of V2
    // ECX contains the result
    {$ifndef GEOMETRY_NO_ASM}
    asm
          FLD  DWORD PTR [EAX]
          FSUB DWORD PTR [EDX]
          FSTP DWORD PTR [ECX]
          FLD  DWORD PTR [EAX+4]
          FSUB DWORD PTR [EDX+4]
          FSTP DWORD PTR [ECX+4]
          FLD  DWORD PTR [EAX+8]
          FSUB DWORD PTR [EDX+8]
          FSTP DWORD PTR [ECX+8]
    {$else}
    begin
      try
       result.V[0]:=v1.V[0]-v2.V[0];
       result.V[1]:=v1.V[1]-v2.V[1];
       result.V[2]:=v1.V[2]-v2.V[2];
      except
    
      end;
    {$endif}
    end;
    

    O___o

     

    Last edit: Sergey Plesnetsov 2015-09-19
  • Sergey Plesnetsov

    Just to inform the community: after lots of tinkering discovered that the problem was actually with models. After experiments with model export, discovered that most important part was .obj triangulation and as simple file structure as possible.

    PS Also, the code I provided in opening post had to be reworked completely as well, so... XD

     

    Last edit: Sergey Plesnetsov 2016-01-02

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.