3d model

Previous topic - Next topic

mars_chaos89

how can i load many 'X' without deleating the old 1...i still cant make the plane model and the 'x' to be call togther...

Cliff3D

#61
Quote from: mars_chaos89 on 2010-Sep-23
how can i load many 'X' without deleating the old 1...i still cant make the plane model and the 'x' to be call togther...

You wouldn't need to load many X's - keep an array of the position of x's and resuse the X ddd. Psuedo-code:


local numXs%=0, Xx#[],Xy[],Xz[]


mainloop:
  draw plane
  if numXs%>0
    for temp% = 1 to numXs%
      draw X
        Move model
    next
   showscreen
   goto mainloop

Something like that ought to do you?

Sadly 3D Convert makes the same size .ddd out of a .obj with no normals or uv - and GLBasic takes the same time to load it :(

But it was worth trying. 30 minutes looks like the best you're going tog et unless Gernot can speed up the 3d routines somehow.

The X's could even be just a square with "X" painted on it - it could be done all in code, no need for a .ddd if you wanted to go that way (I would use a painted texture on a square, myself).

Your function (mark) would want to REDIM the array of X,Y,Z co-ordinates and increase the "X" counter.

mars_chaos89

#62
can i put this in a function( mark() )?

this is how i call for a new file...each time the user push[ ctrl+ n] they will be able to select a file to load...

function newfile:

   SETCURRENTDIR( "./3d/" )

   cmdline$=REPLACE$(cmdline$,   "\\", "/")
   splitpath(cmdline$,argv$[])

   IF LEN(argv$[])>1
      args$ = argv$[1]
   ENDIF

   filefull$=removequotes$(args$)
   IF args$<>""
      filename$= removeextension$(args$)
   ELSE
      filefull$=FILEREQUEST$(TRUE,"GLBasic .ddd, .dda, .ddw|*.ddd;*.dda;*.ddw")
      filename$= removeextension$(filefull$)
   ENDIF

   starttimesec# = GETTIMERALL()
   starttimemin# = GETTIMERALL()
   starttimehour# = GETTIMERALL()

   X_LOADOBJ filefull$, 1
   usetexture=-1
   IF DOESFILEEXIST(filename$+".bmp")
      usetexture=1
      LOADSPRITE filename$+".bmp", 1
   ENDIF
   IF DOESFILEEXIST(filename$+".png")
      usetexture=1
      LOADSPRITE filename$+".png", 1
   ENDIF

endfunction

this is the function mark..where i want the user to push [m] button when they want to put the 'X'...so each time they push the button a new 'X' is appear but unfortunately i still stuck here....

function mark:

        markfile$ = "xmark2.ddd"
   X_LOADOBJ markfile$, 2
   X_DRAWOBJ 2, 0

endfunction

this is as far i am writing the coding write for now....
is it possible to do something like this?

mars_chaos89

how to load two 3d model at the same tyme?


mars_chaos89

ok tq cliff..then i try to draw the two object...i get the plane...but there is no cross appeared...

i try i simple coding to call the cross which is..

x_make3d 1,100000,45
x_loadobj "xmark.ddd", 2
x_drawobj 2,0


the model isnt appeared too...

is the problem lies in my coding or the model?

Kitty Hello

100000 for the far plane is way too much, too. Go as low as you can go to avoid z-fighting.

mars_chaos89

that is for my plane model...the model is big so it need that much z to be able to see it....

Cliff3D

#68
Quote from: Kitty Hello on 2010-Oct-01
100000 for the far plane is way too much, too. Go as low as you can go to avoid z-fighting.

Quote from: mars_chaos89 on 2010-Oct-01
that is for my plane model...the model is big so it need that much z to be able to see it....

The airplane model is huge - here's a quote from the model file itself:

Quote# Bounding box of geometry = (-19218.7,-16685.4,-7419.58) to (20802.8,12470.8,2988.05).

so in the tens of thousands in every direction.

Two things come to mind. Scale down the model prior to converting it to .ddd (I can help with this if needed). This will, of course, change the model.

Alternatively, perhaps the X_SCALING command will help - I can't display the plane in 3D at present because I am using the demo version of GLBasic, but I can use the X_SCALING command in general to resize the model I AM viewing. This might help you, and be quicker and easier. The following code uses my .OBJ model library as it currently stands just to get some scaling information from the model/s, but you should be able to see what's going on (I hope!). It also deomstrated viewing multpiple OBJects at once.

Code (glbasic) Select
LOCAL modelheight#, modelwidth#, modeldepth#, modelxcentre#, modelycentre#, modelzcentre#
modelwidth#=MyOBJModel.maxX#-MyOBJModel.minX#
modelheight#=MyOBJModel.maxY#-MyOBJModel.minY#
modeldepth#=MyOBJModel.maxZ#-MyOBJModel.minZ#

myscale#=modelwidth#
modelxcentre#=MyOBJModel.minX#+(modelwidth#/2)
modelycentre#=MyOBJModel.minY#+(modelheight#/2)
modelzcentre#=MyOBJModel.minZ#+(modeldepth#/2)

IF modelheight#>myscale# THEN myscale#=modelheight#
IF modeldepth#>myscale# THEN myscale#=modeldepth#

myscale#=65.0/myscale#

LOCAL mousestatex, mousestatey, mousebutton1, mousebutton2
MOUSESTATE mousestatex, mousestatey, mousebutton1, mousebutton2
WHILE mousebutton1 + mousebutton2 <> 0
MOUSESTATE mousestatex, mousestatey, mousebutton1, mousebutton2
WEND
//glbeep(RND(205)+50,200)
WHILE mousebutton1 + mousebutton2 = 0
phi=phi+GETTIMER()/20

X_MAKE3D 1, 2500, 45
X_CAMERA 0,0, 120,0, 0 ,0

X_SCALING myscale#, myscale#, myscale#

FOR curXobject% = 1 TO numXobjects%
X_SETTEXTURE myTex%, myBump%
X_CULLMODE -1 // 0 = don't cull, 1 = only draw 'front', -1 = only draw 'back' (front and back as defined by GLBasic's interpretation of winding order)
X_MOVEMENT 0.0 - (modelxcentre# * myscale#) , 0.0 - (modelycentre# * myscale#), 0.0
X_ROTATION phi, 0, 1, 0
X_DRAWOBJ curXobject%, 0
NEXT
X_MAKE2D
PRINT "PRESS MOUSE BUTTON TO CONTINUE",140,460
SHOWSCREEN

MOUSESTATE mousestatex, mousestatey, mousebutton1, mousebutton2
WEND


Although I'm not using .ddd files but .OBJ files, the differences should be minimal. Note that I haven't fixed whatever my "centering" problem is, along the X and Y axes, but that shouldn't detract from being able to see how and where to put some scaling in to reduce the size of the airplane model "live" IMHO.

mars_chaos89

tq2 :booze:....i manage successfully load two 3d model but there something that making me confuse...

can i used x_movement together with x_scaling?
and is there an order that we need to follow in order to used this two command?
such as we need to called x_movement 1st then can we call x_scaling....as far as i know and read we need to used x_scaling before x_rotation....

Kitty Hello

you can combime all of them. Just be sure to know that x_scaling and x_movement will drop any x_rotation. Thus, first scale/move then rotate.

mars_chaos89

tq2....how can i make the model to move and follow the mouse??sorry if the question confused you guys because i dont know how to ask this...

right now this is all i have achieved....

moustate x,y,mbr,mbl

  if mbr=true

        //i dont have any idea right now how can i write the coding here

  endif

can you guys help me with this...

Kitty Hello

the mouse coordinates are 2D, the model is drawn in 3D. You need a Z- value for your mouse.
With X_SCREEN2WORLD you can transform the mouse position into 3D positions.

mars_chaos89

tq2....i will look at it immediately...

mars_chaos89

as im looking at x_world2screen..i saw another command which is x_screen2world...im a bit confused here...what is the different between this two command?and which 1 should i use?