Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!


1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


BlackJoker

Member Since 28 Feb 2013
Offline Last Active Today, 04:40 AM

Topics I've Started

Constant speed for dragging of 3D objects by mouse

31 July 2015 - 03:37 PM

I am implementing dragging 3D object by mouse in my engine.

 

I have the following formulas:

1. I get length of the vector from camera to object

2. Calculate angles like FOV/width (for X axis) * mouseDelta.X

3. Find triangle side length like var x = Math.Tan(angleX)*distance;

4. multiply X *= frame time;

 

So, I receive the length in the 3D world space on which I must move the model.

Then I multiply my camera relative X and Y axis on those final values (X and Y) and add to the current position.

And it seems working for fps 300.

 

But when I set 60 fps, my gametime increases and object become moving much faster.

 

My goal is to make my dragging algorithm fps independent and move all objects with constant speed.

 

Does anyone know how to reach that?


Objects dragging issue

30 July 2015 - 03:12 AM

I am implementing dragging 3D objects by mouse using picking.

 

For now basic implementation is ready, but I faced with one issue.

I am dragging objects relative to the camera X and Y axis. If I look at the back of the object, everything ok, but when I look backward,

axis will invert and when I will move mouse to the left, object will move to the right and vice versa.

 

For now I move object the following way:

objectPosition += camera.ViewMatrix.Right * -moveDistance.X;
objectPosition += camera.ViewMatrix.Up* -moveDistance.Y;

How to make that object always move in the mouse direction independent from camera position or rotation?


Loading textures problem in latest SharpDX (alpha 2)

10 July 2015 - 04:39 AM

I updated sharpdx libs to the latest alpha 002 and faced with fact that there is no ShaderResourceView.FromStream() or FromFile()

 

Does anyone faced with that issue and how to load textures now for DirectX 11? Is there any othe simple way to do that?


[SharpDX] ShaderBytecode from pass leads to exception

28 May 2015 - 04:41 AM

Hello to everyone.

 

I want to load one of my shaders to my engine using sharpdx libs, but receive and exception instead (Unspecified error).

 

Note: I am not using toolkit part of sharpDX.

 

Here is how I load my shader. 

var effectByteCode = ShaderBytecode.CompileFromFile(@"Content\Effects\SkyboxEffect.fx", "fx_5_0");
            cubeMapEffect = new Effect(GraphicsDevice, effectByteCode);

           var pass = cubeMapEffect.GetTechniqueByName("Skybox").GetPassByIndex(0);
            // Layout from VertexShader input signature
            var passSignature = pass.Description.Signature;

            Layout = new InputLayout(GraphicsDevice, passSignature, input);

If I check pass for validness, it will return true.

But on this line 

var passSignature = pass.Description.Signature;

it will fail with exception.

 

Interesting thing here is that I load one more shader before this and it loads without any error.

Here is code of shader:

matrix worldMatrix;
matrix viewMatrix;
matrix projectionMatrix;

float3 CameraPosition;
 
TextureCube skyboxTexture;
SamplerState skyBoxSampler;
 
struct VertexShaderInput
{
   float4 position : SV_POSITION;
   float4 color: COLOR;
   float3 normal : NORMAL;
   float2 tex : TEXCOORD0;
   float4 tan : TANGENT;
   float4 jointIndices : BLENDINDICES0;
   float4 jointWeights : BLENDWEIGHT0;
};
 
struct VertexShaderOutput
{
   float4 position : SV_POSITION;
   float4 color: COLOR;
   float3 normal : NORMAL;
   float3 tex : TEXCOORD0;
   float3 viewDirection: TEXCOORD1;
};
 
VertexShaderOutput VertexShaderFunction(VertexShaderInput input)
{
   VertexShaderOutput output;

   output.position = mul(input.position, worldMatrix);
   output.position = mul(output.position, viewMatrix);
   output.position = mul(output.position, projectionMatrix);

   output.tex = float3(input.tex, 0);
   return output;
}

float4 PixelShaderFunction(VertexShaderOutput input) : SV_TARGET
{
   return skyboxTexture.Sample(skyBoxSampler, input.tex);
}

technique Skybox
{
   pass Pass0
   {
      SetGeometryShader(0);
      SetVertexShader(CompileShader(vs_4_0, VertexShaderFunction()));
      SetPixelShader(CompileShader(ps_4_0, PixelShaderFunction()));
   }
}

[SharpDX] Loading texture from file

24 May 2015 - 06:09 AM

Hello to everyone.

 

I faced with a little problem trying to load a texture from file.

The thing is that I am using pure sharpdx without Toolkit and there is no way to load just a texture.

 

I can load texture directly into ShaderResourceView by calling static method FromStream() or FromFile(), but it create ShaderResourceView and I need texture1d, 2d or 3d.

 

Yes, I can query Interface for any of these textures, but is there a way in sharpDX just to load Texture directly from a file and then do what I need?


PARTNERS