some idea would really help me...

Previous topic - Next topic

mars_chaos89

i have reach this point...

Code (glbasic) Select
TYPE coord
      x
      y
      z
ENDTYPE

   GLOBAL xmark[] AS coord
   DIM xmark[10]

   MOUSESTATE x,y,mbl,mbr

   xmark.x = x
   xmark.y = y
   xmark.z = z

       // load the x mark

main:

   WHILE TRUE
      MOUSESTATE x,y,mbl,mbr
     
   //   make3ddonut()
     

      make3dmarking(i)
     
   
      SHOWSCREEN

   WEND

END

FUNCTION make3dmarking:m

      MOUSESTATE x,y,mbl,mbr
      X_MAKE3D 1,10000,45
      X_CAMERA 10,0,0,   0,0,0



      IF KEY(45)=TRUE               //x
         dirx=(dirx-KEY(203))
         dirx=(dirx+KEY(205))
      ENDIF
      IF KEY(44)=TRUE               //z
         dirz=(dirz-KEY(208))
         dirz=(dirz+KEY(200))
      ENDIF
      IF KEY(21)=TRUE               //y
         diry=(diry+KEY(200))
         diry=(diry-KEY(208))
      ENDIF

      X_MOVEMENT dirz, diry, dirx

         IF mbl=TRUE
            X_SCREEN2WORLD x,y,0,   wx,wy,wz
         ENDIF
         
      X_MOVEMENT wx,wy,wz
      X_SCALING 0.04,0.04,0.04
      X_ROTATION 90, 0,1,0

      X_DRAWOBJ m,0

      X_MAKE2D
      PRINT "xmark(1) :   x ="+ wx + " , y ="+ wy + " , z ="+ wz, 100,200
ENDFUNCTION


at the moment i try to draw 10 'x' that why the dimension is 10....
let say i want to use just a constraint first rather than jumping directly to what i have plan for my application...
so i just try to make the xmark is drawn only when the "m" button is pressed...so i have tried :

a)
Code (glbasic) Select
if key(50)=true
     make3dmarking(n)
endif


this command work but the xmark only appear when the "m" button is pressed and hold...if the we release the button, the xmark will disappear...so there will only be 1 'x'..

b)

Code (glbasic) Select
if key(50)= true
  i=i+1
endif

make3dmarking(i)

i execute this but nothing appeared...

this is as far i get right now...im still trying...any help?

matchy

mars_chaos89, I wrote that code for you mate. Tell me you missed it!

mars_chaos89

i hav try execute the code..but it some error occur....

Code (glbasic) Select
CONSTANT KEY_SPACE=57
CONSTANT KEY_X=45
CONSTANT KEY_Y=21
CONSTANT KEY_Z=44
CONSTANT KEY_LEFT=203
CONSTANT KEY_RIGHT=205
CONSTANT KEY_UP=200
CONSTANT KEY_DOWN=208


ti show that the error is here.....

matchy

That's odd. Please post the error!

mars_chaos89

"3d selection.gbas"(23) error : syntax error

this is the error....

matchy

CONSTANT seems to work fine with compiling with me. Besides, they only declare the key-codes and is irrelevant to the issue. By now you should have changed them to GLOBAL for now.

I've attached the project source with an exe:   ;)

[attachment deleted by admin]

mars_chaos89

#21
i have changed it but something else happen...


C:\DOCUME~1\CBM\LOCALS~1\Temp\glbasic\gpc_temp0.cpp: In function `DGInt __GLBASIC__::input_calc()':
C:\DOCUME~1\CBM\LOCALS~1\Temp\glbasic\gpc_temp0.cpp:363: error: no matching function for call to `INC(DGInt&)'
C:\DOCUME~1\CBM\LOCALS~1\Temp\glbasic\gpc_temp0.cpp:394: error: no matching function for call to `DEC(DGInt&)'
C:\DOCUME~1\CBM\LOCALS~1\Temp\glbasic\gpc_temp0.cpp:407: error: no matching function for call to `INC(DGInt&)'
C:\DOCUME~1\CBM\LOCALS~1\Temp\glbasic\gpc_temp0.cpp:422: error: no matching function for call to `DEC(DGInt&)'
C:\DOCUME~1\CBM\LOCALS~1\Temp\glbasic\gpc_temp0.cpp:435: error: no matching function for call to `INC(DGInt&)'
C:\DOCUME~1\CBM\LOCALS~1\Temp\glbasic\gpc_temp0.cpp:454: error: no matching function for call to `DEC(DGInt&)'
C:\DOCUME~1\CBM\LOCALS~1\Temp\glbasic\gpc_temp0.cpp:467: error: no matching function for call to `INC(DGInt&)'



