• 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.

Archived

This topic is now archived and is closed to further replies.

mwspider

Pixel-perfect selection of 3D terrain

2 posts in this topic

Hi, I have a terrible problem. I have a 3D terrain made up of a grid of vertices and attached triangles using D3D. The terrain is also attached to a height-map to give it some natural height and variability. Now, using the mouse and keys, you can fly around the map and get any vantage point you wish. Although, your mouse also acts like the usual cursor. What I need is : When the mouse is moved around the screen, I want to know exactly where on the map it is pointing. Not just the vertex or the specific triangle, but where exactly on the triangle. This is a horrible problem I think, anybody have any suggestions on how to do this in D3D ? Spider
0

Share this post


Link to post
Share on other sites
Wow, I just grappled with this problem a couple weeks ago. Anyway I wrote some code to do it and I could just paste it here but there's a bit too much and it does use some strange stuff. Goto http://members.xoom.com/mutex0/defyengine and download the sources.

The mouse-triangle selection code is at the locations listed below.

Vw_Select.cpp
DefyFace.cpp -> CDefyFace::IntersectPoint
DefyPoint.cpp -> CDefyPoint::IntersectPoint

The code backtransforms the mouse screen coordinates into a ray (GetMouseRay). It then loops through either all of the faces defined or all of the points (GetPointAtCoord and GetFaceAtCoord) and calls either CDefyPoint::IntersectPoint or CDefyFace::IntersectPoint, which does the actual intersection calculation.

The face intersection code is a bit easier to understand. First it gets 3 points from the point list for the face. Then it converts the points to a Triangle3 structure (TriangleFromVectors in DefyPoint.cpp).

After that it calls LineTriangleIntersection (linetri.cpp) which calculates the intersection point of a ray and a triangle. Linetri.cpp was obtained from Magic Software at http://www.cs.unc.edu/~eberly.

There was a post on one of the forums here about this and most of the info was from a post by someone (can't remember name).

Hope that helps.


Edited by - mutex on 1/19/00 7:10:04 PM
0

Share this post


Link to post
Share on other sites
Hey Spider,
About a week ago, I offered a routine for finding whether a 2d pixel is inside a 2d triangle. You just have to pass the pixel to the function, and the three points of the triangle. If you want the code, email me at jraptis@csmi.com.

If you can get to the direct3d transformations after they''ve been transformed, you can use this. If you don''t know how to, direct3d has a function called PICK (look it up in the SDK) which claims to tell you if a point is within a triangle on an execute buffer. I''ve never used PICK myself, so I don''t know how it works, or even if.

BTW, if you know how to get at d3d vertices after the transform, drop me some code! I know processvertices does it, but I can''t seem to make it work (I use old-fashioned execute buffers, not drawprimitives).

--Goodlife
0

Share this post


Link to post
Share on other sites