Quick Search for:  in language:    
HELLO,WORLD,programming,rotating,cube,demo,ad
   Code/Articles » |  Newest/Best » |  Community » |  Jobs » |  Other » |  Goto » | 
CategoriesSearch Newest CodeCoding ContestCode of the DayAsk A ProJobsUpload
Visual Basic Stats

 Code: 3,149,602. lines
 Jobs: 144. postings

 How to support the site

 
Sponsored by:

 

You are in:

 
 
PDC 2003: Make the connection
Login



Latest Code Ticker for Visual Basic.
Click here to see a screenshot of this code!HistoryWriter Add-In V.1
By Zvonko Kostovski on 9/3

(Screen Shot)

Click here to see a screenshot of this code!Control Winamp
By Dennis Wollentin on 9/3

(Screen Shot)

Fake Virus Version 1.0
By C.J. Laing on 9/3


][String Encoder
By Andron Smth on 9/3


Font Catalog
By Bill Adams on 9/3


professional search
By Ziad Said on 9/3


Click here to see a screenshot of this code!Drew's Meta Tag Generator
By Drew Phillips on 9/3

(Screen Shot)

Fast BruteForce Class
By §e7eN on 9/3


Click here to see a screenshot of this code!Lotus Domino Exploit Scanner
By §e7eN on 9/3

(Screen Shot)

Click here to put this ticker on your site!


Add this ticker to your desktop!


Daily Code Email
To join the 'Code of the Day' Mailing List click here!





Affiliate Sites



 
 
   

Rotating Cube Demo

Print
Email
 

Submitted on: 8/21/1998
By: Theo Kandiliotis  
Level: Not Given
User Rating: By 103 Users
Compatibility:VB 5.0, VB 6.0

Users have accessed this code 21835 times.
 
(About the author)
 
     The HELLO WORLD of 3D programming :) A rotating cube demo. You can adjust the rotation (clockwise or anticlockwise) and the speed by moving the mouse cursor towards the right and left edges of the form.
 

Windows API/Global Declarations:

Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!

'**************************************
'Windows API/Global Declarations for :Ro
'     tating Cube Demo
'**************************************
No API's		
		
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
 
Terms of Agreement:   
By using this code, you agree to the following terms...   
1) You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.   
2) You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
3) You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
4) You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.

'**************************************
' Name: Rotating Cube Demo
' Description:The HELLO WORLD of 3D prog
'     ramming :)
A rotating cube demo. You can adjust the rotation (clockwise or anticlockwise) and the speed by moving the mouse cursor towards the right and left edges of the form.
' By:Theo Kandiliotis
'
' Inputs:Nothing
'
' Returns:Nothing
'
' Assumes:This is Math stuff mostly,has 
'     little to do with VB's methods. I used t
'     he Line method to do all the drawing on 
'     the form.
To run this project ,you have to paste the text indicated, into a blank text file and save it in ASCII format With an FRM suffix.
Notice that it WILL NOT work If you paste it directly on a VB5 code window...Also make sure that no lines are wrapped before you save it as FRM.
Have fun!
'
' Side Effects:No Side Effects
'
'This code is copyrighted and has' limited warranties.Please see http://w
'     ww.Planet-Source-Code.com/vb/scripts/Sho
'     wCode.asp?txtCodeId=1008&lngWId;=1'for details.'**************************************

------======== start copying AFTER this line ======---------
VERSION 5.00
Begin VB.Form frmMain 
AutoRedraw =-1 'True
BackColor=&H00C0C0C0;&
Caption ="Rotating Cube DEMO"
ClientHeight=3195
ClientLeft =60
ClientTop=345
ClientWidth =4680
FillColor=&H00C0C0C0;&
ForeColor=&H00FF0000;&
    LinkTopic="Form1"
    ScaleHeight =213
    ScaleMode=3 'Pixel
    ScaleWidth =312
    StartUpPosition =3 'Windows Default
    WindowState =2 'Maximized
    Begin VB.PictureBox Picture1 
    BackColor=&H00FFFFFF;&
    BorderStyle =0 'None
    Height =1140
    Left=-1035
    ScaleHeight =76
    ScaleMode=3 'Pixel
    ScaleWidth =772
    TabIndex=0
    Top =1440
    Width=11580
    Begin VB.Label Label1 
    AutoSize=-1 'True
    Caption ="Move the mouse towards the edges of the form to adjust rotation and speed"
    BeginProperty Font 
    Name="MS Sans Serif"
    Size=12
    Charset =161
    Weight =700
    Underline=0'False
    Italic =0'False
    Strikethrough=0'False
    EndProperty
    Height =300
    Left=0
    TabIndex=1
    Top =0
    Width=9135
    End
    End
    Begin VB.Timer Timer1 
    Interval=1
    Left=3825
    Top =2835
    End
    End
    Attribute VB_Name = "frmMain"
    Attribute VB_GlobalNameSpace = False
    Attribute VB_Creatable = False
    Attribute VB_PredeclaredId = True
    Attribute VB_Exposed = False
    Private X(8) As Integer
    Private y(8) As Integer
    Private Const Pi = 3.14159265358979
    Private CenterX As Integer
    Private CenterY As Integer
    Private Const SIZE = 250
    Private Radius As Integer
    Private Angle As Integer
    Private CurX As Integer
    Private CurY As Integer
    Private CubeCorners(1 To 8, 1 To 3) As Integer
