
Loffen
Avatar/Signature-
Posts
51 -
Joined
-
Last visited
Content Type
Profiles
Forums
Blogs
Events
Articles
Resources
Downloads
Gallery
Everything posted by Loffen
-
OK, this is not exactly what i was looking for, but it works... In the loop of the service, around the critical part, lock the active thread like this: lock(this) { //critical part of loop } Now, when the service attempts to stop, it actually enters the OnStop function, completes all thasks there, but the locked thread will continue to execute till it leaves the lock block. After there this thread also terminates. Hope this helps someone.. -- Fredrik Aasgaard
-
I got a service running in the background. It checks for xml files in a directory. Whenever a new file is present, the service validates the xml, and if the xml is valid, insert the data into a database. After a while of testing, I figured weird results randomly occur if i stop the service while it's working. This is actually what i expected, so I began a search on the web on how to prevent a service from stopping, before a loop is completed. Maybe it's my english, my way of using search engines or just me, but I could not find anything. Nothing about waiting till a loop is done before terminating the service. I though this was a quite "popular" subject... Any suggestions? Thanks, -- Fredrik Aasgaard
-
Not sure here (yes, i am a DX n00b. Just trying to find some logic in DX). I always thought that SourceBlend and DestinationBlend were linked, and AlphaSourceBlend and AlphaDestinationBlend were linked. But i see you use: device.RenderState.AlphaSourceBlend = Blend.SourceAlpha; device.RenderState.DestinationBlend = Blend.InvSourceAlpha; Really not sure here, just something that popped up in my head while reading... -- Loffen
-
Thanks John! I peeked into the site already befor i posted, but i couldnt find anything i could use. I figured i can just use normal Split() function. This will be more code, but i think it will be easier to read. -- Loffen
-
I am actually coding a map-loader class for my game. In the beginning the map format was quite simple, and i could just read line after line and put things together. Now, my mapformat is getting more complicated, and its much easier to make the whole thing crash. I have done some PHP and i know what regular expressions are, but i never bothered to learn them (mostly because i never needed them), but i think thats the thing i have to use.. My maps are separated into four sections. Config, Terrain data, Object data and Trigger data. I want to read the whole file, then split it up using reg expr. To clearify this i'll make an example: The map: [MAP_CONFIG: map_name=Testmap map_tileset=Default ] [MAP_TERRAIN_DATA: 0;1;0;1;0;1;0;1; 0;1;0;1;0;1;0;1; 0;1;0;1;0;1;0;1; 0;1;0;1;0;1;0;1; ] [MAP_OBJECT_DATA: tree{pos=2,2;} tree{pos=6,3;} ] [MAP_TRIGGER_DATA: hurt{pos=0,0;dmgamount=10;} ] Here i'd like to separate the config, terrain data etc, like this: ConfigVar = map_name=Testmap map_tileset=Default TerrainDataVar = 0;1;0;1;0;1;0;1; 0;1;0;1;0;1;0;1; 0;1;0;1;0;1;0;1; 0;1;0;1;0;1;0;1; etc... I really have no ideas how to do this. If you know some good tutorials, please post them here. Suggestions?? I dont care if i have to change the map format a little... -- Loffen
-
Flickers in weird colors?? pink light yellow etc?? Try running the app with release and not debug DirectX... Worked for some friend.. --Loffen
-
Are you sure this has to do with lightning?? I've seen lotsa thing looking like a light but wasnt... -- Loffen
-
I have been playing around with different textures, colors and different ways of adding the color to the vertex. Well, my english is too bad to tell how confused my head is right now.. will post 2 screenies from app to make things clearer. The first one: * The upper-left tiles are the images in original state. * The "map" has the color integer set to 65000. As you see, the green looks 100% the same, but the pink gets blue !?!?!?! The secund one: The same map as the first one but the color is now added like this: Color.FromArgb(155, 200, 0, 0).ToArgb What i expected from this was that all squares get red (actually 50% transparent red).... EDIT: BTW: as you might want to know, my backbuffer format is Format.A8R8G8B8. Shouldnt this allow me to create transparent colors?? Any suggestions? Tips? --Loffen
-
Whats the latest?? I got 9.0c.. thought that was tha latest :confused: EDIT: hmm... lightning... could add a nice scary atmosphere. Does this work in 2D?? -- Loffen
-
OK. here's my idea: I want to make some tilebased game, were the user/player can place structures on the map. I am pretty sure you have seen this before: There are some green squares under the "not yet placed structure". If i now move the mouse over a rock, some of the squares (the ones overlapping the rock) change to red, showing the player he cant place it there. I guess thats it. And heres my problem: Earlier i moved my sprite by destroying the vertexbuffer and recreated it with different vertex coordinates. I figured this was VERY inefficent, so i learnt how to move the world. Now, in the very same piece of code, while filling the vertexbuffer, i set a color. How can i change this color "in game" without destroying and recreating the vertexbuffer?? I dont want to recreate the vertexbuffer as this was extremely inefficent. Got any ideas, links, suggestions or code snippets?? please post them here... EDIT: When i use a color when filling the buffer, the result is only a lighter or darker square. Not even a glimpse of a color :confused: -- Loffen
-
Hmm.. after looking at these tutorials i maybe change to OGL... looks much better documented here than in the DXDocs (first impression)... Anyway, i reccomend you too visit the tutorial section here. It IS OpenGL, but in the camera moving around example, you could extract the math and convert the rest to DX... Will post about my later impressions... EDIT: Noticed the code is written in c/c++. Well, i'll have to blow away the dust from my c++ book since last time i used it :p EDIT2: Err... c/c++ is still as hard as i remembered. Staying with DX for now :-\ --Loffen
-
cant check it now.. vacation.. Will check when i come home.. Cant you just download my project and check self?? It should be ready to compile... EDIT: I saw you edited your post.. :p --Loffen
-
Thanks... Downloaded it but I am going on vacation soon, look at it when i get back.. EDIT: I believe i saw it once, but microsofts extreme re-use of code, theyr classes, are really too big and often too advanced to learn learn from (well.. if you are willing and have the time to spend lots of hours just to get familiar in the code, it could be a complete and nice learning center....) --Loffen
-
I have till now loaded 40x20 = 800 tiles... EDIT: BTW.. that is no game yet... :p Just download a copy and look how i did it (didn't notice any noticable FPS/Performance drops..)
-
What are you going to make? Mapeditor, model-editor?? Well.. I'm no guru at this and i've actually never tried, but i have thought about it as i later will need a mapeditor... I'd do it like this: Three (or more) views on the screen, One looking towards the front of the object (Y, X), one from the side (X, Z), one from the top (X, Y), and maybe a view with it all textured (shaded, whatever... just to see the results..). Here using (Y, X) means that you should use the Y axis as the X axis and X axis as the Y axis... The three first views will be the areas you drag the rectangle. When dragging the rectangle, you take the "position of the view" and add the mouse X,Y coordinates to get the "real position" inside that view. Then you must create the needed vertices (one with x,y,z where you clicked in the view, one with x + mouseX, y, z one with x,y + mouseY,z and one with x+mouseX, Y+MouseY, z). If you have to set the X, Y or the Z varies from what view the user uses... then just do this with all the sides of the rectangle (3D right??)... As i said i have never tried this, so try it at own risk MWAHAHAH!!! ok, ok, i will relax , have some sleep and drink something with relaxing effect, like red bull :p EDIT: if its hard to understand (for some reason my english get the oposite of tidy, when i explaind difficult things :P), just post the part you didn't understand and i'll try to explain better.. -- Loffen
-
Well, i decided to start of with the amazing thing called 3D graphics. The first big questions that popped up in my head was: 3D Maps? Formats?... I looked at some .bsp (ex: half-life maps) files I found on my computer, they where crypted or something, impossible to read, except the "entity" section... I am not that far yet that i am able to load a map, but i'd like to know what my class should be prepared for... suggestions?? if you ever created a 3d map engine how did you do it?? I have absolutely no idea, and I have a bad feeling, telling me this question has been answeared 100's of times, but I cant find the answear anywhere. Just post a link if you know where the answear is ;). Thanks...
-
I had problems like this in the beginning too... What i did was pressing Ctrl+Alt+Delete and then open taskmanager. Kill the application, and when you return to VS there is an unhandled exception... Hope this helps -- Loffen
-
Ok.. here it is.. Had very short time, so if i missed a part just tell me.. Rendering the transparent sprite is not included though... EngineDocumented.zip
-
Well, The only way i figured to move a sprite (stored in a vertexbuffer), is to dispose the buffer and create a new one with new vertices... This sound really inefficent, but i've seen lots'a things with direct3d that didnt sound efficent... Any suggestions?? EDIT: it did effect my framerate while moving one object. I lost about 4-8 of 150 FPS... This is no real problem, but if it should move 100 objects?? --Loffen
-
or try: PresentInterval.One This will also limit the FPS to the refresh rate of the monitor / display.... --Loffen
-
Ok... I am NO DirectX guru, but i can learn you how i did create a tilemap engine like this (see attached image) and render transparent sprites (no, not the whole sprite, just the bg :p)... and then how to move it i guess... (still trying to figure out an efficent way.) Well first: Do you know how to init a device?? You said it would be enough with some code to rip apart. I will document my engine and swap it with a documented DP (you guessed it, DirectPlay) class... --Loffen This picture shows WHY i am NO artist and WHY i AM a programmer :P (yes thats my map (currently with 2 different tiles, but you can add up to 999999999999 tiles also: infinite). + i made this map of pure boredom. No the windows buttons in the upper-right corner are secret :p)
-
Well, figured out, now posting the answear :p.. When you init the device do not use: dxDevice.RenderState.[color=Red]Alpha[/color]SourceBlend = Blend.SourceAlpha dxDevice.RenderState.[color=Red]Alpha[/color]DestinationBlend = Blend.InvSourceAlpha But: dxDevice.RenderState.SourceBlend = Blend.SourceAlpha dxDevice.RenderState.DestinationBlend = Blend.InvSourceAlpha
-
I am trying to create a 'player' for my tilegame. The sprite function to load the image and create the vertexbuffer looks like this: Public Sub Load(ByVal ImageName As String, ByVal TopLeft As Point, ByVal Width As Integer, ByVal Height As Integer, ByVal ColorKey As Integer) Dim Vertices() As CustomVertex.PositionTextured Try SpriteImage = TextureLoader.FromFile(pDevice, ImageName, Width, Height, D3DX.Default, 0, Format.Unknown, Pool.Default, Filter.Point, Filter.Point, ColorKey) Catch ex As Exception MessageBox.Show("Could not load image: " & ImageName & vbCrLf & ex.StackTrace, "Critical Error", MessageBoxButtons.OK, MessageBoxIcon.Error) End End Try SpriteBuffer = New VertexBuffer(GetType(CustomVertex.PositionTextured), 4, pDevice, Usage.WriteOnly, CustomVertex.PositionTextured.Format, Pool.Default) Vertices = SpriteBuffer.Lock(0, 0) Vertices(0) = New CustomVertex.PositionTextured(TopLeft.X, TopLeft.Y, 1, 0, 0) Vertices(1) = New CustomVertex.PositionTextured(TopLeft.X + Width, TopLeft.Y, 1, 1, 0) Vertices(2) = New CustomVertex.PositionTextured(TopLeft.X, TopLeft.Y + Height, 1, 0, 1) Vertices(3) = New CustomVertex.PositionTextured(TopLeft.X + Width, TopLeft.Y + Height, 1, 1, 1) SpriteBuffer.Unlock() End Sub And the function that draws the sprite like this: Public Sub Render() pDevice.RenderState.AlphaBlendEnable = True pDevice.VertexFormat = CustomVertex.PositionTextured.Format pDevice.SetStreamSource(0, SpriteBuffer, 0) pDevice.SetTexture(0, SpriteImage) pDevice.DrawPrimitives(PrimitiveType.TriangleStrip, 0, 2) pDevice.RenderState.AlphaBlendEnable = False End Sub And during Device Init: Device.RenderState.Lighting = False Device.RenderState.ZBufferEnable = False Device.RenderState.CullMode = Cull.None Device.RenderState.AlphaSourceBlend = Blend.SourceAlpha Device.RenderState.AlphaDestinationBlend = Blend.InvSourceAlpha
-
Sounds logically, will try now.. *Crossing fingers :p* Yay!!! Thanks a lot! Works nice now... --Loffen
-
I would be willing to share my two classes (Sprite class and TileMap class) if youd be willing to share some DirectPlay knowledge... EDIT: I just figured that whith the summerupdate 2004 there is a whole bunch of documentation... Just press Ctrl + Alt + F1, then in the little menu to the left(?), expand the DirectX Summer... -> DirectX Summer Managed -> Introduction -> Direct3d Graphics ... Not looked through, but there should be enough to start with... :p