Jump to content

  • Log In with Google      Sign In   
  • Create Account

TheOrestes

Member Since 10 Feb 2009
Offline Last Active Oct 21 2014 01:11 PM

Topics I've Started

D3DXMatrixLookAtLH vs Custom View Matrix

24 April 2014 - 01:08 AM

Hi,

 

I am quite sure am doing something wrong here but not able to figure it out. Basically,

D3DXMatrixLookAtLH(&m_matView, &m_vecPosition, &m_vecLookAtPoint, &m_WorldUp);

results in : d3dview.png

 

Whereas. custom view matrix calculation :

m_vecLookAtPoint = m_vecLookAtPoint - m_vecPosition;
    D3DXVec3Normalize(&m_vecLookAtPoint, &m_vecLookAtPoint);
    
    D3DXVec3Cross(&m_vecRight, &m_vecLookAtPoint, &m_WorldUp);

    D3DXVec3Normalize(&m_vecRight, &m_vecRight);

    D3DXVec3Cross(&m_WorldUp, &m_vecLookAtPoint, &m_vecRight);
    D3DXVec3Normalize(&m_WorldUp, &m_WorldUp);

    m_matView._11 = m_vecRight.x; m_matView._12 = m_WorldUp.x; m_matView._13 = m_vecLookAtPoint.x; m_matView._14 = 0;
    m_matView._21 = m_vecRight.y; m_matView._22 = m_WorldUp.y; m_matView._23 = m_vecLookAtPoint.y; m_matView._24 = 0;
    m_matView._31 = m_vecRight.z; m_matView._32 = m_WorldUp.z; m_matView._33 = m_vecLookAtPoint.z; m_matView._34 = 0;
    
    m_matView._41 = -D3DXVec3Dot(&m_vecPosition, &m_vecRight);
    m_matView._42 = -D3DXVec3Dot(&m_vecPosition, &m_WorldUp);
    m_matView._43 = -D3DXVec3Dot(&m_vecPosition, &m_vecLookAtPoint);
    m_matView._44 = 1.0f;

results in :

 

customview.png

 

If i manually change the WorldUp vector to (0,-1,0) instead of (0,1,0) i get the default output as in first image.

 

These are my vectors used for the matrix calculations :

    m_vecPosition    = D3DXVECTOR3(3.0f, 3.0f, -10.0f);
    m_WorldUp        = D3DXVECTOR3(0.0f, 1.0f, 0.0f);
    m_vecRight        = D3DXVECTOR3(1.0f, 0.0f, 0.0f);
    m_vecLookAtPoint= D3DXVECTOR3(0.0f, 0.0f, 0.0f);  

The question is, why I have to invert my World up vector during custom view matrix calculation? what is it that am doing wrong?

 

Cheers.

 

 


PC to browser

08 November 2013 - 07:57 PM

Hi Guys,

 

Not sure if this is the right place to post this topic, please let me know if otherwise, i tried putting this in Game Programming section, but no reply, so thought like posting it here.

 

I need some advice on porting front. We have pipeline set in such a way that content is being done on 3d studio max with DirectX 9 shaders. The file format we are working on is VRML format which supports direct DirectX shaders inside the mesh definition. Everything is smooth and fine till this point. However, we are trying to figure out cross platform strategy, where the 3d content will be rendered on the browser as well. Obviously, had it been started with Unity Engine, there was little to worry about ( correct me here ) Or if entire codebase was done keeping in mind this cross platform work in future, we would have faced less issues.

 

obviously, directx shaders won't run on browsers. I came across http://threejs.org/ & http://www.web3d.org/x3d/   as the closest thing which might do the trick for me. VRML mesh format is absolute requirement & these 2 things seems like supporting it. Also, for porting shaders from HLSL to GLSL, I am thinking of using https://github.com/aras-p/hlsl2glslfork .

 

To be honest, I have never worked on browser based technologies before, but am quite comfortable with C++ & DirectX. Hence, I wanted to ask folks around here if this is the sane approach for porting? Please let me know if there is anything else I should keep in mind. Please also point me to any other tools or codebase which handles rendering of VRML mesh formats on Web.

 

Looking forward to hear from you.

 

Cheers.


PC to Browser

05 November 2013 - 10:27 PM

Hi Guys,

 

Not sure if this is the right place to post this topic, please let me know if otherwise. I need some advice on porting front. We have pipeline set in such a way that content is being done on 3d studio max with DirectX 9 shaders. The file format we are working on is VRML format which supports direct DirectX shaders inside the mesh definition. Everything is smooth and fine till this point. However, we are trying to figure out cross platform strategy, where the 3d content will be rendered on the browser as well. Obviously, had it been started with Unity Engine, there was little to worry about ( correct me here ) Or if entire codebase was done keeping in mind this cross platform work in future, we would have faced less issues.

 

obviously, directx shaders won't run on browsers. I came across http://threejs.org/ & http://www.web3d.org/x3d/   as the closest thing which might do the trick for me. VRML mesh format is absolute requirement & these 2 things seems like supporting it. Also, for porting shaders from HLSL to GLSL, I am thinking of using https://github.com/aras-p/hlsl2glslfork .

 

