Post Reply 
GRAPH 3D v2.425 (20-FEB-2017)
12-14-2014, 08:08 PM (This post was last modified: 12-14-2014 08:09 PM by Trickfisch.)
Post: #96
RE: GRAPH 3D v2.412 (Updated 13-DEC-2014)
A cool application. But there was one thing that disturb me.
No Touch Control like zoom or move.

So I've looked in the source code and modified it a little.

Ad the top add this:
Code:
z;

after
Code:
fcolor,clist,reclist;


Now first the g3D_keys().
Code:
g3D_keys()
begin
  local key, run=1,  m;
  local m1, mx1=0, mxa=0, mz1=0, mza=0;
  local m2, mx2=0, mz2=0;
  LOCAL leng2=100, leng1;
  LOCAL x, y, siz=zoom3D, res, sizz;

  g3D_draw();
  
  while run do
    leng1:=leng2;

    key:=wait(-1);

    case

    if TYPE(key)==6 then // Touch
         
       case  
           
          if tmode then g3D_draw(); g3D_trace(); end;

          m:=MOUSE;
          if SIZE(m(1))>0 then 
             mxa:=m(1,2);
             mza:=m(1,1);
          end;

          repeat
             m:=MOUSE;
              
             if Size(m(2))>0 AND Size(m(1))>0 then
                mx1:=m(1,1);
                mx2:=m(2,1);
             end;
   
             //Touch and Zoom
             While (mx1>0) AND (mx2>0) Do
                mz1:=m(1,2);
                mz2:=m(2,2); 
                leng2:=approx(sqrt((mx2-mx1)^2+(mz2-mz1)^2));
 
                if z=0 then
                   // Save Settings and Screen G0 in G2
                   leng1:=leng2;
                   z:=1;  
                   dimgrob_p(G2,360,240);
                   blit_p(G2,G0);
                end;

                // Calculate Zoom and redraw Screen from G2 to G1 (no flicker) to G0 (main Screen) 
                sizz:=leng2/leng1*160;
                RECT(G1);
                blit_p(G1,160-sizz,120-sizz*0.75, 160+sizz, 120+(sizz*0.75),G2,0,0,320,240);
                blit_p(G0, G1);

                m:=MOUSE;
                mx1:=-1;        
                mx2:=-1;
                if Size(m(2))>0 AND Size(m(1))>0 then
                   mx1:=m(1,1);
                   mx2:=m(2,1);         
                end;
             end; 
           

             //Touch and Move
             if SIZE(m(1))>0 then
                m1:=m(1);
             end;
             if m1(5)==#2d then
                mx1:=m1(2)-mxa;
                mz1:=m1(1)-mza;
                mxa:=m1(2);
                mza:=m1(1);
                rotx:=(rotx+mx1) MOD 360;
                rotz:=(rotz+mz1) MOD 360;
                g3D_rotmatrix();
                g3D_draw();
             end;

          UNTIL NOT SIZE(m(1))>0;
          siz:=leng2/leng1*siz;
       end; 
    end;
    
    if key==-1 then run:=0; end;
    if key==9 then g3D_getangles(); g3D_rotmatrix(); g3D_draw(); end;
    if key==27 then g3D_recolor(1); g3D_draw(); end;
    if (key==48 AND contour==0) then tmode:=1; fsel:=flist(tracefunc); g3D_draw(); g3D_trace(); end;

    // default
    repeat
      case
        if key==2 then rotx:=(rotx-5) MOD 360; end;
        if key==12 then rotx:=(rotx+5) MOD 360; end;
        if key==4 then run:=0; end;
        if key==7 then rotz:=(rotz-5) MOD 360; end;
        if key==8 then rotz:=(rotz+5) MOD 360; end;
        if key==1 then roty:=(roty+5) MOD 360; end;
        if key==3 then roty:=(roty-5) MOD 360; end;
        if key==37 then winx:=winx+5; end;
        if key==39 then winx:=winx-5; end;
        if key==33 then winy:=winy+5; end;
        if key==43 then winy:=winy-5; end;
        if key==38 then winx:=-160; winy:=-120; end;
        if key==45 then zoom3D:=max(zoom3D/1.05,.01); end;
        if key==50 then zoom3D:=zoom3D*1.05; end;
      end;
      g3D_rotmatrix();
      g3D_draw();
    until NOT iskeydown(key);
    
    end;

    if z=1 then
         // redraw screen with right zoom
         zoom3D:=siz;
         g3D_rotmatrix();
         g3D_draw();
         z:=0;
    end;
  end; // end while
  freeze;

