Esempio n. 1
0
        public GUISprite(Point2f pos, Size2f size)
        {
            vertices=	new Point3f[4];
            texcoords=	new TexCoord[4];
            colors=	new Color[4];
            faces=	new ushort[6];

            vertices[0]=	new Point3f(pos.x, pos.y, 0f);
            vertices[1]=	new Point3f(pos.x, pos.y+size.height, 0f);
            vertices[2]=	new Point3f(pos.x+size.width, pos.y+size.height, 0f);
            vertices[3]=	new Point3f(pos.x+size.width, pos.y, 0f);

            texcoords[0]=	new TexCoord(0f, 0f);
            texcoords[1]=	new TexCoord(0f, 1f);
            texcoords[2]=	new TexCoord(1f, 1f);
            texcoords[3]=	new TexCoord(1f, 0f);

            applyColor(new Color(255, 255, 255, 255));

            faces[0]=	0;	faces[1]=	1;	faces[2]=	3;
            faces[3]=	1;	faces[4]=	2;	faces[5]=	3;

            bvolume=	new BVRectangle(pos, pos+size);
            comp=	null;
            tb=	new Rectangle(0f, 0f, 1f, 1f);
        }
Esempio n. 2
0
        public static Point3f calcCatmullRom(float t, Point3f p1, Point3f p2, Point3f p3, Point3f p4)
        {
            // Variables
            Vector3	converted=	calcCatmullRom(t, (Vector3)p1, (Vector3)p2, (Vector3)p3, (Vector3)p4);

            return (Point3f)(converted);
        }
Esempio n. 3
0
        public MatrixLMesh(Matrix m)
            : base(new Point3f[]{Point3f.ORIGIN}, new Color(0f), new ushort[]{0})
        {
            vertices=	new Point3f[6];
            colors=	new Color[6];
            faces=	new ushort[6];
            lineWidth=	1f;

            vertices[0]=	new Point3f(m.ox, m.oy, m.oz);
            vertices[1]=	vertices[0]+m.xAxis;
            vertices[2]=	new Point3f(m.ox, m.oy, m.oz);
            vertices[3]=	vertices[2]+m.yAxis;
            vertices[4]=	new Point3f(m.ox, m.oy, m.oz);
            vertices[5]=	vertices[4]+m.zAxis;

            colors[0]=	new Color(255, 0, 0);
            colors[1]=	new Color(255, 0, 0);
            colors[2]=	new Color(0, 0, 255);
            colors[3]=	new Color(0, 0, 255);
            colors[4]=	new Color(0, 255, 0);
            colors[5]=	new Color(0, 255, 0);

            faces[0]=	(ushort)0;
            faces[1]=	(ushort)1;
            faces[2]=	(ushort)2;
            faces[3]=	(ushort)3;
            faces[4]=	(ushort)4;
            faces[5]=	(ushort)5;
        }
Esempio n. 4
0
 // Resizes the sprite to accomidate the gui component
 public void resize(Point2i pt, Size2i size)
 {
     vertices[0]=	new Point3f(pt.x, pt.y, 0f);
     vertices[1]=	new Point3f(pt.x, pt.y+size.height, 0f);
     vertices[2]=	new Point3f(pt.x+size.width, pt.y+size.height, 0f);
     vertices[3]=	new Point3f(pt.x+size.width, pt.y, 0f);
     bvolume=	new BVBox(pt.toPoint3f(), (pt+size).toPoint3f());
 }
Esempio n. 5
0
 public LMesh(Point3f[] v, Color c, ushort[] f)
 {
     vertices=	v;
     colors=	new Color[v.Length];
     applyColor(c);
     faces=	f;
     lineWidth=	1f;
 }
Esempio n. 6
0
 public QMesh(Point3f[] v, TexCoord[] uvs, Color c, ushort[] f)
     : base()
 {
     vertices=	v;
     texcoords=	uvs;
     colors=	new Color[v.Length];
     applyColor(c);
     faces=	f;
 }
Esempio n. 7
0
        // Adds the given point to the spline
        public bool addPoint(Point3f point)
        {
            if(points.add(point))
            {
                segmentSize=	1/(float)points.size;

                return true;
            }

            return false;
        }
Esempio n. 8
0
 internal QMesh(Point3f[] v, TexCoord[] t, Color[] c, ushort[] f, Matrix m, Texture tx, string n, Bone[] pmBones, bool outline)
     : base(Matrix.IDENTITY, pmBones)
 {
     vertices=	v;
     texcoords=	t;
     colors=	c;
     faces=	f;
     pMatrix=	m;
     pTexture=	tx;
     name=	n;
     bRenderOutline=	outline;
 }