To be honest, I have never worked on browser based technologies before, but am quite comfortable with C++ & DirectX. Hence, I wanted to ask folks around here if this is the sane approach for porting? Please let me know if there is anything else I should keep in mind. Please also point me to any other tools or codebase which handles rendering of VRML mesh formats on Web.

 

Looking forward to hear from you.

 

Cheers.


DirectX + Obj + Boost::Serialization

06 January 2013 - 05:53 AM

Hi,

 

Recently I wrote a very basic Obj format loader in DIrectX, thanks to this wonderful article by Adel Amro : http://my.opera.com/adelamro/blog/direct3d-obj-viewer-sample

 

Obj file was taking time to load. I decided to give Boost's binary serialization a try just to check if after converting data into custom mesh format in binary if I get any speed benifits or not. Just to keep things very simple to begin with, I simply chose 4 members to be a part of my custom mesh format : vertex buffer, index buffer, attribute buffer & custom material structure just as blog above uses.

 

To start off with, i chose boost::text_archive to get hang of boost, am using Boost for the very first time. I was able to successfully read data from obj into my own data format & later use my data format to render it on the screen. This assured that all the required setup to render the mesh was correct & properly set.

 

Then I switched to boost::binary_archive. I was able to write the data in Binary format, but when I tried loading it, I got error which hangs up at following code inside boost library. Am absolutely beginner in boost & not able to dig down the root cause for the error. The error occurs at following line inside "boost_binary_iprimitive.hpp" file :

 

 

 std::streamsize s = static_cast<std::streamsize>(count / sizeof(Elem));
    std::streamsize scount = m_sb.sgetn(
        static_cast<Elem *>(address),
        s
    );
    if(scount != s)
        boost::serialization::throw_exception(
            archive_exception(archive_exception::input_stream_error)
        );

 

where the value of s is 4 & scount is 2, which throws the exception. Can anyone let me know what am I doing wrong & what causes for this type of error?

 

Thanks,

TheOrestes.


Custom Maya OBJ model in MeshFromOBJ directx Sample

07 October 2012 - 08:09 AM

Hi,

I was trying to understand obj file loading for 3d models. I am referring to DirectX 9.0 sample "MeshFromOBJ" to understand how it has been done. I tried creating a simple cube in Maya2012 & exported to obj file format. I tried replacing default "cup" model from the sample to my newly exported model. Please refer to the screenshot for the output I am getting.

Attached File  OBJ.jpg   49.25KB   37 downloads

Please also refer to the obj file content which I got after exporting.

[source lang="plain"]# This file uses centimeters as units for non-parametric coordinates.mtllib cube2.mtlg defaultv -0.762213 -0.812331 0.873061v 0.762213 -0.812331 0.873061v -0.762213 0.812331 0.873061v 0.762213 0.812331 0.873061v -0.762213 0.812331 -0.873061v 0.762213 0.812331 -0.873061v -0.762213 -0.812331 -0.873061v 0.762213 -0.812331 -0.873061vt 0.375000 0.000000vt 0.625000 0.000000vt 0.375000 0.250000vt 0.625000 0.250000vt 0.375000 0.500000vt 0.625000 0.500000vt 0.375000 0.750000vt 0.625000 0.750000vt 0.375000 1.000000vt 0.625000 1.000000vt 0.875000 0.000000vt 0.875000 0.250000vt 0.125000 0.000000vt 0.125000 0.250000vn 0.000000 0.000000 1.000000vn 0.000000 0.000000 1.000000vn 0.000000 0.000000 1.000000vn 0.000000 0.000000 1.000000vn 0.000000 1.000000 0.000000vn 0.000000 1.000000 0.000000vn 0.000000 1.000000 0.000000vn 0.000000 1.000000 0.000000vn 0.000000 0.000000 -1.000000vn 0.000000 0.000000 -1.000000vn 0.000000 0.000000 -1.000000vn 0.000000 0.000000 -1.000000vn 0.000000 -1.000000 0.000000vn 0.000000 -1.000000 0.000000vn 0.000000 -1.000000 0.000000vn 0.000000 -1.000000 0.000000vn 1.000000 0.000000 0.000000vn 1.000000 0.000000 0.000000vn 1.000000 0.000000 0.000000vn 1.000000 0.000000 0.000000vn -1.000000 0.000000 0.000000vn -1.000000 0.000000 0.000000vn -1.000000 0.000000 0.000000vn -1.000000 0.000000 0.000000g pCube1usemtl initialShadingGroupf 1/1/1 2/2/2 4/4/3 3/3/4f 3/3/5 4/4/6 6/6/7 5/5/8f 5/5/9 6/6/10 8/8/11 7/7/12f 7/7/13 8/8/14 2/10/15 1/9/16f 2/2/17 8/11/18 6/12/19 4/4/20f 7/13/21 1/1/22 3/3/23 5/14/24[/source]
Is there anything that I am missing or doing wrong while exporting. I used all default settings in the exporter.

PARTNERS