Results 1 to 5 of 5

Thread: Cropping Textures in Direct3D

  1. #1

    Thread Starter
    PowerPoster Fox's Avatar
    Join Date
    Jan 2000
    Location
    *afk*
    Posts
    2,088

    Cropping Textures in Direct3D

    I'm using D3D8 and want to crop textures, is there any better way than dealing with texture coordinates?

  2. #2
    Member Yhoko's Avatar
    Join Date
    May 2002
    Posts
    47
    I suppose you mean cropping like in 3ds max? If so texture coordinates are the only way I can think of...

  3. #3
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    Why don't you want to use Texture coordinates? If they come in percentages I can see where you're coming from, but if not whats the problem?
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  4. #4

    Thread Starter
    PowerPoster Fox's Avatar
    Join Date
    Jan 2000
    Location
    *afk*
    Posts
    2,088
    It's not a problem, I'm just looking for another way. As you can see in my mDXGraphics I'm using tex coords but there's always a better way.. maybe

  5. #5
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    Actually I haven't had a chance - I've got to reinstall Win2k (in about 3 minutes actually ), so I won't have a chance.

    The only other way I can think of is offsetting a bit array (how you do it is up to you). If you're thinking of zooming them in and out, how about making yourself a custom fuction?
    VB Code:
    1. Function ZoomTexCoord(Orig() As PointAPI, ZoomFactor As Single, NewPoints() As PointAPI
    2. Dim Width As Long
    3. Dim Height As Long
    4. Dim cX As Long
    5. Dim cY As Long
    6.  
    7. 'Let me explain; the Orig() array is the texture coordinates for a quad, ex:
    8. ' 0.....1
    9. '   .....
    10. ' 2.....3
    11.  
    12. Width = Orig(1).X - Orig(0).X
    13. Height = Orig(2).Y - Orig(0).Y
    14. cX = Orig(0).X + Width / 2
    15. cY = Orig(0).Y + Height / 2
    16.  
    17. Width = Width * ZoomFactor
    18. Height = Height * ZoomFactor
    19.  
    20. NewPoints(0).X = cX - Width / 2
    21. NewPoints(0).Y = cY - Height/ 2
    22.  
    23. NewPoints(1).X = cX + Width / 2
    24. NewPoints(1).Y = cY - Height / 2
    25.  
    26. NewPoints(2).X = cX - Width / 2
    27. NewPoints(2).Y = cY + Height / 2
    28.  
    29. NewPoints(3).X = cX + Width / 2
    30. NewPoints(3).Y = cY + Height / 2
    31.  
    32. End Function
    Of course this is just a sample, but the function should work (I have no way of checking it at the time being). Ta for now.
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

Posting Permissions

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



Click Here to Expand Forum to Full Width