• Advertisement
  • Popular Tags

  • Popular Now

  • Advertisement
  • Similar Content

    • By Fadey Duh
      Good evening everyone!

      I was wondering if there is something equivalent of  GL_NV_blend_equation_advanced for AMD?
      Basically I'm trying to find more compatible version of it.

      Thank you!
    • By Jens Eckervogt
      Hello guys, 
       
      Please tell me! 
      How do I know? Why does wavefront not show for me?
      I already checked I have non errors yet.
      using OpenTK; using System.Collections.Generic; using System.IO; using System.Text; namespace Tutorial_08.net.sourceskyboxer { public class WaveFrontLoader { private static List<Vector3> inPositions; private static List<Vector2> inTexcoords; private static List<Vector3> inNormals; private static List<float> positions; private static List<float> texcoords; private static List<int> indices; public static RawModel LoadObjModel(string filename, Loader loader) { inPositions = new List<Vector3>(); inTexcoords = new List<Vector2>(); inNormals = new List<Vector3>(); positions = new List<float>(); texcoords = new List<float>(); indices = new List<int>(); int nextIdx = 0; using (var reader = new StreamReader(File.Open("Contents/" + filename + ".obj", FileMode.Open), Encoding.UTF8)) { string line = reader.ReadLine(); int i = reader.Read(); while (true) { string[] currentLine = line.Split(); if (currentLine[0] == "v") { Vector3 pos = new Vector3(float.Parse(currentLine[1]), float.Parse(currentLine[2]), float.Parse(currentLine[3])); inPositions.Add(pos); if (currentLine[1] == "t") { Vector2 tex = new Vector2(float.Parse(currentLine[1]), float.Parse(currentLine[2])); inTexcoords.Add(tex); } if (currentLine[1] == "n") { Vector3 nom = new Vector3(float.Parse(currentLine[1]), float.Parse(currentLine[2]), float.Parse(currentLine[3])); inNormals.Add(nom); } } if (currentLine[0] == "f") { Vector3 pos = inPositions[0]; positions.Add(pos.X); positions.Add(pos.Y); positions.Add(pos.Z); Vector2 tc = inTexcoords[0]; texcoords.Add(tc.X); texcoords.Add(tc.Y); indices.Add(nextIdx); ++nextIdx; } reader.Close(); return loader.loadToVAO(positions.ToArray(), texcoords.ToArray(), indices.ToArray()); } } } } } And It have tried other method but it can't show for me.  I am mad now. Because any OpenTK developers won't help me.
      Please help me how do I fix.

      And my download (mega.nz) should it is original but I tried no success...
      - Add blend source and png file here I have tried tried,.....  
       
      PS: Why is our community not active? I wait very longer. Stop to lie me!
      Thanks !
    • By codelyoko373
      I wasn't sure if this would be the right place for a topic like this so sorry if it isn't.
      I'm currently working on a project for Uni using FreeGLUT to make a simple solar system simulation. I've got to the point where I've implemented all the planets and have used a Scene Graph to link them all together. The issue I'm having with now though is basically the planets and moons orbit correctly at their own orbit speeds.
      I'm not really experienced with using matrices for stuff like this so It's likely why I can't figure out how exactly to get it working. This is where I'm applying the transformation matrices, as well as pushing and popping them. This is within the Render function that every planet including the sun and moons will have and run.
      if (tag != "Sun") { glRotatef(orbitAngle, orbitRotation.X, orbitRotation.Y, orbitRotation.Z); } glPushMatrix(); glTranslatef(position.X, position.Y, position.Z); glRotatef(rotationAngle, rotation.X, rotation.Y, rotation.Z); glScalef(scale.X, scale.Y, scale.Z); glDrawElements(GL_TRIANGLES, mesh->indiceCount, GL_UNSIGNED_SHORT, mesh->indices); if (tag != "Sun") { glPopMatrix(); } The "If(tag != "Sun")" parts are my attempts are getting the planets to orbit correctly though it likely isn't the way I'm meant to be doing it. So I was wondering if someone would be able to help me? As I really don't have an idea on what I would do to get it working. Using the if statement is truthfully the closest I've got to it working but there are still weird effects like the planets orbiting faster then they should depending on the number of planets actually be updated/rendered.
    • By Jens Eckervogt
      Hello everyone, 
      I have problem with texture
      using System; using OpenTK; using OpenTK.Input; using OpenTK.Graphics; using OpenTK.Graphics.OpenGL4; using System.Drawing; using System.Reflection; namespace Tutorial_05 { class Game : GameWindow { private static int WIDTH = 1200; private static int HEIGHT = 720; private static KeyboardState keyState; private int vaoID; private int vboID; private int iboID; private Vector3[] vertices = { new Vector3(-0.5f, 0.5f, 0.0f), // V0 new Vector3(-0.5f, -0.5f, 0.0f), // V1 new Vector3(0.5f, -0.5f, 0.0f), // V2 new Vector3(0.5f, 0.5f, 0.0f) // V3 }; private Vector2[] texcoords = { new Vector2(0, 0), new Vector2(0, 1), new Vector2(1, 1), new Vector2(1, 0) }; private int[] indices = { 0, 1, 3, 3, 1, 2 }; private string vertsrc = @"#version 450 core in vec3 position; in vec2 textureCoords; out vec2 pass_textureCoords; void main(void) { gl_Position = vec4(position, 1.0); pass_textureCoords = textureCoords; }"; private string fragsrc = @"#version 450 core in vec2 pass_textureCoords; out vec4 out_color; uniform sampler2D textureSampler; void main(void) { out_color = texture(textureSampler, pass_textureCoords); }"; private int programID; private int vertexShaderID; private int fragmentShaderID; private int textureID; private Bitmap texsrc; public Game() : base(WIDTH, HEIGHT, GraphicsMode.Default, "Tutorial 05 - Texturing", GameWindowFlags.Default, DisplayDevice.Default, 4, 5, GraphicsContextFlags.Default) { } protected override void OnLoad(EventArgs e) { base.OnLoad(e); CursorVisible = true; GL.GenVertexArrays(1, out vaoID); GL.BindVertexArray(vaoID); GL.GenBuffers(1, out vboID); GL.BindBuffer(BufferTarget.ArrayBuffer, vboID); GL.BufferData(BufferTarget.ArrayBuffer, (IntPtr)(vertices.Length * Vector3.SizeInBytes), vertices, BufferUsageHint.StaticDraw); GL.GenBuffers(1, out iboID); GL.BindBuffer(BufferTarget.ElementArrayBuffer, iboID); GL.BufferData(BufferTarget.ElementArrayBuffer, (IntPtr)(indices.Length * sizeof(int)), indices, BufferUsageHint.StaticDraw); vertexShaderID = GL.CreateShader(ShaderType.VertexShader); GL.ShaderSource(vertexShaderID, vertsrc); GL.CompileShader(vertexShaderID); fragmentShaderID = GL.CreateShader(ShaderType.FragmentShader); GL.ShaderSource(fragmentShaderID, fragsrc); GL.CompileShader(fragmentShaderID); programID = GL.CreateProgram(); GL.AttachShader(programID, vertexShaderID); GL.AttachShader(programID, fragmentShaderID); GL.LinkProgram(programID); // Loading texture from embedded resource texsrc = new Bitmap(Assembly.GetEntryAssembly().GetManifestResourceStream("Tutorial_05.example.png")); textureID = GL.GenTexture(); GL.BindTexture(TextureTarget.Texture2D, textureID); GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)All.Linear); GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)All.Linear); GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba, texsrc.Width, texsrc.Height, 0, PixelFormat.Bgra, PixelType.UnsignedByte, IntPtr.Zero); System.Drawing.Imaging.BitmapData bitmap_data = texsrc.LockBits(new Rectangle(0, 0, texsrc.Width, texsrc.Height), System.Drawing.Imaging.ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppRgb); GL.TexSubImage2D(TextureTarget.Texture2D, 0, 0, 0, texsrc.Width, texsrc.Height, PixelFormat.Bgra, PixelType.UnsignedByte, bitmap_data.Scan0); texsrc.UnlockBits(bitmap_data); GL.Enable(EnableCap.Texture2D); GL.BufferData(BufferTarget.TextureBuffer, (IntPtr)(texcoords.Length * Vector2.SizeInBytes), texcoords, BufferUsageHint.StaticDraw); GL.BindAttribLocation(programID, 0, "position"); GL.BindAttribLocation(programID, 1, "textureCoords"); } protected override void OnResize(EventArgs e) { base.OnResize(e); GL.Viewport(0, 0, ClientRectangle.Width, ClientRectangle.Height); } protected override void OnUpdateFrame(FrameEventArgs e) { base.OnUpdateFrame(e); keyState = Keyboard.GetState(); if (keyState.IsKeyDown(Key.Escape)) { Exit(); } } protected override void OnRenderFrame(FrameEventArgs e) { base.OnRenderFrame(e); // Prepare for background GL.Clear(ClearBufferMask.ColorBufferBit); GL.ClearColor(Color4.Red); // Draw traingles GL.EnableVertexAttribArray(0); GL.EnableVertexAttribArray(1); GL.BindVertexArray(vaoID); GL.UseProgram(programID); GL.BindBuffer(BufferTarget.ArrayBuffer, vboID); GL.VertexAttribPointer(0, 3, VertexAttribPointerType.Float, false, 0, IntPtr.Zero); GL.ActiveTexture(TextureUnit.Texture0); GL.BindTexture(TextureTarget.Texture3D, textureID); GL.BindBuffer(BufferTarget.ElementArrayBuffer, iboID); GL.DrawElements(BeginMode.Triangles, indices.Length, DrawElementsType.UnsignedInt, 0); GL.DisableVertexAttribArray(0); GL.DisableVertexAttribArray(1); SwapBuffers(); } protected override void OnClosed(EventArgs e) { base.OnClosed(e); GL.DeleteVertexArray(vaoID); GL.DeleteBuffer(vboID); } } } I can not remember where do I add GL.Uniform2();
    • By Jens Eckervogt
      Hello everyone
      For @80bserver8 nice job - I have found Google search. How did you port from Javascript WebGL to C# OpenTK.?
      I have been searched Google but it shows f***ing Unity 3D. I really want know how do I understand I want start with OpenTK But I want know where is porting of Javascript and C#?
       
      Thanks!
  • Advertisement
  • Advertisement
Sign in to follow this  

OpenGL which model import lib to use?

This topic is 679 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

fbx sdk ? assimp? 

the axis system of fbx sdk is awful, i use LHS but the model  is flipped ( the head is down ,the foot  is up) when choosing the Directx axis system, 

but when it switch to opengl axis system, it works!!! the model display in correct rotation. 

Even I can't find how to  extract the local transform matrix( relative to parent )  of joint in each frame. 

now I can only extract the global matrix of joint in each frame.

the fbx seems not to be used by a newbie.

 

assimp is annoying !  it support every format in appearance , but it  support nothing in reality !!

Edited by Josh Petrie
profanity

Share this post


Link to post
Share on other sites
Advertisement

looks like some folks take exception to your colorful language.  :o

 

dx uses a left hand system

 

ogl uses a right hand system.

 

sounds like fbx uses a right hand system.

 

assimp is an import only library not a format conversion library. IE it reads many formats into its own proprietary format in memory, from which you are supposed to copy out the data into whatever format you choose. so it imports many formats, and exports none  (supposedly - i don't use it myself)

 

for what you're trying to do, i'd import the fbx into blender or truespace, export to .x format, then use Dx code to load the .x file - of course that gets it into a directx game, not a custom game which just happens to have a  left hand system like Dx does.  

 

for a custom left hand system, you'll need to write code to either copy the assimp data to your data structures in memory at load time (IE use assimp as your load routine) , or use assimp to write a custom conversion tool that reads fbx (or whatever) and writes out whatever format you want to use to load data into your game - including possibly your own custom format.

 

its quite common for folks to find all the exiting formats lacking and to use their own for a game. that's where assimp is really useful.

 

to use a custom format, you have to convert data from standard formats used by modeling tools. using assimp, the import half of the work is already done for you - and that's the hard half. all you have to do is write export code for your custom format, which should be easy, cause it will be a simple and efficient format that does just exactly what the game needs and nothing more.

 

generally speaking, getting data out of a modeling package and into a custom game engine seems to be non-trivial.  i used Dx code to avoid the entire issue to the maximum extent possible. it ain't pretty, but at least it works. it was the closest thing i could find to a turn-key solution for a dx based game.

Edited by Norman Barrows

Share this post


Link to post
Share on other sites

AutoDesk's .FBX is kind of a nightmare. I looked pretty closely at that for DX. It's proprietary and they don't want you to know anything about it. Maybe worse than that is the file format is a kitchen sink format. 3D game models is a very small part of what that file format is designed for. So, you'll be sifting through mountains of garbage trying to find your model. AutoDesk makes a whole library that works with the file. The reason I abandoned the idea is that you have to learn their library. I decided it was much easier and faster to teach myself Python and figure out Blender's internal data structures than it is to learn the FBX library. If I'm going to spend 3 months learning something, why not spend those 3 months figuring out how to make my own.

 

And that's exactly what I did. I learned enough Python to write my own custom exporter from Blender to write my own custom model file. Then it can be right handed, left handed, upside down, or whatever you want. I think I chose to go with a left handed system in DX  because XNA and OGL went that way. I don't really remember. I think you can specify which you want to use in OGL and DX.

 

Anyway, I than wrote my code to read my custom model data file. It's setup for rigid animation, but not skinned animation. I haven't gotten as far as skinned animation. But I think many of the file formats out there are not really setup for skinned animation either.

 

I also wrote a humanoid animation file format that exports from Blender using Python. So, I'm half way there to skinned animation.

 

Anyway, if you are interested in looking at that code, I published the entire VS DX11 project on my website. All the files should be there including my model files, the python code for Blender, and complete source code for DX. Everything is 100% from scratch. It's nothing but DX11 and C++ (and Python and Blender of course). I'm not crazy about Python, but it gets the job done in Blender. I just learned enough to write those scripts. Fishing around in Blender for the data is an exercise. But most everything you need is already there in that script, saving you that trouble. My model format supports textures, sub-meshes, parent-child relationships with sub-meshes. I called it the PUNC file format for Position, UV, Normal, Color because that's the data for each vertex it contains. There's also a world matrix for each sub-mesh.

 

But you're welcome to download that project and make use of the code. That Blender Python script could probably be written better by someone who actually knows Python. I literally learned Python just to write those scripts. But they get the job done and extract the model data from Blender, although there's no error checking and you have to do things like making sure you have the model selected before running the exporter.

Share this post


Link to post
Share on other sites

I've used Assimp several years ago for my pet project (not a game, but a raytracer). I've found it quite powerfull (yet not perfect) and I can only suppose it got better in the latest 5 years.

I had a couple of issues with materials: I don't remember the details, but IIRC it was something annoying related to transparency/specularity which prevented me from using a couple of features of my RT. It was designed for real time rendering, though, so maybe those limitations were perfectly fine in such use cases.

Share this post


Link to post
Share on other sites

I've used Assimp several years ago for my pet project (not a game, but a raytracer). I've found it quite powerfull (yet not perfect) and I can only suppose it got better in the latest 5 years.

I had a couple of issues with materials: I don't remember the details, but IIRC it was something annoying related to transparency/specularity which prevented me from using a couple of features of my RT. It was designed for real time rendering, though, so maybe those limitations were perfectly fine in such use cases.

can you give me  the code how to extract assimp animation .... ?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement