Leveleditor - Problem...

Übersicht BlitzBasic Blitz3D

Neue Antwort erstellen

AmateurBB

Betreff: Leveleditor - Problem...

BeitragSa, Aug 04, 2007 21:09
Antworten mit Zitat
Benutzer-Profile anzeigen
Hi!

Ich hab vor kurzem angefangen einen Leveleditor für Blitz3D zu Programmieren. Leider werden die Skalierwerte der Objekte nicht gespeichert. Da ich nicht weiß, warum, bitte ich euch um eure Hilfe Wink

Hier Code + Bilder downloaden...

Hier ist der Code vom Editor, aber es fehlen eben Bilder etc.

Code: [AUSKLAPPEN]

graphics3d 1280, 800
setbuffer backbuffer()

DIM mshnme$(1000)
DIM sx#(1000)
DIM sy#(1000)
DIM sz#(1000)
DIM rx#(1000)
DIM ry#(1000)
DIM rz#(1000)
DIM px#(1000)
DIM py#(1000)
DIM pz#(1000)
Dim msh(1000)

camera = createcamera()
PositionEntity camera,100,15,900
camerarange camera, 1, 100

light = createlight()

terrain = loadterrain("hmp.bmp")
TerrainDetail terrain,4000,True
ScaleEntity terrain,1,50,1
Terrainshading terrain, 1
Entitytexture terrain, loadtexture("grid.bmp", 256+2)
Ambientlight 255, 255, 255
EntityPickMode terrain, 2

fkimg=loadimage("fk.bmp")
MidHandle fkimg
ctrl=loadImage("ctrl.bmp")
MaskImage ctrl, 255, 0, 255

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


o = 0
obj=ReadFILE("objekte.txt")
 While not Eof(obj)
  o = o + 1
  mshnme$(o)=ReadLine$(obj)
  sx#(o)=readINT (obj)
  sy#(o)=readINT (obj)
  sz#(o)=readINT (obj)
  rx#(o)=readINT (obj)
  ry#(o)=readINT (obj)
  rz#(o)=readINT (obj)
  px#(o)=readINT (obj)
  py#(o)=readINT (obj)
  pz#(o)=readINT (obj)
   msh(o)=LoadMesh(mshnme$(o))
  ScaleEntity msh(o), sx#(o), sy#(o), sz#(o)
  RotateEntity msh(o), rx#(o), ry#(o), rz#(o)
  PositionEntity msh(o), px#(o), py#(o), pz#(o)
  EntityType msh(o), 2
  EntityPickMode msh(o), 2
 Wend
closefile obj

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  ;nmsh=LoadMesh(nent$)
  ;ScaleEntity nmsh, nsx#, nsy#, nsz#
  ;RotateEntity nmsh, nrx#, nry#, nrz#
  ;PositionEntity nmsh, npx#, npy#, npz#
   nmsh=msh(1)
   nsx#=sx#(1)
   nsy#=sy#(1)
   nsz#=sz#(1)
   npx#=px#(1)
   npy#=py#(1)
   npz#=pz#(1)
   nrx#=rx#(1)
   nry#=ry#(1)
   nrz#=rz#(1)
   nmshnme$=mshnme$(1)
   curr = 1

MoveMouse GraphicsWidth()/2, GraphicsHeight()/2
while not keyhit(28)
EntityColor nmsh, 255, 64, 64
;b# = b# + 2
;a# = SIN(b#)*64+128

if keydown(200) moveentity camera, 0, 0, 1
if keydown(208) moveentity camera, 0, 0, -1
if keydown(42) g# = .1 else g# = 1
if keydown(30) npx# = npx# - g#
if keydown(32) npx# = npx# + g#
if keydown(31) npz# = npz# - g#
if keydown(17) npz# = npz# + g#
if keydown(44) npy# = npy# - g#/10
if keydown(45) npy# = npy# + g#/10
if keydown(2) nry# = nry# - g#
if keydown(3) nry# = nry# + g#
if keydown(4) nrx# = nrx# - g#
if keydown(5) nrx# = nrx# + g#
if keydown(6) nrz# = nrz# - g#
if keydown(7) nrz# = nrz# + g#
if keydown(59) Entitytexture terrain, loadtexture("grid.bmp", 256+2): EntityAlpha terrain, 1
if keydown(60) Entitytexture terrain, loadtexture("grasgrid2.bmp"): EntityAlpha terrain, 0.8
if keydown(61) Entitytexture terrain, loadtexture("gras.bmp"): EntityAlpha terrain, 1
if keydown(36) nsx# = nsx# + g#/100
if keydown(38) nsx# = nsx# - g#/100
if keydown(23) nsz# = nsz# + g#/100
if keydown(50) nsz# = nsz# - g#/100
if keydown(51) nsy# = nsy# + g#/100
if keydown(52) nsy# = nsy# - g#/100
if keyhit(16) wf = 1 - wf
wireframe wf

If Keydown(15)

 ins$=INPUT("Welches Objekt einfügen?")
 test=LoadMesh(ins$)
 if test<>0 then
  o = o + 1
   sx#(o) = 1
   sy#(o) = 1
   sz#(o) = 1
   px#(o) = EntityX#(camera)
   py#(o) = Entityy#(camera)
   pz#(o) = Entityz#(camera)

   mshnme$(o)=ins$
  msh(o)=LoadMesh(mshnme$(o))
  ScaleEntity msh(o), sx#(o), sy#(o), sz#(o)
  RotateEntity msh(o), rx#(o), ry#(o), rz#(o)
  PositionEntity msh(o), px#(o), py#(o), pz#(o)
  EntityType msh(o), 2
  EntityPickMode msh(o), 2
 endif
 freeentity test
 flushkeys
