Sphere

Started by
23 comments, last by SystemFiles 14 years, 1 month ago
Hi, currently I try to implement a simple sphere into game mod. I'm creating the sphere with
D3DXCreateSphere(pDevice,1.0f,10,10,&Mesh,NULL);
In my renderfunc I set the Position of the sphere. The Position is taken from a Vector:
D3DXMATRIX position;
D3DXMatrixTranslation(&position,1300.0f,157.0f,63.0f);
Device->SetTransform(D3DTS_WORLD,&position);
Mesh->DrawSubset(0);
When I look ingame to this position no sphere there. Is there something wrong with my MatrixTranslation? greetz [Edited by - KN4CK3R on January 28, 2010 12:01:44 PM]
Advertisement
The functions look correct (except for pDevice in one call and Device in the other - that's suspicious).

Do any of the functions return errors?

Where are you positioning the viewpoint to view the sphere, and in what direction does the viewpoint face?

Please don't PM me with questions. Post them in the forums for everyone's benefit, and I can embarrass myself publicly.

You don't forget how to play when you grow old; you grow old when you forget how to play.

sry, in the code it's called pDevice too.

I don't positioning the viewpoint, I just use the normal ingame view. Do I need to set a different viewpoint? I think that would change the game itself. I only want to add this sphere to the point the vector shows to. Am I right and I can use D3DXMatrixTranslation with the vectors who comes from the game. (my position etc)

greetz
I don't know what game mod you're using so I can't really tell you.
Quote:When I look ingame to this position no sphere there.

How do you do that? What position and direction do you set the view to?

If you draw a mesh at a position, the camera/view/whatever-you-use must be positioned somewhere near the sphere (but not at the same position) and looking toward it.

In D3DX, somewhere in the code the projection and view matrices are set. That determines where in your 3D world your eyepoint is positioned and the direction you're looking.

What does that code look like in your application?

Please don't PM me with questions. Post them in the forums for everyone's benefit, and I can embarrass myself publicly.

You don't forget how to play when you grow old; you grow old when you forget how to play.

I don't have the original code. The game only calls the render func from the mod. Would it help if I post what GetTransform returns?

edit: I tried this but it won't work.
D3DXMATRIX Position, Scale, Matrix;D3DXMatrixTranslation(&Position,955.f,-162.f,137.f);D3DXMatrixScaling(&Scale,5.0f,5.0f,5.0f);pDevice->GetTransform(D3DTS_VIEW,&camera);Matrix = Position*Scale*camera;pDevice->SetTransform(D3DTS_WORLD,&Matrix);Mesh->DrawSubset(0);


greetz
Try using PIX to debug it. Since you're working with a state machine, a lot of things can go wrong if you just add the code in the middle of the game source code. You might need to reset shaders, culling, z-buffer and more.
Quote:
Quote:When I look ingame to this position no sphere there.

How do you do that?

You implied you can set the position to look at. How do you do that?

Also, if you position the sphere at several points close to (0,0,0), can you see it then? Such as (5,0,0), (-5,0,0), (0,5,0), (0,-5,0), (0,0,5), (0,0,-5).

Please don't PM me with questions. Post them in the forums for everyone's benefit, and I can embarrass myself publicly.

You don't forget how to play when you grow old; you grow old when you forget how to play.

I think the cameraposition is the head from the player in this first person game. so if I walk and look around i change the camera or not? And if I create a sphere at a visible position in front of me (D3DXMatrixTranslation(&Position,955.f,-162.f,137.f);) i should see the sphere.

greetz
Quote:if I walk and look around i change the camera or not?

That sounds like it's changing the camera position. Can you tell your position? Is it displayed?

Please don't PM me with questions. Post them in the forums for everyone's benefit, and I can embarrass myself publicly.

You don't forget how to play when you grow old; you grow old when you forget how to play.

Are you calling BeginScene(), EndScene() ?
Have you set up your projection matrix ?

with the few lines that you posted you haven't given us much to work with.

but since you are using an existing game engine that allows you to make direct call to D3D i would expect that you had to set up all the rendering code yourself.

Have you tried reading the documentation ?

This topic is closed to new replies.

Advertisement