Esempio n. 9
0
        public GUISprite()
        {
            vertices=	new Point3f[4];
            texcoords=	new TexCoord[4];
            colors=	new Color[4];
            faces=	new ushort[6];

            for(int i= 0; i< vertices.Length; i++)
                vertices[i]=	Point3f.ORIGIN;
            texcoords[0]=	new TexCoord(0f, 0f);
            texcoords[1]=	new TexCoord(0f, 1f);
            texcoords[2]=	new TexCoord(1f, 1f);
            texcoords[3]=	new TexCoord(1f, 0f);

            colors[0]=	new Color(1f);
            colors[1]=	new Color(1f);
            colors[2]=	new Color(1f);
            colors[3]=	new Color(1f);

            faces[0]=	0;	faces[1]=	1;	faces[2]=	3;
            faces[3]=	1;	faces[4]=	2;	faces[5]=	3;
            bvolume=	null;
        }
Esempio n. 10
0
 public CircleLMesh(Point3f pos, float rad, int segments, Color c)
     : base(new Point3f[]{Point3f.ORIGIN}, new Color(255, 255, 255), new ushort[]{0})
 {
     pRadius=	rad;
     pMatrix=	Matrix.IDENTITY;
     pMatrix.translation=	pos;
     vertices=	Mathx.createCircularPoints(pos, rad, segments);
     colors=	new Color[vertices.Length];
     applyColor(c);
     faces=	new ushort[vertices.Length*2];
     for(int i= 0; i< vertices.Length; i++)
     {
         if(i== vertices.Length-1)
         {
             faces[i*2]=	(ushort)i;
             faces[i*2+1]=	(ushort)0;
         }
         else
         {
             faces[i*2]=	(ushort)i;
             faces[i*2+1]=	(ushort)(i+1);
         }
     }
 }
Esempio n. 11
0
 // Subtracts the point with the size to get another point
 public Point3f subtract(Point3f pt)
 {
     return new Point3f(width-pt.x, height-pt.y, depth-pt.z);
 }
Esempio n. 12
0
 // Adds the point with the size to get another point
 public Point3f add(Point3f pt)
 {
     return new Point3f(width+pt.x, height+pt.y, depth+pt.z);
 }
Esempio n. 13
0
        // Gets the minimum value of the point
        public static Point3f min(Point3f value, Point3f min)
        {
            // Variables
            Point3f	temp=	value;

            if(value.x< min.x)
                temp.x=	min.x;
            if(value.y< min.y)
                temp.y=	min.y;
            if(value.z< min.z)
                temp.z=	min.z;

            return temp;
        }
Esempio n. 14
0
        // Gets the maximum value of the point
        public static Point3f max(Point3f value, Point3f max)
        {
            // Variables
            Point3f	temp=	value;

            if(value.x> max.x)
                temp.x=	max.x;
            if(value.y> max.y)
                temp.y=	max.y;
            if(value.z> max.y)
                temp.z=	max.z;

            return temp;
        }
Esempio n. 15
0
        // Creates a cylindrical bounding volume from the given 3d points
        public static BVCylinder createFromPoints(Point3f[] vertices)
        {
            if(vertices== null)
                throw new ArgumentNullException();
            if(vertices.Length== 0)
                throw new ArgumentException("No vertices declared");

            // Variables
            Point3f	min=	new Point3f(float.MinValue);
            Point3f	max=	new Point3f(float.MaxValue);
            float	r;
            float	h;

            for(int i= 0; i< vertices.Length; i++)
            {
                min=	Mathx.min(vertices[i], min);
                max=	Mathx.max(vertices[i], max);
            }

            r=	Mathx.calcLength(max.x-min.x, max.z-min.z);
            r/=	2f;
            h=	max.y-min.y;
            min=	max|min;
            min.y=	max.y;

            return new BVCylinder(min, h, r);
        }
Esempio n. 16
0
        // Creates a circular bounding volume from the given 3d points
        public static BVCircle createFromPoints(Point3f[] vertices)
        {
            if(vertices== null)
                throw new ArgumentNullException();

            // Variables
            Point2f[]	results=	new Point2f[vertices.Length];

            for(int i= 0; i< vertices.Length; i++)
            {
                results[i].x=	vertices[i].x;
                results[i].y=	vertices[i].y;
            }

            return createFromPoints(results);
        }
Esempio n. 17
0
 // Subtracts the two points to get a vector pointing in between both
 public Vector3 subtract(Point3f pt)
 {
     return new Vector3((float)x-pt.x, (float)y-pt.y, 0f-pt.z);
 }
Esempio n. 18
0
 public Sound play(string key, Point3f pos)
 {
     return play(key, pos, false);
 }
Esempio n. 19
0
        // Creates a bounding volume box from the given 3d points
        public static BVBox createFromPoints(Point3f[] vertices)
        {
            if(vertices== null)
                throw new ArgumentNullException();
            if(vertices.Length== 0)
                throw new Exception("Vertices not declared");

            // Variables
            Point3f	pmMin=	new Point3f(float.MinValue);
            Point3f	pmMax=	new Point3f(float.MaxValue);

            for(int i= 0; i< vertices.Length; i++)
            {
                pmMin=	Mathx.min(vertices[i], pmMin);
                pmMax=	Mathx.max(vertices[i], pmMax);
            }

            return new BVBox(pmMin, pmMax);
        }
