• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.

amigo1970

Members
  • Content count

    12
  • Joined

  • Last visited

Community Reputation

100 Neutral

About amigo1970

  • Rank
    Member
  1. Thanks again ApochPiQ, the thing is that this is a test.. they have give me a non working game that needs to be repair. I get stuck into this point... everything is working well till the m_Contact is call (that's what show in the watch), then all values comes wrong. So i was thiniking maybe there is a problem with that value.
  2. [CODE] #include "Entity.h" #include <wchar.h> #include "float.h" #include "Graphics/RenderItem.h" using Sfas::Game::Entity; Entity::Entity( int id ) : m_Position( 0.0f, 0.0f, 0.0f ), m_Velocity( 0.0f, 0.0f, 0.0f ), m_Acceleration( 0.0f, 0.0f, 0.0f ), m_LastFrameAcceleration( 0.0f, 0.0f, 0.0f ), m_ForceAccumulator( 0.0f, 0.0f, 0.0f ), m_Scale( 1.0f, 1.0f, 1.0f ), m_ContactNormal( 0.0f, 0.0f, 0.0f ), m_ContactPoint( 0.0f, 0.0f, 0.0f ), m_Movement( 0.0f, 0.0f, 0.0f ), m_Contact( 0 ), m_Radius( 0.0f ), m_Damping(0.99f), m_InverseMass(0.0f), m_TimeActive(0.0f), m_Restitution(0.0f), m_Penetration(0.0f), m_Friction(0.0f), m_Tolerance(0.0f), m_ID( id ), m_Active(false), m_Collision(false) { } Entity::Entity( int id, float scale, float damping ) : m_Position( 0.0f, 0.0f, 0.0f ), m_Velocity( 0.0f, 0.0f, 0.0f ), m_Acceleration( 0.0f, 0.0f, 0.0f ), m_LastFrameAcceleration( 0.0f, 0.0f, 0.0f ), m_ForceAccumulator( 0.0f, 0.0f, 0.0f ), m_Scale( scale, scale, scale ), m_ContactNormal( 0.0f, 0.0f, 0.0f ), m_ContactPoint( 0.0f, 0.0f, 0.0f ), m_Movement( 0.0f, 0.0f, 0.0f ), m_Contact( 0 ), m_Radius( 0.0f ), m_Damping(damping), m_InverseMass(0.0f), m_TimeActive(0.0f), m_Restitution(0.0f), m_Penetration(0.0f), m_Friction(0.0f), m_Tolerance(0.0f), m_ID( id ), m_Active(false), m_Collision(false) { } Entity::Entity( int id, const D3DXVECTOR3& pos, float scale, float damping ) : m_Position(pos), m_Velocity( 0.0f, 0.0f, 0.0f ), m_Acceleration( 0.0f, 0.0f, 0.0f ), m_LastFrameAcceleration( 0.0f, 0.0f, 0.0f ), m_ForceAccumulator( 0.0f, 0.0f, 0.0f ), m_Scale( scale, scale, scale ), m_ContactNormal( 0.0f, 0.0f, 0.0f ), m_ContactPoint( 0.0f, 0.0f, 0.0f ), m_Movement( 0.0f, 0.0f, 0.0f ), m_Contact( 0 ), m_Radius( 0.0f ), m_Damping(damping), m_InverseMass(0.0f), m_TimeActive(0.0f), m_Restitution(0.0f), m_Penetration(0.0f), m_Friction(0.0f), m_Tolerance(0.0f), m_ID( id ), m_Active(false), m_Collision(false) { } Entity::Entity( int id, const D3DXVECTOR3& pos, const D3DXVECTOR3& scale, float damping ) : m_Position(pos), m_Velocity( 0.0f, 0.0f, 0.0f ), m_Acceleration( 0.0f, 0.0f, 0.0f ), m_LastFrameAcceleration( 0.0f, 0.0f, 0.0f ), m_ForceAccumulator( 0.0f, 0.0f, 0.0f ), m_Scale( scale ), m_ContactNormal( 0.0f, 0.0f, 0.0f ), m_ContactPoint( 0.0f, 0.0f, 0.0f ), m_Movement( 0.0f, 0.0f, 0.0f ), m_Contact( 0 ), m_Radius( 0.0f ), m_Damping(damping), m_InverseMass(0.0f), m_TimeActive(0.0f), m_Restitution(0.0f), m_Penetration(0.0f), m_Friction(0.0f), m_Tolerance(0.0f), m_ID( id ), m_Active(false), m_Collision(false) { } Entity::~Entity(void) { } void Entity::Render( Engine::RenderItem * drw ) { if( m_Active ) { D3DXMATRIX world; D3DXMATRIX move; D3DXMATRIX scale; D3DXMatrixTranslation( &move, m_Position.x, m_Position.y, m_Position.z ); D3DXMatrixScaling( &scale, m_Scale.x, m_Scale.y, m_Scale.z ); world = scale * move; drw->Draw( &world ); } } void Entity::Update( float dt ) { if( m_Active ) { m_ForceAccumulator.y -= ( kGravity * GetMass() ); LinearIntegration( dt ); // Count this frame m_TimeActive += dt; } } bool Entity::CheckForCollision( const Entity& other ) { float left1 = m_Position.x - ( m_Scale.x * 0.5f ); float left2 = other.m_Position.x - ( other.m_Scale.x * 0.5f ); float right1 = left1 + m_Scale.x; float right2 = left2 + other.m_Scale.x; float top1 = m_Position.y + ( m_Scale.y * 0.5f ); float top2 = other.m_Position.y + ( other.m_Scale.y * 0.5f ); float bottom1 = top1 - m_Scale.y; float bottom2 = top2 - other.m_Scale.y; if (bottom1 > top2) return false; if (top1 < bottom2) return false; if (right1 < left2) return false; if (left1 > right2) return false; // Create the contact information ready for resolution D3DXVECTOR3 direction = m_Position - other.m_Position; D3DXVec3Normalize( &direction, &direction ); m_ContactPoint = other.m_Position + ( direction * other.m_Radius ); if( other.m_Collision && top1 >top2 && bottom1 < top2 ) { m_Penetration = top2 - bottom1; m_ContactNormal = D3DXVECTOR3( 0.0f, 1.0f, 0.0f ); } return true; } void Entity::OnCollision( Entity& other ) { // Default behavour SetActive( false ); } void Entity::LinearIntegration( float dt ) { // Don't Integrate invalid particles if (m_InverseMass <= 0.0f) { return; } // Update current position with velocity m_Position += ( m_Velocity * dt ); // Calculate acceleration m_LastFrameAcceleration = m_Acceleration; m_LastFrameAcceleration += ( m_ForceAccumulator * m_InverseMass ); // Calculate velocity m_Velocity += ( m_LastFrameAcceleration * dt ); // Damp the velocity to slow the object over time m_Velocity *= pow(m_Damping, dt); // Save and clear forces m_ForceAccumulator.x = m_ForceAccumulator.y = m_ForceAccumulator.z = 0.0f; } void Entity::SetMass( float mass) { m_InverseMass = ( 1.0f / mass ); } float Entity::GetMass() const { if( m_InverseMass == 0 ) { return FLT_MAX; } else { return (1.0f / m_InverseMass ); } } float Entity::CalculateSeparatingVelocity( Entity& other ) { D3DXVECTOR3 relativeVelocity = m_Velocity; relativeVelocity -= other.GetVelocity(); return D3DXVec3Dot(&relativeVelocity, &m_ContactNormal); } void Entity::Resolve(Entity& other, float duration) { m_Contact = &other; ResolveVelocity(duration); ResolveInterpenetration(duration); } void Entity::ResolveVelocity(float duration) { float separatingVelocity = 0.1f; if( m_Contact != 0 ) { // Find the velocity in the direction of the contact separatingVelocity = CalculateSeparatingVelocity(*m_Contact); } // Check if it needs to be resolved if (separatingVelocity > 0) { // The contact is either separating, or stationary - there's // no impulse required. return; } // Calculate the new separating velocity float newSepVelocity = -separatingVelocity * m_Restitution; // Check the velocity build-up due to acceleration only D3DXVECTOR3 accCausedVelocity = m_LastFrameAcceleration; if (m_Contact != 0) { accCausedVelocity -= m_Contact->GetAcceleration(); } D3DXVECTOR3 normalThisFrame = m_ContactNormal * duration; float accCausedSepVelocity = D3DXVec3Dot( &accCausedVelocity, &normalThisFrame ); // If we've got a closing velocity due to acelleration build-up, // remove it from the new separating velocity if (accCausedSepVelocity < 0) { newSepVelocity += m_Restitution * accCausedSepVelocity; // Make sure we haven't removed more than was // there to remove. if (newSepVelocity < 0) { newSepVelocity = 0; } } float deltaVelocity = newSepVelocity - separatingVelocity; // We apply the change in velocity to each object in proportion to // their inverse mass (i.e. those with lower inverse mass [higher // actual mass] get less change in velocity).. float totalInverseMass = m_InverseMass; if (m_Contact != 0) { totalInverseMass += m_Contact->m_InverseMass; } // If all particles have infinite mass, then impulses have no effect if (totalInverseMass <= 0) { return; } // Calculate the impulse to apply float impulse = deltaVelocity / totalInverseMass; // Find the amount of impulse per unit of inverse mass D3DXVECTOR3 impulsePerIMass = m_ContactNormal * impulse; // Apply impulses: they are applied in the direction of the contact, // and are proportional to the inverse mass. m_Velocity = ( m_Velocity + impulsePerIMass * m_InverseMass ); if( m_Contact != 0 ) { // Particle 1 goes in the opposite direction m_Contact->m_Velocity = ( m_Contact->m_Velocity + impulsePerIMass * -m_Contact->m_InverseMass ); } } void Entity::ResolveInterpenetration(float duration) { // If we don't have any penetration, skip this step. if (m_Penetration <= 0) { return; } // The movement of each object is based on their inverse mass, so // total that. float totalInverseMass = m_InverseMass; if ( m_Contact != 0 ) { totalInverseMass += m_Contact->m_InverseMass; } // If all particles have infinite mass, then we do nothing if (totalInverseMass <= 0) { return; } // Find the amount of penetration resolution per unit of inverse mass D3DXVECTOR3 movePerIMass = m_ContactNormal * (m_Penetration / totalInverseMass); // Calculate the the movement amounts m_Movement = movePerIMass * m_InverseMass; if( m_Contact != 0 ) { m_Contact->m_Movement = movePerIMass * -m_Contact->m_InverseMass; } // Apply the penetration resolution m_Position = ( m_Position + m_Movement ); if( m_Contact != 0 ) { m_Contact->SetPosition(m_Contact->m_Position + m_Contact->m_Movement); } } [/CODE] Really, really appreciate all this help..
  3. [CODE] Entity::Entity( int id ) : m_Position( 0.0f, 0.0f, 0.0f ), m_Velocity( 0.0f, 0.0f, 0.0f ), m_Acceleration( 0.0f, 0.0f, 0.0f ), m_LastFrameAcceleration( 0.0f, 0.0f, 0.0f ), m_ForceAccumulator( 0.0f, 0.0f, 0.0f ), m_Scale( 1.0f, 1.0f, 1.0f ), m_ContactNormal( 0.0f, 0.0f, 0.0f ), m_ContactPoint( 0.0f, 0.0f, 0.0f ), m_Movement( 0.0f, 0.0f, 0.0f ), m_Contact( 0 ), m_Radius( 0.0f ), m_Damping(0.99f), m_InverseMass(0.0f), m_TimeActive(0.0f), m_Restitution(0.0f), m_Penetration(0.0f), m_Friction(0.0f), m_Tolerance(0.0f), m_ID( id ), m_Active(false), m_Collision(false) { [/CODE] This the Entity.cpp Thanks very much..
  4. After new ways of usage the debugger explained by a friend and in here.. I think I found the problem, but i dunno yet the solution.. [attachment=8526:mContact.jpg] Any ideas, clues or expl., are more than welcome. Thanks for this
  5. So the code looks ok? there is a way to find the problem from null pointer Thanks for super fast response
  6. Sorry i need fresh ideas I duno where to go, stuck in here for a big while. Is this expresion wrong? [attachment=8494:lives.jpg] or maybe this? [attachment=8495:matrix.jpg] any clue, ideas, or explanation will be very, very apreciated. Thanks for oyur time and always support.
  7. Sorry I just realize that it's better and simple to use windows msg instead of direct input.. Any good tutorial or reference Thanks
  8. Thanks, wrong size of the buffer, as u said. Really appreciate the super fast response.
  9. <code> void TextRenderer::DrawFormattedTextLine( const WCHAR* strMsg, int x, int y, D3DXCOLOR colour, ... ) { WCHAR strBuffer[512]; va_list args; va_start( args, strMsg ); swprintf_s( strBuffer, 512, strMsg, args ); strBuffer[511] = L'\0'; va_end( args ); DrawTextLine( strBuffer, x, y, colour ); } </code>
  10. Hi to alll Devs. Sorry i've been stuck for a few hours in here.... Ive got a not working little game that i must make it to work. There is no errors now but the one attached.. i'v been looking around but nothing clear. the last chage i made and maybe is that the problem. was in swprintf_s( strBuffer, 512, strMsg, args ); identifier not found for swprintf_s. so I add #include <wchar.h> in the header to make it work as seen that the little game use this instead of <stdio.h>. Please help!!. Any clue pointing or fresh ideas are more than welcome. Thanks in advance for all your time.
  11. Hello to all Dev's.. Just new around here, sorry for my lack of knowledge.. I've got a couple of questions here. stock for a while before posting. 1. I've implement a vrml loader and found that the normal index and coord index from Maya sometimes came with 4 values. The question is that i manage to read the 3 values when usually happens, but not load properly with the fourth one. i've done something like.. fscanf(fp,"%d %d %d %d %d",&(ind[i]), &(ind[i+1]), &ind[i+2], &ind[i+3],&temp); Read them but not in correct order. 2. How to load the Normals and the coordinates from a wrml loader from Max. I manage to load the mesh but not the normals and coordinates acording int i,j; for (j=0;j<noofshapes;j++) { for (i=0;i<noofpoly[j]*3;i=i+3) { glBegin(GL_TRIANGLES); //glNormal3f( &(norms[j][3*nindices[j][i])); I've try this glVertex3fv(&(coords[j][3*indices[j][i]])); //glTexCoord2f.. what in here? glVertex3fv(&(coords[j][3*indices[j][i+1]])); //glTexCoord2f.. what in here? glVertex3fv(&(coords[j][3*indices[j][i+2]])); //glTexCoord2f.. what in here? glEnd(); } } And if someone can point me to tutorials about OpenGl and games even paid ones? Thanks in advance and sorry for my In glish [img]http://www.opengl.org/discussion_boards/images/graemlins/default/wink.gif[/img]