Results 1 to 7 of 7

Thread: making Holes in a model on the fly (of type m15)

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1

    making Holes in a model on the fly (of type m15)

    the project is to make holes in a flat rectangular model of type M15.
    just click on the woody surface to make square holes, move the mouse while pressing it and you have a worm path. use arrows to rotate the surface, and P,L to move light up down, press F1 for help with keys.
    the model composed from triangles and every triangle have 3 vertices, the order of vertices like this picture:
    m15.jpg
    i don't know if it is possible to delete the triangle vertices in the memory, but we can assign the coordinates of the second vertex to the first vertex so we have a very thin triangle (ie: a line) and the what was space inside the triangle now outside and we can look through it.
    i have constructed a cubes over every consecurtive 2 triangles so to check if the mouse click is within one.
    then deleting a 2 triangles which form a square. i feel something not precise here but my brain are frozen from cold.
    there is something regarding the light, it is the Gray color around the holes, we can get rid of it if we turn off light. i don't know why this phenomena.

    holes.JPG

    references:
    of course i depend heavily on the Petr tactics/plans/code in
    demo_of_0192.TBASIC" IN FOLDER "TBGL_BonusPack_1_6_0_10\GUIandText\Selection" in the TBGL Bonus Pack Version: 1.6.0.10 downloaded from here
    http://www.thinbasic.com/index.php?o...tegory&catid=5

    2- water_patch example in the thread http://www.thinbasic.com/community/s...ow-to-get-this
    Attached Files Attached Files

  2. #2
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,128
    Rep Power
    732
    Hi Zak,

    thanks for sharing the code! I can see my original example used lot of the legacy stuff, so I fine tuned the code:
    • no need for UI module to handle input, TBGL has own functions now
    • no need to reset each key manually, TBGL_ResetKeyState() does it for all keys
    • TBGL_CreateWindow is marked as obsolete, I recommend using TBGL_CreateWindowEx
    • TBGL_SetupLightSource is marked as obsolete, TBGL_SetLightParameter gives more precision (you can just change position, or just color, not needed to specify all again and again as with the obsolete function)
    • changed the lighting a bit, so moving the light is more evident
    • added new function: holding right mouse button will create mountains, when you hold shift, it will create valley


    I managed to minimize the shading artefact to just one vertex - the problem is in the SMOOTH mode, TBGL averages the normals of adjacent triangles for given point. As the deleting is implemented in the code as compressing the triangle to one point, it has very strange normal, so it "damages" the normals of the neighbors. If you switch to PRECISE mode, you will see the problem will be gone.


    Petr

    P.S.: During the autumn, I did a minor revision of whole BonusPack, you can download the recent version here: http://www.thinbasic.com/index.php?o...download&cid=6

    EDIT: Possible solution could be to not compress the triangle to single point, but redefine it to really tiny subpixel triangle with the same orientation as original. Then the normal is preserved and no artifacts should appear.
    Attached Files Attached Files
    Last edited by Petr Schreiber; 04-03-2012 at 10:54.
    Learn 3D graphics with ThinBASIC, learn TBGL!
    Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB

  3. #3
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,777
    Rep Power
    10
    Little problem in F1 Help function: missing handle.
    Better passing main window handler like: Function drawHelp(ByVal hWnd As DWord)
    www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
    Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000

  4. #4
    thank you Eros and Petr, without the M15 huge number of functions i never be able to destroy visualy a model. i can't find in another langauages such an easy manipulations for models, and many people in different forums are asking about this but they are left alone.
    my next project will be to destroy a wall ie a surface with thickness, and finaly a small game in which an artillery are bombing the wall to destroy it, depends on the momentum of the projectile, distance, direction, but i am too slow, and will post it if ever finished here.

  5. #5
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,128
    Rep Power
    732
    Eros, the F1 problem was introduced by me when refactoring the code, I reuploaded the attachement which fixes that and adds more help text

    Zak, that sounds great! You could use TBGL_m15SetVertexRGB with some dark color to make the hole borders look "burned".
    Please try the attached forgotten demo (I think I never posted it). You can click on the model of starship, and it interactively makes it explode on those places - including burned and damaged borders of the explosion and flying debris.


    Petr
    Attached Files Attached Files
    Learn 3D graphics with ThinBASIC, learn TBGL!
    Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB

  6. #6
    that is a gorgeous demo Petr, i have burned the ship completely, in fact i need time to grasp the code.


    in the example holes_in_model4 making bumps and valleys with R-click and shift R-click is a great demo it can be used in a demo to inflate virtual balloons or even in a demo to show a pregnant woman for the biology classes.
    i want to add a little thing for the rectangular flat models. this is to cut the time to a half ,ie instead of looping from 1 to vertexCount we check if x is negative or positive, but this is if the model vertices have this coordinates or we need another plan if not.
    If x > 0 Then
           beginsCalc = vertexCount /2 
           square = (vertexCount /6)/2
           Else
            beginsCalc = 1: square = 0
          EndIf 
          For i = beginsCalc To vertexCount Step 6
            square += 1
            If TBGL_PointInside3D( x, 0, z, %TBGL_OBJ_CUBE, Cubes(square).x, Cubes(square).y, Cubes(square).z, Cubes(square).r) Then          
              deleteSquares(i)
            End If
          Next
    
    PS: another idea is to use TBGL_m15GetModelDimensions( 1, dx, dy, dz ) to see what is the half of the rectangle, i will keep thinking about this .
    Last edited by zak; 04-03-2012 at 12:12.

  7. #7
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,777
    Rep Power
    10
    Quote Originally Posted by zak View Post
    without the M15 huge number of functions i never be able to destroy visualy a model. i can't find in another langauages such an easy manipulations for models, and many people in different forums are asking about this but they are left alone
    Petr has done an enormous amount of job inside TBGL.
    He deserve a great audience. But or later it will happen.
    www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
    Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000

Similar Threads

  1. Making robots that are ethical - perhaps of interest
    By LanceGary in forum Shout Box Area
    Replies: 1
    Last Post: 10-11-2010, 19:32
  2. making .ini files
    By sandyrepope in forum INI
    Replies: 3
    Last Post: 20-08-2007, 10:01
  3. making programs pretty
    By sandyrepope in forum Console
    Replies: 9
    Last Post: 13-05-2007, 20:55
  4. making help files for our programs
    By sandyrepope in forum thinBasic General
    Replies: 1
    Last Post: 20-02-2007, 20:18

Members who have read this thread: 0

There are no members to list at the moment.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •