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

andyS91

Members
  • Content count

    3
  • Joined

  • Last visited

Community Reputation

105 Neutral

About andyS91

  • Rank
    Newbie
  1. Is there a way to add a texture to an object so that you can only see it on the shadow side of the object (some kind of inverse lightning)? I've got a sphere with a earth texture on it and a light (sun) rotating around the earth. The lighted side looks fine but the shadow side is just black (or gray shadowed depending on material settings). What i want is to add a 2. texture with earth at night (city lights and so on) which should only be visible on the shadow side and not on the daylight side. I've searched for hours and tried different lightning and blending options but nothing worked. The night texture is either visible everywhere or no where. Any suggestions how to solve this? Thank you in advance! p.s. I'm using DirectX9
  2. Thank you very much - now I've got it! [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img] If someone is having the same problems, here's the code for adding texture coordinates to a standard sphere mesh: [code] public static void ComputeTexCoords(Device device, ref Mesh mesh) { mesh.ComputeNormals(); Mesh newMesh = mesh.Clone(device, mesh.CreationOptions, mesh.VertexFormat | VertexFormat.Texture1); mesh.Dispose(); mesh = newMesh; VertexElement[] elems = mesh.GetDeclaration(); int posElem = FindElementIndex(elems, DeclarationUsage.Position); int normalElem = FindElementIndex(elems, DeclarationUsage.Normal); int texCoordsElem = FindElementIndex(elems, DeclarationUsage.TextureCoordinate); DataStream ds = mesh.LockVertexBuffer(LockFlags.None); while (ds.Position < ds.Length) { long oldPos = ds.Position; Vector3 vec; ds.Position += elems[normalElem].Offset; vec = ds.Read<Vector3>(); ds.Position = oldPos; var phi = Math.Acos((double)vec.Y); var v = (float)(phi / Math.PI); var u = 0f; if (vec.Y == 1.0f || vec.Y == -1.0f) { u = 0.5f; } else { u = (float)(Math.Acos(Math.Max(Math.Min(( double)-vec.Z / Math.Sin(phi), 1.0 ), -1.0)) / (2.0 * Math.PI)) ; u = (vec.X > 0f) ? u : 1 - u; } ds.Position += elems[texCoordsElem].Offset; ds.Write<float>(u); ds.Write<float>(v); ds.Position = oldPos + mesh.BytesPerVertex; } mesh.UnlockVertexBuffer(); }[/code] [code] public static int FindElementIndex(VertexElement[] elems, DeclarationUsage usage) { for (int i = 0; i < elems.Length; ++i) { if (elems[i].Usage == usage) return i; } return -1; }[/code] Just create a sphere with Mesh.CreateSphere and a Texture with Texture.FromFile, call the ComputeTexCoords method with this mesh and your D3D9 device as argument and set up drawing the texture with device.setTexture in your render method. I also recommend to set the renderstate to device.SetRenderState(RenderState.Wrap0, TextureWrapping.WrapCoordinate0) to avoid a ugly seam. Most of the sourcecode isn't written by me (indeed I've written very less of it myself). The underlaying structure is from this post here: [url="http://www.gamedev.net/topic/548474-slimdx-mesh-utility-functions-source-included/"]http://www.gamedev.n...ource-included/[/url] with changes regarding the calculation of the UV-coordinates (which I've taken from here: [url="http://channel9.msdn.com/coding4fun/articles/Ask-the-ZMan-Applying-Textures-Part-3"]http://channel9.msdn...Textures-Part-3[/url]). I hope the authors of those articles don't mind if I reuse their code. Thanks again for your help and good luck for those who try to do the same ;)
  3. I was trying to add some Textures to a sphere created with Mesh.CreateSphere. As far as i know those spheres don't have texture coordinates so i tried to add them using the sample code provided here [url="http://www.gamedev.net/topic/548474-slimdx-mesh-utility-functions-source-included/"]http://www.gamedev.n...ource-included/[/url]. I called the ComputeTexCoords method from the first post with the previously created mesh as argument and then set the texture with SetTexture in the render method (Mike's code in the second post throws for some reason out of bounds exceptions and I don't know why). When launching the program everything seems to be ok but when i rotate the sphere by 90° (no matter in which direction) the texture is highly distorted (like a vortex around the x-axis). The texture I was trying to use is this one: [url="http://celestia.h-schmidt.net/earth-vt/unshaded1024.jpg"]http://celestia.h-sc...nshaded1024.jpg[/url]. If it's helpful i'll post a screenshot of the distorted texture on the sphere later (it's on another computer). Can someone tell me what I'm doing wrong? Is it something with the ComputeTexCoords method or with the Texture? Do I have to change some RenderState/SamplerState settings? Thank you in advance. p.s.: I'm using Direct3D9 with SlimDX and Visual Studio 2008 (C#)