|
-
Nov 18th, 2005, 10:54 PM
#1
-
Nov 18th, 2005, 11:48 PM
#2
Re: [VB6]102,168 Poly Teapot Example
Nice, but you forgot an Error_Handler line in the UnLoad event. I added one, and it ran fine. You should really use Option Explicit.
-
Nov 19th, 2005, 12:06 AM
#3
Re: [VB6]102,168 Poly Teapot Example
I like 
dglienna - he is using Option Explicit. It doesn't catch undefined labels. I think the issue there is using "Start with Full Compile", or turning off "Compile On Demand". That catches it.
-
Nov 19th, 2005, 12:09 AM
#4
Re: [VB6]102,168 Poly Teapot Example
I thought about that after I posted, and of course you are right.
It was missing though.
-
Nov 19th, 2005, 09:24 AM
#5
Re: [VB6]102,168 Poly Teapot Example
Yeah my VB is set to where it automatically puts in Option Explicit.
-
Nov 19th, 2005, 01:24 PM
#6
Re: [VB6]102,168 Poly Teapot Example
Very nice,
Get rid of this line from your Fast_Cos and Fast_Sin functions
Change to this
VB Code:
Public Function Fast_Cos(ByVal Theta As Single) As Single
If Theta < 0 Then Theta = Theta + 360
Dim Theta_Integer As Long
Dim Theta_Fraction As Single
Theta_Integer = Theta Mod 360
Theta_Fraction = Theta - Int(Theta)
Fast_Cos = Cos_Look_Up_Table(Theta_Integer) + Theta_Fraction * (Cos_Look_Up_Table(Theta_Integer + 1) - Cos_Look_Up_Table(Theta_Integer))
End Function
Last edited by moeur; Nov 19th, 2005 at 02:02 PM.
-
Nov 19th, 2005, 01:48 PM
#7
Re: [VB6]102,168 Poly Teapot Example
 Originally Posted by moeur
Very nice,
Get rid of this line from your Fast_Cos and Fast_Sin functions
Sorry bout that. It's done. I forgot that the mod operator automatically eliminated the decimals.
-
Nov 19th, 2005, 02:05 PM
#8
Re: [VB6]102,168 Poly Teapot Example
Actually you still need a mod operator in case theta > 360 so change as I edited above.
-
Nov 19th, 2005, 02:06 PM
#9
Re: [VB6]102,168 Poly Teapot Example
Ok will do 
If you have any other suggestions and optimizations that I can make, let me know. Maybe we can push it even further.
-
Nov 19th, 2005, 05:57 PM
#10
Re: [VB6]102,168 Poly Teapot Example
Actually, the code you have for Fast_Sin and Fast_Cos runs more slowly than the intrinsic sin and cos functions. This is mainly because of the Mod statement.
If you can insure that the angle never goes beyond +-359 then you can remove that statement. Here is a modified version that runs slightly faster than the intrinsic functions and faster than your original function with more accuracy.
These formulas were derived from the following trig formulas
cos(A+a) = Cos(A)*Cos(a) - Sin(A)*Sin(a)
sin(A+a)= Sin(A)*Cos(a) + Cos(A)*Sin(a)
Sin(a) = a - (a^3)/6 + (a^5)/720 - ... where a is in radians
Cos(a) = 1 - (a^2)/2 + (a^4)/24 - ... where a is in radians
VB Code:
Public Function Fast_Cos(ByVal Theta As Single) As Single
If Theta < 0 Then Theta = Theta + 360
Dim Theta_Integer As Long
Dim Theta_Fraction As Single
'remove this checking, too slow
' Theta_Integer = Theta Mod 360
Theta_Integer = CLng(Theta)
Theta_Fraction = Theta - Theta_Integer
'Old function
'Fast_Cos = Cos_Look_Up_Table(Theta_Integer) + Theta_Fraction * (Cos_Look_Up_Table(Theta_Integer + 1) - Cos_Look_Up_Table(Theta_Integer))
'New function
'cos(A+a) = Cos(A)*Cos(a) - Sin(A)*Sin(a)
Fast_Cos = Cos_Look_Up_Table(Theta_Integer) - Sin_Look_Up_Table(Theta_Integer) * Theta_Fraction * DegToRad
End Function
Public Function Fast_Sin(ByVal Theta As Single) As Single
If Theta < 0 Then Theta = Theta + 360
Dim Theta_Integer As Long
Dim Theta_Fraction As Single
'remove this checking, too slow
'Theta_Integer = Theta Mod 360
Theta_Integer = CLng(Theta)
Theta_Fraction = Theta - Theta_Integer
'old function
'Fast_Sin = Sin_Look_Up_Table(Theta_Integer) + Theta_Fraction * (Sin_Look_Up_Table(Theta_Integer + 1) - Sin_Look_Up_Table(Theta_Integer))
'New function
'sin(A+a)= Sin(A)*Cos(a) + Cos(A)*Sin(a)
Fast_Sin = Sin_Look_Up_Table(Theta_Integer) + Cos_Look_Up_Table(Theta_Integer) * Theta_Fraction * DegToRad
End Function
-
Nov 20th, 2005, 11:42 AM
#11
Re: [VB6]102,168 Poly Teapot Example
Thanks moeur, I'll give that a whirl when I get home.
-
Nov 20th, 2005, 11:55 AM
#12
Re: [VB6]102,168 Poly Teapot Example
 Originally Posted by Jacob Roman
Who says VB is too slow for games? I just managed to pull off 102,168 polygons to be visible on the screen at once, not including the mouse cursor and skybox, and still managed to stick with realtime speed. It's faster in fullscreen mode. You can download the source code here where it says "Download my 3D Engine HERE"
www.angelfire.com/fl5/memorydll/index.html
Use the Numpad and Mouse to control the camera, F12 to Snapshot, and Esc to quit. Enjoy 
An example like this doesn't show ANYTHING about VBs speed. Since nearly ALL the processing for this sample is done on the GPU... So your statement doesn't hold...sorry JR...
- ØØ -
-
Nov 20th, 2005, 12:02 PM
#13
Re: [VB6]102,168 Poly Teapot Example
 Originally Posted by NoteMe
An example like this doesn't show ANYTHING about VBs speed. Since nearly ALL the processing for this sample is done on the GPU...  So your statement doesn't hold...sorry JR...
- ØØ -
I'm just showing that it is possible to pull off commercial quality games with a 100,000-1,000,000 polygons on the screen at once in VB
-
Nov 20th, 2005, 12:05 PM
#14
Re: [VB6]102,168 Poly Teapot Example
But it has nothing to do with VB I tell you. It is like making NotePad in VB and say that VB is soooo fast, because it works...Your VB code in that example is executed about 1/300 of the time. The rest is used to push graphics over the Bus, and to do the actual rendering, which has nothing to do with VB.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|