Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

148 Neutral

About MahanGM

  • Rank
  1. I figured I had a problem with vertex declaration. It's fixed now. Thanks for your time
  2. I'm trying to draw 2d planes with textures. Previously, I was doing this with fixed functions which was fine, but now I'm moving into shaders and I'm stuck.   I have written below shader: /**  * Parameters  */ const float4x4     WorldViewProjMatrix; const int         MaxAnisotropy; const texture     MainTexture; const float4     MainColor; const bool        IsMainTextureSet = true; /**  * Samplers  */ sampler2D MainSampler = sampler_state {     Texture = <MainTexture>;     AddressU = Clamp;     AddressV = Clamp;     MipFilter = Point;     MinFilter = Point;     MagFilter = Point;     MaxAnisotropy = <MaxAnisotropy>;     MipMapLodBias = 0; }; /**  * Structs  */ struct VertexShaderInput {     float4 Position : POSITION0;     float2 TextureUV : TEXCOORD0; }; struct VertexShaderOutput {     float4 Position : POSITION0;     float2 TextureUV : TEXCOORD0; }; struct PixelShaderOutput {     float4 Color : COLOR0; }; /**  * Functions  */ VertexShaderOutput VertexShaderMain(VertexShaderInput input) {     VertexShaderOutput output;     output.Position = mul(input.Position, WorldViewProjMatrix);     output.TextureUV = input.TextureUV;     return output; } PixelShaderOutput PixelShaderMain(VertexShaderOutput input) {     PixelShaderOutput output;     float4 textureColor = (IsMainTextureSet) ? tex2D(MainSampler, input.TextureUV) : float4(1.0f, 1.0f, 1.0f, 1.0f);     output.Color = saturate(textureColor * MainColor);     return output; }   /**  * Techniques  */ technique Diffuse {     pass Pass0     {         VertexShader = compile vs_2_0 VertexShaderMain();         PixelShader = compile ps_2_0 PixelShaderMain();     } } The problem is, only first row and column of the texture is drawn. This seems to be a uv coordination problem, but if it was the problem it shouldn't have worked with fixed functions too.   I have attached two files. One is the shot from my application and second is my 128x128 test texture. If you look at the first picture you can see there is a red 2d plane with only the first row and column part of the second picture applied to it. In second picture first row and column is a red line.   I'm sure there is something I'm missing.
  3. Hey I didn't try that at all. Thanks for the reply. It's solved.
  4. I faced a problem when I wanted to change the content of a member variable in my script class.   This is my class: class Foo {   int baz1;   Bar@ baz2; } I can easily change value types in C++ by: int* value = (int*)addressOfbaz1; (*value) = 456; But this doesn't work with object handles and I know why, but I don't know how I can alter the address that object handles are pointing to.
  5. @Andreas Jonsson   That's a good solution. And by the way, I completely forgot about meta data.   Thanks for the assist.
  6. Generally speaking you're right, but my case is not general. I'm using a base class to provide some behind the scene benefits to script classes at runtime but don't want to involve them in my host app. I'm trying to get public member variables to architect a unity3d like scripting system where you can assign values to your public members before runtime and some other stuff. That's why.   I was checking GetProperty parameters now, there is nothing for this kind of stuff.
  7. @jbadams Thanks man. I was looking for this forum.   @Juliean Thanks. I've seen GetProperty method in object type class before. I didn't test it then but I now have, but since my script classes are derived from another base class, this will give me all member variables declared in both classes. Is there a way to avoid this?
  8. I'm trying to get member variables declared in an anglescript script class from my host application. There is a function for getting the global properties, but none for getting script class properties.
  9. MahanGM

    asBEHAVE_ASSIGNMENT is missing

    Oh, I'm sorry. Thanks for the response.
  10. MahanGM

    asBEHAVE_ASSIGNMENT is missing

    I was using angelscript version 2.23.1 and I had this problem when I wanted to register assignment behavior for one of my value types. I downloaded the 2.29.1 version and I still have the same problem. I've checked angelscript header file and this label is just not there.
  11. I've been drawing primitives recently and I have problem with rendering order. I was expecting by setting different z values for my quads, I'd get a kind of depth system. I'm not sure what I'm doing wrong or even my theory is true.   I simply create my vertices: Vertex2D vertices[] = {     {0, 0, 0, color, 0, 0},     {rect.Width(), 0, 0, color, 1, 0},     {0, rect.Height(), 0, color, 0, 1},     {rect.Width(), rect.Height(), 0, color, 1, 1},     {rect.Width(), 0, 0, color, 1, 0}, }; Then I set translation for them: D3DXMATRIX translationMatrix; D3DXMatrixTranslation(&translationMatrix, rect.X() - 0.5f, rect.Y() - 0.5f, depth); device->SetTransform(D3DTS_WORLD, &translationMatrix); And finally draw.   Before this, I was using D3DXSprite to draw sprites and I was drawing shapes with the Direct3D device itself. There was a depth problem between primitives drawn by Direct3D device and sprites drawn by D3DXSprite so I decided to switch to textured quads for sprite drawing and eliminate D3DXSprite. D3DXSprite had a front to back depth sort flag that could manage different z values, I don't know if there is a magical way to achieve what D3DXSprite is offering or it's just a simple vector sort, I just need to know what's the solution.   Thanks.
  12. Hey thanks. I don't know why I didn't think of that in the first place. I was setting a wrong offset in SetStreamSource(). Thanks again.
  13. Hi. I've been working on a simple line draw and I can't get the colors to work. I want to draw a red line. This is my result:     I have defined two vertices with the same color (red with an alpha of 255). As you can see source color is completely black. If I disable blend mode, I'd still get this result, but if I enable it and play with D3DRS_SRCBLEND and D3DRS_DESTBLEND, I can change the result, but it never gets to the point that I want which is a full red line.   My vertex format is as follows:   D3DFVF_XYZ | D3DFVF_DIFFUSE   Someone said that it might be from vertices normal vectors, but I don't have any lighting in my scene so it's not that. However, if I change D3DFVF_XYZ to D3DFVF_XYZRHW and pass value 1 for rhw, it'll draw the line with correct color, but that's not the format I want. I want to be able to apply geometry changes to my vertices and I know RHW does not receive any of that. And, I have a totally bright material and even if I set D3DMCS_COLOR1 for D3DRS_DIFFUSEMATERIALSOURCE, I'd still get the same result in the picture above.
  14. Is this possible in lua to achieve? player.scripts["movement"].properties["stat"] = "stand" print (player.scripts["movement"].properties["stat"]) I've done the second line in c++ with this approach: luabind::object FakeScript::getProp() { luabind::object obj = luabind::newtable(L); for(auto i = this->properties.begin(); i != this->properties.end(); i++) { obj[i->first] = i->second; } return obj; } But I'm stuck with setter. The first line in lua code which I'm trying to set value "stand" for key "stat" is not going to work and it keep directing me to the getter method. Setter method only works when I drop `["stat"]` from `properties`.   I can do something like this in my script: player.scripts["movement"].properties = {stat = "stand"} But this isn't what I want because I have to go through my real keys in c++ to determine which one is placed in the setter method argument.   This is my map in class: std::map<std::string, std::string> properties;
  15. MahanGM

    error lnk1104

    I'm not sure but link the debug library to see if it works "d3dx9d.lib". And ensure that you include the Lib and Include path of DX SDK after all of the included libraries such as Windows SDK.
  • 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!