is this a bug?

Just starting out? Need help? Post your questions and find answers here.
Dreglor
Enthusiast
Enthusiast
Posts: 759
Joined: Sat Aug 02, 2003 11:22 pm
Location: OR, USA

is this a bug?

Post by Dreglor »

sorry for being an annoying newbie, but i have enconter a big problem while codeing my 3d engein the compliler keeps give me an error on this one line it expecting a ")" on the end and there should be the procedure has alot of nested arrays which that seam to create the problem now if i get rid of an arrys through the other procedures but if there are no arrays in the code after that it's just fine
i counted all of the "(" and ")" and found there all in order so when i try to correct the problem (adding a ")" ot the end of the line) it as for more of them
it seams that it nevers ends (i stopped adding after i added 300)
so i'm am thinking that this is a compliler bug and i want to make sure it is.
heres the procedure and all of the "dim" code

Code: Select all

#HW_limit.l=1000000
Dim normal_vector1(2)
Dim normal_vector2(2)
Dim normal(2)
Dim face_center(2)
Dim rtemp(#HW_limit)
Dim O_face_num(#HW_limit)
Dim O_vertex_X(#HW_limit,#HW_limit)
Dim O_vertex_Y(#HW_limit,#HW_limit)
Dim O_vertex_Z(#HW_limit,#HW_limit)
Dim O_face_vertex(#HW_limit,#HW_limit,3)
Dim O_X.f(#HW_limit)
Dim O_Y.f(#HW_limit)
Dim O_Z.f(#HW_limit)
Procedure Drake_BFaceCulling()
;"BFaceculling" or Back Face Culling, it bassicaly removes all of the faces that are not pointing at the camrea
; the faces that are pointing at the camrea are put into a Rendering list for Zsorting then to rendering
; i cannot explain thsi very well because i don't fully understand it yet...never the less it works
  For O=0 To O_num
    For F=0 To O_face_num(O)
      normal_vector1(0)=O_vertex_X(O,O_face_vertex(O,F,0))-O_vertex_X(O,O_face_vertex(O,F,1))
      normal_vector1(1)=O_vertex_Y(O,O_face_vertex(O,F,0))-O_vertex_Y(O,O_face_vertex(O,F,1))
      normal_vector1(2)=O_vertex_Z(O,O_face_vertex(O,F,0))-O_vertex_Z(O,O_face_vertex(O,F,1))
      
      normal_vector2(0)=O_vertex_X(O,O_face_vertex(O,F,2))-O_vertex_X(O,O_face_vertex(O,F,1))
      normal_vector2(1)=O_vertex_Y(O,O_face_vertex(O,F,2))-O_vertex_Y(O,O_face_vertex(O,F,1))
      normal_vector2(2)=O_vertex_Z(O,O_face_vertex(O,F,2))-O_vertex_Z(O,O_face_vertex(O,F,1))
      
      normal(0)=normal_vector1(1)*normal_vector2(2)-normal_vector1(2)*normal_vector2(1)
      normal(1)=normal_vector1(2)*normal_vector2(0)-normal_vector1(0)*normal_vector2(2)
      normal(2)=normal_vector1(0)*normal_vector2(1)-normal_vector1(1)*normal_vector2(0)
      
      face_center(0)=O_X(O)+(O_vertex_X(O,O_face_vertex(O,F,0))+O_vertex_X(O,O_face_vertex(O,F,1))+O_vertex_X(O,O_face_vertex(O,F,3)))/3
      face_center(1)=O_Y(O)+(O_vertex_Y(O,O_face_vertex(O,F,0))+O_vertex_Y(O,O_face_vertex(O,F,1))+O_vertex_Y(O,O_face_vertex(O,F,3)))/3
      face_center(2)=O_Z(O)+(O_vertex_Z(O,O_face_vertex(O,F,0))+O_vertex_Z(O,O_face_vertex(O,F,1))+O_vertex_Z(O,O_face_vertex(O,F,3)))/3
      
      length_normal=Sqr((normal(0)*normal(0))+(normal(1)*normal(1))+(normal(2)*normal(2)))
      length_center=Sqr((face_center(0)*face_center(0))+(face_center(1)*face_center(1))+(face_center(2)*face_center(2)))
      
      normal(0)=normal(0)/length_normal
      normal(1)=normal(1)/length_normal
      normal(2)=normal(2)/length_normal
      
      face_center(0)=face_center(0)/length_center
      face_center(1)=face_center(1)/length_center
      face_center(2)=face_center(2)/length_center
      f_dir_v=(normal(0)*face_center(0))+(normal(1)*face_center(1))+(normal(2)*face_center(2)) 
      If f_dir_v < 0
        rtemp(O,F)=1
      Else
        rtemp(O,F)=0
      EndIf
    Next F
  Next O
EndProcedure
i thinking that the complier get stuck in a forever loop waiting for the ")" so it just keep returning a error until it hits eof
~Dreglor
Num3
PureBasic Expert
PureBasic Expert
Posts: 2812
Joined: Fri Apr 25, 2003 4:51 pm
Location: Portugal, Lisbon
Contact:

Post by Num3 »

The problem is here...

you define rtemp has

Code: Select all

Dim rtemp(#HW_limit) 
but You're trying t get a value into it like this

Code: Select all

      If f_dir_v < 0 
        rtemp(O,F)=1 
      Else 
        rtemp(O,F)=0 
      EndIf 
should be:

Code: Select all

      If f_dir_v < 0 
        rtemp(F)=1 
      Else 
        rtemp(F)=0 
      EndIf 
Dreglor
Enthusiast
Enthusiast
Posts: 759
Joined: Sat Aug 02, 2003 11:22 pm
Location: OR, USA

Post by Dreglor »

ah thank you!
i could figure out what the hell was going on!
it those little things that you always miss
i was looking in the wrong place...
thanks num3
~Dreglor
Post Reply