Analoge Uhr
Übersicht

![]() |
The_NiciBetreff: Analoge Uhr |
![]() Antworten mit Zitat ![]() |
---|---|---|
Code: [AUSKLAPPEN] Graphics3D 200,200,32,2
SetBuffer BackBuffer() ;Grafikschnickschnack cam=CreateCamera() PositionEntity cam,0,10,-8 RotateEntity cam, 50,0,0 light=CreateLight() RotateEntity light, 20,0,0 PositionEntity light, 0,0,10 Zifferblatt=CreateCylinder(32) PositionEntity Zifferblatt, 0,0,0 ScaleEntity Zifferblatt, 10,1,10 EntityColor Zifferblatt, 255,0,0 Sekundenzeigerhalterung=CreatePivot() PositionEntity Sekundenzeigerhalterung,0,0,0 Sekundenzeiger=CreateCube(Sekundenzeigerhalterung) ScaleEntity Sekundenzeiger, 0.5,0.2,5.5 PositionEntity Sekundenzeiger, 0,1,4.5 EntityColor Sekundenzeiger, 100,200,0 Minutenzeigerhalterung=CreatePivot() PositionEntity Minutenzeigerhalterung,0,0,0 Minutenzeiger=CreateCube(Minutenzeigerhalterung) ScaleEntity Minutenzeiger, 0.5,0.3,4 PositionEntity Minutenzeiger, 0,1,3.5 EntityColor Minutenzeiger, 100,0,255 Stundenzeigerhalterung=CreatePivot() PositionEntity Stundenzeigerhalterung, 0,0,0 Stundenzeiger=CreateCube(Stundenzeigerhalterung) ScaleEntity Stundenzeiger, 0.5,0.4,3 PositionEntity Stundenzeiger, 0,1,2.5 EntityColor Stundenzeiger, 100,100,100 While Not KeyHit(1) Stunde# = Left(CurrentTime(),2) Minute# = Mid(CurrentTime(),4,2) Sekunde# = Right(CurrentTime(),2) RotateEntity Sekundenzeigerhalterung, 0,-Sekunde/60*360,0 RotateEntity Minutenzeigerhalterung, 0,(-Minute/60*360)+(-Sekunde/60*6),0 RotateEntity Stundenzeigerhalterung, 0,(-Stunde/12*360)+(-Minute/60*30),0 RenderWorld Text 100,10, "3D Watch by The_Nici and kernle32DLL",True,True Text 100,30,CurrentTime(),True,True Flip Wend FreeTimer(timer) End Viel Spass damit. Ahja, die Kameradrehung sorgt für eine optische Täuschung, sie ist soweit ichw eiss ziemlich genau, die Uhr. =) EDIT: Bug behoben. UPDATE: um 00:00:00 wird die Uhr neu gestellt, da es um eine abweichung von 0.0003 grad kommen kann... NEUE VERSION: Dank Kernle =D Code: [AUSKLAPPEN] Graphics3D 200,200,32,2
SetBuffer BackBuffer() ;Grafikschnickschnack cam=CreateCamera() PositionEntity cam,0,10,-8 RotateEntity cam, 50,0,0 light=CreateLight() RotateEntity light, 20,0,0 PositionEntity light, 0,0,10 Zifferblatt=CreateCylinder(32) PositionEntity Zifferblatt, 0,0,0 ScaleEntity Zifferblatt, 10,1,10 EntityColor Zifferblatt, 255,0,0 Sekundenzeigerhalterung=CreatePivot() PositionEntity Sekundenzeigerhalterung,0,0,0 Sekundenzeiger=CreateCube(Sekundenzeigerhalterung) ScaleEntity Sekundenzeiger, 0.5,0.2,5.5 PositionEntity Sekundenzeiger, 0,1,4.5 EntityColor Sekundenzeiger, 100,200,0 Minutenzeigerhalterung=CreatePivot() PositionEntity Minutenzeigerhalterung,0,0,0 Minutenzeiger=CreateCube(Minutenzeigerhalterung) ScaleEntity Minutenzeiger, 0.5,0.3,4 PositionEntity Minutenzeiger, 0,1,3.5 EntityColor Minutenzeiger, 100,0,255 Stundenzeigerhalterung=CreatePivot() PositionEntity Stundenzeigerhalterung, 0,0,0 Stundenzeiger=CreateCube(Stundenzeigerhalterung) ScaleEntity Stundenzeiger, 0.5,0.4,3 PositionEntity Stundenzeiger, 0,1,2.5 EntityColor Stundenzeiger, 100,100,100 ;Zeiger stellen! ss=Mid(CurrentTime(),7) minmin=Mid(CurrentTime(),4,5) hh=Mid(CurrentTime(),1,2) RotateEntity Sekundenzeigerhalterung, 0,-ss*6,0 RotateEntity Minutenzeigerhalterung, 0,-minmin*6,0 RotateEntity Stundenzeigerhalterung, 0,-hh*30,0 timer=CreateTimer(10) While Not KeyHit(1) WaitTimer(timer) TurnEntity Sekundenzeigerhalterung, 0,-0.6,0 TurnEntity Minutenzeigerhalterung, 0,-0.01,0 TurnEntity Stundenzeigerhalterung, 0,-0.001,0 If CurrentTime()="00:00:00" Then ss=Mid(CurrentTime(),7) minmin=Mid(CurrentTime(),4,5) hh=Mid(CurrentTime(),1,2) RotateEntity Sekundenzeigerhalterung, 0,-ss*6,0 RotateEntity Minutenzeigerhalterung, 0,-minmin*6,0 RotateEntity Stundenzeigerhalterung, 0,-hh*30,0 End If RenderWorld Text 0,180, "3D Watch by The_Nici" Flip Wend FreeTimer timer End |
||
- Zuletzt bearbeitet von The_Nici am Fr, Jun 29, 2007 22:41, insgesamt einmal bearbeitet
![]() |
Kernle 32DLL |
![]() Antworten mit Zitat ![]() |
---|---|---|
Die Funktion zum drehen der Zeiger ist etwas komplizierter als sie sein muss ^^ Da ich mich noch vor kurzem damit beschäftigt habe, habe ich den 2. Teil deines Code mal kurz umgebaut...
Code: [AUSKLAPPEN] While Not KeyHit(1)
Stunde# = Left(CurrentTime(),2) Minute# = Mid(CurrentTime(),4,2) Sekunde# = Right(CurrentTime(),2) RotateEntity Sekundenzeigerhalterung, 0,-Sekunde/60*360,0 RotateEntity Minutenzeigerhalterung, 0,(-Minute/60*360)+(-Sekunde/60*6),0 RotateEntity Stundenzeigerhalterung, 0,(-Stunde/12*360)+(-Minute/60*30),0 RenderWorld Text 100,10, "3D Watch by The_Nici",True,True Text 100,30,CurrentTime(),True,True Flip Wend End Falls dich das "(-Sekunde/60*6)" beim Minutenzeiger, und das "(-Minute/60*30)" beim Stundenzeiger verwirrt - Die sind dazu da, damit sich die angesprochenen Zeiger "flüssiger" bewegen. Achja: Das Uhrstellen vor der Schleife fällt so natürlich auch weg ^^ Grüßle: Kernle PS: Aber ansonsten: Coole Idee ^^ |
||
Mein PC: "Bluelight" - Xtreme Gamer PC [Video]
Meine Projekte: Cube-Wars 2010 [Worklog] Anerkennungen: 1. Platz BCC #7 , 1. Platz BCC #22 , 3. Platz BAC #89 Ich war dabei: NRW Treff III, IV ; Frankfurter BB Treffen 2009 |
![]() |
The_Nici |
![]() Antworten mit Zitat ![]() |
---|---|---|
Danke, kernle32, deine Versi ist wirklich besser =)
Ein kleiner Verbesserungsvorschlag: Text 100,10, "3D Watch by The_Nici and Kernle32DLL",True,True |
||
![]() |
Kernle 32DLL |
![]() Antworten mit Zitat ![]() |
---|---|---|
oh, ist zwar nicht nötig, aber wenn du drauf bestehst, gerne ^_^
Grüßle: Kernle |
||
Mein PC: "Bluelight" - Xtreme Gamer PC [Video]
Meine Projekte: Cube-Wars 2010 [Worklog] Anerkennungen: 1. Platz BCC #7 , 1. Platz BCC #22 , 3. Platz BAC #89 Ich war dabei: NRW Treff III, IV ; Frankfurter BB Treffen 2009 |
![]() |
hecticSieger des IS Talentwettbewerb 2006 |
![]() Antworten mit Zitat ![]() |
---|---|---|
Cool, sowas wollte ich auch schon immer mal machen. Jetzt habe ich mich dazu errungen. Hier mein Beitrag zum Thema:
Code: [AUSKLAPPEN] Graphics3D 256,256,0,2
SetBuffer BackBuffer() camera=CreateCamera() PositionEntity camera,0,0,-80 CameraClsColor camera,64,64,80 CameraZoom camera,1.0/48 CameraProjMode camera,2 light=CreateLight() TurnEntity light,50,-50,0 AmbientLight 64,64,64 ihrp#=0 imrp#=0 isrp#=0 shrp#=0 smrp#=0 ssrp#=0 hzeiger=CreateCylinder(6) EntityColor hzeiger,55,155,255 ScaleEntity hzeiger,2.2,10,1 PositionMesh hzeiger,0,1,0 EntityShininess hzeiger,1 EntityOrder hzeiger,-1 mzeiger=CreateCylinder(6) EntityColor mzeiger,255,55,55 ScaleEntity mzeiger,1.2,14,1 PositionMesh mzeiger,0,1,0 EntityShininess mzeiger,1 EntityOrder mzeiger,-2 szeiger=CreateCylinder(6) EntityColor szeiger,255,255,55 ScaleEntity szeiger,0.7,18,1 PositionMesh szeiger,0,1,0 EntityShininess szeiger,1 EntityOrder szeiger,-3 blatt=CreateSphere(24) EntityColor blatt,64,64,80 ScaleEntity blatt,42,42,10 EntityShininess blatt,.25 center=CreateSphere(12) EntityColor center,64,64,80 ScaleEntity center,4,4,1 EntityOrder center,-4 For h=1 To 12 PositionEntity CreateSphere(3),Cos(h*30)*38,Sin(h*30)*38,-10 Next timer=CreateTimer(20) While Not KeyHit(1) ct$=CurrentTime() ssrp=-Int(Mid(ct,7,2))*6 smrp=-Int(Mid(ct,4,2))*6 shrp=-Int(Mid(ct,1,2))*30+smrp/12 If shrp=0 If ihrp<0 ihrp=ihrp+360 If smrp=0 If imrp<0 imrp=imrp+360 If ssrp=0 If isrp<0 isrp=isrp+360 ihrp=ihrp+(shrp-ihrp)/3 imrp=imrp+(smrp-imrp)/3 isrp=isrp+(ssrp-isrp)/3 RotateEntity hzeiger,0,0,ihrp RotateEntity mzeiger,0,0,imrp RotateEntity szeiger,0,0,isrp WaitTimer(timer) RenderWorld Flip Wend End |
||
Download der Draw3D2 V.1.1 für schnelle Echtzeiteffekte über Blitz3D |
- Zuletzt bearbeitet von hectic am Sa, Jun 30, 2007 1:55, insgesamt 3-mal bearbeitet
![]() |
The_Nici |
![]() Antworten mit Zitat ![]() |
---|---|---|
Hectic, du stellst mal wieder alles in den Schatten... 0.0
Echt krass! |
||
![]() |
hecticSieger des IS Talentwettbewerb 2006 |
![]() Antworten mit Zitat ![]() |
---|---|---|
Ha ha, danke. Als es eben 00:15 war, habe ich festgestellt, dass meine Stundenanzeige etwas falsch lag. Der Stundenzeiger zeigte schnur gerade nach oben, was das lesen zB nahe bei +/- x:00 echt zu einem unmöglichem gemacht hätte. Habe eben mein Stundenzeiger mit dem Minutenwerten gebunden. Somit sollte gefixt sein.
Was den Codes angeht, dein Code ist dafür kürzer. So eine Uhr ist ja jetzt nicht so schwer zu machen. Für mich halt so eine Sache, die ich schon immer mal so machen wollte. Richtig schön wäre es aber, die Zeiger auf eine Textur zu zeichnen, damit die Treppengebilde bei Schrägstellung von der Grafikkarte weichgezeichnet würden.^^ |
||
Download der Draw3D2 V.1.1 für schnelle Echtzeiteffekte über Blitz3D |
![]() |
KabelbinderSieger des WM-Contest 2006 |
![]() Antworten mit Zitat ![]() |
---|---|---|
Jo, sieht gut aus
Macht das doch vielleicht als Function (create_clock) oder sowas, für Leute, die ihre Spiele verschönern wollen. Irgendwie eine Schande, man gibt sich in Spielen immer soviel Mühe mit den Details und diese deletantischen Spieler und nicht-Programmierer nehmen die nachher nichmal wahr ![]() |
||
<Wing Avenger Download> ◊◊◊ <Macrophage Download> |
![]() |
FireballFlame |
![]() Antworten mit Zitat ![]() |
---|---|---|
Möööööönsch hectic, das Teil ist klasse!
Das muss ich irgendwo in mein Spiel einbaun, bin schon am überlegen... ^^ €: Die will ich garnicht ins HUD einbaun, sondern irgendwo hinhängen ![]() |
||
PC: Intel Core i7 @ 4x2.93GHz | 6 GB RAM | Nvidia GeForce GT 440 | Desktop 2x1280x1024px | Windows 7 Professional 64bit
Laptop: Intel Core i7 @ 4x2.00GHz | 8 GB RAM | Nvidia GeForce GT 540M | Desktop 1366x768px | Windows 7 Home Premium 64bit |
- Zuletzt bearbeitet von FireballFlame am Mo, Jul 16, 2007 12:03, insgesamt einmal bearbeitet
![]() |
hecticSieger des IS Talentwettbewerb 2006 |
![]() Antworten mit Zitat ![]() |
---|---|---|
Nagut, wenn eine Funktion erwünscht, so mache ich doch mal schnell eine. Hier die Funktionsweise:
Per Include muss folgende .bb -Datei eingebunden werden. Clock3D.bb -Code: [AUSKLAPPEN] ;Clock.V.1.0
;Autor.hectic ;www.hectic.de ;Camera-Cheking If camera=0 RuntimeError "variable ''camera'' not found" ;Clock-Vorspann Local clock_brush=CreateBrush() Local clock_pixel=CreateTexture(2,2,3) Global clock_mesh=CreateMesh(camera) WritePixel 0,0,$00ffffff,TextureBuffer(clock_pixel) WritePixel 1,0,$ffffffff,TextureBuffer(clock_pixel) WritePixel 0,1,$00ffffff,TextureBuffer(clock_pixel) WritePixel 1,1,$00ffffff,TextureBuffer(clock_pixel) ScaleTexture clock_pixel,2,2 BrushTexture clock_brush,clock_pixel Global clock_face=CreateSurface(clock_mesh,clock_brush) PositionEntity clock_mesh,0,0,GraphicsWidth()/2 EntityOrder clock_mesh,-102 FreeTexture clock_pixel FreeBrush clock_brush EntityFX clock_mesh,3 ;Clock-Funktion Function Clock3D$(f_clock_xp#,f_clock_yp#,f_clock_size#,f_clock_time=-1) Local clock_angle% ;Schleifenvariable Local clock_time$ ;Zeitstring Local clock_xp# ;X-Position Local clock_yp# ;Y-Position Local clock_sh% ;Stunden Local clock_sm% ;Minuten Local clock_ss% ;Sekunden ;Zeitvergabe If f_clock_time=-1 clock_time=CurrentTime() Else clock_ss=f_clock_time Mod 60 clock_sm=Floor(f_clock_time/60) Mod 60 clock_sh=Floor(f_clock_time/3600) Mod 24 clock_time=Right("00"+Str(clock_sh),2)+":"+Right("00"+Str(clock_sm),2)+":"+Right("00"+Str(clock_ss),2) End If ;Alles löschen ClearSurface clock_face If f_clock_size>0 ;Ziffernblatt-Zeichnen For clock_angle=1 To 12 clock_xp=Sin(clock_angle*30)*f_clock_size clock_yp=Cos(clock_angle*30)*f_clock_size TFormNormal clock_xp,clock_yp,0,0,0 clock_v0=AddVertex(clock_face,f_clock_xp+clock_xp/2+TFormedY()*f_clock_size/12,f_clock_yp+clock_yp/2-TFormedX()*f_clock_size/12,0, 0.5,0.5) clock_v1=AddVertex(clock_face,f_clock_xp+clock_xp/2-TFormedY()*f_clock_size/12,f_clock_yp+clock_yp/2+TFormedX()*f_clock_size/12,0, 2.5,0.5) clock_v2=AddVertex(clock_face,f_clock_xp+clock_xp-TFormedY()*f_clock_size/12,f_clock_yp+clock_yp+TFormedX()*f_clock_size/12,0, 2.5,0.5) clock_v3=AddVertex(clock_face,f_clock_xp+clock_xp+TFormedY()*f_clock_size/12,f_clock_yp+clock_yp-TFormedX()*f_clock_size/12,0, 0.5,0.5) VertexColor clock_face,clock_v0,240,240,240,0 VertexColor clock_face,clock_v1,240,240,240,0 VertexColor clock_face,clock_v2,240,240,240,.5 VertexColor clock_face,clock_v3,240,240,240,.5 VertexNormal clock_face,clock_v0,0,0,-1 VertexNormal clock_face,clock_v1,0,0,-1 VertexNormal clock_face,clock_v2,0,0,-1 VertexNormal clock_face,clock_v3,0,0,-1 AddTriangle(clock_face,clock_v0,clock_v1,clock_v2) AddTriangle(clock_face,clock_v2,clock_v3,clock_v0) Next ;Zeiger-Stellungen-Festlegen clock_ss=Int(Mid(clock_time,7,2))*6 clock_sm=Int(Mid(clock_time,4,2))*6 clock_sh=Int(Mid(clock_time,1,2))*30+clock_sm/12 ;Stunden-Zeiger-Zeichnen clock_xp=f_clock_xp+Sin(clock_sh)*f_clock_size/1.5 clock_yp=f_clock_yp+Cos(clock_sh)*f_clock_size/1.5 TFormNormal clock_xp-f_clock_xp,clock_yp-f_clock_yp,0,0,0 clock_v0=AddVertex(clock_face,f_clock_xp+TFormedY()*f_clock_size/12,f_clock_yp-TFormedX()*f_clock_size/12,0, 0.5,0.5) clock_v1=AddVertex(clock_face,f_clock_xp-TFormedY()*f_clock_size/12,f_clock_yp+TFormedX()*f_clock_size/12,0, 2.5,0.5) clock_v2=AddVertex(clock_face,clock_xp-TFormedY()*f_clock_size/12,clock_yp+TFormedX()*f_clock_size/12,0, 2.5,0.5) clock_v3=AddVertex(clock_face,clock_xp+TFormedY()*f_clock_size/12,clock_yp-TFormedX()*f_clock_size/12,0, 0.5,0.5) VertexColor clock_face,clock_v0,240,240,120,1 VertexColor clock_face,clock_v1,240,240,120,1 VertexColor clock_face,clock_v2,240,60,60,1 VertexColor clock_face,clock_v3,240,60,60,1 VertexNormal clock_face,clock_v0,0,0,-1 VertexNormal clock_face,clock_v1,0,0,-1 VertexNormal clock_face,clock_v2,0,0,-1 VertexNormal clock_face,clock_v3,0,0,-1 AddTriangle(clock_face,clock_v0,clock_v1,clock_v2) AddTriangle(clock_face,clock_v2,clock_v3,clock_v0) ;Minuten-Zeiger-Zeichnen clock_xp=f_clock_xp+Sin(clock_sm)*f_clock_size/1.25 clock_yp=f_clock_yp+Cos(clock_sm)*f_clock_size/1.25 TFormNormal clock_xp-f_clock_xp,clock_yp-f_clock_yp,0,0,0 clock_v0=AddVertex(clock_face,f_clock_xp+TFormedY()*f_clock_size/18,f_clock_yp-TFormedX()*f_clock_size/18,0, 0.5,0.5) clock_v1=AddVertex(clock_face,f_clock_xp-TFormedY()*f_clock_size/18,f_clock_yp+TFormedX()*f_clock_size/18,0, 2.5,0.5) clock_v2=AddVertex(clock_face,clock_xp-TFormedY()*f_clock_size/18,clock_yp+TFormedX()*f_clock_size/18,0, 2.5,0.5) clock_v3=AddVertex(clock_face,clock_xp+TFormedY()*f_clock_size/18,clock_yp-TFormedX()*f_clock_size/18,0, 0.5,0.5) VertexColor clock_face,clock_v0,240,240,120,1 VertexColor clock_face,clock_v1,240,240,120,1 VertexColor clock_face,clock_v2,240,240,240,1 VertexColor clock_face,clock_v3,240,240,240,1 VertexNormal clock_face,clock_v0,0,0,-1 VertexNormal clock_face,clock_v1,0,0,-1 VertexNormal clock_face,clock_v2,0,0,-1 VertexNormal clock_face,clock_v3,0,0,-1 AddTriangle(clock_face,clock_v0,clock_v1,clock_v2) AddTriangle(clock_face,clock_v2,clock_v3,clock_v0) ;Sekunden-Zeiger-Zeichnen clock_xp=f_clock_xp+Sin(clock_ss)*f_clock_size clock_yp=f_clock_yp+Cos(clock_ss)*f_clock_size TFormNormal clock_xp-f_clock_xp,clock_yp-f_clock_yp,0,0,0 clock_v0=AddVertex(clock_face,f_clock_xp+TFormedY()*f_clock_size/24,f_clock_yp-TFormedX()*f_clock_size/24,0, 0.5,0.5) clock_v1=AddVertex(clock_face,f_clock_xp-TFormedY()*f_clock_size/24,f_clock_yp+TFormedX()*f_clock_size/24,0, 2.5,0.5) clock_v2=AddVertex(clock_face,clock_xp-TFormedY()*f_clock_size/24,clock_yp+TFormedX()*f_clock_size/24,0, 2.5,0.5) clock_v3=AddVertex(clock_face,clock_xp+TFormedY()*f_clock_size/24,clock_yp-TFormedX()*f_clock_size/24,0, 0.5,0.5) VertexColor clock_face,clock_v0,240,240,240,1 VertexColor clock_face,clock_v1,240,240,240,1 VertexColor clock_face,clock_v2,240,240,240,1 VertexColor clock_face,clock_v3,240,240,240,1 VertexNormal clock_face,clock_v0,0,0,-1 VertexNormal clock_face,clock_v1,0,0,-1 VertexNormal clock_face,clock_v2,0,0,-1 VertexNormal clock_face,clock_v3,0,0,-1 AddTriangle(clock_face,clock_v0,clock_v1,clock_v2) AddTriangle(clock_face,clock_v2,clock_v3,clock_v0) ;Deckblatt-Zeichnen For clock_angle=1 To 12 clock_v0=AddVertex(clock_face,f_clock_xp+Sin(clock_angle*30-15)*f_clock_size/6,f_clock_yp+Cos(clock_angle*30-15)*f_clock_size/6,0, 1.5,0.5) clock_v1=AddVertex(clock_face,f_clock_xp+Sin(clock_angle*30+15)*f_clock_size/6,f_clock_yp+Cos(clock_angle*30+15)*f_clock_size/6,0, 1.5,0.5) clock_v2=AddVertex(clock_face,f_clock_xp,f_clock_yp,0, 1.5,0.5) clock_v3=AddVertex(clock_face,f_clock_xp,f_clock_yp,0, 1.5,0.5) VertexColor clock_face,clock_v0,160,160,160,0 VertexColor clock_face,clock_v1,160,160,160,0 VertexColor clock_face,clock_v2,240,240,240,1 VertexColor clock_face,clock_v3,240,240,240,1 VertexNormal clock_face,clock_v0,0,0,-1 VertexNormal clock_face,clock_v1,0,0,-1 VertexNormal clock_face,clock_v2,0,0,-1 VertexNormal clock_face,clock_v3,0,0,-1 AddTriangle(clock_face,clock_v0,clock_v1,clock_v2) AddTriangle(clock_face,clock_v2,clock_v3,clock_v0) Next End If Return clock_time$ End Function Zum testen folgenden Beispielcode ausführen. Beispiel.bb -Code: [AUSKLAPPEN] Graphics3D 800,800,0,2
SetBuffer BackBuffer() camera=CreateCamera() PositionEntity camera,0,0,0 CameraClsColor camera,64,64,80 Include "Clock3D.bb" size=200 While Not KeyHit(1) If MouseHit(1) a=0 If MouseHit(2) a=1:count=0 size=size-MouseZSpeed()*20 If size>400 size=400 If size<40 size=40 If a=0 t$=Clock3D(MouseX()-400,400-MouseY(),size) If a=1 t$=Clock3D(MouseX()-400,400-MouseY(),size,count):count=count+1 RenderWorld Text 20,20,"LR-Maustasten für Modus" Text 20,40,"Mausrad für Skallierung" If a=0 Text 20,60,"Aktuelle Zeit: "+t If a=1 Text 20,60,"Vorgegebene Zeit: "+t Text 20,80,"Uhrgröße: "+size Flip Wend End - Mit den Maustasten Links/Rechts kann man zwischen aktueller und vorgegebener Zeit wählen. - Vorgegebene Zeit anzeigen lassen; Clock3D( XPos, YPos, Size, Sekunden) - Aktuelle Zeit anzeigen lassen; Clock3D( XPos, YPos, Size ) - Will man keine Uhr mehr anzeigen, so muss einmal Clock3D(0,0,0) angegeben werden. - Es kann nur eine Uhr zur Zeit angezeigt werden. - Wie bei Draw3D muss CreateCamera vor Include ausgedührt werden, und diese muss camera heissen. Kein Plan wie man es sonst ohne Init machen soll? Viel Spaß damit, und sorry The_Nici ist ja eigentlich dein Threat. ![]() |
||
Download der Draw3D2 V.1.1 für schnelle Echtzeiteffekte über Blitz3D |
![]() |
Silver_Knee |
![]() Antworten mit Zitat ![]() |
---|---|---|
Clock3D ohne camera und variablensparend (nur eine Global/keine Locals im <Main program>)Code: [AUSKLAPPEN] ;Clock.V.1.1
;Autor.hectic ;www.hectic.de ;Co-Autor.FTC ;www.FS-COM.com ;Clock-Vorspann Global clock_mesh Function init_clock() Local clock_brush=CreateBrush() Local clock_pixel=CreateTexture(2,2,3) clock_mesh=CreateMesh() WritePixel 0,0,$00ffffff,TextureBuffer(clock_pixel) WritePixel 1,0,$ffffffff,TextureBuffer(clock_pixel) WritePixel 0,1,$00ffffff,TextureBuffer(clock_pixel) WritePixel 1,1,$00ffffff,TextureBuffer(clock_pixel) ScaleTexture clock_pixel,2,2 BrushTexture clock_brush,clock_pixel CreateSurface(clock_mesh,clock_brush) PositionEntity clock_mesh,0,0,GraphicsWidth()/2 EntityOrder clock_mesh,-102 FreeTexture clock_pixel FreeBrush clock_brush EntityFX clock_mesh,3 End Function ;Clock-Funktion Function Clock3D$(f_clock_xp#,f_clock_yp#,f_clock_size#,f_clock_time=-1) If clock_mesh=0 Init_clock() Endif clock_face=getsurface(clock_mesh,1) Local clock_angle% ;Schleifenvariable Local clock_time$ ;Zeitstring Local clock_xp# ;X-Position Local clock_yp# ;Y-Position Local clock_sh% ;Stunden Local clock_sm% ;Minuten Local clock_ss% ;Sekunden ;Zeitvergabe If f_clock_time=-1 clock_time=CurrentTime() Else clock_ss=f_clock_time Mod 60 clock_sm=Floor(f_clock_time/60) Mod 60 clock_sh=Floor(f_clock_time/3600) Mod 24 clock_time=Right("00"+Str(clock_sh),2)+":"+Right("00"+Str(clock_sm),2)+":"+Right("00"+Str(clock_ss),2) End If ;Alles löschen ClearSurface clock_face If f_clock_size>0 ;Ziffernblatt-Zeichnen For clock_angle=1 To 12 clock_xp=Sin(clock_angle*30)*f_clock_size clock_yp=Cos(clock_angle*30)*f_clock_size TFormNormal clock_xp,clock_yp,0,0,0 clock_v0=AddVertex(clock_face,f_clock_xp+clock_xp/2+TFormedY()*f_clock_size/12,f_clock_yp+clock_yp/2-TFormedX()*f_clock_size/12,0, 0.5,0.5) clock_v1=AddVertex(clock_face,f_clock_xp+clock_xp/2-TFormedY()*f_clock_size/12,f_clock_yp+clock_yp/2+TFormedX()*f_clock_size/12,0, 2.5,0.5) clock_v2=AddVertex(clock_face,f_clock_xp+clock_xp-TFormedY()*f_clock_size/12,f_clock_yp+clock_yp+TFormedX()*f_clock_size/12,0, 2.5,0.5) clock_v3=AddVertex(clock_face,f_clock_xp+clock_xp+TFormedY()*f_clock_size/12,f_clock_yp+clock_yp-TFormedX()*f_clock_size/12,0, 0.5,0.5) VertexColor clock_face,clock_v0,240,240,240,0 VertexColor clock_face,clock_v1,240,240,240,0 VertexColor clock_face,clock_v2,240,240,240,.5 VertexColor clock_face,clock_v3,240,240,240,.5 VertexNormal clock_face,clock_v0,0,0,-1 VertexNormal clock_face,clock_v1,0,0,-1 VertexNormal clock_face,clock_v2,0,0,-1 VertexNormal clock_face,clock_v3,0,0,-1 AddTriangle(clock_face,clock_v0,clock_v1,clock_v2) AddTriangle(clock_face,clock_v2,clock_v3,clock_v0) Next ;Zeiger-Stellungen-Festlegen clock_ss=Int(Mid(clock_time,7,2))*6 clock_sm=Int(Mid(clock_time,4,2))*6 clock_sh=Int(Mid(clock_time,1,2))*30+clock_sm/12 ;Stunden-Zeiger-Zeichnen clock_xp=f_clock_xp+Sin(clock_sh)*f_clock_size/1.5 clock_yp=f_clock_yp+Cos(clock_sh)*f_clock_size/1.5 TFormNormal clock_xp-f_clock_xp,clock_yp-f_clock_yp,0,0,0 clock_v0=AddVertex(clock_face,f_clock_xp+TFormedY()*f_clock_size/12,f_clock_yp-TFormedX()*f_clock_size/12,0, 0.5,0.5) clock_v1=AddVertex(clock_face,f_clock_xp-TFormedY()*f_clock_size/12,f_clock_yp+TFormedX()*f_clock_size/12,0, 2.5,0.5) clock_v2=AddVertex(clock_face,clock_xp-TFormedY()*f_clock_size/12,clock_yp+TFormedX()*f_clock_size/12,0, 2.5,0.5) clock_v3=AddVertex(clock_face,clock_xp+TFormedY()*f_clock_size/12,clock_yp-TFormedX()*f_clock_size/12,0, 0.5,0.5) VertexColor clock_face,clock_v0,240,240,120,1 VertexColor clock_face,clock_v1,240,240,120,1 VertexColor clock_face,clock_v2,240,60,60,1 VertexColor clock_face,clock_v3,240,60,60,1 VertexNormal clock_face,clock_v0,0,0,-1 VertexNormal clock_face,clock_v1,0,0,-1 VertexNormal clock_face,clock_v2,0,0,-1 VertexNormal clock_face,clock_v3,0,0,-1 AddTriangle(clock_face,clock_v0,clock_v1,clock_v2) AddTriangle(clock_face,clock_v2,clock_v3,clock_v0) ;Minuten-Zeiger-Zeichnen clock_xp=f_clock_xp+Sin(clock_sm)*f_clock_size/1.25 clock_yp=f_clock_yp+Cos(clock_sm)*f_clock_size/1.25 TFormNormal clock_xp-f_clock_xp,clock_yp-f_clock_yp,0,0,0 clock_v0=AddVertex(clock_face,f_clock_xp+TFormedY()*f_clock_size/18,f_clock_yp-TFormedX()*f_clock_size/18,0, 0.5,0.5) clock_v1=AddVertex(clock_face,f_clock_xp-TFormedY()*f_clock_size/18,f_clock_yp+TFormedX()*f_clock_size/18,0, 2.5,0.5) clock_v2=AddVertex(clock_face,clock_xp-TFormedY()*f_clock_size/18,clock_yp+TFormedX()*f_clock_size/18,0, 2.5,0.5) clock_v3=AddVertex(clock_face,clock_xp+TFormedY()*f_clock_size/18,clock_yp-TFormedX()*f_clock_size/18,0, 0.5,0.5) VertexColor clock_face,clock_v0,240,240,120,1 VertexColor clock_face,clock_v1,240,240,120,1 VertexColor clock_face,clock_v2,240,240,240,1 VertexColor clock_face,clock_v3,240,240,240,1 VertexNormal clock_face,clock_v0,0,0,-1 VertexNormal clock_face,clock_v1,0,0,-1 VertexNormal clock_face,clock_v2,0,0,-1 VertexNormal clock_face,clock_v3,0,0,-1 AddTriangle(clock_face,clock_v0,clock_v1,clock_v2) AddTriangle(clock_face,clock_v2,clock_v3,clock_v0) ;Sekunden-Zeiger-Zeichnen clock_xp=f_clock_xp+Sin(clock_ss)*f_clock_size clock_yp=f_clock_yp+Cos(clock_ss)*f_clock_size TFormNormal clock_xp-f_clock_xp,clock_yp-f_clock_yp,0,0,0 clock_v0=AddVertex(clock_face,f_clock_xp+TFormedY()*f_clock_size/24,f_clock_yp-TFormedX()*f_clock_size/24,0, 0.5,0.5) clock_v1=AddVertex(clock_face,f_clock_xp-TFormedY()*f_clock_size/24,f_clock_yp+TFormedX()*f_clock_size/24,0, 2.5,0.5) clock_v2=AddVertex(clock_face,clock_xp-TFormedY()*f_clock_size/24,clock_yp+TFormedX()*f_clock_size/24,0, 2.5,0.5) clock_v3=AddVertex(clock_face,clock_xp+TFormedY()*f_clock_size/24,clock_yp-TFormedX()*f_clock_size/24,0, 0.5,0.5) VertexColor clock_face,clock_v0,240,240,240,1 VertexColor clock_face,clock_v1,240,240,240,1 VertexColor clock_face,clock_v2,240,240,240,1 VertexColor clock_face,clock_v3,240,240,240,1 VertexNormal clock_face,clock_v0,0,0,-1 VertexNormal clock_face,clock_v1,0,0,-1 VertexNormal clock_face,clock_v2,0,0,-1 VertexNormal clock_face,clock_v3,0,0,-1 AddTriangle(clock_face,clock_v0,clock_v1,clock_v2) AddTriangle(clock_face,clock_v2,clock_v3,clock_v0) ;Deckblatt-Zeichnen For clock_angle=1 To 12 clock_v0=AddVertex(clock_face,f_clock_xp+Sin(clock_angle*30-15)*f_clock_size/6,f_clock_yp+Cos(clock_angle*30-15)*f_clock_size/6,0, 1.5,0.5) clock_v1=AddVertex(clock_face,f_clock_xp+Sin(clock_angle*30+15)*f_clock_size/6,f_clock_yp+Cos(clock_angle*30+15)*f_clock_size/6,0, 1.5,0.5) clock_v2=AddVertex(clock_face,f_clock_xp,f_clock_yp,0, 1.5,0.5) clock_v3=AddVertex(clock_face,f_clock_xp,f_clock_yp,0, 1.5,0.5) VertexColor clock_face,clock_v0,160,160,160,0 VertexColor clock_face,clock_v1,160,160,160,0 VertexColor clock_face,clock_v2,240,240,240,1 VertexColor clock_face,clock_v3,240,240,240,1 VertexNormal clock_face,clock_v0,0,0,-1 VertexNormal clock_face,clock_v1,0,0,-1 VertexNormal clock_face,clock_v2,0,0,-1 VertexNormal clock_face,clock_v3,0,0,-1 AddTriangle(clock_face,clock_v0,clock_v1,clock_v2) AddTriangle(clock_face,clock_v2,clock_v3,clock_v0) Next End If Return clock_time$ End Function Code verbessert. trotzdem nur eine globale |
||
- Zuletzt bearbeitet von Silver_Knee am Mo, Jul 16, 2007 10:56, insgesamt einmal bearbeitet
![]() |
hecticSieger des IS Talentwettbewerb 2006 |
![]() Antworten mit Zitat ![]() |
---|---|---|
Hi FTC, der Sinn mit der Kamera ist ja die Uhr als Child der Kamera zu machen, so dass die Kamera weiterhin frei bewegbar bleibt. Daher müsste man zumindest Init(camera) machen, wo man das Handle der Kamera an die Funktion mit gibt. Auf Init wollte ich aber verzichten, was aber wohl so eine persönliche Meinung ist. Beim ausführen des Codes kommt eine Fehlermeldung, dass Global nur im Hauptprogramm ausgeführt werden darf. Korrigier mal bitte dein Code und setze Global clock_face ausserhalb der init_clock() -Funktion. | ||
Download der Draw3D2 V.1.1 für schnelle Echtzeiteffekte über Blitz3D |
![]() |
Silver_Knee |
![]() Antworten mit Zitat ![]() |
---|---|---|
hi ich hab den code verbessert und ich denke wenn man sowieso eine uhr vor der nase hat brauch man sich auch nicht bewegen ich wollte sowieso mal die einschränkung "eine uhr" verändern und setze mich gleich mal ran... dann aber mit init funktion da man für jede clock ne handle braucht. bis gleich.
EDIT bin wieder da.... und die Clock3D funktion ist nun ultrakompatibel. Man nehme an du willst die alte version vo hectic verwenden. das einzige neue ist das du nach dem ersten verwenden von Clock3D folgendes ins Main prog schreiben musst: Code: [AUSKLAPPEN] EntityParent clock_mesh,camera,0
dabei ist camera deine Kamera (wer hätte das gedacht) willst du nun mehrere 3d-Clocks haben machst du es wie bei allen anderen create-befehlen: Code: [AUSKLAPPEN] clock=CreateClock(parent)
und bei der funktion Clock3d hängst du nurnoch die clock hintan (nach der Zeitvergabe). clock ist dabei ein ganz normales Entity. Drehen, Scalen, Positionieren, alles kein problem. Achso der Code: [AUSKLAPPEN] ;Clock.V.1.1
;Autor.hectic ;www.hectic.de ;Co-Autor.FTC ;www.FS-COM.com ;Standart-Uhr erstellen Function CreateClock(parent=0) Local clock_brush=CreateBrush() Local clock_pixel=CreateTexture(2,2,3) mesh=CreateMesh(parent) WritePixel 0,0,$00ffffff,TextureBuffer(clock_pixel) WritePixel 1,0,$ffffffff,TextureBuffer(clock_pixel) WritePixel 0,1,$00ffffff,TextureBuffer(clock_pixel) WritePixel 1,1,$00ffffff,TextureBuffer(clock_pixel) ScaleTexture clock_pixel,2,2 BrushTexture clock_brush,clock_pixel CreateSurface(mesh,clock_brush) FreeTexture clock_pixel FreeBrush clock_brush EntityFX mesh,3 Return mesh clock_mesh=mesh End Function Global clock_mesh ;Eine Uhr auf ein surface malen Function Clock3D$(f_clock_xp#,f_clock_yp#,f_clock_size#,f_clock_time=-1,mesh=0,special_surf=1) If mesh<>0 clock_mesh=mesh EndIf If clock_mesh=0 clock_mesh=CreateClock() PositionEntity clock_mesh,0,0,GraphicsWidth()/2 EndIf clock_face=GetSurface(clock_mesh,special_surf) Local clock_angle% ;Schleifenvariable Local clock_time$ ;Zeitstring Local clock_xp# ;X-Position Local clock_yp# ;Y-Position Local clock_sh% ;Stunden Local clock_sm% ;Minuten Local clock_ss% ;Sekunden ;Zeitvergabe If f_clock_time=-1 clock_time=CurrentTime() Else clock_ss=f_clock_time Mod 60 clock_sm=Floor(f_clock_time/60) Mod 60 clock_sh=Floor(f_clock_time/3600) Mod 24 clock_time=Right("00"+Str(clock_sh),2)+":"+Right("00"+Str(clock_sm),2)+":"+Right("00"+Str(clock_ss),2) End If ;Alles löschen ClearSurface clock_face If f_clock_size>0 ;Ziffernblatt-Zeichnen For clock_angle=1 To 12 clock_xp=Sin(clock_angle*30)*f_clock_size clock_yp=Cos(clock_angle*30)*f_clock_size TFormNormal clock_xp,clock_yp,0,0,0 clock_v0=AddVertex(clock_face,f_clock_xp+clock_xp/2+TFormedY()*f_clock_size/12,f_clock_yp+clock_yp/2-TFormedX()*f_clock_size/12,0, 0.5,0.5) clock_v1=AddVertex(clock_face,f_clock_xp+clock_xp/2-TFormedY()*f_clock_size/12,f_clock_yp+clock_yp/2+TFormedX()*f_clock_size/12,0, 2.5,0.5) clock_v2=AddVertex(clock_face,f_clock_xp+clock_xp-TFormedY()*f_clock_size/12,f_clock_yp+clock_yp+TFormedX()*f_clock_size/12,0, 2.5,0.5) clock_v3=AddVertex(clock_face,f_clock_xp+clock_xp+TFormedY()*f_clock_size/12,f_clock_yp+clock_yp-TFormedX()*f_clock_size/12,0, 0.5,0.5) VertexColor clock_face,clock_v0,240,240,240,0 VertexColor clock_face,clock_v1,240,240,240,0 VertexColor clock_face,clock_v2,240,240,240,.5 VertexColor clock_face,clock_v3,240,240,240,.5 VertexNormal clock_face,clock_v0,0,0,-1 VertexNormal clock_face,clock_v1,0,0,-1 VertexNormal clock_face,clock_v2,0,0,-1 VertexNormal clock_face,clock_v3,0,0,-1 AddTriangle(clock_face,clock_v0,clock_v1,clock_v2) AddTriangle(clock_face,clock_v2,clock_v3,clock_v0) Next ;Zeiger-Stellungen-Festlegen clock_ss=Int(Mid(clock_time,7,2))*6 clock_sm=Int(Mid(clock_time,4,2))*6 clock_sh=Int(Mid(clock_time,1,2))*30+clock_sm/12 ;Stunden-Zeiger-Zeichnen clock_xp=f_clock_xp+Sin(clock_sh)*f_clock_size/1.5 clock_yp=f_clock_yp+Cos(clock_sh)*f_clock_size/1.5 TFormNormal clock_xp-f_clock_xp,clock_yp-f_clock_yp,0,0,0 clock_v0=AddVertex(clock_face,f_clock_xp+TFormedY()*f_clock_size/12,f_clock_yp-TFormedX()*f_clock_size/12,0, 0.5,0.5) clock_v1=AddVertex(clock_face,f_clock_xp-TFormedY()*f_clock_size/12,f_clock_yp+TFormedX()*f_clock_size/12,0, 2.5,0.5) clock_v2=AddVertex(clock_face,clock_xp-TFormedY()*f_clock_size/12,clock_yp+TFormedX()*f_clock_size/12,0, 2.5,0.5) clock_v3=AddVertex(clock_face,clock_xp+TFormedY()*f_clock_size/12,clock_yp-TFormedX()*f_clock_size/12,0, 0.5,0.5) VertexColor clock_face,clock_v0,240,240,120,1 VertexColor clock_face,clock_v1,240,240,120,1 VertexColor clock_face,clock_v2,240,60,60,1 VertexColor clock_face,clock_v3,240,60,60,1 VertexNormal clock_face,clock_v0,0,0,-1 VertexNormal clock_face,clock_v1,0,0,-1 VertexNormal clock_face,clock_v2,0,0,-1 VertexNormal clock_face,clock_v3,0,0,-1 AddTriangle(clock_face,clock_v0,clock_v1,clock_v2) AddTriangle(clock_face,clock_v2,clock_v3,clock_v0) ;Minuten-Zeiger-Zeichnen clock_xp=f_clock_xp+Sin(clock_sm)*f_clock_size/1.25 clock_yp=f_clock_yp+Cos(clock_sm)*f_clock_size/1.25 TFormNormal clock_xp-f_clock_xp,clock_yp-f_clock_yp,0,0,0 clock_v0=AddVertex(clock_face,f_clock_xp+TFormedY()*f_clock_size/18,f_clock_yp-TFormedX()*f_clock_size/18,0, 0.5,0.5) clock_v1=AddVertex(clock_face,f_clock_xp-TFormedY()*f_clock_size/18,f_clock_yp+TFormedX()*f_clock_size/18,0, 2.5,0.5) clock_v2=AddVertex(clock_face,clock_xp-TFormedY()*f_clock_size/18,clock_yp+TFormedX()*f_clock_size/18,0, 2.5,0.5) clock_v3=AddVertex(clock_face,clock_xp+TFormedY()*f_clock_size/18,clock_yp-TFormedX()*f_clock_size/18,0, 0.5,0.5) VertexColor clock_face,clock_v0,240,240,120,1 VertexColor clock_face,clock_v1,240,240,120,1 VertexColor clock_face,clock_v2,240,240,240,1 VertexColor clock_face,clock_v3,240,240,240,1 VertexNormal clock_face,clock_v0,0,0,-1 VertexNormal clock_face,clock_v1,0,0,-1 VertexNormal clock_face,clock_v2,0,0,-1 VertexNormal clock_face,clock_v3,0,0,-1 AddTriangle(clock_face,clock_v0,clock_v1,clock_v2) AddTriangle(clock_face,clock_v2,clock_v3,clock_v0) ;Sekunden-Zeiger-Zeichnen clock_xp=f_clock_xp+Sin(clock_ss)*f_clock_size clock_yp=f_clock_yp+Cos(clock_ss)*f_clock_size TFormNormal clock_xp-f_clock_xp,clock_yp-f_clock_yp,0,0,0 clock_v0=AddVertex(clock_face,f_clock_xp+TFormedY()*f_clock_size/24,f_clock_yp-TFormedX()*f_clock_size/24,0, 0.5,0.5) clock_v1=AddVertex(clock_face,f_clock_xp-TFormedY()*f_clock_size/24,f_clock_yp+TFormedX()*f_clock_size/24,0, 2.5,0.5) clock_v2=AddVertex(clock_face,clock_xp-TFormedY()*f_clock_size/24,clock_yp+TFormedX()*f_clock_size/24,0, 2.5,0.5) clock_v3=AddVertex(clock_face,clock_xp+TFormedY()*f_clock_size/24,clock_yp-TFormedX()*f_clock_size/24,0, 0.5,0.5) VertexColor clock_face,clock_v0,240,240,240,1 VertexColor clock_face,clock_v1,240,240,240,1 VertexColor clock_face,clock_v2,240,240,240,1 VertexColor clock_face,clock_v3,240,240,240,1 VertexNormal clock_face,clock_v0,0,0,-1 VertexNormal clock_face,clock_v1,0,0,-1 VertexNormal clock_face,clock_v2,0,0,-1 VertexNormal clock_face,clock_v3,0,0,-1 AddTriangle(clock_face,clock_v0,clock_v1,clock_v2) AddTriangle(clock_face,clock_v2,clock_v3,clock_v0) ;Deckblatt-Zeichnen For clock_angle=1 To 12 clock_v0=AddVertex(clock_face,f_clock_xp+Sin(clock_angle*30-15)*f_clock_size/6,f_clock_yp+Cos(clock_angle*30-15)*f_clock_size/6,0, 1.5,0.5) clock_v1=AddVertex(clock_face,f_clock_xp+Sin(clock_angle*30+15)*f_clock_size/6,f_clock_yp+Cos(clock_angle*30+15)*f_clock_size/6,0, 1.5,0.5) clock_v2=AddVertex(clock_face,f_clock_xp,f_clock_yp,0, 1.5,0.5) clock_v3=AddVertex(clock_face,f_clock_xp,f_clock_yp,0, 1.5,0.5) VertexColor clock_face,clock_v0,160,160,160,0 VertexColor clock_face,clock_v1,160,160,160,0 VertexColor clock_face,clock_v2,240,240,240,1 VertexColor clock_face,clock_v3,240,240,240,1 VertexNormal clock_face,clock_v0,0,0,-1 VertexNormal clock_face,clock_v1,0,0,-1 VertexNormal clock_face,clock_v2,0,0,-1 VertexNormal clock_face,clock_v3,0,0,-1 AddTriangle(clock_face,clock_v0,clock_v1,clock_v2) AddTriangle(clock_face,clock_v2,clock_v3,clock_v0) Next End If Return clock_time$ End Function |
||
Übersicht


Powered by phpBB © 2001 - 2006, phpBB Group