• What do you need help with? V. 3.0
    4,884 replies, posted
Working on making my first program using models in XNA, and I seem to have run into a roadblock. I'm following a great book that tells you what to do instead of showing you the code block, and you learn a LOT more from it. The only problem is that it makes finding issues hard as hell. I tried for awhile to find what's wrong with this, and I just can't. Can anyone tell me what's wrong? This is my model declaration class. [code] using System; using System.Collections.Generic; using System.Linq; using System.Text; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; namespace Cube { class Basicmodel { List<Basicmodel> models = new List<Basicmodel>( ); public Model model { get; protected set; } protected Matrix world = Matrix.Identity; public BasicModel(Model m) { model = m; } protected override void LoadCotent( ) { models.Add(new BasicModel( Game.Content.Load<Model>(@"models/gun"))); base.LoadContent( ); } public virtual void update ( ) { } public override Draw(GameTime gameTime) { base.Draw(gameTime); } public void Draw(Camera camera) { Matrix[] transforms = new Matrix[model.Bones.Count]; model.CopyAbsoluteBoneTransformsTo(transforms); foreach (ModelMesh mesh in model.Meshes) { foreach (BasicEffect be in mesh.Effects) { be.EnableDefaultLighting( ); be.Projection = camera.projection; be.View = camera.view; be.World = GetWorld( ) * mesh.ParentBone.Transform; } mesh.Draw( ); } } public virtual Matrix Getworld( ) { return world; } } } [/code] The errors are; [code]Error 7 The name 'GetWorld' does not exist in the current context C:\Users\Administrator\Documents\OpenTK\Cube\Cube\Cube\Basicmodel.cs 58 32 Cube [/code] [code] Error 1 Method must have a return type C:\Users\Administrator\Documents\OpenTK\Cube\Cube\Cube\Basicmodel.cs 22 16 Cube [/code] [code] Error 2 Method must have a return type C:\Users\Administrator\Documents\OpenTK\Cube\Cube\Cube\Basicmodel.cs 41 25 Cube [/code] [code] Error 4 An object reference is required for the non-static field, method, or property 'Microsoft.Xna.Framework.Game.Content.get' C:\Users\Administrator\Documents\OpenTK\Cube\Cube\Cube\Basicmodel.cs 30 17 Cube [/code] [code] Error 5 'object' does not contain a definition for 'LoadContent' C:\Users\Administrator\Documents\OpenTK\Cube\Cube\Cube\Basicmodel.cs 32 18 Cube [/code] [code] Error 6 'object' does not contain a definition for 'Draw' C:\Users\Administrator\Documents\OpenTK\Cube\Cube\Cube\Basicmodel.cs 43 18 Cube [/code] [code] Error 3 'Cube.Basicmodel.BasicModel(Microsoft.Xna.Framework.Graphics.Model)' is a 'method' but is used like a 'type' C:\Users\Administrator\Documents\OpenTK\Cube\Cube\Cube\Basicmodel.cs 29 28 Cube [/code]
Ultimate beginner in help, can anyone give it a shot? I just jumped into SFML, using the tutorials from start on, but it seems to struggle when I try to draw a simple window with the basic event handling, like stated in the tutorial. Here's a pic of what's actually happening in there. [img]http://i.solidfiles.net/8e008.jpg[/img] Events work like planned and when moving the window it creates the effect which reminds me of winning a game of Patience, with the cards. I hope I made myself clear enough for people to understand what's actually happening, I am sure it's a small fix but I just can't get to it.
Spell::handle_immediate' : local function definitions are illegal - getting that error. I have a feeling that i didn't close somewhere but I can't find it. [url]http://pastebin.com/ZfxjeHCX[/url]
[QUOTE=Bomber9900;31123543]Spell::handle_immediate' : local function definitions are illegal - getting that error. I have a feeling that i didn't close somewhere but I can't find it. [url]http://pastebin.com/ZfxjeHCX[/url][/QUOTE] Missing a } to end the function.
I'll give it a try. [editline]15th July 2011[/editline] [QUOTE=high;31123787]Missing a } to end the function.[/QUOTE] That fixed a lot of errors but I have one persistent thorn. error C2059: syntax error : 'if' [code] if (unitTarget->GetTypeId() == TYPEID_PLAYER); { fz = m_caster->GetBaseMap()->GetHeight(fx,fy,fz,true); if (fabs(fz-oz) > 4.0f) { fx = ox; fy = oy; fz = oz; } { unitTarget->NearTeleportTo(fx, fy, fz, unitTarget->GetOrientation(),unitTarget==m_caster); } }[/code]
[QUOTE=Bomber9900;31123896]I'll give it a try. [editline]15th July 2011[/editline] That fixed a lot of errors but I have one persistent thorn. error C2059: syntax error : 'if' [code] if (unitTarget->GetTypeId() == TYPEID_PLAYER); { fz = m_caster->GetBaseMap()->GetHeight(fx,fy,fz,true); if (fabs(fz-oz) > 4.0f) { fx = ox; fy = oy; fz = oz; } { unitTarget->NearTeleportTo(fx, fy, fz, unitTarget->GetOrientation(),unitTarget==m_caster); } }[/code][/QUOTE] Remove the semicolon on the end of that first if
I'm having a Seg fault that only happens on linux for some crazy reason , works fine on windows. anything linux wont like about this? [code] Program received signal SIGSEGV, Segmentation fault. [Switching to Thread -1218664768 (LWP 10296)] CBaseCombatCharacter::DropFlag (this=0x8bc97f8, team=2) at baseentity.h:1936 1936 const_cast<CBaseEntity*>(this)->CalcAbsolutePosition(); Current language: auto; currently c++ [/code]
I can think of only three causes: 1. The object was allocated in read-only memory (originally const), thus the const_cast introduces undefined behavior 2. The CBaseCombarChatacter is actually an uninitialized object. 3. The memory was deleted, but is still accessed.
Im trying to make a bloom effect with SFML2 but I it doesnt seem to be working dont know if anyone can have a look :/ [url]http://dl.dropbox.com/u/30243525/Lua%20tutorial.zip[/url] I also get a weird error when I close the window :/
Damn, you can't post any new threads in the XNA game studio forums, due to a glitch. My problem is really simple, too, but I can't seem to figure it out.
[QUOTE=Map in a box;31117136]I told you how in waywo. You should of followed the get started guide, or atleast googled it first.[/QUOTE] Thanks, but I actually tried everything. I wouldn't have posted if it was something that could be solved with a simple google search.
Something is really wrong with my code. [IMG]http://gyazo.com/513dd8c8b5346f1221e0b90c761d5e10.png[/IMG] It's just skipping the goddamn [code]ElseIf s = "n"[/code] even though you can clearly see that [code]s = "n"[/code] It's SO DAMN FRUSTRATING. [b]edit:[/b] Okay, so now, when i assigned s to "n" manually, it works. I think there's something with recieving "n" via a TCP connection that's making a difference between "n" and "n". :psyduck:
Is there some kind of problem whereby if you clear a rendertarget transparent in XNA it draws purple?
[QUOTE=Richy19;31142259]Is there some kind of problem whereby if you clear a rendertarget transparent in XNA it draws purple?[/QUOTE] There is no transparent color. Clear only fills the rt with the provided color. If you use rgba0,0,0,0 it doesn't modify the original content. Purple is the "error" color in xna to show you that something went wrong (useful for shader debugging). Maybe you want to clear your rt with black, then "add"-draw it on another rt or the mainscreen. edit: @woodcutter11: also check for the length. maybe you just want to get the first char of the string?[URL="http://www.facepunch.com/members/297169-Woodcutter11"] [/URL]
[QUOTE=Mr. Smartass;31117501]Working on making my first program using models in XNA, and I seem to have run into a roadblock. I'm following a great book that tells you what to do instead of showing you the code block, and you learn a LOT more from it. The only problem is that it makes finding issues hard as hell. I tried for awhile to find what's wrong with this, and I just can't. Can anyone tell me what's wrong? This is my model declaration class.[/QUOTE] [csharp] using System; using System.Collections.Generic; using System.Linq; using System.Text; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; namespace Cube { class BasicModel //Missing inheritance and wrong case { List<BasicModel> models = new List<BasicModel>( ); //Wrong case public Model model { get; protected set; } protected Matrix world = Matrix.Identity; public BasicModel(Model m) { model = m; } protected override void LoadContent( ) //Typo { models.Add(new BasicModel( Game.Content.Load<Model>(@"models/gun"))); base.LoadContent( ); } public virtual void update ( ) { } public override void Draw(GameTime gameTime) //Missing return type of void { base.Draw(gameTime); } public void Draw(Camera camera) { Matrix[] transforms = new Matrix[model.Bones.Count]; model.CopyAbsoluteBoneTransformsTo(transforms); foreach (ModelMesh mesh in model.Meshes) { foreach (BasicEffect be in mesh.Effects) { be.EnableDefaultLighting( ); be.Projection = camera.projection; be.View = camera.view; be.World = GetWorld( ) * mesh.ParentBone.Transform; } mesh.Draw( ); } } public virtual Matrix GetWorld( ) //Wrong case { return world; } } } [/csharp] Fixed what I could. I am not sure what class you are supposed to be inheriting though. My guess is something like [URL="http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.drawablegamecomponent.aspx"]DrawableGameComponent[/URL].
[QUOTE=Felheart;31142845]There is no transparent color. Clear only fills the rt with the provided color. If you use rgba0,0,0,0 it doesn't modify the original content. Purple is the "error" color in xna to show you that something went wrong (useful for shader debugging). Maybe you want to clear your rt with black, then "add"-draw it on another rt or the mainscreen. [/QUOTE] Well Im trying to use Neoforce controls but when it renders it seems to render the Neoforce window fine yet the background(which should be transparent to allow the background to show) is purple.
I'm not entirely sure if this is the right place for this, but this doesn't really seem like it needs a thread. I'm trying to get into programming, I've tried it a few different ways, but I can never seem to really get past basic logic. That, however, is not what I'm asking about. How did you learn programming? Through a book or a friend/mentor? Did it help/hurt to play music? Should I have sporadic bursts of teachings throughout the day? Or maybe just an hour or so of condensed learning with no distractions? Again, I'd like to apologize if this is the wrong thread (considering all the actual code going around).
[QUOTE=high;31143193][csharp] using System; using System.Collections.Generic; using System.Linq; using System.Text; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; namespace Cube { class BasicModel //Missing inheritance and wrong case { List<BasicModel> models = new List<BasicModel>( ); //Wrong case public Model model { get; protected set; } protected Matrix world = Matrix.Identity; public BasicModel(Model m) { model = m; } protected override void LoadContent( ) //Typo { models.Add(new BasicModel( Game.Content.Load<Model>(@"models/gun"))); base.LoadContent( ); } public virtual void update ( ) { } public override void Draw(GameTime gameTime) //Missing return type of void { base.Draw(gameTime); } public void Draw(Camera camera) { Matrix[] transforms = new Matrix[model.Bones.Count]; model.CopyAbsoluteBoneTransformsTo(transforms); foreach (ModelMesh mesh in model.Meshes) { foreach (BasicEffect be in mesh.Effects) { be.EnableDefaultLighting( ); be.Projection = camera.projection; be.View = camera.view; be.World = GetWorld( ) * mesh.ParentBone.Transform; } mesh.Draw( ); } } public virtual Matrix GetWorld( ) //Wrong case { return world; } } } [/csharp] Fixed what I could. I am not sure what class you are supposed to be inheriting though. My guess is something like [URL="http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.drawablegamecomponent.aspx"]DrawableGameComponent[/URL].[/QUOTE] Thanks. I am using DrawableGameComponent, and that DID fix up alot of the errors. Unfortunately, the errors that still crop that are outside my meager knowlege are [code]Error 1 An object reference is required for the non-static field, method, or property 'Microsoft.Xna.Framework.Game.Content.get' C:\Users\Administrator\Documents\OpenTK\Cube\Cube\Cube\Basicmodel.cs 30 17 Cube [/code] [code]Error 2 'object' does not contain a definition for 'LoadContent' C:\Users\Administrator\Documents\OpenTK\Cube\Cube\Cube\Basicmodel.cs 32 18 Cube [/code] [code]Error 3 'object' does not contain a definition for 'Draw' C:\Users\Administrator\Documents\OpenTK\Cube\Cube\Cube\Basicmodel.cs 43 18 Cube [/code]
Hey, I'm fairly new to Love2D and I'm trying to get animations working, unfortunately I can't figure out how to get any libraries in and Google is of no help to me. So, Quick question- How do i get libraries working in love2d? Thanks
[QUOTE=Woodcutter11;31142146]Something is really wrong with my code. [IMG]http://gyazo.com/513dd8c8b5346f1221e0b90c761d5e10.png[/IMG] It's just skipping the goddamn [code]ElseIf s = "n"[/code] even though you can clearly see that [code]s = "n"[/code] It's SO DAMN FRUSTRATING. [b]edit:[/b] Okay, so now, when i assigned s to "n" manually, it works. I think there's something with recieving "n" via a TCP connection that's making a difference between "n" and "n". :psyduck:[/QUOTE] Handle events like that with a byte. I doubt you'll have more than 255 so it should be good. Plus data doesn't weirdo out like that. Directcast() for byte conversion [editline]16th July 2011[/editline] Use & for string concatenation as well, not + [editline]16th July 2011[/editline] And while you're at it, drop the entire If statement nesting and just use Select Case
[QUOTE=Garb;31147130]Hey, I'm fairly new to Love2D and I'm trying to get animations working, unfortunately I can't figure out how to get any libraries in and Google is of no help to me. So, Quick question- How do i get libraries working in love2d? Thanks[/QUOTE] Download the library you want, put it in the folder that houses the main.lua. In your main.lua, write [lua]require("library") -- if the filename of the library is library.lua[/lua] Also, you'll have more luck with asking LÖVE questions on the [url=http://love2d.org/forums/]LÖVE forums[/url].
I am trying to render the area for a game I am making using sfml 2 but when I run the program in windows 7 says it has crashed and I just see a white screen. There are no compile errors Edit: Stop laughing at me :( Edit2: How do I pass a single object in an array to a function? Edit3: Fixed My while loop tryed to use a non existant slot in my array [code] #include <SFML/Graphics.hpp> int main() { sf::RenderWindow App(sf::VideoMode(800, 600, 32), "Legends of Arora"); App.SetFramerateLimit(60); sf::Image imagegrass; if(!imagegrass.LoadFromFile("images/grass.png")) return EXIT_FAILURE; sf::Sprite RenderArea[27] [21];//Extra space here :O but it didn't fix it when I removed the space. int i = 0; while (i <= 27) { int ii = 0; while(ii <= 21) { RenderArea[i][ii].SetImage(imagegrass); RenderArea[i][ii].SetColor(sf::Color(255,255,255,255)); RenderArea[i][ii].SetPosition(i * 32,ii * 32); RenderArea[i][ii].SetScale(1.f,1.f); ii++; } i++; } while (App.IsOpened()) { sf::Event Event; while (App.PollEvent(Event)) { if (Event.Type == sf::Event::Closed) App.Close(); } int i = 0; int ii = 0; while (i <= 27) { ii = 0;//Remove this it doesn't crash but only works for 1 row while(ii <= 21) { App.Draw(RenderArea[i][ii]); ii++; } i++; } App.Display(); } return EXIT_SUCCESS; } [/code]
my eternal love with SFML 2 is fading away, fucking fonts. The tutorials on their site are not up-to-date for the fonts part and is causing some problems in the overall learning process. Loading arial.ttf with this piece of (copied) code: [CODE] sf::Font MyFont; if (!MyFont.LoadFromFile("arial.ttf")) return EXIT_FAILURE; sf::Text Text("Hellow", font, 30); [/CODE] is causing this to happen in the console: [CODE] Failed to load "arial.ttf" <failed to create font face> [/CODE] Can anyone please help me with this? Thanks in advance
[QUOTE=Chezburger;31154345]my eternal love with SFML 2 is fading away, fucking fonts. The tutorials on their site are not up-to-date for the fonts part and is causing some problems in the overall learning process. Loading arial.ttf with this piece of (copied) code: [CODE] sf::Font MyFont; if (!MyFont.LoadFromFile("arial.ttf")) return EXIT_FAILURE; [/CODE] is causing this to happen in the console: [CODE] Failed to load "arial.ttf" <failed to create font face> [/CODE] Can anyone please help me with this? Thanks in advance[/QUOTE] you need to have the font file with the EXE
If you want to use custom fonts, package them with the EXE. If you want to use a system font, I think you can use something like "%windir%\fonts\font_name.ttf" as the path, although of course that isn't very portable at all.
hmmm it seems that this thing isn't in for it either way, you guys sure this isn't a 1.6 > 2.0 conversion thing? (Which I highly doubt)
It's telling you that it can't find the font file you specified. Either because the font doesn't exist, or the path you gave it is wrong, or whatever. Doesn't matter what version of SFML you use, if you give it the wrong path, it's not gonna be able to load the font :v: The easiest solution is to just copy the font into the program's working directory (note: if you're running this from inside an IDE, the working directory isn't necessarily the EXE file's directory.)
Yay, sweet victory. It works fine now, sorry that you had to explain everything on 3-year-old level, still getting the hang of it all. Thanks man! [media]http://www.youtube.com/watch?v=3GwjfUFyY6M[/media]
[QUOTE=Chezburger;31154973]Yay, sweet victory. It works fine now, sorry that you had to explain everything on 3-year-old level, still getting the hang of it all. Thanks man![/QUOTE] No problem, we all gotta start somewhere! Glad to hear you got it working :)
I'm really new to C++, and I'm trying to use some of the basics to make a simple calculator to see if I can. [CODE]#include <iostream> using namespace std; int main () { double a, c; int b; cout << "Welcome to the calculator! Press r to redo the program at any time.\n \n"; loop1: cout << "Enter first number.\n "; cin >> a; if (a < 999999) cout << "Now enter your operation.\n1 = addition\n2 = subtraction\n3 = multiplication\n4 = division\n "; else if (a > 999999) { cout << "That number too high\n"; goto loop1; } else if (a < -999999) { cout << "That number is too low\n"; goto loop1; } else if (a == 'r') goto loop1; else { cout << "That's not a number.\n"; goto loop1; } loop2: cin >> b; if (b == 1) cout << "Now enter your second number.\n"; else if (b == 2) cout << "Now enter your second number.\n"; else if (b == 3) cout << "Now enter your second number.\n"; else if (b == 4) cout << "Now enter your second number.\n"; else { cout << "That's not in any of the given operations.\n"; goto loop2; } cin >> c; if (b == 1) cout << "The answer is " << a+c << ".\n\n"; else if (b == 2) cout << "The answer is " << a-c << ".\n\n"; else if (b == 3) cout << "The answer is " << a*c << ".\n\n"; else if (b == 4) cout << "The answer is " << a/c << ".\n\n"; goto loop1; return 0; }[/CODE] There's no errors or anything, but the problem lies where it asks you to enter the first number. [CODE]if (a < 999999) cout << "Now enter your operation.\n1 = addition\n2 = subtraction\n3 = multiplication\n4 = division\n "; else if (a > 999999) { cout << "That number is too high\n"; goto loop1; } else if (a < -999999) { cout << "That number is too low\n"; goto loop1; } else if (a == 'r') goto loop1; else { cout << "That's not a number.\n"; goto loop1; }[/CODE] If you type anything that's not a number or out of number boundaries, it'll write "That's not in any of the given operations" over and over. If I already used the calculator (go through the process of solving a problem) it'll keep writing that same process over and over again as fast as my computer can process. I just want it to restart from loop1 (cout << "Enter first number.";). It works with all the other loops, but not that one. Help a noob out?
Sorry, you need to Log In to post a reply to this thread.