dx9 tutorial help

Started by
20 comments, last by phil67rpg 10 years, 11 months ago
I am able to draw a triangular pyramid to the screen, I am working with the directxtutorial.com web site. I really like this tutorial. I want to draw 20 triangular pyramids to the screen. Here is the code I am working with.

        { -1.0f, -1.0f, 0.0f, D3DCOLOR_XRGB(0, 255, 0), },
        { -1.0f, 1.0f,-1.0f, D3DCOLOR_XRGB(0, 0, 255), },
        { 1.0f, 1.0f, 0.0f, D3DCOLOR_XRGB(255, 0, 0), },
        { 1.0f, -1.0f, -1.0f, D3DCOLOR_XRGB(0, 0, 255), },
Advertisement

Glad to hear it, phil!

biggrin.png

void hurrrrrrrr() {__asm sub [ebp+4],5;}

There are ten kinds of people in this world: those who understand binary and those who don't.

Is this a thread for the 'Announcements' section? Or are you asking us how you might go about drawing 20 pyramids to the screen?

Stitchs.

I want to know how to draw 20 triangular pyramids to the screen

I want to know how to draw 20 triangular pyramids to the screen

Repeat the code for 1 pyramids 20 times, but of set each one by x (otherwise they will be drawn on top of each other)?

Mobile Developer at PawPrint Games ltd.

(Not "mobile" as in I move around a lot, but as in phones, mobile phone developer)

(Although I am mobile. no, not as in a babies mobile, I move from place to place)

(Not "place" as in fish, but location.)

so I should use a for loop?

Use a for-loop where for each increment, you change the coordinates so that each pyramid is drawn at a certain distance away from the last. This will put them into a single row or column of pyrmaids.

If you wanted a pattern, try using a second for-loop nested in your first. The first can move the pyramids along the X-axis, then the second moves them on the Y-axis. This results in, for example. five triangles being drawn in a column, inner loop exits to outer loop, column start moves to the right. This is repeated until you have 20 drawn on the screen, in 4 columns of 5 pyramids.

Regards,

Stitchs.

am I on the right track with this code

        { x, -x, 0.0f, D3DCOLOR_XRGB(0, 255, 0), },
        { -x, x,-1.0f, D3DCOLOR_XRGB(0, 0, 255), },
        { x, x, 0.0f, D3DCOLOR_XRGB(255, 0, 0), },
        { x, -x, -1.0f, D3DCOLOR_XRGB(0, 0, 255), },

am I on the right track with this code


        { x, -x, 0.0f, D3DCOLOR_XRGB(0, 255, 0), },
        { -x, x,-1.0f, D3DCOLOR_XRGB(0, 0, 255), },
        { x, x, 0.0f, D3DCOLOR_XRGB(255, 0, 0), },
        { x, -x, -1.0f, D3DCOLOR_XRGB(0, 0, 255), },

Well,yes and no, the first 3 floats are X,Y and Z (i assume, sorry), this (im pretty sure) will create them in a diagonal pattern

for(float i; i <= (20*32); i+=32.0f){

...
{ -i, -1.0f, 0.0f,d3dcolor_xrgb(0,255,0),}

....

}

the loop increases by 32 each itteration, thus, the spacing between the pyramid will be 32px on the x axis

bare in mind its only an example :)

hopw that helps

Mobile Developer at PawPrint Games ltd.

(Not "mobile" as in I move around a lot, but as in phones, mobile phone developer)

(Although I am mobile. no, not as in a babies mobile, I move from place to place)

(Not "place" as in fish, but location.)

You'll want to create a static model of your pyramid. That means no variables in the pyramid declaration. Once that's done you use a transform to place the pyramid where you want to render it in the world.

This process is described in lesson 5 on the site you're using.

void hurrrrrrrr() {__asm sub [ebp+4],5;}

There are ten kinds of people in this world: those who understand binary and those who don't.

This topic is closed to new replies.

Advertisement