Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

263 Neutral

About Yura

  • Rank
  1.   I've just tried it. Didn't help.
  2.   No, it doesnt. Still the same. I've tried with different values
  3. The King2 I've tried different variants with M32 value - result the same, text is at the top..     Jason Z The King2 is right, I'm using Sprites for text rendering, they are out of shader at all. But if there is no other chance to enable Z-value with sprites, I'm ready to try to implement your variant
  4.   Naming failure ftw. "float f" is meant to be "float z", therefore the 3rd coordinate, and therefore the depth for your text. m_mTransform initialially is an identity matrix, getting filled with the inverse (depending on how you sort your sprites - front to back or back to front, so you might want to try on that one) z coordinate. You can create it in the function call, but I decided to "cache" it in the class for (small) performance reason. So the better understandable function might go:   void D3DFont::DrawText(RECT rect, LPCWSTR lpText, DWORD dFlags, float z, D3DCOLOR color) { D3DXMATRIX mTransform; D3DXMatrixIdentity(&mTransform);     m_mTransform(3,2) = 1.0f - z;     m_lpD3DSprite->SetTransform(&mTransform);     m_lpFont->DrawText(m_lpD3DSprite, lpText, -1, &rect, dFlags, color); }   Nope, text is still at the top   sprite.Begin(SpriteFlags.AlphaBlend); Matrix matr = Matrix.Identity; matr.M32 = -5; //hardcoded, just a try variat, primitives min z is -1 sprite.Transform = matr; //transform sprite with this matrix SignFont.DrawText(sprite, "o", new Rectangle((int)(screenPoint.X - 1), (int)(screenPoint.Y - 1), (int)(screenPoint.X + 1), (int)(screenPoint.Y + 1)), FontDrawFlags.NoClip | FontDrawFlags.Center | FontDrawFlags.VerticalCenter, new ColorBGRA(100, 0, 255, 255)); sprite.Transform = Matrix.Identity; // after rendering text cancel transform for other elements ............................. sprite.End();
  5.   Can you make some explanation: what if F-value (float f)?  And m_mTransform is World matrix?
  6.   And how do I check if input vertice is a part of the text or a part of the primitive? Primitives can have 0.0 z-component as well...
  7. Hi, I'm using sprites for text rendering. I need to enable z-buffer (depth) for text, but standart function does not require 3rd component, only X and Y. Vector3 point = Vector3.Project(....); if (!string.IsNullOrEmpty(textToRender)) { infoLine.DrawText(sprite, textToRender, (int)point.X, (int)point.Y, black); }   So my text is always "at the top", and I need to hide it under other elements. What can I do?   EDIT: infoLine is a SharpDX.Direct3D9.Font class member
  8. Yura

    Picking objects

      On Picking Ray construction, what does input params mean? x and y - mouse position, as far as I understand width and height - Viewport width and height float near - ????   And at public bool Intersects(Float4x4 transform... transform - it's  a world matrix?
  9. Yura

    Picking objects

      Have already implemented the basic functionality of picking. I mean Pick ray calculation, from picked screen coordinates, etc?   In case you have a lot of 3D objects in scene you can make the map table of relationships between 3D object in scene and object in your application data model. You have to do it once per scene/level creation.   I had found some methods to check picking, like this: public static bool CheckPicking(Viewport viewport, BoundingBox bBox, Vector2 coord, Matrix mViewProj, out float distance) { Vector3 ZNearPlane = Vector3.Unproject(new Vector3(coord, 0), 0, 0, viewport.Width, viewport.Height, viewport.MinZ, viewport.MaxZ, mViewProj); Vector3 ZFarPlane = Vector3.Unproject(new Vector3(coord, 1), 0, 0, viewport.Width, viewport.Height, viewport.MinZ, viewport.MaxZ, mViewProj); Vector3 direction = ZFarPlane - ZNearPlane; direction.Normalize(); Ray ray = new Ray(ZNearPlane, direction); if (ray.Intersects(ref bBox, out distance)) return true; return false; }   This method checks intersection with some object (Bounding box, triangle, sphere or plane). It can be used to calculate intersection with concrette figure by iteration over all collection, but it is not the best desision. I'm looking for better solution...
  10. Yura

    Picking objects

        Interesting.. And if I'll make those simple primitives classes, would it help? If I'll keep my buffers for rendering and create such classes for each element representation? How do I then connect those classes with image on the screen ? I need fast method, I have prety much primitives and iteration over them all is not a good solution for me.. My full goal is to get information about picked element - it's type and vertices. No other manipulations are needed (at least yet  )     It is sorted, but quite specifically.  I have Elements - generic collection, which contain data about each primitive (list of vertices, type, etc). I can't change it (it's a library), but I can try to use it in my purposes, to represent the object in logic, for example... I can use some technics or patterns to expand this collection with needed methods, like intersection. But I dont understand one thing - how do I connect those classes with image on the screen, image, taken from buffers ?
  11. Yura

    Picking objects

        So, I have 2 collections: a collection of Elements, and a collection of Vertices. I take all vertices and add them to the vertex buffer. Then I build IndexBuffer, using information from the collection of elements. Each element store information (ID) of vertices, which belongs to it. Several different elements can contain same vertex (or vertices).   By picking I want choose some element (primitive) on the screen and print information about it's vertices.
  12. Yura

    Picking objects

    VertexBuffer + IndexBuffer are very nice for my type of data settings. Comfortably to build and use. In general, I have very massive models, more then 6 000 000 primitives, and VB + IB shows great efficient in working with such models. Can you say the same about separate copies of primitives? If yes, I'm ready to rebuild geometry for using this method.  
  13. I know picking objects is well covered topic, nevertheless I have problems with it and asking you to help me. So, my objective is to select (pick) some primitive on the screen, surround picked object with some border (for visibility) and return list of it's vertices.  Code samples, which I found in internet are built about "primitive structures" - each primitive, like line, triangle, rectangle, etc. has it's  representation class with data of each primitive. In my program I use a little different approach: I have 1 global vertexBuffer and IndexBuffer. Those buffers contain locked data of whole figure, which can have very much different primitives. I need to pick some of those primitives. Is it possible with such project structure?  
  14. Thanks user88! I calculated normals and all seems to be ok. I've implemented Blinn-Phong algorithm, it is what I need! But I have a question: I have vectors EyePosition and LooAtVector and I want source light always be at the camera position. Otherwords, the side of the figure, on which I'm looking, must be lighted. Look at my source code and tell me what I'm doing wrong:   //Vertex shader ...... // Will be moved into PixelShader for deferred rendering float3 lightDirection = LookAtPosition; output.L = -lightDirection; // Light Direction output.N = mul(input.Normal, World); // Surface Normal [World Coordinates] ....... float4 PixelShaderFunction(VertexShaderOutput input, float face : VFACE) : COLOR { //my color float4 color = colors[round(input.texCoord * 11)]; // [Ambient Light] I = Ai * Ac float Ambient_Intensity = 0.7f; float4 Ambient_Colour = color; float4 Ambient_Light = Ambient_Intensity * Ambient_Colour; // [Diffuse Light] I = Di * Dc * N.L float Diffuse_Intensity = 0.7f; float4 Diffuse_Colour = color; float NdotL = dot(normalize(input.N), normalize(input.L)); float4 Diffuse_Light = Diffuse_Intensity * color * saturate(NdotL); //----------Blinn-Phong // Compute the half vector Eye + Light float3 half_vector = normalize(EyePosition + EyePosition); //in my case eye+eye, couse I want light to be the same position as light // Compute the angle between the half vector and normal float HdotN = max( 0.0f, dot( half_vector, input.N ) ); // Compute the specular colour float4 cSpecular = float4(1.0f,1.0f,1.0f,1.0f); //white float fSpecularExponent = 5; float3 specular = cSpecular * pow( HdotN, fSpecularExponent ); // Determine the final colour return float4( Diffuse_Light + specular + Ambient_Light, 1.0f ); }
  15. The problem is that I don't have Normal vector on each vertice, so I'm using one default (0,1,0) for all vertices, and this is not good! I don't know where to find or how to calculate normal on each vertice, so I tried to make  reflection map, but with no desired result...
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!