DanielDoyle

Members
  • Content count

    32
  • Joined

  • Last visited

Community Reputation

102 Neutral

About DanielDoyle

  • Rank
    Member
  1. Hi I'm using MFC (first time using it) and I've got some code inside the dialogue's OnPaint method I want to debug. When the program loads the breakpoint is obviously hit, pressing run the breakpoint is not hit again (its at the top of the function on generated code that should always hit) Does anyone know why it does not seem to call again after the first time Thanks
  2. aha...... That actually makes sense now you just said that......It is probably that which is causing the problem because it would actually be a null ptr that i'm looking at
  3. Hi I've come back this code after a few months, and i still cant find a solution to the problem. The problem is, the object tree I have created (stores objects in a tree structure to split of the environment into areas for rendering purposes), I use: checkCollisionRadius(PositionData* P, float radius, bool Delete) P = holds position data - p->Pos is a D3DXVECTOR3() which is only used in this function radius = distance from P->Pos to check against Delete = should an object collided with be deleted from the list the tree is structured into nodes denoting an area in 3d space, each holding one RenderList object (renderlist is a linked list of renderable objects) one problem with this is, some objects don't seem to be checked for collision e.g. and object on screen is sometimes obviously colliding with the player in the range but they are not deleted. the second problem is after a while of some objects been deleted i will encounter an access violation error from one of the renderlist nodes trying to access a null object (although a null pointer cant be added to a renderlist node, if(object != null) add object is used etc) the areas of code that could be problematic would be: ObjectTree (OPTree) [code] bool OPTree::checkCollisionRadius(PositionData* P, float radius, bool Delete) { OPNode* N = ParentOPNode; while(N->Child1 != NULL) { //are we inside child 1? float x(P->Pos.x),y(P->Pos.z); if((x >= N->Child1->x1 && x <= N->Child1->x2) && (y <= N->Child1->y1 && y >= N->Child1->y2)) { N = N->Child1; } else if((x >= N->Child2->x1 && x <= N->Child2->x2) && (y <= N->Child2->y1 && y >= N->Child2->y2)) { N = N->Child2; } } //******************** //loop through all objects in it's renderlist D3DXVECTOR3 distance; for(int i(0); i < N->list.GetAOCount(); i++) { //calculates the vector between P and the object in the list distance = P->Pos - N->list[i]->getPositionData().Pos; //checks if the length between is in range of the radius if(D3DXVec3Length(&distance) <= radius) { if(Delete) //deletes if Delete was set to true N->list.RemoveObject(i); //returns true because we hit an object return true; } } //if nothing collided then we return false return false; } [/code] RenderList (RenderList) [code] AthenaObject* RenderList::operator [](UINT index) { if(index >= AORenderCount) return NULL; else { RenderNode* N = nullptr; for(int i(0); i <= index; i++) { if(i == 0) N = Parent; else N = N->Child; } return N->Object; } } [/code] [code] bool RenderList::RemoveObject(int index) { //if index if greater than or equal the amount of objects we have then return false if(index >= AORenderCount) { return false; } else //else loop till we get the correct node //then remove it { //trying to remove the parent, so remove the parent //and set it's child as the new parent if(index == 0) { if(AORenderCount == 0 || AORenderCount == 1 /*check 1 because that means we only have one object in the list - the parent*/) { Parent->Release(); delete Parent; Parent = nullptr; AORenderCount = 0; return true; } else { Parent = Parent->Child; Parent->Parent->Child = nullptr; //not doing this releases all the other nodes :S Parent->Parent->Release(); delete Parent->Parent; Parent->Parent = nullptr; --AORenderCount; return true; } } else { RenderNode* N = Parent; for(int i(0); i <= index; i++) { if(i == 0) N = Parent; else N = N->Child; } //set this nodes parent to look at this nodes child to remove this node //from the list //then relese the node and null the pointer N->Parent->Child = N->Child; N->Child = nullptr; //not doing this releases all the other nodes :S N->Release(); delete N; N = nullptr; --AORenderCount; return true; } } } [/code] Any Help would be greatly appreciated as i can not see any problem with this myself, although I'm probably not seeing something silly Thanks
  4. correct me if i'm wrong, but doesnt that require a mesh structure to hold the bounding box? or is it different for sprites?
  5. are the sprites rotated at all during gameplay? if not then do a simple check against the position of the sprite and its width (if the sprites origin is set top left) i cant remember the exact code i used once before but i think in pseudo code it was something like: [code] if (sprite1.left >= sprite2.left - sprite2.width && sprite1.left < sprite2.left + sprite2.width) && (sprite1.top >= sprite2.top - sprite2.height && sprite1.top < sprite2.top + sprite2.height) then collision = true[/code] yes it's in vb syntax but thats how i remember it, will be simple enough to change though Hope that helps
  6. http://msdn.microsoft.com/en-us/library/bb205788%28v=vs.85%29.aspx the effect is pretty self explanitary, if you dont understand the concept of passes etc and how how shaders work, look into them first. but for the directX side of things, the functions do what they say on the tin
  7. Mesh Not drawn properly

    [quote name='VISQI' timestamp='1307849284' post='4822271'] [quote name='GreaseMonkey' timestamp='1307837586' post='4822222'] The main problem is see, is some of the walls positions are set in clockwise order, other walls points are counter-clockwise, that would most likely be your main problem, try creating the so they are all in clockwise order and it should work [/quote] I am not drawing it in the order that it is shown. I am using an index buffer and it is working in clock-wise order, i thought that was implied. The index buffer is working per quad like this : 0, 1, 2, 0, 2, 3 [/quote] That is correct for the first set in verticies, but drawing out the second set draws them counter clockwise (it would be clockwise is you were facing another direction)
  8. Mesh Not drawn properly

    The main problem is see, is some of the walls positions are set in clockwise order, other walls points are counter-clockwise, that would most likely be your main problem, try creating the so they are all in clockwise order and it should work
  9. i didnt get what you were saying in your post much, but going by the title, id say your trying to access private members of the class directly?
  10. enurming vertex shader input attribs

    [quote name='Pooya65' timestamp='1307224834' post='4819546'] hi how can i enrum(get name of) vertex shader attribs (input vertex type like as color and position) ? for example i want get name of the "in_Position" and "in_Color" from following shader: [code] float4x4 in_ModelviewProjectionMatrix; struct OutputVS { float4 posH : POSITION0; }; OutputVS vmain(float3 in_Position : POSITION0, float3 in_Color : COLOR0) { .... } [/code] i can get in_ModelviewProjectionMatrix fromconstant table but in_Position and in_Color aren't exist in constant table. i want use this variables for creating desired VertexDeclaration for my vertex shader automatically in my engine [/quote] Hi, when you look at bits such as : POSITION0, they refer to the position in your vertex declaration which has the index of 0, and the same goes for the colour
  11. [quote name='lucky6969b' timestamp='1307117981' post='4819122'] [code] m_pDevice->SetRenderState (D3DRS_ALPHABLENDENABLE, true); m_pDevice->SetRenderState (D3DRS_ZENABLE, true); [/code] [/quote] Can you post some more code than this? the problem no doubt lies in how you are setting your render states
  12. the front buffer and back buffer are the exact same, they just get swaped during drawing draw to back buffer, flip this to front buffer and present while drawing to the other buffer (now the current back buffer) so after you present the back buffer i suppose you could do what i said by grabbing the front buffer (which it would then be)
  13. Render .X file

    it wont be D3DXLoadMeshFromX() thats causing the problem, i assume thats what the model viewer uses also can you provide your loading code, render code and the d3dParams setup, i would imagine it would be in the params section if lighting is not an issue, and having the z-buffer enabled means that rendering the subsets out in an incorrect order should matter
  14. Hi I'm not all to sure a device to device pass like that is possible, but i suppose you could try setting the destination devices render target to the surface you would normally pass to it, such as: device2->setrendertarget(surface); device1->getrendertarget(surface); i dont want to say that would work, im not sure on how the devices keep track of their surface pointers, but i do know from a brief bit of work on shadow mapping you had to reset the render targets etc, so i should imagine that may work if the surface pointer was not initially null
  15. Problem with 2D Camera

    enable your lighting, generally nothing will draw if you have lighting disabled and all you have is a blank screen