Re: attach texture to a cube.

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Callum Winter (callum_at_REMOVE_THISwinter9999.fsnet.co.uk)
Date: 04/03/04


Date: Sat, 3 Apr 2004 13:22:22 +0100

To do this accurately you will need to split the cube into 6 subsets(sides),
then set each texture between rendering each one.
Also note if your cube only has 8 vertices you will need 2 texture coords
per vertex or 2 of the sides wont get mapped properly due to the texture
coords being incorrect at some vertices as they were used by another side.
either this or you can create your cube with 4 vertices per side, then each
one only needs 1 texture coord.

Depends which is most comfortable for you and what the needs of the
application are, but if its only a cube with textures it wont hurt to define
24 instead of 8 vertices for it, with 1 tex coord set, and this would be
simpler to texture.
The tex coords for each vertex will then be. Top left (0, 0), Top Right
(1,0), Bottom Left (0, 1), Bottom Right (1, 1).
To map the texture just call Device->SetTexture before rendering each side.
Direct x then uses the tex coords you set and applies the texture for you
when its rendered.

Hope this helps.
Callum.

"Richard Zhu" <yzhu@algis.ca> wrote in message
news:106gqmvsr1n70e5@corp.supernews.com...
> I have 6 textures, want to attach to a cube.x object, after loading the x
> file, how to get the vetex coordinate ? and attach each texture to each
> surface, any examples ? the question may be too simple, I really saw it
> before, but now forget how to ,
> thanks guys.
>
>



Relevant Pages

  • problems with rendering to texture
    ... I have a problem with rendering to texture. ... I'm using glCopyTexImage2D ... When I'm trying to render a cube where each vertex has different ...
    (comp.graphics.api.opengl)
  • Re: Converting fom cube face to texture
    ... You'll need to specify 3D texture coordinates on your object to correctly ... That would be very simple for a cube object. ... >> Wessam Bahnassi ... >>> Ultimatly im trying to render a cube map round my scene. ...
    (microsoft.public.win32.programmer.directx.graphics)
  • Re: DirectX and ScreenSaverProc
    ... just set the new texture pointer for changing it on the cube... ... > How do you suggest that I load all the pictures of a given directory? ... >> app main loop is a big no-no for performance... ...
    (microsoft.public.win32.programmer.directx.graphics)
  • blending texture issue
    ... I am simulating streams of natural light (such as from an open door or ... textured with a texture that has culling turned off. ... When I select a standard solid texture, I can move inside the cube and ... I can only see the blending effect from outside the ...
    (microsoft.public.win32.programmer.directx.graphics)
  • RE: Whats the best way to render a lot of text on a lot of surfaces?
    ... When you pull a cube close to you, ... If I were trying to solve this problem, I would render text to a texture, ... I assume that the text is not changing from frame to frame, ...
    (microsoft.public.win32.programmer.directx.graphics)