• Content count

  • Joined

  • Last visited

Community Reputation

120 Neutral

About adrian_134

  • Rank
  1. Hi!   I have one problem with my camera in 2D game, my camera look like this: camera tarack one obiect but camera can move only when is near game border, and i don't know how i can calculate camera position something obiect allowing of this game border. Now i try do this that: var value = pos_obj.x - widthGame / 2;         if (value < 0) value = 0;         if (value > widthGame / 2) value = widthGame / 2; But it's dosen't work very good; My camera code: var border = 150; if (g_CameraX > pos_obj.x - border) g_CameraX = pos_obj.x - border;     if (g_CameraX < pos_obj.x + border - 640) g_CameraX = pos_obj.x + border - 640;     if (g_CameraX < 0) g_CameraX = 0;     if (g_CameraX > 1100 - 640) g_CameraX = 1100 - 640;
  2. DirectWrite and DirectX 11

    I don't have any answer becouse this is very simple or it's impossible to do it ?
  3. Hi!   I have a few questions about select function, i wrote this code: void TCPSerwer::sel()     {         struct timeval tv = {1, 0};         fd_set temp_list = m_RecvList;         //if(select(m_fdmax + 1, &temp_list, NULL, NULL, &tv) == SOCKET_ERROR)         if(select(0, &temp_list, NULL, NULL, &tv) == SOCKET_ERROR)         {             perror( "select" );             exit( 1 );         }                  for(int i = 0; i <= m_fdmax; i++ )         {             if(FD_ISSET(i, &temp_list))             {                 // New connection                 if(i == m_ListenSocket)                 {                     acceptClient();                 }                 // Data from client                 else                 {                     PacketHeader header;                     int nbytes = recv(i, (char*)(&header), sizeof(PacketHeader),                     // Error                     if(nbytes < 0)                     {                         disconnectClient(i);                     }                     // success                     else                     {                         std::cout << "type: " << header.type << "   len: " << header.length << std::endl;                     }                 }             }         }     } I can give first arg to select function and i can don't do that, but why ? Why a should give first arg to select ? m_fdmax is highest number of socket, but this code working without this arg. Next question is, why select need timeout ? When i don't give this arg select marks all socket as socket that can be readable but select doing this when socket haven't any data to read. When i give this arg i don't have this problem. But why ?   if m_fdmax is highest number of socket, i have to find next highest number of socket when i close connection, Right ? And i should doing this that: int size = m_ClientVector.size(); for(int i = 0; i < size; i++) {        if(m_ClientVector[i] > m_fdmax)                m_fdmax = m_ClientVector[i]; }
  4. DirectWrite and DirectX 11

    any answer ?
  5. DirectWrite and DirectX 11

    And i want to do that on this method, but i still have a few question, the first is: I can draw text with DirectWrite in other place than winapi message WM_PAINT ? I can do this in render function ? And how i can copy BitmapRenderTarget to Direct3D texture ?
  6. DirectWrite and DirectX 11

    Yes, i know something about this, but i want to write my library to doing this but i dont know how i can do it. I look at source of this library and i cant understand how it's working
  7. Hi!   How i can connect DirectWrite and DirectX 11, I want to render text to directx surface and use this texture as bitmap font ? I can't find  any tutorial about this. I must draw text in WM_PAINT message but is this only one way to do this ?
  8. Hello! To open image or sound we can use this code: [code] public String getExt(String filename){ int dotIndex = 0; for(int i = filename.length()-1; i >= 0; i--) { if(filename.charAt(i) == '.') { dotIndex = i; break; } } return filename.substring(dotIndex + 1, filename.length()); } public String getTypeAction(String s) { int slashIndex = 0; for(int i = 0; i < s.length(); i++) { if(s.charAt(i) == '/') { slashIndex = i; break; } } return s.substring(0, slashIndex); } ////// ////// MimeTypeMap mime = MimeTypeMap.getSingleton(); String ext = getExt(file_to_action.getName()); ext = ext.toLowerCase(); String type = mime.getMimeTypeFromExtension(ext); Intent intent = new Intent(); intent.setAction(android.content.Intent.ACTION_VIEW); intent.setDataAndType(Uri.fromFile(file_to_action), getTypeAction(type) + "/*" ); startActivity(intent);[/code] But the problem is when i want to open any different file for example: .mhtml, .bak. apk. When i do this my application is crash. I don't know where is the problem, i have application for .mhtml, .odt extenio but my application can't use this applications to open the file. How i can open all file format or how i can check avaliable application for any file format ?
  9. I was definite if D3D9 don't support integer operations the compilator show any error, i tried multibly by 255 ant convert to int but i got bad result, now i know why. I have last question, i rode this article and i saw what data are save to lut texture, on U axis slope, on V axis altitude. This is good solution because i don't must refresh my lut texture when i change terrain geometry. But i don't know how i should save altitude data, range on V axis is 0-1, my heightmap vertex can have any height. How save and read this ? I should do somthing like this: Pixel Shader: [code] float height; float3 B = tex2D(lutsampler, float2(height / LUTTextureHeight, normal.y); [/code] Or: [code] float height; float3 B = tex2D(lutsampler, float2(height / MaxTerrainHeight, normal.y); [/code] I don't know how i should do this....
  10. Hi! I create lut texture for precedural terrain texturing, that texture have the same size what my heightmap, because i want to store texture id in each pixel for one vertex, for example pixel[0, 1] store texture id for vertex[0, 1]. But i have problem when i try read texture id in pixel shader. LUT texture is D3DFMT_A8R8G8B8. That is code who save data to lut texture: [code] int getTextureID(D3DXVECTOR3 n) { D3DXVECTOR3 nn; D3DXVec3Normalize(&nn, &n); if(nn.y <= 0.9f) { return 10; } return 0; } /// void generateTerrainVertex() { D3DXVECTOR3 p(0.0f, 0.0f, 0.0f); int c = 0; for(int i = 0; i < cWidth; i++) { p.z = -(float)i * 2.0f); for(int j = 0; j < cHeight; j++) { p.x = (float)j * 2.0f; p.y = cHeightMap[getVertex(i, j)]; v[c].pos = p; v[c].normal = calcNormal(i, j); v[c].texcoord.x = (float)i / (float)cLUT->getWidth(); v[c].texcoord.y = (float)j / (float)cLUT->getHeight(); // LUT Texture int id = getTextureID(v[c].normal); data[i + j * cLUT->getWidth()] = (id<<16) | (0<<8) | 0; c++; } } } [/code] The code is very simple because i want to lern this technique... In my pixel shader i read texure id: [code] float3 Color = c0; float3 B = tex2D(lutSampler, input.nonTiledTexCoord).rgb; int texID = int(B.r); if(texID == 10) { Color = c1; } [/code] "texID == 10" is false, i don't know why, why texID isn't 10 ? When i generated vertex i saved to lut texture 10 or 0, in pixel shader i have unknown value... Why ? When i change the code: [code] float3 Color = c0; float3 B = tex2D(lutSampler, input.nonTiledTexCoord).rgb; if(B.r >= 0.01f) { Color = c1;} [/code] And i get this: The result is correctly but why b.r have unknown value ? c0 - grass c1 - stone
  11. Shadow maping in deferred render

    Thank you, now it's working very good. I was looking for the problem very long timg, i don't know how i can't saw this notice. Thank you very much.
  12. Hello! I have problem with shadow maping in deferred render. For shading object, in pixel shader directional light i use this code: [code] // Compute screen-space position float4 position; position.x = input.TexCoord.x * 2.0f - 1.0f; position.y = -(input.TexCoord.x * 2.0f - 1.0f); position.z = depthVal; position.w = 1.0f; // Transform to world space position = mul(position, InvertViewProjection); position /= position.w; // ----------------------- Shadow --------------- float4 lightScreenPos = mul(position, lightViewProjection); lightScreenPos /= lightScreenPos.w; // Find sample position in shadow map float2 lightSamplePos; lightSamplePos.x = lightScreenPos.x / 2.0f + 0.5f; lightSamplePos.y = -lightScreenPos.y / 2.0f + 0.5f; float m = 0.2f; float depthInMap = tex2D(shadowTextureSampler, lightSamplePos); float distance = lightScreenPos.z; if((distance - 0.0001f) <= depthInMap) { m = 1.0f; // Is in light } diffuseLight.rgb *= m; [/code] I want get m = 1.0f when is in light or 0.2f when is in shadow but when i using this code all my objects are in shadow or are illuminated this is the screen: [url=""][/url] When i turn and move my camera i getting somfing like this: [url=""][/url] I thing the problem is in the pixel shader becouse this code working correctly for forward rendering (picture in left side). I don't know where is the problem, meybe in lightScreenPos calculations, but what could be wrong ? Directional light working correctly, i have problem only with shadow map.