Private Sub Form_Load()

Show With Picture1 .Width = Label1.Width .Height = Label1.Height End With
Picture1.Move ScaleWidth / 2 - Picture1.ScaleWidth / 2, Picture1.Height CenterX = ScaleWidth / 2 CenterY = ScaleHeight / 2 Angle = 0 Radius = Sqr(2 * (SIZE / 2) ^ 2) CubeCorners(1, 2) = SIZE / 2 CubeCorners(2, 2) = SIZE / 2 CubeCorners(3, 2) = -SIZE / 2 CubeCorners(4, 2) = -SIZE / 2 CubeCorners(5, 2) = SIZE / 2 CubeCorners(6, 2) = SIZE / 2 CubeCorners(7, 2) = -SIZE / 2 CubeCorners(8, 2) = -SIZE / 2 End Sub
Private Sub DrawCube()
Cls For i = 1 To 8 X(i) = CenterX + CubeCorners(i, 1) - CubeCorners(i, 3) / 8 y(i) = CenterY + CubeCorners(i, 2) + CubeCorners(i, 3) / 8 Next
Line (X(3), y(3))-(X(4), y(4)) Line (X(4), y(4))-(X(8), y(8)) Line (X(3), y(3))-(X(7), y(7)) Line (X(7), y(7))-(X(8), y(8)) Line (X(1), y(1))-(X(3), y(3)) Line (X(1), y(1))-(X(2), y(2)) Line (X(5), y(5))-(X(6), y(6)) Line (X(5), y(5))-(X(1), y(1)) Line (X(5), y(5))-(X(7), y(7)) Line (X(6), y(6))-(X(8), y(8)) Line (X(2), y(2))-(X(4), y(4)) Line (X(2), y(2))-(X(6), y(6)) Line (X(1), y(1))-(X(4), y(4)) Line (X(2), y(2))-(X(3), y(3)) Line (X(4), y(4))-(X(8), y(8)) Line (X(3), y(3))-(X(7), y(7)) DoEvents End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, y As Single)
CurX = X CurY = y End Sub
Private Sub Timer1_Timer()
Select Case CurX Case Is > ScaleWidth / 2 Angle = Angle + Abs(CurX - ScaleWidth / 2) / 20 If Angle > 360 Then Angle = 0 Case Else Angle = Angle - Abs(CurX - ScaleWidth / 2) / 20 If Angle < 0 Then Angle = 360 End Select
For i = 1 To 3 Step 2 CubeCorners(i, 3) = Radius * Cos((Angle) * Pi / 180) CubeCorners(i, 1) = Radius * Sin((Angle) * Pi / 180) Next
For i = 2 To 4 Step 2 CubeCorners(i, 3) = Radius * Cos((Angle + 2 * 45) * Pi / 180) CubeCorners(i, 1) = Radius * Sin((Angle + 2 * 45) * Pi / 180) Next
For i = 5 To 7 Step 2 CubeCorners(i, 3) = Radius * Cos((Angle + 6 * 45) * Pi / 180) CubeCorners(i, 1) = Radius * Sin((Angle + 6 * 45) * Pi / 180) Next
For i = 6 To 8 Step 2 CubeCorners(i, 3) = Radius * Cos((Angle + 4 * 45) * Pi / 180) CubeCorners(i, 1) = Radius * Sin((Angle + 4 * 45) * Pi / 180) Next
DrawCube End Sub
-----==== paste the above into a text file and save it With an FRM suffix In ASCII format.Then just load the FRM file In the VB5 enviroment=========-------------------------


Other 1 submission(s) by this author

 

 
Report Bad Submission
Use this form to notify us if this entry should be deleted (i.e contains no code, is a virus, etc.).
Reason:
 
