Jump to content
  • Advertisement

CPPNick

Member
  • Content count

    326
  • Joined

  • Last visited

Community Reputation

100 Neutral

About CPPNick

  • Rank
    Member
  1. CPPNick

    Max script help

    Phew! done. here is the code if anyone wants to take a look. rollout new "Edgemap Exporter" ( label lab "Export Edgemap" button btn_export "Export" on btn_export pressed do ( s = objects as array theLines = for o in s where classof o == Line collect o theCircles = for o in s where classof o == Circle collect o nLines = theLines.count nCirlces = theCircles.count if(nLines != 0 or nCircles != 0) then ( out_name = getSaveFileName types: "Edge Map(*.emap) |*.emap|" out_file = createfile out_name -- make an array to hold all the line segments segArray = #() if(nLines > 0) then ( for aLine = 1 to nLines do ( -- for each spline in the Line object thisLine = theLines[aLine] nSplines = numSplines thisLine for aSpline = 1 to nSplines do ( nKnots = numKnots thisLine aSpline if(isClosed thisLine aSpline) then ( if(nKnots > 1) then ( pt1 = getKnotPoint thisLine aSpline nKnots pt2 = getKnotPoint thisLine aSpline 1 append segArray #(pt1, pt2) if(nKnots > 2) then ( for aKnot = 2 to nKnots do ( pt1 = getKnotPoint thisLine aSpline (aKnot - 1) pt2 = getKnotPoint thisLine aSpline aKnot append segArray #(pt1, pt2) ) ) ) ) else ( if(nKnots > 1) then ( for aKnot = 2 to nKnots do ( pt1 = getKnotPoint thisLine aSpline (aKnot - 1) pt2 = getKnotPoint thisLine aSpline aKnot append segArray #(pt1, pt2) ) ) ) ) ) format "%\n" segArray.count to:out_file for thisSeg = 1 to segArray.count do ( format "% % % %\n" (segArray[thisSeg][1].x) (segArray[thisSeg][1].y) (segArray[thisSeg][2].x) (segArray[thisSeg][2].y) to:out_file ) ) if(nCircles != 0) then ( format "%\n" nCirlces to:out_file for i = 1 to nCirlces do ( Circle1 = theCircles format "% % %\n" (Circle1.center.x) (Circle1.center.y) (Circle1.radius) to:out_file ) ) -- close out_file ) ) ) CreateDialog new
  2. CPPNick

    Max script help

    getting closer! rollout new "Edgemap Exporter" ( label lab "Export Edgemap" button btn_export "Export" on btn_export pressed do ( s = objects as array theLines = for o in s where classof o == Line collect o theCircles = for o in s where classof o == Circle collect o nLines = theLines.count nCirlces = theCircles.count if(nLines != 0 or nCircles != 0) then ( //-- out_name = getSaveFileName types: "Edge Map(*.emap) |*.emap|" //-- out_file = createfile out_name // -- make an array to hold all the line segments // --segArray = #() for aLine = 1 to nLines do ( // -- for each spline in the Line object thisSpline = theLines[aLine] nSplines = numSplines thisSpline for aSpline = 1 to nSplines do ( nSegments = numSegments thisSpline aSpline for aSeg = 1 to nSegments do ( print "This is a segment!" ) ) ) //-- if(nCircles != 0) then //-- ( //-- format "%\n" nCirlces to:out_file //-- for i = 1 to nCirlces do //-- ( //-- Circle1 = theCircles //-- format "% % %\n" (Circle1.center.x) (Circle1.center.y) (Circle1.radius) to:out_file //-- ) //-- ) //-- close out_file ) ) ) CreateDialog new just cant figure out how to retrieve the vertices from the segment =/
  3. CPPNick

    Max script help

    I need some help with this thing that I am making for a school project. I need to get a map of edges out of max to use for collision detection in our game. This is what I have so far. rollout new "Edgemap Exporter" ( label lab "Export Edgemap" button btn_export "Export" on btn_export pressed do ( out_name = getSaveFileName types: "Edge Map(*.emap) |*.emap|" out_file = createfile out_name edgemap = snapshotAsMesh selection[1] --I need to get a list of the edges of the object here --num_verts = edgemap.numEdges --format "%\n" num_verts to:out_file --vert1 = getVert tmesh num_verts --vert2 = getVert tmesh 1 --format "% % % %\n" (vert1.x) (vert1.y) (vert2.x) (vert2.y) to:out_file --for v = 2 to num_verts do --( --vert1 = getVert tmesh v - 1 --vert2 = getVert tmesh v --format "% % % %\n" (vert1.x) (vert1.y) (vert2.x) (vert2.y) to:out_file --) close out_file ) ) CreateDialog new I have got the thing saving a file properly and everything, but I need a way to get a list of all the edges of a spline(with all corners). can anyone point me in the right direction? thanks for any help on this.
  4. CPPNick

    How to detect speed hack?

    Quote:Checking distance between frames / seconds. I think Modern Warefare 2 uses this method.. A friend of mine had a cheat, so naturally I wanted to see if it actually worked(not recommended, you may lose your account permanently) but the speed cheat only worked when we played on a "hacked server" which allowed it. If you tried the hack in a regular game, you would see yourself jolting back and forth like the server was resetting your position when it saw that you had moved impossibly far for that amount of time. Quote:Players who are impossibly good end up playing against each other, which means that cheaters play other cheaters. pretty sure mw2 does this too. [Edited by - CPPNick on September 19, 2010 8:55:35 PM]
  5. CPPNick

    Help with UPnP? (code)

    Do you know how this problem will be handled in the future then? Does the IPv6 protocol address this somehow? I imagine that all it would take to overcome this would be to update the TCP/IP packet header to also contain a private network IP. anyways, imo, if people download illegally cracked software, and get a trojan, that should be their problem...and as far as operating systems go, I would rather click "allow" for each incoming or outgoing connection then have to deal with virus scanners or firewalls.. people take computers for granted way to easily... I am not going to try and start a flame war here, but I hope that the new EHF fees they are imposing on computer products in Canada are just the beginning. There should be laws that protect people's rights to use their technology. If I can get a ticket for speeding, why not for spamming ? :)
  6. CPPNick

    Help with UPnP? (code)

    I'm really surprised I didn't get any answers for this. Anyways, it works now. I edited the code above to reflect the newest, working code, for uPnP (automatic port forwarding).
  7. Hi, I need a little help with uPnP if anyone can spare a minute. I wanted to learn socket programming, so I made a nice little web server that uses IO completion ports and all that good stuff. When I forward the port manually from within the my router's settings, the server runs fine. I recently tried to get it to work with uPnP, but had no luck. I tried connecting to the server from outside my home network, but couldn't get a response. I checked that: 1) uPnP is enabled in the router's settings 2) I am not receiving any errors from my code This is the code for the wrapper that I made: mappedport.h #ifndef INC_MAPPEDPORT_H #define INC_MAPPEDPORT_H #pragma comment (lib, "ws2_32.lib") #include <winsock2.h> #include <ws2tcpip.h> #include <Natupnp.h> #include <Windows.h> class MappedPort { private: HRESULT hr; wchar_t protocol_[4]; long lport_; bool initialized_; bool mapped_; IUPnPNAT *uPnP; IStaticPortMapping *spmOut; IStaticPortMappingCollection *spmCol; bool Initialize(); public: MappedPort(); MappedPort(long lPort, wchar_t *protocol /* "TCP" or "UDP" */, wchar_t *description); ~MappedPort(); bool Map(long lPort, wchar_t *protocol /* "TCP" or "UDP" */, wchar_t *description); bool Unmap(); bool IsMapped(); }; #endif /* INC_MAPPEDPORT_H */ mappedport.cpp #include "mappedport.h" MappedPort::MappedPort() { Initialize(); } MappedPort::MappedPort(long lPort, wchar_t *protocol, wchar_t *description) { if(Initialize()) mapped_ = Map(lPort, protocol, description); } bool MappedPort::Initialize() { lport_ = 0; mapped_ = false; initialized_ = false; hr = 0; uPnP = NULL; spmOut = NULL; spmCol = NULL; if(CoInitialize(NULL) == S_OK) { hr = CoCreateInstance(__uuidof(UPnPNAT), NULL, CLSCTX_ALL, __uuidof(IUPnPNAT), (void **)&uPnP); if(hr == S_OK && uPnP != NULL) { hr = uPnP->get_StaticPortMappingCollection(&spmCol); if(hr == S_OK && spmCol != NULL) { initialized_ = true; } } } return initialized_; } MappedPort::~MappedPort() { if(mapped_) this->Unmap(); if(uPnP) uPnP->Release(); if(spmCol) spmCol->Release(); if(spmOut) spmOut->Release(); if(initialized_) CoUninitialize(); } bool MappedPort::Map(long lPort, wchar_t *protocol, wchar_t *description) { WSADATA wsaData; char hostname[256]; PHOSTENT hostinfo; wchar_t ip[16]; lport_ = lPort; wcscpy_s(protocol_, 4, protocol); if((initialized_ == true) && (mapped_ == false)) { spmCol->Remove(lport_, protocol_); if(WSAStartup(MAKEWORD(2,2), &wsaData) == 0) { if(gethostname(hostname, sizeof(hostname)) == 0) { hostinfo = gethostbyname(hostname); if(hostinfo != NULL) { if(InetNtopW(AF_INET, (struct in_addr*)*hostinfo->h_addr_list, ip, sizeof(ip)) != NULL) { if(spmCol->Add(lPort, protocol, lPort, ip, TRUE, description, &spmOut) == S_OK) { mapped_ = true; } } } } WSACleanup(); } } return mapped_; } bool MappedPort::Unmap() { return (spmCol->Remove(lport_, protocol_) == S_OK); } bool MappedPort::IsMapped() { return mapped_; } If someone could point out any obvious errors that I am making here, it would be greatly appreciated. bonus: if you can fix it, you can keep it =D thanks [Edited by - CPPNick on August 30, 2010 8:46:13 AM]
  8. CPPNick

    Help with new desktop specs?

    I might recommend is a newer graphics card, as DirectX 11 is out now. The GTX285 only supports 10.1. The GTX 470 will out perform the 285 for about the same price. I would consider a faster CPU as well. 3.0ghz+. 4GB or ram would be fine, but the more you have, the less time you will spend waiting for your OS to dig things out of your hard drive. I only have win7 32bit, which means I'm stuck with only 3gb or ram...Alt+Tabbing out of Starcraft 2 makes me want to cry..lol If you plan on getting the i7 and then overclocking it instead of getting a faster chip, make sure you get some kind of water cooling system, and a good mother board. I use the corsair hydro series cooler..the huge elaborate ones really aren't necessary unless you are trying to go past 4ghz..which is really just for show at this point IMO. Anyways, gl with it, and remember you can always google "xxxx review" to find performance testing of most computer products and see if they are good enough for what you plan to use them for.
  9. CPPNick

    Help understanding article

    Quote:Just ignore that article. sounds like a plan lol
  10. CPPNick

    Help understanding article

    Quote:when you pop an element, then push a new one, you can reuse the memory of the popped element for the newly pushed one. Maybe I misunderstood what he was planning to use this for. What if he pops 3 elements, and then adds three? wouldn't that then force his code to use "new" at least two more times? Quote:after allocating N items, it is cheaper to allocate up to N items again If his app needs to pop the entire list of say, 20 items, except one element, how will he keep track of the other 19 that were allocated and reuse them? I don't see any way of reusing memory without traversing all elements looking for an empty one each time. I know an array is out of the question for a set of indeterminate size, because any kind of reallocation to add space would necessitate the copying of all the data to a new location, which can be slow.... Do you guys see what I am getting at here?
  11. I need to use a dynamic collection of objects that maintain a constant memory address in my project. In this article, the guy says that he is using an alternative to C++ "new" by using assignments instead. I don't see the significance in this article. http://www.atalasoft.com/cs/blogs/stevehawley/archive/2008/05/05/when-new-is-too-slow.aspx Firstly, this looks a lot like a simple linked list...but the writer seems think he has found some innovative way of handling his problem..even though linked lists have probably been around about as long as pointers. Secondly, I don't understand how he figures that he can avoid the overhead of allocating new space by using assignment, because before you can assign a value to anything, it first has to be allocated, i.e., using new. Can anyone clarify this a little bit for me?
  12. CPPNick

    Quick Winsock Question

    Thanks =D This simplifies things for me immensely.
  13. If I am using overlapped sockets with i/o completion ports, is it ok to use WSASend on a socket to send data after posting the initial WSARecv on that same socket, but before having received any data? Will the socket still receive data and trigger the completion port if I have sent data through it? Thanks, Nick
  14. CPPNick

    Please help with ifstream

    The program above was just a test project. The exact problem I was having was because ifstream::read(test, 5) doesn't add a terminating '/0' and basic_string::append() takes "C-strings" which can be defined as: "Array of char[n], where n is the length of the string (in characters) plus 1 for the terminating '\0' that marks the end of the string" http://msdn.microsoft.com/en-us/library/69ze775t%28VS.80%29.aspx therefore this did not work properly: test.append(test); rather than allocate extra space though, I used the second optional argument of append() to specify a number of characters to copy, since append() would not otherwise know where to stop without the terminating '\0' test.append(test, 5); This was part of a web server, and for the HTTP response body, the web browser doesn't expect '\0' terminated strings. That is another reason I chose not to allocate the extra byte. [Edited by - CPPNick on July 23, 2010 9:38:03 AM]
  15. CPPNick

    Please help with ifstream

    ok, The only place I have ever seen something like this is in an MSDN example for GetOpenFileName() I don't understand the difference between '\0' and '0' though =/ at least I have something to go on now though. Thanks, you guys are life savers. I was about to go check into the looney bin..lol
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!