Jump to content
  • Advertisement

ChaosPhoenix

Member
  • Content Count

    353
  • Joined

  • Last visited

Community Reputation

242 Neutral

About ChaosPhoenix

  • Rank
    Member
  1. It works for message because message is an array of values. This call SDLNet_TCP_Send(tcpsock,message,len); is really equivalent to SDLNet_TCP_Send(tcpsock,&message[0],len); Since by default not specifying an element in array points to the address of the first element in that array. As others said, you would need to pass in &len since len is a single value and not an array.
  2. ChaosPhoenix

    Nlerp/Slerp with 2 vectors. [Solved]

    Ah, you're correct. Works fine. I remember initially thinking I needed to use LERP but for some reason decided against it. Haha, like I said, a bit brain fried today. Doesn't LERP run into problems if you use matrix rotation? Luckily I'm not dealing with rotation currently (and can use Quaternions if need be when the time comes), but just something I should probably just keep myself aware of. Congrats on CML. I love it. I use it for all my OpenGL projects.
  3. I have 2 3D vectors. One being the original position, the 2nd being the target position. I'm trying to simply interpolate between the two. I should note I'm using the Configurable Math Library (love it), but I figure this is just a basic math issue that I'm probably doing incorrectly than anything wrong with the library so I didn't feel the need to post this on their specific forum. Code: // ms_OriginalPos = Vector3 // ms_targetPos = Vector3 // ms_interpValue = float between 0.0 - 1.0 vector3 nlerpVec = cml::nlerp(ms_originalPos, ms_targetPos, ms_interpValue); // Returned vector is normalized, so multiply it by the original length/magnitude to get the correct position. float magnitude = (ms_targetPos - ms_originalPos).length(); vector3 newPosition = (nlerpVec * magnitude); setPosition(newPosition); I'm probably missing something very simple since my brain is a bit fried currently and this is my first attempt at something like this. Thanks for the help. [Edited by - ChaosPhoenix on August 2, 2009 4:42:22 PM]
  4. Quote:Original post by Zahlman Quote:Original post by ChaosPhoenix BaseObject doesn't do anything. It was simply a way for me to be able to keep a pointer to any object that inherits from either RenderObject or LogicObject without knowing what they were. Although, now that I think about it, that serves no real purpose since BaseObject itself has absolutely no methods or members. It's no different from a void * in this case. So, that might be a way to go. Indeed. What were you hoping to be able to accomplish this way? :) Further, have you considered composition instead of inheritance? I think it was one of those "Well, maybe this will come in handy later" trains of thought. :) I'll look into composition as well. Thanks for all the help guys. :)
  5. Quote:Original post by bluntman Maybe you should consider either removing BaseObject, or deriving final classes (e.g. Player) from it directly rather than the intermediate classes (I am assuming it provides functions you need but haven't shown in the code you posted, if it doesn't then just remove it completely). BaseObject doesn't do anything. It was simply a way for me to be able to keep a pointer to any object that inherits from either RenderObject or LogicObject without knowing what they were. Although, now that I think about it, that serves no real purpose since BaseObject itself has absolutely no methods or members. It's no different from a void * in this case. So, that might be a way to go.
  6. Quote:Original post by Wavarian Okay, first of all those 3 base classes all need virtual destructors. Secondly, you're experiencing the diamond-inheritance problem. class BaseObject {}; class BaseRenderObject : virtual public BaseObject {}; class BaseLogicObjct : virtual public BaseObject {}; class Player : public BaseRenderObject, public BaseLogicObject {}; Wiki: diamond inheritance Ah, yea, forgot about the destructors...that would of been a fun debugging experience... So, after reading that wiki article it looks like I could possibly use virtual inheritance to get around this issue but I'm honestly leaning towards refactoring my design here and just simplifying those two base classes (BaseRenderObject and BaseLogicObject) into one object. The whole concept was objects can inherit from either depending on their needs (to be render, or simply to run logic, or both). But I can simplify that design patter and still keep the functionality.
  7. Quote:Original post by frob Paste your actual code, please. Alrighty. #ifndef _BASEOBJECT_H_ #define _BASEOBJECT_H_ class BaseObject { protected: BaseObject(); ~BaseObject(); }; #endif #ifndef _BASERENDER_OBJECT_H_ #define _BASERENDER_OBEJCT_H_ #include "BaseObject.h" class BaseRenderObject : public BaseObject { public: virtual void render() = 0; protected: BaseRenderObject(int bucket = -1); ~BaseRenderObject(); }; #endif #ifndef _BASELOGIC_OBJECT_H_ #define _BASELOGIC_OBJECT_H_ #include "BaseObject.h" class BaseLogicObject : public BaseObject { public: virtual void update(float deltaTime) = 0; protected: BaseLogicObject(int bucket = -1); ~BaseLogicObject(); }; #endif #ifndef _TEXT_H_ #define _TEXT_H_ #include "BaseRenderObject.h" #include "BaseLogicObject.h" class Text : public BaseRenderObject, public BaseLogicObject { ... }; #endif This would be the file with the problem. #ifndef _PLAYER_H_ #define _PLAYER_H_ #include "BaseRenderObject.h" #include "BaseLogicObject.h" #include "Text.h" class Player: public BaseRenderObject, public BaseLogicObject { public: Player(); ~Player(); virtual void update(float deltaTime); virtual void render(); private: ... Text textObject; //C2011 }; #endif
  8. Alright, I hate to come here with this question but I think a set of new eyes on this problem may see something I'm not. I'm currently getting the lovely C2011 (Class Redefinition) error with the following inheritance scheme: ClassA ClassB(: public Class A) ClassC(: public Class A) ClassD(: public ClassB, public ClassC) ClassE(: public ClassB, public ClassC) No big deal right? Well, ClassE actually contains a Class D object. This is what causes the C2011 error. Even if I forward declare Class D and just use it as a pointer, I still get the redefinition error. I'm using inclusion guards on all my files, but this error still occurs. Any thoughts?
  9. ChaosPhoenix

    'LPSTR' to 'LPCWSTR'

    This error is caused by the newer visual studios defaulting to unicode/wide char strings on new projects(IIRC). You can simply place #undefine UNICODE at the top of your source code. Or you can go into your Project Properties->Configuration Properties->Character Set->Set to Multi-Byte
  10. ChaosPhoenix

    Camera Soft Attach

    Hey All, Been a while since I had to do a camera class and I need to implement a soft attach system so the camera can follow around objects in the world (3rd person over the shoulder type stuff). I believe the logic goes something like this (but correct me if I'm wrong) - Create a queue of Matrices - Push on the starting matrix (object position + camera offset, whatever) - Every frame push on a delta matrix that is the difference between the objects matrix ( basically deltaMatrix = currentMatrix * InversePreviousMatrix) - Apply the oldest delta matrix on the queue to the current camera matrix Sound good? Am I missing something? Is there anything more optimized than storing a queue of matrices? Thanks Guys.
  11. ChaosPhoenix

    Something off with my Specular Map shader

    Quote:Original post by bjarnia I would double check that you are normalizing everything. Every time I get lighting calculations wrong it's me forgetting to normalize vectors. Ps... what does this do? float3 lightReflect = (-realLightDir, normalTex); ... I don't get it? Is there a function call missing? Weird. Yea, there is supposed to be a reflect function there.
  12. ChaosPhoenix

    Something off with my Specular Map shader

    Quote:Original post by bjarnia Is it just me or do you not use "t" at all? Think you might be mixing up s and t Ugh...yea T should be my normal lighting value. Changed it to this and it seems to be better: // Specular light value float t = pow(max(dot(lightReflect, OUTPUT.camera), 0.0f), specularPower); // Diffuse intensity float s = max(dot(realLightDir, normalTex), 0.0f); // No specular lighting if we shouldn't get light normally. if(s <= 0.0f) t = 0.0f; // Final specular value. Modulated by a specular map. float3 spec = t* (s * tex2D(SpecularMapSampler, OUTPUT.tex)); // Diffuse texture sample. float4 color = s * tex2D(ColorMapSampler, OUTPUT.tex); // Spec + Diffuse color.rgb = (color.rgb + spec); Something still seems off though :/
  13. ChaosPhoenix

    Something off with my Specular Map shader

    Quote:Original post by PfhorSlayer if(s <= 0.0f) t = 0.0f; float3 spec = (s * tex2D(SpecularMapSampler, OUTPUT.tex)).rgb; I have a feeling your problem is somewhere in those two lines :) Hmm, care to elaborate? I've tried messing things a bit and still no luck.
  14. Hey guys, Working on a shader to render models with basic diffuse, normal, and specular maps. I have things up and running it but looks like my models are getting only specular highlights(i.e. everything is either fully lit, or super bright). Here is the shader currently: [SOURCE] uniform extern float4x4 worldViewProj : WorldViewProjection; uniform extern float4x4 worldInverse : WorldInverse; uniform extern float3 cameraPosition; uniform extern float3 lightPosition; uniform extern texture colorMap; uniform extern texture normalMap; uniform extern texture specularMap; uniform extern float specularPower; struct inputVS { float3 pos : POSITION; float3 tangent : TANGENT; float3 binormal : BINORMAL; float3 normal : NORMAL; float2 tex : TEXCOORD0; }; struct outputVS { float4 pos : POSITION; float3 camera : TEXCOORD0; float3 lightDir: TEXCOORD1; float2 tex : TEXCOORD2; }; sampler NormalMapSampler = sampler_state { Texture = <normalMap>; MinFilter = ANISOTROPIC; MaxAnisotropy = 8; MagFilter = LINEAR; MipFilter = LINEAR; AddressU = WRAP; AddressV = WRAP; }; sampler ColorMapSampler = sampler_state { Texture = <colorMap>; MinFilter = ANISOTROPIC; MaxAnisotropy = 8; MagFilter = LINEAR; MipFilter = LINEAR; AddressU = WRAP; AddressV = WRAP; }; sampler SpecularMapSampler = sampler_state { Texture = <specularMap>; MinFilter = ANISOTROPIC; MaxAnisotropy = 8; MagFilter = LINEAR; MipFilter = LINEAR; AddressU = WRAP; AddressV = WRAP; }; outputVS mainVS(inputVS INPUT) { // Zero out our structure. outputVS outVS = (outputVS)0; // Contruct TBN Matrix float3x3 TBNMatrix; TBNMatrix[0] = INPUT.tangent; TBNMatrix[1] = INPUT.binormal; TBNMatrix[2] = INPUT.normal; // Tangent Space transform float3x3 TangentSpace = transpose(TBNMatrix); // Camera World Pos to local Camera position; float3 localCameraPos = mul(float4(cameraPosition, 1.0f), worldInverse); // Local camera vector float3 tangentToCamera = localCameraPos - INPUT.pos; // Local camera to tangent space outVS.camera = mul(tangentToCamera, TangentSpace); // Light direction from world space to local space float3 lightDirection = mul(float4(lightPosition, 0.0f), worldInverse); // Light Direction into tangent space outVS.lightDir = mul(lightDirection, TangentSpace); // Basic local pos to H space outVS.pos = mul(float4(INPUT.pos, 1.0f), worldViewProj); // Pass on the texture coord outVS.tex = INPUT.tex; // To the pixel shader! return outVS; } float4 mainPS(outputVS OUTPUT) : COLOR { // Normalize our Camera and light vectors, just in case. OUTPUT.camera = normalize(OUTPUT.camera); OUTPUT.lightDir = normalize(OUTPUT.lightDir); // Reverse the light direction float3 realLightDir = -OUTPUT.lightDir; // Sample the normal map float3 normalTex = tex2D(NormalMapSampler, OUTPUT.tex); // from 0 to 1 to -1 to 1 normalTex = 2.0f * normalTex - 1.0f; normalTex = normalize(normalTex); // Reflection ray for our specular lighting float3 lightReflect = (-realLightDir, normalTex); // Specular light value float t = pow(max(dot(lightReflect, OUTPUT.camera), 0.0f), specularPower); // Diffuse intensity float s = max(dot(realLightDir, normalTex), 0.0f); // No specular lighting if we shouldn't get light normally. if(s <= 0.0f) t = 0.0f; // Final specular value. Modulated by a specular map. float3 spec = (s * tex2D(SpecularMapSampler, OUTPUT.tex)).rgb; // Diffuse texture sample. float4 color = tex2D(ColorMapSampler, OUTPUT.tex); // Spec + Diffuse color.rgb = (color.rgb + spec); // Return color return color; } I think the problem is in these lines (as altering them has given me some results, hard black lighting edges, but nothing that would "fix" the issue). float t = pow(max(dot(lightReflect, OUTPUT.camera), 0.0f), specularPower); float s = max(dot(realLightDir, normalTex), 0.0f); if(s <= 0.0f) t = 0.0f; float3 spec = (s * tex2D(SpecularMapSampler, OUTPUT.tex)).rgb; float4 color = tex2D(ColorMapSampler, OUTPUT.tex); color.rgb = (color.rgb + spec); I've been coding for a while today so some fresh eyes might see what I'm not. :)
  15. ChaosPhoenix

    Specular Maps

    Hey all, I'm trying to load a model that contains a specular map. I'm semi-familiar with the basic formula for computing specular lighting (although if anyone has a good refresher link, I'd love to review my stuff), but I've never dealt with a specular map. Does a specular map replace specular lighting, or does it simply influence the results of the specular lighting by providing a bias? Thanks!
  • 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!