Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 01 Dec 2000
Offline Last Active Apr 02 2014 02:54 PM

Topics I've Started

xna + shaders + model that has multiple textures

01 February 2010 - 04:10 PM

Hi, Drawing a model that has multiple textures using the BasicEffect works pretty straight forward. However using my own custom shaders/effects, how to pass the list textures from a model to the shader? Or rather, get the list of textures from the xna model (using 3d studio 2009 and .fbx). Thanks, Scott

xna + making far away objects move but keeping them unapproachable

09 November 2009 - 05:28 AM

Hi, So in a 3d space scene I have a planet that is drawn very far away. I do not want it to be approachable by the player so I have it drawn at a fixed position around the camera position while ignoring the depth buffer. this works fine however i would prefer it if it would look like it is very very slowly getting closer if i fly towards it (slower then other immediate vicinity objects that is). Earth and beyond did this well.

[.net] (solved)c# streamreader reading line and getting data

22 February 2009 - 06:12 PM

Hi, I'm working on a C# MD5 (doom3) model loader and the Joint data formation is saved such as: "origin" -1 ( 0 0 0 ) ( -0.5 -0.5 -0.5 ) I'm using StreamReader to read the whole line and then I'd like to split the data accordingly, for example split[0] = string // "origin" split[1] = int // -1 split[2] = float // 0 split[3] = float // 0 split[4] = float // 0 split[5] = float // -0.5 split[6] = float // -0.5 split[7] = float // -0.5 Using C I would just use sscanf however c# doesn't seem to have an equivalent that i've come across: sscanf (buff, "%s %d ( %f %f %f ) ( %f %f %f )", joint->name, &joint->parent, &joint->pos[0], &joint->pos[1], &joint->pos[2], &joint->orient[0], &joint->orient[1], &joint->orient[2]) Thanks, Scott [Edited by - Nibbles on February 23, 2009 1:34:37 PM]

screen to world coords on a specific plane

08 February 2009 - 05:30 PM

hi, So I have this function that returns a vector (x, y, z) of the world coords from screen coords (usually the mouse position).
public CVector3 ScreenToWorld(Point p)
            int[] viewport = new int[4];
            double[] modelview = new double[16];
            double[] projection = new double[16];
            float[] wz = new float[1];
            double x, y, z;

            Gl.glGetIntegerv(Gl.GL_VIEWPORT, viewport);
            Gl.glGetDoublev(Gl.GL_MODELVIEW_MATRIX, modelview);
            Gl.glGetDoublev(Gl.GL_PROJECTION_MATRIX, projection);
            Gl.glReadPixels(p.X, viewport[3] - p.Y, 1, 1, Gl.GL_DEPTH_COMPONENT, Gl.GL_FLOAT, wz);
            Glu.gluUnProject(p.X, viewport[3] - (double)p.Y, (double)wz[0], modelview, projection, viewport, out x, out y, out z);

            return new CVector3((float)x, (float)y, (float)z);

However, for my editor i'm working on (4 viewports, Front, Left, Top, and FreeView) I'm trying to have the Front viewport assume the Z value is always 0, the Left viewport assume the X value is always 0, and the Top viewport assume the Y value is always 0. All the viewports are in full 3d, the only thing different is what camera is being used to view the scene. Does anyone see a way to modify this function do that that? or even just one of them? Thanks, Scott

My Quadtree class... I don't know how to test it...

26 November 2008 - 12:31 PM

So I FINALLY grew a pair and actually made an attempt at writing a quadtree class accepting the possibility that I'd get frustrated and quit. I did however managed to whip something out that seems right (to me). Anyways, I have no idea how to test this so if anyone would mind having a quick read through I'd appreciate any advice/criticism/concerns. So far it only builds the quadtree... I'm not sure what the next step is. The coding is probably messy and will stay as such until i know that is in fact... messy. Oh, and I plan on eventually throwing a terrain in the mix (ya, original eh?). Behold:

using System;
using System.Drawing;

namespace MyFramework
    public enum QuadTreeNodeType

    /// <summary>
    /// Description of QuadTreeNode.
    /// </summary>
    public class CQuadTreeNode
        public int iIndex;
        public int iSize;
        public CVector3 v3Center;

        public QuadTreeNodeType Type;

        public CQuadTreeNode qtnParent;
        public CQuadTreeNode[] qtnChild;

        public Rectangle BoundingBox;

        public CQuadTreeNode(CQuadTree quadtree, CQuadTreeNode parent, CVector3 v3center, int size)
            qtnParent = parent;
            if (qtnParent == null)
                Type = QuadTreeNodeType.Root;

            iSize = size;

            v3Center = v3center;

            BoundingBox = new Rectangle((int)v3Center.X - (iSize / 2),	// X
                                        (int)v3Center.Z - (iSize / 2), 	// Y
                                        iSize, 							// W
                                        iSize);							// H

            iIndex = quadtree.iNodeIndex;

            if (iSize > quadtree.iPatchSize)
                Type = QuadTreeNodeType.Node;
                Subdivide(quadtree, this, iSize / 2);
                Type = QuadTreeNodeType.Leaf;

        public void Subdivide(CQuadTree quadtree, CQuadTreeNode parent, int size)
            qtnChild = new CQuadTreeNode[4];

            CVector3 v1 = new CVector3(v3Center.X - (size / 2), 0, v3Center.Z - (size / 2));
            CVector3 v2 = new CVector3(v3Center.X + (size / 2), 0, v3Center.Z - (size / 2));
            CVector3 v3 = new CVector3(v3Center.X - (size / 2), 0, v3Center.Z + (size / 2));
            CVector3 v4 = new CVector3(v3Center.X + (size / 2), 0, v3Center.Z + (size / 2));

            qtnChild[0] = new CQuadTreeNode(quadtree, this, v1, size);
            qtnChild[1] = new CQuadTreeNode(quadtree, this, v2, size);
            qtnChild[2] = new CQuadTreeNode(quadtree, this, v3, size);
            qtnChild[3] = new CQuadTreeNode(quadtree, this, v4, size);

    /// <summary>
    /// Description of QuadTree.
    /// </summary>
    public class CQuadTree
        public int iSize;
        public int iPatchSize;
        public int iNodeIndex;

        CQuadTreeNode qtnRoot;

        public CQuadTree(int size, int patchsize)
            iSize = size;
            iPatchSize = patchsize;
            iNodeIndex = 0;

            qtnRoot = new CQuadTreeNode(this, null, new CVector3(iSize / 2, 0, iSize / 2), size);

Thanks, Scott Ps. After almost 8 years on this bored I suddenly hate my username.