Sign in to follow this  

About Direct3D - Line Strips

This topic is 4222 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi everyone! I am a university student who just start to learn DirectX. (I use Borland C++ Builder as my tool.) I used the example of Tutorial 2 in MSDN Library. http://msdn.microsoft.com/library/default.asp?url=/library/en-us/directx9_c/Direct3D_Tutorials.asp I modified the source code in order to draw "Line Strips". http://msdn.microsoft.com/library/default.asp?url=/library/en-us/directx9_c/Line_Strips.asp As you can see in this file(compile Vertices.cpp): http://140.138.148.144/~s922511/Test_1.zip I found that even though I changed the z-axis value of point, the result showed in the window still looked like a 2D picture. How can I make the result looks more like a 3D picture like this: http://140.138.148.144/~s922511/3D.bmp What's the problem I faced? What can I do to create a floor as the picture I have shown above? Is there anyone can help me to resolve these problems? I will be very appreciated about that! If you can help me by modifying my source file in the hyperlink above, and showing the result I want, that will be great!! Just e-mail to me when you finish this work. Thank you very much!! My E-mail : deathv129@yahoo.com.tw Please set e-mail's title to "gameDev.Net feedback" so I can recognize it. Thank you very much!! m(_ _)m [Edited by - deathv129 on May 1, 2006 9:56:59 PM]

Share this post


Link to post
Share on other sites
Hello,

You are using the wrong vertex format. Tutorial #2 shows you how to draw a triangle in screen space ( 2D ).

To go 3D you need to change D3DFVF_XYZRHW to D3DFVF_XYZ.

Your vertex structure needs to change to something like:


struct Vertex
{
float x, y, z; // rhw taken out
DWORD color;
};



Since your'e working in 3D you need to set the correct view, projection and world transforms too.

- Pure

Share this post


Link to post
Share on other sites
After I change D3DFVF_XYZRHW to D3DFVF_XYZ and vertex structure,
my window doesn't show anything.

Can you tell me how to set the correct view, projection and world transforms?

Thank you very much!!

Share this post


Link to post
Share on other sites
You'll need to use transformed vertices as stated above. Check out tutorial 3 from the SDK ("Tutorial 3: Matrices"). This is basically the same as tutorial 2 but with transformed vertices (and with this tutorial it should be no problem to go 3d)

Share this post


Link to post
Share on other sites


Hello,

Try doing something this, not tested and from the top of my head:



// Setup world transform
D3DXMATRIX matWorld;
D3DXMatrixIdentity( &matWorld );
d3d9_device->SetTransform( D3DTS_WORLD, &matWorld );

// Setup projection transform
D3DXMATRIX matProjection;
D3DXMatrixPerspectiveFovLH( &matProj, 45.0f, float( window_width / window_height ), 1.0f, 1000.0f );
d3d9_device->SetTransform( D3DTS_PROJECTION, &matWorld );

// Setup view transform
D3DXMATRIX matView;
D3DXVECTOR3 vEyePt ( 0.0f, 0.0f, 0.0f ); // where you are standing
D3DXVECTOR3 vLookatPt( 0.0f, 0.0f, 1.0f ); // where you are looking
D3DXVECTOR3 vUpVec ( 0.0f, 1.0f, 0.0f ); // leave this like this
D3DXMatrixLookAtLH( &matView, &vEyePt, &vLookatPt, &vUpVec );
d3d9_device->SetTransform( D3DTS_VIEW, &matView);

// Setup triangle to be drawn right in front of us
Vertex triangle[]
{
{ 0.0f, 1.0f, 1.0f, 0xffff0000 }, // top
{ 1.0f, -1.0f, 1.0f, 0xff00ff00}, // right
{ -1.0f, -1.0f, 1.0f, 0xff00ffff }, // left
};

// Draw triangle
// ....




- Pure

Share this post


Link to post
Share on other sites
Hi everyone!

Here I meet a problem again!

I modified the Toturial 3 in the SDK.

It can show the result I want now.

Here is my source code:

My source code

There is no virus in this zip file, I have scanned it for many times, so don't worry about this!

But it performs an auto rotation of Y-axis now.

I want to use mouse to control the rotation of X-axis and Y-axis.

Furthermore, I also want to use the mouse's scroll wheel to control the depth of z-axis.

Is there anyone can help me to solve these problems?

If you can help me by modifying my source code from the hyperlink above, that will be great!!

Thank you very much!!

Just e-mail to me, when you finish this work.

My E-mail:
deathv129@yahoo.com.tw


(
By the way, some files need a Unicode build when I compile them.

For example, the "EnhancedMesh" sample in the SDK.

What can I do to make my Borland C++ builder 6.0 can compile it?
)

Share this post


Link to post
Share on other sites
Sorry, but its quite unlikely that:
1. Someone will just write the code you want and
2. Email you when they have done it.

If you have money to offer then there are plenty of folk who will be more than happy to be paid to code for you.

If you want mouse control in the way you describe you should take a look at any of the SDK samples and the dxut code since it implements all of these things. Or you can read the mouse messages yourself and use it to modify the view transformation.

Share this post


Link to post
Share on other sites
I have taken a look at the SDK samples "EnhancedMesh".
But my BCB can't compile it.
It just tell me DXUT need a Unicode build and how to make Visual C++ Builder can compile it.
I don't know what to do with BCB.

Anyone can help me?

Share this post


Link to post
Share on other sites

This topic is 4222 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this