end;



!Not a must have!
And for a better trace mode. Even the trace mode control. It have some problems, like that in the movement the trace is not rendered. But somebody could solve it.

Code:
g3D_trace()
begin
  local key, run=1, m;
  local m1, mx1=0, mxa=0, mz1=0, mza=0;

  g3D_drawtrace();

  while run do

    key:=wait(-1);

    case
    if TYPE(key)==6 then
        if TYPE(key)==6 then // Touch
           
          m:=MOUSE;
          if SIZE(m(1))>0 then 
            mxa:=m(1,2);
            mza:=m(1,1);
          end;

          repeat
            m:=MOUSE;

            
            //Touch and Move
            if SIZE(m(1))>0 then
              m1:=m(1);
            end;
            if m1(5)==#2d then
              mx1:=m1(2)-mxa;
              mz1:=m1(1)-mza;
              mxa:=m1(2);
              mza:=m1(1);
              rotx:=(rotx+mx1) MOD 360;
              rotz:=(rotz+mz1) MOD 360;
              g3D_rotmatrix();
              g3D_draw();
            end;

          UNTIL NOT SIZE(m(1))>0;
        end; 
        g3D_drawtrace();
      end;
    if key==-1 then tmode:=0; run:=0; end;
    if key==9 then g3D_getangles(); g3D_rotmatrix(); g3D_draw(); g3D_drawtrace(); end;
    if key==27 then g3D_recolor(1); g3D_draw(); g3D_drawtrace(); end;
    if key==45 then 
      tracefunc:=tracefunc-1;
      if tracefunc<1 then tracefunc:=size(flist); end;
      fsel:=flist(tracefunc);
      g3D_draw(); g3D_drawtrace(); 
    end;
    if key==50 then
      tracefunc:=tracefunc+1;
      if tracefunc>size(flist) then tracefunc:=1; end;
      fsel:=flist(tracefunc);
      g3D_draw(); g3D_drawtrace(); 
    end;

    repeat
      case
        if key==4 then tmode:=0; run:=0; end;
        if key==48 then tmode:=0; run:=0; end;
        if key==2 then ytrace:=ytrace+1; wait(.1); end;
        if key==12 then ytrace:=ytrace-1; wait(.1);  end;
        if key==7 then xtrace:=xtrace-1; wait(.1);  end;
        if key==8 then xtrace:=xtrace+1; wait(.1);  end;
        if key==37 then winx:=winx+5; g3D_draw(); end;
        if key==39 then winx:=winx-5; g3D_draw(); end;
        if key==33 then winy:=winy+5; g3D_draw(); end;
        if key==43 then winy:=winy-5; g3D_draw(); end;
        if key==38 then winx:=-160; winy:=-120; g3D_draw(); end;
      end;
      g3D_drawtrace();
    until NOT iskeydown(key);
 
    end;

  end; // end while

  g3D_draw();

end;



Interesting are only the variable definitions at the top of a function, all the code in
Code:
 if TYPE(key)==6 then
and the variable
Code:
z
at the top.


In this code the style icons can't be displayed.
I've tried to implement this, but the actual version can't handle a single click. So every time you touch the screen, this popup would be displayed. Sorry :'(.
In a old version I have created a full dialog for all settings (even the secrets), but I didn't added this in the new one. Because there is a dialog on the view button in the main screen.


So here is the full code.

.txt  HPPrime_touch_v2.412.txt (Size: 53.85 KB / Downloads: 94)

