[QUOTE=BMCHa;38872936]You want simple alpha testing, not alpha blending.[/QUOTE]
Will that allow me to draw a model like this without having to:
a) sort the models or even polygons?
and
b) drawing parts of the model twice (wings and rest) ?
[QUOTE=Felheart;38875025]Will that allow me to draw a model like this without having to:
a) sort the models or even polygons?
and
b) drawing parts of the model twice (wings and rest) ?[/QUOTE]
As far as I know, yes. It's basically 1-bit alpha, with the binary transparency set by an alpha threshold. So as far as the render pipeline is concerned it might as well be opaque geometry with holes. That screenshot you posted ([url]http://www.hiveworkshop.com/forums/resource_images/9/models_8100_screenshot.jpg[/url]) uses it, as does most foliage in games. (For the same performance reasons you mention)
[QUOTE=Shadaez;38874744]Well, is there any way to say "Every instance of the class MyClass, do this method"? That's what I'm looking for.
[editline]18th December 2012[/editline]
only thing I can think of is creating a list of them, and adding to the list in the __init__ of the class, or something?[/QUOTE]
That sounds like you could get a workable solution out of it, but I think if you're going to want to do something like that, you should make a class that handles it for you. For example, the EntityManager in my game works something like this:
[cpp]entityMan.add(new EntityPlayer(<some data here>)); // Adds the Entity* to entityMan's internal list.
// Later...
entityMan.tick(); // Loops over entityMan's internal list, calling tick() on each Entity in there.[/cpp]
[QUOTE=Shadaez;38874744]Well, is there any way to say "Every instance of the class MyClass, do this method"? That's what I'm looking for.
[editline]18th December 2012[/editline]
only thing I can think of is creating a list of them, and adding to the list in the __init__ of the class, or something?[/QUOTE]
That's probably the best way to do it.
[QUOTE=Chris220;38876020]That sounds like you could get a workable solution out of it, but I think if you're going to want to do something like that, you should make a class that handles it for you. For example, the EntityManager in my game works something like this:
[cpp]entityMan.add(new EntityPlayer(<some data here>)); // Adds the Entity* to entityMan's internal list.
// Later...
entityMan.tick(); // Loops over entityMan's internal list, calling tick() on each Entity in there.[/cpp][/QUOTE]
Awesome! That's a great idea and exactly what I need.
working on a model loader/animation system using IQM,
anyone know what all 4 blendweights are meant to add up to?
Also I am trying to create a method where I can pass in the weight that a joint has over a vertex, and it will create a 4x4 matrix that I can use to just multiply with the vertex's position, but to apply rotation would I need to make use of the vertices normals as well?
This is what my current joint class looks liek:
[cpp]
const glm::vec3 Joint::GetTranslation()
{
if(mParent != NULL)
return mTranslation + mParent->GetTranslation();
return mTranslation;
}
const glm::quat Joint::GetQuaterion()
{
return mQuaterion;
}
const glm::vec3 Joint::GetScale()
{
if(mParent != NULL)
return mScale * mParent->GetScale();
return mScale;
}
glm::vec3 Joint::ApplyForces(const glm::vec3 &pVec3,float pWeight)
{
glm::vec3 trans = GetTranslation();
glm::mat4 rot = glm::mat4_cast(GetQuaterion());
glm::mat4 scale = glm::scale(glm::mat4(1.0f),GetScale());
glm::vec4 out = ((glm::vec4( pVec3.x, pVec3.y, pVec3.z, 0.0f ) * scale) * rot);
return glm::vec3(out.x, out.y, out.z) + trans;
}
[/cpp]
Im kinda having a ard time grasping the concept of how this is then applied to each vertex, if anyone can explain
Trying to implement BoyerMoores alogorithm in Haskell.
It works when there is an exact match, so I think my shift function is wrong or something.
Any help?
[url]http://hpaste.org/79494[/url]
[QUOTE=Richy19;38881058]working on a model loader/animation system using IQM,
anyone know what all 4 blendweights are meant to add up to?
Also I am trying to create a method where I can pass in the weight that a joint has over a vertex, and it will create a 4x4 matrix that I can use to just multiply with the vertex's position, but to apply rotation would I need to make use of the vertices normals as well?
This is what my current joint class looks liek:
[cpp]
const glm::vec3 Joint::GetTranslation()
{
if(mParent != NULL)
return mTranslation + mParent->GetTranslation();
return mTranslation;
}
const glm::quat Joint::GetQuaterion()
{
return mQuaterion;
}
const glm::vec3 Joint::GetScale()
{
if(mParent != NULL)
return mScale * mParent->GetScale();
return mScale;
}
glm::vec3 Joint::ApplyForces(const glm::vec3 &pVec3,float pWeight)
{
glm::vec3 trans = GetTranslation();
glm::mat4 rot = glm::mat4_cast(GetQuaterion());
glm::mat4 scale = glm::scale(glm::mat4(1.0f),GetScale());
glm::vec4 out = ((glm::vec4( pVec3.x, pVec3.y, pVec3.z, 0.0f ) * scale) * rot);
return glm::vec3(out.x, out.y, out.z) + trans;
}
[/cpp]
Im kinda having a ard time grasping the concept of how this is then applied to each vertex, if anyone can explain[/QUOTE]
The values of blendweights are meant to add up to 1. If you only have 2 bones influencing a vertex equally, expect the blendweights to be <0.5, 0.5, 0, 0>.
The way joints work is that you start with the root node, which is given either the identity matrix, or a transformation from the origin of the model. From there, each child bone applies a transformation (usually only rotation and translation) to the parent bone's matrix. This accumulates the transformations of each joint.
If you would, for a second, forget about blending/multiple joint indices and imagine there's only a single joint for each vertex. When you multiply each vertex by it's joint's transformation matrix, it will transform the vertex to the joint position.
There's also the inverse base frame, which undoes the pose that the mesh starts off in.
Now with multiple joints per vertex and blending between them, you're basically just doing 4 vertex transformations and interpolating between them with the given multipliers.
That's pretty much all I know about it. In implementation, some of the linear algebra makes me scratch my head (baseFrame[pose.Parent] * m * inverseBaseFrame[j]?). I've been putting off implementing proper classes for animation, there are other, more important things to do, but that might help you get on the right track. Just try things out, if the result is really weird, just keep changing it until it works.
[QUOTE=robmaister12;38884456]The values of blendweights are meant to add up to 1. If you only have 2 bones influencing a vertex equally, expect the blendweights to be <0.5, 0.5, 0, 0>.
The way joints work is that you start with the root node, which is given either the identity matrix, or a transformation from the origin of the model. From there, each child bone applies a transformation (usually only rotation and translation) to the parent bone's matrix. This accumulates the transformations of each joint.
If you would, for a second, forget about blending/multiple joint indices and imagine there's only a single joint for each vertex. When you multiply each vertex by it's joint's transformation matrix, it will transform the vertex to the joint position.
There's also the inverse base frame, which undoes the pose that the mesh starts off in.
Now with multiple joints per vertex and blending between them, you're basically just doing 4 vertex transformations and interpolating between them with the given multipliers.
That's pretty much all I know about it. In implementation, some of the linear algebra makes me scratch my head (baseFrame[pose.Parent] * m * inverseBaseFrame[j]?). I've been putting off implementing proper classes for animation, there are other, more important things to do, but that might help you get on the right track. Just try things out, if the result is really weird, just keep changing it until it works.[/QUOTE]
I changed how my joint class works:
[cpp]
const glm::vec3 Joint::GetTranslation()
{
if(mParent != NULL) return mTranslation + mParent->GetTranslation();
return mTranslation;
}
const glm::quat Joint::GetQuaterion()
{
if(mParent != NULL) return mQuaterion * mParent->GetQuaterion();
return mQuaterion;
}
const glm::vec3 Joint::GetScale()
{
if(mParent != NULL) return mScale * mParent->GetScale();
return mScale;
}
glm::mat4 Joint::ApplyForces(float pWeight)
{
glm::mat4 trans = glm::translate(glm::mat4(1.0f),GetTranslation());
glm::mat4 rot = glm::mat4_cast(GetQuaterion());
glm::mat4 scale = glm::scale(glm::mat4(1.0f),GetScale());
return (trans * rot * scale) * pWeight;
}
[/cpp]
According to my calculations this allows me to call a joints applyforce method with a given weight and it should give me a mat4 representing the force it has over a vertex, owever I dont understand what to do with the rotation, how can a point in 3d space be rotated? unless its rotated around a different point but the iqm spec doesnt specify anything
[QUOTE=Richy19;38884912]I changed how my joint class works:
[cpp]
const glm::vec3 Joint::GetTranslation()
{
if(mParent != NULL) return mTranslation + mParent->GetTranslation();
return mTranslation;
}
const glm::quat Joint::GetQuaterion()
{
if(mParent != NULL) return mQuaterion * mParent->GetQuaterion();
return mQuaterion;
}
const glm::vec3 Joint::GetScale()
{
if(mParent != NULL) return mScale * mParent->GetScale();
return mScale;
}
glm::mat4 Joint::ApplyForces(float pWeight)
{
glm::mat4 trans = glm::translate(glm::mat4(1.0f),GetTranslation());
glm::mat4 rot = glm::mat4_cast(GetQuaterion());
glm::mat4 scale = glm::scale(glm::mat4(1.0f),GetScale());
return (trans * rot * scale) * pWeight;
}
[/cpp]
According to my calculations this allows me to call a joints applyforce method with a given weight and it should give me a mat4 representing the force it has over a vertex, owever I dont understand what to do with the rotation, how can a point in 3d space be rotated? unless its rotated around a different point but the iqm spec doesnt specify anything[/QUOTE]
You're transforming spaces. When you rotate a joint, all the child nodes have their spaces transformed by the joint's matrix. A rotation means that, say, the X axis, would be off at some weird angle relative to local space.
[B]What would be a good IDE to use for C++?
[/B]I currently use Code::Blocks, but it feels bloated, and some of the should be per-project settings are made global, like AStyle and backups. Also it crashes for completely random reasons, like saving your file, or removing a file from all targets, so it's less than optimal.
I need something alike to NetBeans (Java), but with less focus on Java and Ant, mainly because I have no idea how to write make files yet. I tried the C++ one but it's not really working well for me, mainly because it already fails at compiling a simple Hello World Example, due to their makefile being broken.[/li]
[B]How do I get SFML to work with TDM-GCC(mingw32) and TDM64-GCC(mingw64)?[/B]
When I use anything from the precompiled binaries in TDM-GCC the library just explodes with the debugger.
For example, the following code leads to a bluescreen:
[CODE]#include <SFML/System.hpp>
#include <iostream>
int main() {
sf::Clock Clock;
float t1 = Clock.GetElapsedTime();
float t2 = Clock.GetElapsedTime(); //<- Bluescreen
return false;
}[/CODE]
[B](GLSL) Is this Phong shading shader correct?
[/B]I currently render it onto a cube, but depending on the side I render it on, the lightning changes direction.
The cube is a normal 24 vertex cube, with 12 triangles/6 quads, the UVs match for each side, as the Diffuse map shows.
I don't even know if my implementation should work, because the only references I had are wikipedia and images of phong shading.
[CODE][[Vertex]]
#version 110
//!START Diffuse Mapping
varying vec2 f2DiffuseCoord;
//!END Diffuse Mapping
//!START Phong Shading (One Light)
varying vec4 f4VertexPosition;
varying vec3 f3VertexNormal;
//!END Phong Shading (One Light)
//!START Phong Shading (NormalMap) (One Light)
varying vec3 f3VertexTangent;
varying vec3 f3VertexBinormal;
//!END Phong Shading (NormalMap) (One Light)
void main(void) {
gl_Position = ftransform();
//!START Diffuse Mapping
f2DiffuseCoord = gl_MultiTexCoord0.xy;
//!END Diffuse Mapping
//!START Phong Shading (One Light)
// Info: Converting this to World Space is rather easy:
// Remove all gl_ModelViewMatrix and gl_NormalMatrix multiplications.
f4VertexPosition = gl_ModelViewMatrix * gl_Vertex;
f3VertexNormal = normalize(gl_NormalMatrix * gl_Normal);
//!END Phong Shading (One Light)
//!START Phong Shading (NormalMap) (One Light)
f3VertexTangent = normalize(gl_NormalMatrix * gl_MultiTexCoord0.xyz);
f3VertexBinormal = normalize(cross(f3VertexNormal, f3VertexTangent));
//!END Phong Shading (NormalMap) (One Light)
}
[[Fragment]]
#version 110
//!START Diffuse Mapping
uniform sampler2D s2DiffuseMap;
varying vec2 f2DiffuseCoord;
//!END Diffuse Mapping
//!START Phong Shading (One Light)
uniform vec3 f3LightPosition; //Light position in Eye Space.
uniform vec3 f3LightAmbient;
uniform vec3 f3LightDiffuse;
uniform float fLightSpecularPercent;
varying vec4 f4VertexPosition;
varying vec3 f3VertexNormal;
//!END Phong Shading (One Light)
//!START Phong Shading (NormalMap) (One Light)
uniform sampler2D s2NormalMap;
varying vec3 f3VertexTangent;
varying vec3 f3VertexBinormal;
//!END Phong Shading (NormalMap) (One Light)
//!START Phong Shading (SpecularMap) (One Light)
void main(void) {
//!START Diffuse Map
vec4 f4DiffuseColor = texture2D(s2DiffuseMap, f2DiffuseCoord, -1);
//!END Diffuse Map
//!START Phong Shading (NormalMap) (One Light)
vec3 f3LightDirection = normalize(f4VertexPosition.xyz - f3LightPosition);
// Grab and calculate Tangent Space Normals
vec3 f3TSNormal = (2.0 * texture2D(s2NormalMap, f2DiffuseCoord, -1).rgb - 1.0);
vec3 f3Normal = normalize((f3VertexTangent * f3TSNormal.y) + (f3VertexBinormal * f3TSNormal.x) + (f3VertexNormal * f3TSNormal.z));
float fLambert = -dot(normalize(f3VertexNormal + f3Normal), f3LightDirection);
//!END Phong Shading (NormalMap) (One Light)
//!START Phong Shading (One Light)
// Light Ambient Color is always applied.
vec4 f4PhongColor = vec4(f4DiffuseColor.rgb * f3LightAmbient, f4DiffuseColor.a);
// Light Diffuse Color is only applied when the light is in the right direction.
if (fLambert > 0.0f) {
f4PhongColor.rgb += f4DiffuseColor.rgb * f3LightDiffuse * fLambert;
// Light Specular Color is applied as a percentage of the Lambert.
float fSpecularLambert = (fLambert - (1.0f - fLightSpecularPercent)) * (1.0f / fLightSpecularPercent);
if (fSpecularLambert > 0.0f) {
f4PhongColor.rgb += f4DiffuseColor.rgb * f3LightDiffuse * fSpecularLambert;
}
}
//!END Phong Shading (One Light)
gl_FragColor = f4PhongColor;
}[/CODE]
Sorry for this incredibly long post, but I have no idea where else to ask.
[QUOTE=Xaymar;38887864]What would be a good IDE to use for C++?
[/QUOTE]
Visual Studio 2012 is great at organization and has a fantastic debugger, and it doesn't feel bloated like CB
[editline]19th December 2012[/editline]
You should also see if your diffuse shader works correctly before you implement phong into the mix
[QUOTE=Meatpuppet;38889637]doesn't feel bloated like CB[/QUOTE]
The fuck? Have you seen the size of VS2012?
[QUOTE=Jookia;38891399]The fuck? Have you seen the size of VS2012?[/QUOTE]
I believe the express editions are several times larger than C::B and it just gets bigger from there.
Puush is broken on my computer (some authentication errors, support doesn't want to answer me) so I decided to code my own software using puush's API: [url]http://pastebin.com/qiiMEzQ3[/url]
However, I am clueless at how to actually upload a image. I figured as much that "api/up" is to be used, but what should I send at the "f" parameter? Is it a "multipart/form-data" type data, or what?
[QUOTE=Meatpuppet;38889637]Visual Studio 2012 is great at organization and has a fantastic debugger, and it doesn't feel bloated like CB[/QUOTE]
Personally, I think VS2012 is even more bloated than Code::Blocks, but it hides it better. Sadly it has little support for external compilers, as far as i know.
[QUOTE=Meatpuppet;38889637]You should also see if your diffuse shader works correctly before you implement phong into the mix[/QUOTE]
Is there a reference / information paper/pdf you could link me to? I don't have many resources available here.
[QUOTE=Xaymar;38896309]Personally, I think VS2012 is even more bloated than Code::Blocks, but it hides it better. [B]Sadly it has little support for external compilers, as far as i know.[/B]
[/QUOTE]
[IMG]http://www.fearswe.net/s/Capture-201212192321429549-948x280.png[/IMG]
[QUOTE=Lord Fear;38896661][IMG]http://www.fearswe.net/s/Capture-201212192321429549-948x280.png[/IMG][/QUOTE]
Do makefile projects support adding new files and then hitting compile without changing the makefile? If yes, then I guess I have a new file format to learn.
Edit: The reason I'm asking is because I only know of projects that have their makefile contain all source files...
Can any one help me with MySql in VB.NET? Specifically with grabbing information from the columns? I have the query but am having troubles getting the values collected.
Hit me up on Steam if you can.
A simple java application;
[cpp]
public static void main(String[] args)
{
int array[] = new int[3];
for(int i = 0; i < array.length; i++)
{
array[i] = i;
System.out.println("Normal: " + array[i]);
}
for(int i = 0; i < array.length; i++)
{
reverse(array);
System.out.println("Reversed: " + array[i]);
}
}
public static int[] reverse(int in[])
{
int result[] = new int[in.length];
for(int i = 0; i < in.length - 1; i++)
{
for(int j = in.length - 1; j > 0; j--)
{
result[i] = in[j];
}
}
return result;
}
[/cpp]
Can anyone tell me what I'm doing wrong?
I'm assuming that;
result[0] = in[2]
result[1] = in[1]
result[2] = in[0]
Which would then be;
result[0] = 2
result[1] = 1
result[2] = 0
Which would then be returning;
{2, 1, 0}
Which is the reverse of the inputted;
{0, 1, 2}
Is there something valuable I'm missing with my nested for loop?
It should be array = reverse(array);
Also, don't have two loops to reverse the array, just one.
for(int i = 0; i < in.length; i++){
result[i] = in[in.length-i-1];
}
Currently making a roguelike, and I got a problem that I've been thinking about the last 3 days. Just theoretically how would I go about creating a corridor generation algorithm? I've been googling a lot, and somehow ended up on the A* algorithm, but that's a pathfinding algorithm. How would I use that to generate a corridor? I can probably make a predefined corridor by using A* but how I would go about random generating them is currently beyond me.
So what I am asking is, a theoretical solution for a corridor generation algorithm. I would really appreciate the help.
Corridors are paths between rooms so it makes sense one might use a pathfinding algorithm. Mark other rooms' and corridors' walls as high-cost areas so your pathfinder will automatically try to avoid breaching into other rooms and corridors while pathing a way between two rooms.
[editline]20th December 2012[/editline]
And possibly randomize the costs of other tiles so your corridors aren't just straight lines.
[editline]20th December 2012[/editline]
However there are other approaches as well. Assuming I already have a list of rooms, I'd probably construct some kind of a minimum spanning tree out of them and then randomly add edges that don't intersect with other edges. It should give a nicely balanced dungeon, with different qualities depending on how the rooms are aligned to each other: all grouped together it's labyrinthian, and rooms arranged linearly would get connected linearly.
[editline]20th December 2012[/editline]
A Euclidean minimum spanning tree already has the quality that edges don't intersect, so there'd be no need to pathfind between rooms to ensure that corridors don't intersect with each other or other rooms. Unless that's desirable.
Are your rooms generated as well? If so, why not make a generator that makes corridors in random directions, and then randomly makes some of the corridors room-sized?
[QUOTE=ThePuska;38903817]Corridors are paths between rooms so it makes sense one might use a pathfinding algorithm. Mark other rooms' and corridors' walls as high-cost areas so your pathfinder will automatically try to avoid breaching into other rooms and corridors while pathing a way between two rooms.
[editline]20th December 2012[/editline]
And possibly randomize the costs of other tiles so your corridors aren't just straight lines.
[editline]20th December 2012[/editline]
However there are other approaches as well. Assuming I already have a list of rooms, I'd probably construct some kind of a minimum spanning tree out of them and then randomly add edges that don't intersect with other edges. It should give a nicely balanced dungeon, with different qualities depending on how the rooms are aligned to each other: all grouped together it's labyrinthian, and rooms arranged linearly would get connected linearly.
[editline]20th December 2012[/editline]
A Euclidean minimum spanning tree already has the quality that edges don't intersect, so there'd be no need to pathfind between rooms to ensure that corridors don't intersect with each other or other rooms. Unless that's desirable.[/QUOTE]
Hm, thanks. That gave me some ideas, but then I would define costs of each tile, then when generator checks, I just multiply the cost of non-interesting tiles by like 100 or so?
[QUOTE=Xaymar;38897489]Do makefile projects support adding new files and then hitting compile without changing the makefile? If yes, then I guess I have a new file format to learn.
Edit: The reason I'm asking is because I only know of projects that have their makefile contain all source files...[/QUOTE]
It's like any regular project in VS, except it uses an external build system as pointed out. It will update/edit the makefile for you automatically. It's not a project to edit/create a makefile.
I'm currently trying to implement a singly-linked list in C++ as a challenge for myself, however I can't figure out exactly how to add nodes and keep the head/tail correct.
[cpp]
typedef struct node
{
int data;
struct node* next;
} node;
[/cpp]
is my node data structure. I've read some articles about linked lists, however I'm still not quite sure how to add/remove/go through the list. Could anyone help me, with maybe some resources or examples?
This is more C than C++.
[cpp]/* Prepend "n" to "list", return the new list. */
node *add_first(node *list, node *n)
{
n->next = list;
return n;
}
/* Append "n" to "list", return the new list. */
node *add_last(node *list, node *n)
{
node *t = list;
if (t)
{
while (t->next)
t = t->next;
t->next = n;
return list;
}
else
return n;
}[/cpp]
After another two hours of figuring out, I finally got that the head is the node on the left-most side, and you then traverse the list through the right.
[img]http://www.codeproject.com/KB/cpp/linked_list/image006.gif[/img]
Useful.
Is there a standard solution for the situations where you create a lookat matrix but both the forward and up vectors aren't perpendicular? Right now I just pick another axis for the up vector - is that sufficient?
Sorry, you need to Log In to post a reply to this thread.