Your Vote!

What do you think of this code(in the Not Given category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor See Voting Log
 
Other User Comments
5/1/1999 3:47:00 AM:ccjx
PLease email me a copy of that and show 
me how can i change the text and maybe 
add a graphic.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
5/14/1999 10:59:00 PM:D
can you please e-mail the source for 
that
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
5/18/1999 8:09:00 AM:Greg Roberts
I was very impressed!
Well, actually i 
am very impressed!
I was sort of 
expecting properly shaded 3d, but even 
looking at that WELL DONE!
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
5/25/1999 9:40:00 AM:Keir
I am having some trouble with this, i 
have been program for a while, and i am 
using VB6, i can find no reference to 
"Begin" that you use so much to set 
propertys on objects,  Would you send 
me a form with this on it, perhaps then 
i would understand.  Thanks 
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
5/25/1999 11:26:00 AM:Keir
Anyone have any ideas on how to make a 
timer that can have a interval less 
then 1 ms  , email me if so
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
5/28/1999 10:28:00 PM:MNK
Keir, you can use a dummy for - next 
loop to make the computer lose 
time.Since that takes a very less amt 
of time, you can check by trial and 
error method and choose your timing. 
But it gets processor and memory 
dependant.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
7/22/1999 10:12:00 PM:Cool
CooL LooKinG CodE MaN.  KeeP iT Up.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
7/22/1999 10:14:00 PM:ProGMasTeR
Short and Simple Code.  
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
7/26/1999 11:02:00 PM:Derek
nice code and i like the presentation 
method :)
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
7/31/1999 1:26:00 AM:Jonathan Feucht
I have been always trying to do that! 
Very neat! I'm going to use your code 
to try to build a rhubics cube or 
something.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
8/2/1999 1:19:00 PM:Anil Monteiro
Awesome ..!!!
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
8/23/1999 3:21:00 PM:Matt
Oh my, this is wicked, and there no use 
of ocx's!!, i made a tacky 3d game at 
www.mars1998.freeserve.co.uk\doomed.zip
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
10/1/1999 8:13:00 AM:Erik Pedersen
Hi!
Do you got the code for a yatzy 
game, that is programmed in VB-6.0? If 
you have it, can you please mail it to 
me. 
Best regards
Erik Pedersen
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
10/7/1999 9:53:00 PM:Robert
Very impressive Code!!!!!!
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
10/9/1999 4:28:00 AM:David L.S.
Please, Can you send me the source code 
to me e-mail?
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
11/9/1999 2:08:00 AM:Wendell
please send me a copy of that source 
code (zipped) thanks very much.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
11/13/1999 7:31:00 AM:alan
cool...
pls send me a copy of that 
code with zipped. thanks
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
11/18/1999 11:53:00 PM:Dragonrider15
nice code...good for beginners.  
although i have something to suggest:  
zip it up to post it or give the code, 
but not the actual insides of the .frm 
file.  and out of the 2 i suggested, 
zipping it up for d/l would be best.  
just a 
tip
Dragonrider15
dragonrider15@hotm
ail.com
http://welcome.to/dragonrider15
srealm
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
6/22/2000 1:32:28 PM:ZenZagg
Is there any reason it makes my hard 
drive sound like a trash compactor when 
it runs? 
*cht-cht-cht-cht-cht-cht-cht-cht-cht-cht
!* nonstop... heh, nice except for the 
nonstop HD accesses
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
1/9/2003 12:19:37 PM:
cool...
please send me a copy of that 
code with zipped. thanks
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
Add Your Feedback!
Note:Not only will your feedback be posted, but an email will be sent to the code's author in your name.

NOTICE: The author of this code has been kind enough to share it with you.  If you have a criticism, please state it politely or it will be deleted.

For feedback not related to this particular code, please click here.
 
Name:
Comment:

 

Categories | Articles and Tutorials | Advanced Search | Recommended Reading | Upload | Newest Code | Code of the Month | Code of the Day | All Time Hall of Fame | Coding Contest | Search for a job | Post a Job | Ask a Pro Discussion Forum | Live Chat | Feedback | Customize | Visual Basic Home | Site Home | Other Sites | About the Site | Feedback | Link to the Site | Awards | Advertising | Privacy

Copyright© 1997 by Exhedra Solutions, Inc. All Rights Reserved.  By using this site you agree to its Terms and Conditions.  Planet Source Code (tm) and the phrase "Dream It. Code It" (tm) are trademarks of Exhedra Solutions, Inc.