this error come up..


i also have see what your program do...but that not exactly what i want to do...

Code (glbasic) Select
SYSTEMPOINTER TRUE
SETSCREEN 900,700,TRUE

TYPE coord
x
y
z
ENDTYPE

GLOBAL xmark[] AS coord
DIM xmark[10]

MOUSESTATE x,y,mbl,mbr

xmark[i].x = x
xmark[i].y = y
xmark[i].z = z

n=0
LOADSPRITE "../../3d viewer v2/3d viewer v2.app/donut.bmp", 1
X_LOADOBJ "../../3d viewer v2/3d viewer v2.app/donut.ddd", 1
X_LOADOBJ "../xmark.ddd",m


main:

WHILE TRUE
MOUSESTATE x,y,mbl,mbr

// make3ddonut()
make3dmarking(n)

GETSCREENSIZE width,height
centerx = width/2
centery = height/2
PRINT "x="+ x, 100,100
PRINT "y="+ y, 100,120
PRINT "width ="+ width, 100,140
PRINT "height ="+ height, 100,160
PRINT "center point = "+ centerx + " , " + centery, 100,180
PRINT "xmark(" + m +") : x ="+ xmark[m].x + " , y ="+ xmark[m].y + " , z ="+ xmark[m].z, 100,220

SHOWSCREEN

WEND

END

FUNCTION make3dmarking:m

MOUSESTATE x,y,mbl,mbr


X_MAKE3D 1,10000,45
X_CAMERA 10,0,0, 0,0,0


IF KEY(45)=TRUE //x
dirx=(dirx-KEY(203))
dirx=(dirx+KEY(205))
ENDIF
IF KEY(44)=TRUE //z
dirz=(dirz-KEY(208))
dirz=(dirz+KEY(200))
ENDIF
IF KEY(21)=TRUE //y
diry=(diry+KEY(200))
diry=(diry-KEY(208))
ENDIF

X_MOVEMENT dirz, diry, dirx

IF mbl=TRUE
X_SCREEN2WORLD x,y,0, wx,wy,wz
xmark[m].x=wx
xmark[m].y=wy
xmark[m].z=wz
ENDIF

X_MOVEMENT wx,wy,wz
X_SCALING 0.04,0.04,0.04
X_ROTATION 90, 0,1,0

X_DRAWOBJ m,0

X_MAKE2D
PRINT "xmark(1) : x ="+ wx + " , y ="+ wy + " , z ="+ wz, 100,200
//PRINT "xmark(" + m +") : x ="+ xmark[m].x + " , y ="+ xmark[m].y + " , z ="+ xmark[m].z, 100,220


ENDFUNCTION

FUNCTION make3ddonut:

INC phi, MOUSEAXIS(0)

X_MAKE3D 1,10000,45
X_CAMERA 10,0,0, 0,0,0
X_SCALING 0.1,0.1,0.1
X_ROTATION phi, 0,1,0

X_SETTEXTURE 1, -1
X_DRAWOBJ 1,0

ENDFUNCTION


this is my full code...what i want to do is put the 'x' mark on that donut model as many as we want...and save it...


[attachment deleted by admin]

Cliff3D

#22
At http://www.glbasic.com/forum/index.php?topic=4738.msg35786#msg35786 there's a really helpful post about a flow diagram program (free!) which might help find where the problem in your logic is. I'm stuck on a netbook at the moment which is not the very best for studying someone else's code on :( but based on previous posts it looks like you're not fully "getting" the way you need to pull the 3D model, the concept of an array of marker positions, the keypresses, and a disply loop (that displays the aircraft/doughnut, all previous X marks, and the current "floating" X mark) together.

I doubt I could draw a good chart using this screen either, but here's my thoughts in a "level at a time" manner.

First you have to decalre all your variables and set them to useful/default values.

In the outside / main loop you should display your main model. If any X's have been set you should display those. If an X has been activated but not fixed in place you should display it (differently to fixed X's IMHO).

Within the loop, either before or after displaying, you should check for keypresses. If the key is "make an X" then increase the number of X's, set the initial position of the new X.

ELSE If the key is a "move X" key then change the position of the current/last X mark.

ELSE If the key is a "set X position" then deal with that event (may be the same as the "create new X key, in which case this doesn't need writing).

ELSE If the key is a camera movement key then move the camera.

At the moment, although this may be partly because I can see so little code at a time on this tiny screen, I can't see how you are displaying all the pre-set X's as you think about setting a new one. Apologies if it's all present and correct and I am just failing to see it :(

A flowchart might be easier to study, and might enlighten you as to where things are going wrong as you create the chart anyway :D