Have fun with it ;-)
I wait for replies and critic.
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
GRAPH 3D v2.425 (20-FEB-2017) - Han - 12-15-2013, 01:20 AM
RE: GRAPH 3D v2.1 - Han - 12-16-2013, 07:24 PM
RE: GRAPH 3D v2.1 - Han - 12-16-2013, 09:48 PM
RE: GRAPH 3D v2.2 (beta) - Terje Vallestad - 12-21-2013, 08:11 AM
RE: GRAPH 3D v2.1 - John Colvin - 12-17-2013, 02:51 AM
RE: GRAPH 3D v2.1 - Han - 12-17-2013, 03:19 AM
RE: GRAPH 3D v2.2 (beta) - Han - 12-18-2013, 07:14 PM
RE: GRAPH 3D v2.2 (beta) - ArielPalazzesi - 12-19-2013, 10:55 AM
RE: GRAPH 3D v2.2 (beta) - LarsF - 12-19-2013, 08:03 PM
RE: GRAPH 3D v2.2 (beta) - John Colvin - 12-19-2013, 11:54 PM
RE: GRAPH 3D v2.2 (beta) - Han - 12-20-2013, 12:07 AM
RE: GRAPH 3D v2.2 (beta) - Harold A Climer - 12-25-2013, 11:06 PM
RE: GRAPH 3D v2.2 (beta) - Han - 12-30-2013, 05:46 AM
RE: GRAPH 3D v2.2 (beta) - Thomas_Sch - 12-31-2013, 09:53 AM
RE: GRAPH 3D v2.2 (beta) - ArielPalazzesi - 12-31-2013, 05:42 PM
RE: GRAPH 3D v2.2 (beta) - eried - 01-01-2014, 07:54 AM
RE: GRAPH 3D v2.2 (beta) - Han - 01-02-2014, 06:28 AM
RE: GRAPH 3D v2.2 (beta) - ArielPalazzesi - 01-02-2014, 10:31 AM
RE: GRAPH 3D v2.422 (21-DEC-2014) - Albedo - 08-03-2015, 04:31 PM
RE: GRAPH 3D v2.425 (20-FEB-2017) - tom234 - 05-20-2019, 11:54 AM
RE: GRAPH 3D v2.425 (20-FEB-2017) - Han - 05-22-2019, 01:17 AM
RE: GRAPH 3D v2.412 (Updated 13-DEC-2014) - Trickfisch - 12-14-2014 08:08 PM
RE: GRAPH 3D v2.42 Memory leak - slawek39 - 12-19-2014, 05:38 PM
RE: GRAPH 3D v2.422 (21-DEC-2014) - akmon - 12-25-2014, 09:06 PM
RE: GRAPH 3D v2.422 (21-DEC-2014) - Han - 12-24-2014, 04:31 AM
RE: GRAPH 3D v2.422 (21-DEC-2014) - Han - 01-25-2015, 03:50 PM
RE: GRAPH 3D v2.422 (21-DEC-2014) - Han - 02-05-2015, 08:35 PM
RE: GRAPH 3D v2.422 (21-DEC-2014) - Han - 02-05-2015, 10:48 PM
RE: GRAPH 3D v2.422 (21-DEC-2014) - Han - 09-29-2015, 03:13 PM
RE: GRAPH 3D v2.422 (21-DEC-2014) - Han - 09-30-2015, 12:53 AM
RE: GRAPH 3D v2.422 (21-DEC-2014) - Han - 09-30-2015, 04:35 PM
RE: GRAPH 3D v2.422 (21-DEC-2014) - Dacobi - 10-21-2015, 10:51 AM
RE: GRAPH 3D v2.422 (21-DEC-2014) - Han - 11-06-2015, 12:45 AM
RE: GRAPH 3D v2.422 (21-DEC-2014) - Han - 11-03-2016, 06:15 PM
RE: GRAPH 3D v2.422 (21-DEC-2014) - Han - 11-05-2016, 12:45 AM
RE: GRAPH 3D v2.422 (21-DEC-2014) - Han - 11-05-2016, 02:02 AM
RE: GRAPH 3D v2.422 (21-DEC-2014) - Han - 12-04-2016, 04:06 AM
RE: GRAPH 3D v2.422 (21-DEC-2014) - Han - 01-20-2017, 07:09 PM
RE: GRAPH 3D v2.424 (20-JAN-2017) - Han - 02-17-2017, 09:56 PM
RE: GRAPH 3D v2.424 (20-JAN-2017) - Han - 02-20-2017, 04:14 PM
RE: GRAPH 3D v2.425 (20-FEB-2017) - Lessa - 08-16-2017, 08:54 PM
RE: GRAPH 3D v2.425 (20-FEB-2017) - Han - 03-06-2017, 03:51 PM
RE: GRAPH 3D v2.425 (20-FEB-2017) - Han - 08-21-2017, 12:00 PM
RE: GRAPH 3D v2.425 (20-FEB-2017) - Lessa - 08-22-2017, 11:57 AM
RE: GRAPH 3D v2.425 (20-FEB-2017) - Han - 08-24-2017, 05:33 PM
RE: GRAPH 3D v2.425 (20-FEB-2017) - akmon - 02-03-2018, 11:48 PM
RE: GRAPH 3D v2.425 (20-FEB-2017) - Han - 02-06-2018, 07:25 PM
RE: GRAPH 3D v2.425 (20-FEB-2017) - Arno K - 04-08-2018, 04:04 PM



User(s) browsing this thread: 1 Guest(s)