Sign in to follow this  

3 Directx related problems

This topic is 3843 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, I need some help with a program I have to make... the program is supposed to simulate a physics system, where I have a open ended cylinder rotating with a ball inside it. the ball is like it's on tracks so it won't come out. I've already completed the program in my opinion, however like I'm still sort of new to directx it's giving me some errors and doing things I don't understand why. I'll join a link to the place where I put the source files online. I've placed comments next to the places that are giving me problems. All of them in the file "anim.cpp". There are other comments in portuguese, but just ignore those. My problems consist of the following, I'm getting an access reading violation and I don't know why. This happens when I'm setting up the matrices for the perspective view. Another one is that the "cylinder" isn't being drawn correctly and the "fase space" isn't being drawn at all, in my opinion. The program has 3 windows, the one on the top left for the 3d preview, the one on the top right for the "fase space" and the one on the bottom for options. The fase space is supposed to be lots of lines that don't follow any order in particular, I'll send an example in the rar file as well. I need help on any of these 3 problem if you can help me only in one of them, no problem and please do, I need this finished on monday and I didn't think I'd have these problems. I also accept any suggestions to improve the program! http://cribe.no.sapo.pt/Prog.rar

Share this post


Link to post
Share on other sites
This sounds like homework, consequently, I'm only going to give you guidance (also, I'm not downloading your code, you could have pasted it here using the appropriate forum tags).

Quote:

I'm getting an access reading violation and I don't know why.

You're doing something naughty to memory you don't actually have control over. This usually means you're using a pointer that was not initialized, or was already freed, or your writing beyond the bounds of the memory you allocated for an array, et cetera. The actual cause of the bug is usually not where the bug manifests itself (e.g., you might crash when you dereference the pointer on line 100, but you declared the pointer, and failed to initialize it, on line 22).

Quote:

Another one is that the "cylinder" isn't being drawn correctly

Define "not drawn correctly." Perhaps you have your cull winding set incorrectly? Set the cull mode to none and see if that improves things. Another possibility is that you do not have depth buffering enabled. You can find out what all those terms mean in the D3D SDK documentation, if you're not familiar with them.

Quote:

and the "fase space" isn't being drawn at all, in my opinion... The fase space is supposed to be lots of lines that don't follow any order in particular

You mean "face?" What is the "face space?" And what is it supposed to look like? Again, you need to be more specific.

Share this post


Link to post
Share on other sites
ok, I understand that you don't want to "make" it for me... but this isn't homework, it's a final project, slightly more important!

The fase space is a name for a special kind of graphic that shows the speed in function of the position, like you can have nearly any speed for any position it consists of lots of lines instead of a single line (which is a graphic). Maybe for the fase space the best help I could have would be to know when you're only drawing in 2D how do you know the coordinates of the limits of the screen being drawn?

About the culling I think I've placed it correctly, the object is 180 units away from the camera, and the culling plane is 250 units away from the camera. The object has a radius of 150 and is rotating about itself so just part of it should not be drawn when rotating and the camera angle (I don't know the technical term) is Pi/4.

And the reading violation is the weirdest of all because when I run the program, it does some loops and eventually it gives the reading access violation, which means it uses the code several times before giving me the error...

[edit] I just fixed that access reading violation, but another one appeared on this code

D3dRen_Main->DrawPrimitive( D3DPT_TRIANGLESTRIP, 0, 10 );

my problem is once again, the code executes several times before giving me the error, and I'm not allocating the D3dRen_Main several times because it's a global variable. Obviously this code is inside the D3dRen_Main->BeginScene() and D3dRen_Main->EndScene()

Share this post


Link to post
Share on other sites

This topic is 3843 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