endif


If keydown(29) then
   fk = 1
   CameraPick (camera, graphicsWidth()/2, graphicsheight()/2)
   picked = pickedentity()
   For u = 1 to o
      if msh(u) = picked then
        if msh(curr) <> msh(u) then
            EntityColor nmsh, 255, 255, 255
            msh(curr)=nmsh
            sx#(curr)=nsx#
            sy#(curr)=nsy#
            sz#(curr)=nsz#
            px#(curr)=npx#
            py#(curr)=npy#
            pz#(curr)=npz#
            rx#(curr)=nrx#
            ry#(curr)=nry#
            rz#(curr)=nrz#
            mshnme$(curr)=nmshnme$
            curr = u
            name$ = mshnme$(u)
            nmsh=msh(u)
            nsx#=sx#(u)
            nsy#=sy#(u)
            nsz#=sz#(u)
            npx#=px#(u)
            npy#=py#(u)
            npz#=pz#(u)
            nrx#=rx#(u)
            nry#=ry#(u)
            nrz#=rz#(u)
            nmshnme$=mshnme$(u)
         Endif   
      endif

   next
   if terrain = picked then name$ = "Terrain"
   if picked = 0 then name$ = "<nothing>"
else
   fk = 0
endif


ScaleEntity nmsh, nsx#, nsy#, nsz#
RotateEntity nmsh, nrx#, nry#, nrz#
PositionEntity nmsh, npx#, npy#, npz#

;if keydown(200) moveentity camera, 0, 1, 0
if keydown(1) END

x = x + MouseYSpeed()
If x > 360 then x = x - 360
If x < -360 then x = x + 360
y = y - MouseXSpeed()
If y > 360 then y = y - 360
If y < -360 then y = y + 360
RotateEntity camera, x, y, 0
MoveMouse GraphicsWidth()/2, GraphicsHeight()/2
RENDERWORLD
Text 1, 20, name$

if fk=1 DrawImage fkimg, graphicsWidth()/2, GraphicsHeight()/2
DrawImage ctrl, 0, GraphicsHeight()-50

Flip
wend

            msh(curr)=nmsh
            sx#(curr)=nsx#
            sy#(curr)=nsy#
            sz#(curr)=nsz#
            px#(curr)=npx#
            py#(curr)=npy#
            pz#(curr)=npz#
            rx#(curr)=nrx#
            ry#(curr)=nry#
            rz#(curr)=nrz#
            mshnme$(curr)=nmshnme$


obj=WriteFILE("objekte.txt")

For w = 1 to o
WriteLine obj, mshnme$(w)
WriteINT obj, sx#(w)
WriteINT obj, sy#(w)
WriteINT obj, sz#(w)
WriteINT obj, rx#(w)
WriteINT obj, ry#(w)
WriteINT obj, rz#(w)
WriteINT obj, px#(w)
WriteINT obj, py#(w)
WriteINT obj, pz#(w)
next

;WriteLine obj, nent$
;WriteINT obj, nsx
;WriteINT obj, nsy
;WriteINT obj, nsz
;WriteINT obj, nrx
;WriteINT obj, nry
;WriteINT obj, nrz
;WriteINT obj, npx
;WriteINT obj, npy
;WriteINT obj, npz
closefile obj

peacemaker

BeitragSo, Aug 05, 2007 18:23
Antworten mit Zitat
Benutzer-Profile anzeigen
Ich habs mir den Code nicht durchgelesen, aber koennte GetMatElement (http://blitzbase.de/befehle3d/getmatelement.htm) , das sein was du suchst?

MfG
~Tehadon~
www.tehadon.de
http://www.blitzforum.de/worklogs/14/

AmateurBB

Betreff: Leider nein...

BeitragSo, Aug 05, 2007 19:31
Antworten mit Zitat
Benutzer-Profile anzeigen
Leider stimmt der Befehl nicht für das, was ich brauche.

Position, Drehung und Skalierung sollen in der Datei "objekte.txt" gespeichert werden. Das funktioniert auch, außer das die Skalierung aus der Reihe tanzt und ich wies nicht wieso Sad
Notebook Medion 97400 | 2 Ghz | 2x ATI Radeon XPRESS 200M (onboard) | Blitz3D 1.86 | Windows 7 / Windows XP | http://www.powerswitch-entertainment.de.vu/

Xeres

Moderator

BeitragSo, Aug 05, 2007 19:46
Antworten mit Zitat
Benutzer-Profile anzeigen
Warum ließt und schreibst du Interger wenn du Float verwendest Question
Bisschen Kommentar zu dem Code wäre da hilfreich.... bzw. nur den nötigen, nicht den ganzen Wust.
Win10 Prof.(x64)/Ubuntu 16.04|CPU 4x3Ghz (Intel i5-4590S)|RAM 8 GB|GeForce GTX 960
Wie man Fragen richtig stellt || "Es geht nicht" || Video-Tutorial: Sinus & Cosinus
T
HERE IS NO FAIR. THERE IS NO JUSTICE. THERE IS JUST ME. (Death, Discworld)

AmateurBB

Betreff: Ich bin so dämlich...

BeitragSo, Aug 05, 2007 20:16
Antworten mit Zitat
Benutzer-Profile anzeigen
Na super, ich bin so ein *BEEP*! Thx für eure hilfe Wink
Notebook Medion 97400 | 2 Ghz | 2x ATI Radeon XPRESS 200M (onboard) | Blitz3D 1.86 | Windows 7 / Windows XP | http://www.powerswitch-entertainment.de.vu/

Neue Antwort erstellen


Übersicht BlitzBasic Blitz3D

Gehe zu:

Powered by phpBB © 2001 - 2006, phpBB Group