小编bbo*_*sak的帖子

斜坡碰撞检查

我正在开发一个新游戏,并试图根据玩家相对于斜坡坐标的坐标来检测玩家(在斜坡上)是否与给定的网格发生碰撞。我正在使用这个功能,它似乎不起作用(斜率似乎太小或什么)

//Slopes



        float slopeY = max.Y-min.Y;

    float slopeZ = max.Z-min.Z;

    float slopeX = max.X-min.X;

    float angle = (float)Math.Atan(slopeZ/slopeY);

    //Console.WriteLine(OpenTK.Math.Functions.RadiansToDegrees((float)Math.Atan(slopeZ/slopeY)).ToString()+" degrees incline");



    slopeY = slopeY/slopeZ;

    float slopeZX = slopeY/slopeX;

    //End slopes

    float surfaceposX = max.X-coord.X;

    float surfaceposY = max.Y-coord.Y;

    float surfaceposZ = min.Z-coord.Z;



    min-=sval;

    max+=sval;

    //Surface coords



    //End surface coords



    //Y SHOULD = mx+b, where M = slope and X = surfacepos, and B = surfaceposZ



    if(coord.X<max.X& coord.X>min.X&coord.Y>min.Y&coord.Y<max.Y&coord.Z>min.Z&coord.Z<max.Z) {







        if(slopeY !=0) {

        Console.WriteLine("Slope = "+slopeY.ToString()+"SlopeZX="+slopeZX.ToString()+" surfaceposZ="+surfaceposZ.ToString());

            Console.WriteLine(surfaceposY-(surfaceposY*slopeY));



            //System.Threading.Thread.Sleep(40000);



        if(surfaceposY-(surfaceposZ*slopeY)<3 || surfaceposY-(surfaceposX*slopeZX)<3) …
Run Code Online (Sandbox Code Playgroud)

c# collision-detection opentk

5
推荐指数
1
解决办法
1113
查看次数

WP7芒果 - 如何获取给定主机名的IP地址

我需要从DnsEndPoint获取给定主机名的IP地址,并将其转换为IPEndPoint.我该怎么做呢?WP7缺少Dns.GetHostEntry函数,所以有没有办法在不创建Socket的情况下执行此操作,将数据发送到主机,然后从主机接收ping并读取RemoteEndPoint属性以获取主机的IP地址?

c# ip dns windows-phone-7

5
推荐指数
1
解决办法
3758
查看次数

C# - Convert.ToSingle()的更快替代品

我正在研究一个从文本文件中读取数百万个浮点数的程序.这个程序在我正在设计的游戏中运行,所以我需要它快速(我正在加载一个obj文件).到目前为止,由于Convert.ToSingle()的速度较慢,加载一个相对较小的文件大约需要一分钟(没有预编译).有更快的方法吗?

编辑:这是我用来解析Obj文件的代码

http://pastebin.com/TfgEge9J

using System;
using System.IO;
using System.Collections.Generic;
using OpenTK.Math;
using System.Drawing;
using PlatformLib;

public class ObjMeshLoader
{
    public static StreamReader[] LoadMeshes(string fileName)
    {
        StreamReader mreader = new StreamReader(PlatformLib.Platform.openFile(fileName));
        MemoryStream current = null;
        List<MemoryStream> mstreams = new List<MemoryStream>();
        StreamWriter mwriter = null;

        if (!mreader.ReadLine().Contains("#"))
        {
            mreader.BaseStream.Close();
            throw new Exception("Invalid header");
        }

        while (!mreader.EndOfStream)
        {
            string cmd = mreader.ReadLine();
            string line = cmd;
            line = line.Trim(splitCharacters);
            line = line.Replace("  ", " ");

            string[] parameters = line.Split(splitCharacters);
            if (parameters[0] == "mtllib") …
Run Code Online (Sandbox Code Playgroud)

c# opengl mono opentk

4
推荐指数
1
解决办法
2671
查看次数

如何使用msi安装程序安装同一应用程序的多个实例

我正在使用visual studio设置项目来创建我的msi安装程序.我的要求是使用相同的安装程序创建应用程序的多个实例,而不更改版本号/产品代码.

没有使用Wix/Installshield有没有办法做到这一点.

c# deployment windows-installer

3
推荐指数
2
解决办法
4534
查看次数

C#相当于VB 6串口SETTINGS功能

在C#中,以下命令的等价物是什么?comm.Settings ="2400,N,8,1"

c# vb6

2
推荐指数
1
解决办法
446
查看次数

为UDP数据包添加额外的校验和是否值得额外开销?

我正在开发一个通过UDP传输加密文件的应用程序(是的;我知道UDP通常不用于文件传输,但这是一个边缘情况),并且想知道它是否值得增加额外校验和的额外开销到包.我知道UDP数据包不会被损坏,但是添加额外的校验和是否值得?

.net c# networking udp

2
推荐指数
1
解决办法
667
查看次数

MemoryStream.SetLength(0)和MemoryStream.Capacity = 0不清除已用内存

我有一个流媒体的程序,它创建两个巨大的MemoryStreams,然后在完成后需要将它们归零.问题是,在我调用BOTH MemoryStream.SetLength(0)后,内存似乎没有被回收; 和MemoryStream.Capacity = 0. GC.Collect()似乎解决了这个问题,但我听说这是糟糕的编程习惯,因为它会导致应用程序中的所有线程挂起; 虽然挂起的线程在短时间内不会成为问题,但需要清除内存.但是,如果问题有另一种解决方法,那就太好了.有什么建议?

.net c# garbage-collection memorystream

2
推荐指数
1
解决办法
1518
查看次数

适用于Windows 8的任何简单的DirectX示例(开发人员预览版)?

有没有关于如何在DirecX for Windows 8 Developer预览中绘制简单三角形的好教程?游戏示例太复杂,无法理解新DirectX版本的"基本"工作方式(这似乎与DirectX 9完全不同).

c# c++ directx windows-8

2
推荐指数
1
解决办法
3081
查看次数

DotNetZip - 如何在不创建单独文件的情况下保存回原始流

我正在开发一个系统,我有一个Stream(可以搜索),我正在读取一个ZIP文件,然后我将修改后的ZIP文件写回该流.这样做会导致文件损坏.这可以使用以下代码演示:


using System;
using System.Collections.Generic;
using System.Text;
using Ionic.Zip;
using System.Windows.Forms;
using System.IO;
namespace ziptester
{
    class Program
    {
        [STAThread]
        static void Main(string[] args)
        {
            OpenFileDialog mdlg = new OpenFileDialog();
            mdlg.ShowDialog();
            Stream fstream = File.Open(mdlg.FileName,FileMode.Open,FileAccess.ReadWrite);
            ZipFile mfile = ZipFile.Read(fstream);
            mfile.UpdateEntry("test.txt", new byte[500]);
            fstream.Position = 0;
            mfile.SaveProgress += new EventHandler(mfile_SaveProgress);
            mfile.Save(fstream);


            Console.ReadKey();
        }

        static void mfile_SaveProgress(object sender, SaveProgressEventArgs e)
        {
            if (e.EventType == ZipProgressEventType.Saving_Completed)
            {
                Console.WriteLine("Save completed");
            }
        }
    }
}

.net c# stream dotnetzip

2
推荐指数
1
解决办法
711
查看次数

Visual Studio 中的 Windows 内核调试器如何工作?

我最近开始尝试为 Windows 开发文件系统驱动程序,并开始研究 Visual Studio 2013 中提供的内核调试器。内核开发人员是一个了不起的软件——它能够调试实时内核(断点、通过 RS232 连接连接的远程机器的堆栈跟踪、内存访问和所有内容。不过,我不明白的一件事是如何通过 RS232 端口进行这种调试?我对内核的理解是,它是直接寻址硬件组件的软件,是系统中最底层的软件之一。某些东西怎么可能在内核“之上”运行,从而允许远程调试内核本身?内核怎么可以纯软件调试;

windows debugging kernel driver

2
推荐指数
1
解决办法
832
查看次数