Esempio n. 20
0
        // Plays the given sound, if found, in a 3d perspective
        public Sound play(string key, Point3f pos, bool loop)
        {
            // Variables
            int	index=	game.loadedSounds.getIndex(key);
            int	channel;
            Sound	sound;

            if(index== -1)
                return new Sound(-1);
            sound=	game.loadedSounds.getValueByIndex(index);

            channel=	getNextFreeChannel();

            if(channel== -1)
                return new Sound(-1);

            Al.alSourceStop(channel);
            Al.alListener3f(Al.AL_POSITION, pos.x, pos.y, pos.z);
            Al.alListener3f(Al.AL_VELOCITY, 0f, 0f, 0f);
            Al.alSourcei(channel, Al.AL_BUFFER, sound.ID);
            Al.alSourcef(channel, Al.AL_PITCH, sound.pVolume);
            Al.alSourcef(channel, Al.AL_GAIN, pMasterVolume);

            if(loop)
                Al.alSourcei(channel, Al.AL_LOOPING, 1);
            else
                Al.alSourcei(channel, Al.AL_LOOPING, 0);

            sound.channel=	channel;
            Al.alSourcePlay(channel);

            return sound;
        }
Esempio n. 21
0
 public BVBox(Point3f pmMin, Point3f pmMax)
 {
     min=	Mathx.getMostMin(pmMin, pmMax);
     max=	Mathx.getMostMax(pmMin, pmMax);
     position=	max|min;
 }
Esempio n. 22
0
 public BVCylinder(Point3f pmPos, float pmHeight, float pmRadius)
 {
     pPos=	pmPos;
     height=	Math.Abs(pmHeight);
     pRadius=	Math.Abs(pmRadius);
 }
Esempio n. 23
0
 // Sets the bounds for rendering without calling the event
 internal void setBounds(Rectangle rect)
 {
     vertices[0]=	new Point3f(rect.x, rect.y, 0f);
     vertices[1]=	new Point3f(rect.x, rect.y+rect.height, 0f);
     vertices[2]=	new Point3f(rect.x+rect.width, rect.y+rect.height, 0f);
     vertices[3]=	new Point3f(rect.x+rect.width, rect.y, 0f);
     bvolume=	new BVRectangle(rect.x, rect.y, rect.width, rect.height);
 }
Esempio n. 24
0
        // Clamps the point to the given min and max bounds
        public static Point3f clamp(Point3f value, Point3f min, Point3f max)
        {
            // Variables
            Point3f	temp=	value;

            if(value.x< min.x)
                temp.x=	min.x;
            else if(value.x> max.x)
                temp.x=	max.x;
            if(value.y< min.y)
                temp.y=	min.y;
            else if(value.y> max.y)
                temp.y=	max.y;
            if(value.z< min.z)
                temp.z=	min.z;
            else if(value.z> max.z)
                temp.z=	max.z;

            return temp;
        }
Esempio n. 25
0
 // Gets the midpoint of the two points
 public Point3f getMidpoint(Point3f pt)
 {
     return new Point3f(((float)x+pt.x)/2f, ((float)y+pt.y)/2f, (0+pt.z)/2f);
 }
Esempio n. 26
0
        // Gives you a set of points that create a circle with the given position
        public static Point3f[] createCircularPoints(Point3f pos, float radius, int vertexAmount)
        {
            // Variables
            Point3f[]	points=	new Point3f[vertexAmount];
            float	segment=	TWO_PI_F/(float)vertexAmount;

            for(int i= 0; i< vertexAmount; i++)
            {
                points[i].x=	pos.x+radius*(float)(Math.Cos(i*segment));
                points[i].y=	pos.y;
                points[i].z=	pos.z+radius*(float)(Math.Sin(i*segment));
            }

            return points;
        }
Esempio n. 27
0
 public LMesh(Point3f[] v, ushort[] f)
     : this(v, new Color(1f), f)
 {
 }
Esempio n. 28
0
        // Gets the most minimum point of the two given points
        public static Point3f getMostMin(Point3f val1, Point3f val2)
        {
            // Variables
            Point3f	pt=	Point3f.ORIGIN;

            if(val1.x< val2.x)
                pt.x=	val1.x;
            else
                pt.x=	val2.x;
            if(val1.y< val2.y)
                pt.y=	val1.y;
            else
                pt.y=	val2.y;
            if(val1.z< val2.z)
                pt.z=	val1.z;
            else
                pt.z=	val2.z;

            return pt;
        }
Esempio n. 29
0
 public override bool contains(ref Point3f pt)
 {
     return contains(ref pt.x, ref pt.y);
 }
Esempio n. 30
0
 public BVBox(Point3f pmMin, Size3f size)
     : this(pmMin, pmMin+size)
 {
 }