Jump to content
  • Advertisement

Zaph-0

Member
  • Content Count

    127
  • Joined

  • Last visited

Everything posted by Zaph-0

  1. Hi guys, as the title says, I have a question regarding the rotation of an object. When I render an object right now I create its rotation matrix at render time like this: D3DXMatrixRotationYawPitchRoll(&rotationmatrix, y , x , z ); For this I need to have the individual x,y,z angles at render-time to create the rotation matrix. The problem I have now is that I want to rotate an object several times (always based on the preceeding rotation). I cannot simply add the angles onto another (x on x, y on y, etc...) because then they are not aware of the other axis angles and the rotation turns out wrong. Its like a merry-go-round that keeps rotating around its z-axis and even if you tilt the ground (x or y axis) the z-axis tilts as well and it keeps rotating around the tilted z-axis. What I want is that at subsequent rotations the angles are calculated as if the already rotated object was not rotated and the rotation affects now all 3 axis accordingly. It would be much easier if I would simply calculate several rotation matrices and apply them one after the other (I think that should work) but I do some complicated math with the angles so I cannot change my approach and need to create the whole rotation (as mentioned above) at render time. I am not sure how I can do this and would really appreciate some help.
  2. Quote:Original post by jyk Quote:I need the euler angles for a sort of steering behaviour where I need to know the angle the object is facing in all 3 directions to calculate its behaviour relative to other objects in the area.I don't believe it :-) Ok, maybe I'm wrong, and you do need Euler angles here, but I'll continue to play devil's advocate anyway. Say you have an object, A, and want to determine its behavior based on the relative position (and possibly orientation) of object B. Take A's transform, invert it, and multiply it with B's transform; this will give you B's transform expressed in A's local space. It seems to me that this would give you pretty much all the information you'd need for the purposes of AI. From this, you can determine whether the object of interest is above or below, to the right or to the left, in front or behind, facing away or facing towards, etc., and can then apply steering behaviors as appropriate. It's not really clear to me how this would be easier to accomplish using Euler angles. Euler angles would be easier because I don't only need how the locations relative to another but also the angles they are facing each other in global numbers. And even if it would work with matrices I made a huge chunk of AI and steering behaviour that took me ages to perfect and don't really want to change it. So euler angles it is... ^_^
  3. Quote:Original post by jyk Quote:Original post by Zaph-0 Quote:Original post by jyk Not sure if I understand the question completely, but if you store the orientation in matrix or quaternion form (rather than as Euler angles), you can apply whatever rotations you want to it on a per-update basis. Thats exactly what I cannot do as I need to keep the rotation as numbers (euler angles) for other things that are going on. As I understood it I cannot go back from a rotation matrix to the angles and I need them so I have to do it this way.I'm always a little skeptical when people say they 'have to have' Euler angles - can you say anything about what you need them for? Anyway, it is possible to convert a rotation matrix to a set of Euler angles. It's a little tricky, and the solution is often non-unique, but if you need to go back and forth for some reason, it's certainly possible. I need the euler angles for a sort of steering behaviour where I need to know the angle the object is facing in all 3 directions to calculate its behaviour relative to other objects in the area. Is there no way where I can simply rotate the 3 angles as if I were applying rotation matrices one after the other ?
  4. Quote:Original post by jyk Not sure if I understand the question completely, but if you store the orientation in matrix or quaternion form (rather than as Euler angles), you can apply whatever rotations you want to it on a per-update basis. Thats exactly what I cannot do as I need to keep the rotation as numbers (euler angles) for other things that are going on. As I understood it I cannot go back from a rotation matrix to the angles and I need them so I have to do it this way.
  5. Zaph-0

    c++ mfc and cdialog

    Hi, I use mfc with dx9, maybe that can help you somewhat: I create an mfc app (any kind will do, view/doc, dialog, etc...) and then create an extra cwnd with the parent set to the cwnd of the app window: screenwnd.CreateEx(parent, x, y, cx, cy); and then create the dx device with the wnd handle of the created cwnd: d3d->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, screenwnd.m_hWnd, D3DCREATE_HARDWARE_VERTEXPROCESSING, &d3dpp, &d3ddevice ); and then when I do: d3ddevice->Clear(); d3ddevice->BeginScene(); ..Render... d3ddevice->EndScene(); d3ddevice->Present(&visiblerc, NULL, NULL, NULL); I see the rendered screen.
  6. Hi, as the title already says, I need to somehow import 3DS Max files with animation. I don't think importing a .max file is practical therefore I think about exporting a file from max in a different format and then importing that. I already tried the panda x-porter and kw x-port x-file and the ogremax .mesh exporter but they all gave broken results with the geometry being off. As I need the animation in a matrices-format and not like .3ds where the full meshes are included for every frame I am not sure which format to choose. There are a few that formats Max can export by default like fbx, dae, dwf and others but I am not certain about how (or even if) anyone of them includes animation and delivers usable results. The material is not important as long as it exports the name of the material used in max. I don't really care about which format as long as it has the full geometry, matrix-based simple animation and doesn't take too much time to code an importer for my app. Thanks for any advice...
  7. Quote:Original post by NumberXaero Unfortunately Im yet to find a an exporter for the more complex formats that isnt broken in some way (fbx, COLLADA, etc.). Ah, thats really bad. I mean, didn't anyone who got a usable version running that somehow just exports geometry, material and matrix based animation ? Quote:Original post by NumberXaero Which version of max are you using? I am using 3ds Max 2010 32-bit on xp. I cannot use another version as that is the only one available to me. Quote:Original post by NumberXaero I wouldnt use the built in collada exporters, the OpenCOLLADA exporters work pretty well I find. Yeah, the built in exporter created broken geometry while that at least looks alright with the opencollada exporter. Quote:Original post by NumberXaeroIm curious how the materials are coming out wrong, I know of a at least one bug with materials having to do with specular level textures in OpenCOLLADA, why you dont get any animations is odd, they always worked for me. Or is it that the viewer just doesnt support them. What I find strange is that the materials are black/look off on the same parts of the object where the ogremax exporter somehow made them look translucent or kind of rendered the backfaces. In max everything looks ok, though so I am a little confused with this. Could you recommend a Collada Viewer that supports animation ? Quote:Original post by NumberXaero It seems the only way to get a flawless export the way you want it is to write one yourself. All exporters seem broken in some way if you use them long enough and exhaust all the features. COLLADA aimed to support everything and be easy to understand and use, but a lot of poorly written code that didnt follow or misinterpreted the spec sort of knocked it off track. Maya COLLADA seems to work very well, 3DS Max has loads of problems unfortunately. Is there a place where I can start with that ? I really don't want to waste any time with something basic like this which I thought wouldn't be an issue at all. I mean, I'd still use my old 3ds importer if not for the animation...
  8. Yeah well, I considered it, but I don't really want to. It's way too much effort that I am sure someone else has done before and I don't really need to duplicate. I mean, thats what (open) formats are there for. And considering how many broken exporters I found so far, I don't really think its all that easy or they wouldn't all fail that badly. The last thing I need now is to invest alot of time into something like writing a max exporter and then find out its a flaw in max. It is somewhat irritating that most exporters seem to have problems with the mostly same parts of my object (and the animation). I already wasted lots of time writing an x-file importer (can't use d3dx) just to find out the x-file exporters don't really work for my mesh.
  9. Hi, thanks for your reply. I just tried collada and it looks as if the export using the built-in autodesk collada exporter as well as the opencollada export plugin you mentioned deliver broken results. While both of them export wrong materials for some objects the built-in autodesk collada exporter creates also misplaced objects. And neither of them seems to export any animation at all, although I selected the animation option for the exported file. Well, at least no viewer was able to show me any animation at least. Strangely the ogre exporter showed me the same parts as strangely transparent looking that the opencollada exporter had problems with (completely black objects in the viewer). Is there maybe something I need to do before exporting or is there maybe something else that I could use ? I mean, I cannot be *that* hard to export a somewhat complex object, or can it ?
  10. Zaph-0

    How to make billboards ?

    Ah, it seems I got it working, but I found a few things a little strange so I'm not sure what to make of this. 1. Instead of using the position x,y,z at m.14, m.24, m.34 they are at m.41, m.42, m.43. 2. The billboard is being displayed clockwise and must be created that way. Ah well it works, thats all that matters for now... ^_^
  11. Hi guys, I've been combing the internet for hours and found (as usual) nothing useful. I want to do billboards with c++ and dx9. The reason I chose billboards over point sprites is that I want to rotate them and I heard thats not that easy possible with them and they are just generally to unflexible. Anyway, I managed to display a bunch of objects but now I want to display billboards for some special effects. For that I made a square out of 2 triangles that I display a texture on which works pretty good, but of course I cannot apply my usual matrices because when the camera position moves I look on the billboard from a different angle until it disappears (backface, etc...). The point of the billboard is that its always facing the camera and that is where my problems start. The way I take it I have to rotate every billboard according to the angle it is regarding to the camera, right ? Or is it enough to simply rotate all billboards that they are parallel to the viewing plane ? I am not really sure and would appreciate any help with this, especially as to how I create a new view matrix/matrices for the billboards.
  12. Zaph-0

    How to make billboards ?

    Hi, thanks alot for your reply. I read your link but unfortunately I don't really understand how to implement it. I created a matrix from the view matrix like you mentioned there which looks like this: matBillBoard._11 = matView._11; matBillBoard._12 = matView._21; matBillBoard._13 = matView._31; matBillBoard._14 = x; matBillBoard._21 = matView._12; matBillBoard._22 = matView._22; matBillBoard._23 = matView._32; matBillBoard._24 = y; matBillBoard._31 = matView._13; matBillBoard._32 = matView._23; matBillBoard._33 = matView._33; matBillBoard._34 = z; matBillBoard._41 = 0; matBillBoard._42 = 0; matBillBoard._43 = 0; matBillBoard._44 = 1; I have now 3 questions to this. 1. Is this correct ? 2. what exactly is x,y,z ? I tried putting there some values but to no avail. 3. How do I exactly apply this matrix ? My usual way of applying matrices is like this: object->matObject * matWorld * matView * matProj; How does this new matrix fit into there ? Thanks in advance... ^_^ [Edited by - Zaph-0 on December 27, 2009 6:00:33 PM]
  13. Zaph-0

    Vertexshader - No z-test?

    might sound stupid, but is the zbuffer enabled ? d3ddevice->SetRenderState( D3DRS_ZENABLE, D3DZB_TRUE );
  14. Hi, I have a little Problem and hope anyone of you can help me with this. I have 2 identical transparent objects in 3D space. From the Camera object one (lets call it A) is behind the other one (lets call this one B). Obviously A looks smaller as it is further away. And on screen it looks as if they are centered around the same point, which of course they aren't in 3D space but only because of the conversion to 2D and the current camera position. My problem now is that I need to increase the scale of object A so that the they match each other on screen. In 3D space object A would be much bigger than object B but because B is closer they would look the same. Kind of complicated but I can't really figure the math out as to how to scale object A based on its distance to B. I would really appreciate some help with this. Thanks in advance.
  15. Hi, I am trying to rendering a mesh with several different kinds of material with dx9. I can theoretically do that in 1 rendercall because all materials are encoded into the vertex information as a D3DDECLTYPE_UBYTE4 and can be handled in the vertex and pixel shader at runtime (animation, etc...). In the vertex and pixel shaders I have set it to be a BLENDINDICES type (don't know what else to use) and pass it from the vertex shader to the pixel shader where its being evaluated and then the appropriate texture with modifications being rendered. But the problem I am having is that the value I get for the BLENDINDICES is not always correct. If I set it to 100 and test for 100 I get something like noise or Z-fighting for the pixels. Some ok, some not. If I test it for >90 its sort of ok, but can't I pass exact 8bit values using D3DDECLTYPE_UBYTE4 ? It seems to be working in the vertex shader though only the pixel shader is giving strange results. Here is my PS Code: struct PS_INPUT { float4 Position : POSITION; float4 VertexData : BLENDINDICES; float2 Texture : TEXCOORD0; }; struct PS_OUTPUT { float4 Color : COLOR0; }; PS_OUTPUT ps_main( in PS_INPUT In ) { PS_OUTPUT Out; if(In.VertexData.g == 100) { Out.Color = tex2D(Tex0, In.Texture) * float4(0,1,1,1); } else { Out.Color = tex2D(Tex0, In.Texture); } return Out; } And here the picture thats demonstrates the problem. The light blue pixels are ok, the white pixels are not. Thanks in advance for any help with this...
  16. Changing it to int4 changed nothing but changing the code to if((In.VertexData.g > 99.9) && (In.VertexData.g < 100.1)) { Out.Color = tex2D(Tex0, In.Texture) * float4(0,1,1,1); } else { Out.Color = tex2D(Tex0, In.Texture); } seems to have done the trick as it works every time now. I think thats a really lame solution because then I could have just used the color arguments from 0.0 to 1.0 that are supported everywhere instead of the less common ubyte4 where I can use values from 0 to 255. I would never have thought that floats are that unprecise. I know that I can not make exact comparisons after I did some math with the floats but those where just set and passed along. Well, I guess my gpu is taking some shortcuts somewhere... Maybe I'll just round the value. That seems to work as well. Thanks for your help. ^_^
  17. Hi, yes in every triangle they all have the same values.
  18. Hi guys, I need a way to set data in an alphachannel of a bitmap and save it to file in C++. I heard Windows Bitmaps (BMP) are not that good for alpha related things so I think I'll go with PNG-Files. I can load PNG Files already with DirectX and use them but now I need to manipulate them and save them back. So if anyone knows how I can save a PNG with an alpha-channel on Windows XP with Visual Studio 6.0 (no platform sdk or anything and no extra libraries like libpng, so pure c++ source only) I would really appreciate it. Thanks in advance... ^_^ PS: should someone know how I can save a BMP with alpha I'd take that too...
  19. Hi guys and thanks for your replies. I don't know how I could miss that, but I am using the d3dx function to load the bitmaps. That means that of course I can use D3DXSaveTextureToFile to save it as a png back to a file, so thanks alot for that advice. ^_^ PS: I can get the latest editions of Visual Studio for free at work (the license allows us to use them at home too) but never actually saw a need to upgrade at home from my ancient 6.0 to a more recent version. What's better in them ? Is there really a reason to upgrade ?
  20. Zaph-0

    [Directx 10] .3DS loader???

    Hi, as far as I know the animation in the 3ds format is really bad because it doesn't use matrices or bones but saves the entire geometry for each frame. I think you'd be better of using the .x format. There are many tools to convert objects to or save in the .x format and DirectX has functions to completely load the .x format with only a few commands. I think there are plenty of samples that cover that. If you still choose to load .3ds files I think you can get the format specification to code your own reader or working reader with c++ source at: http://www.wotsit.org/list.asp?fc=2
  21. Hi, thanks for your reply. Quote:Original post by Erik Rufelt You could use the camera-position as one point, and put the other at any value away from the camera (I assume viewport.maxZ is 1.0 which should be OK). If you don't know the camera position then of course the method you use is the way to go, and get two points from the matrices. I am currently trying to change the camera system and try if I can use it as a reference point for the near point. Quote:Original post by Erik RufeltWhat is your world matrix? So far I do all the moving of the camera in the world matrix and the rotating of the camera in the viewmatrix. I plan though to move it all into the worldmatrix and have the camera at a fixed location and move/rotate the world around it. Quote:Original post by Erik RufeltFor this you should probably use an identity world matrix, as you want the ray in world-space, not in object-space (if you transform your objects). You only want the camera transform to influence your ray. Well, I have extra matrices for objects which I use for them for position and rotating (and animation) and I don't use any of those matrices for this. Quote:Original post by Erik RufeltI also don't understand why you change the values in viewport. You should use the viewport for the current view, as obtained from the device, and setting it manually is unnecessary. Are you sure your window matches exactly 800,600? Ah I forgot to remove that, but the viewport is 800x600 and those lines don't do anything actually. I removed them from the code snippet. Like I mentioned before I am changing the way my world and view matrix work. Could that be the problem why my code didn't work ?
  22. Hi, I'm trying to find a position on a horizontal plane (height is variable) by clicking with the mouse on it. As far as I know the usual way to do this is to use "D3DXVec3Unproject" to get a ray defined by 2 vertices and then do an intersection test with the plane with "D3DXPlaneIntersectLine". My problem now is that it doesn't seem to work. ^_^ To be a little more precise, I think the "D3DXPlaneIntersectLine"-part in my code is ok because I used some numbers to test it, but the part to get the 2 vertex coordinates with "D3DXVec3Unproject" which are at the near and far plane seem somehow wrong. Or at least the results I get are. When I change the angle from which the camera looks on the plane I get quite different results for clicking at the same position. Even without changing the camera, the difference from the results I get to the real position for clicking in one corner of the screen and then the other corner are different themselves. Everything is just somehow off. I tried to implement the pick sample from directx 9 and I get similar strange results. I also checked the matrices I use and they are the same the scene is rendered with. My code is this: bool CScene::Pick(int x, int y, D3DXVECTOR3 & vector) { D3DXVECTOR3 vec0,vec1; D3DXPLANE plane; D3DVIEWPORT9 viewport; D3DXVECTOR3 pos; d3ddevice->GetViewport(&viewport); pos.x = (float)x; pos.y = (float)y; pos.z = viewport.MaxZ; D3DXVec3Unproject(&vec1, &pos, &viewport, &matrixProj, &matrixView, &matrixWorld); pos.z = viewport.MinZ; D3DXVec3Unproject(&vec0, &pos, &viewport, &matrixProj, &matrixView, &matrixWorld); plane.a = 0.0f; plane.b = 0.0f; plane.c = 1.0f; plane.d = -height; D3DXPlaneIntersectLine(&vector, &plane, &vec0, &vec1); return true; } I would really appreciate any advice on this... [Edited by - Zaph-0 on December 17, 2009 9:49:30 AM]
  23. Zaph-0

    play animation from .x file XNA

    Hi, I do not use XNA, but how about: http://www.riemers.net/eng/Tutorials/XNA/Csharp/Series2/Loading_a_Model.php
  24. Thanks, that is exactly what I was looking for. ^_^
  25. Hi, I am trying to render a complex object consisting out of several subobjects (each with its own set of vertices) with 1 rendercall and am wondering how I should handle the animation (and therefore different matrices) of the subobjects. I think I will give every subject its own transformation matrix that I set before rendertime and index which one to use from the vertexdata. I considered using D3DFVF_XYZB1 for that but using a whole float for a simple index seems kind of wasteful. Especially considering that I might want to give other data along as well (materialtype for the supershader, etc...) and do not want a vertex to be bigger that 32byte so I considered using the RGBA 4byte encoded specular or diffuse color instead. I could put which matrix to use for each subobject into the R part (have to multiply it with 256 since it ranges from 0 to 1, though) and maybe the materialtype, lights, etc. into the other GBA parts. Is that acceptable, will this maybe cause huge performance loss or did I miss something completely ? Thanks for any advice on this. ^_^
  • 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!