mirror of
https://github.com/lubosz/overte.git
synced 2025-08-11 14:35:10 +02:00
got a basic avatar skeleton with a simpler starter user interaction for moving the right hand
This commit is contained in:
parent
a0f09b597a
commit
87fe21f835
5 changed files with 65 additions and 53 deletions
|
@ -147,7 +147,8 @@ glm::vec3 start_location(6.1f, 0, 1.4f);
|
||||||
int stats_on = 0; // Whether to show onscreen text overlay with stats
|
int stats_on = 0; // Whether to show onscreen text overlay with stats
|
||||||
bool starsOn = true; // Whether to display the stars
|
bool starsOn = true; // Whether to display the stars
|
||||||
bool paintOn = false; // Whether to paint voxels as you fly around
|
bool paintOn = false; // Whether to paint voxels as you fly around
|
||||||
|
VoxelDetail paintingVoxel; // The voxel we're painting if we're painting
|
||||||
|
unsigned char dominantColor = 0; // The dominant color of the voxel we're painting
|
||||||
int noise_on = 0; // Whether to add random noise
|
int noise_on = 0; // Whether to add random noise
|
||||||
float noise = 1.0; // Overall magnitude scaling for random noise levels
|
float noise = 1.0; // Overall magnitude scaling for random noise levels
|
||||||
|
|
||||||
|
@ -512,23 +513,18 @@ void simulateHead(float frametime)
|
||||||
|
|
||||||
glm::vec3 headPos = myHead.getPos();
|
glm::vec3 headPos = myHead.getPos();
|
||||||
|
|
||||||
VoxelDetail paintingVoxel;
|
::paintingVoxel.x = headPos.z/-10.0; // voxel space x is negative z head space
|
||||||
paintingVoxel.x = headPos.z/10.0; // voxel space x is positive z head space
|
::paintingVoxel.y = headPos.y/-10.0; // voxel space y is negative y head space
|
||||||
paintingVoxel.y = headPos.y/-10.0; // voxel space y is negative y head space
|
::paintingVoxel.z = headPos.x/-10.0; // voxel space z is negative x head space
|
||||||
paintingVoxel.z = headPos.x/-10.0; // voxel space z is negative x head space
|
|
||||||
paintingVoxel.s = 1.0/256;
|
|
||||||
paintingVoxel.red = 0;
|
|
||||||
paintingVoxel.green = 255;
|
|
||||||
paintingVoxel.blue = 0;
|
|
||||||
|
|
||||||
unsigned char* bufferOut;
|
unsigned char* bufferOut;
|
||||||
int sizeOut;
|
int sizeOut;
|
||||||
|
|
||||||
if (paintingVoxel.x >= 0.0 && paintingVoxel.x <= 1.0 &&
|
if (::paintingVoxel.x >= 0.0 && ::paintingVoxel.x <= 1.0 &&
|
||||||
paintingVoxel.y >= 0.0 && paintingVoxel.y <= 1.0 &&
|
::paintingVoxel.y >= 0.0 && ::paintingVoxel.y <= 1.0 &&
|
||||||
paintingVoxel.z >= 0.0 && paintingVoxel.z <= 1.0) {
|
::paintingVoxel.z >= 0.0 && ::paintingVoxel.z <= 1.0) {
|
||||||
|
|
||||||
if (createVoxelEditMessage('I',0,1,&paintingVoxel,bufferOut,sizeOut)){
|
if (createVoxelEditMessage('I',0,1,&::paintingVoxel,bufferOut,sizeOut)){
|
||||||
agentList.broadcastToAgents((char*)bufferOut, sizeOut,AgentList::AGENTS_OF_TYPE_VOXEL);
|
agentList.broadcastToAgents((char*)bufferOut, sizeOut,AgentList::AGENTS_OF_TYPE_VOXEL);
|
||||||
delete bufferOut;
|
delete bufferOut;
|
||||||
}
|
}
|
||||||
|
@ -715,7 +711,12 @@ void display(void)
|
||||||
drawtext(WIDTH-200,20, 0.10, 0, 1.0, 0, agents, 1, 1, 0);
|
drawtext(WIDTH-200,20, 0.10, 0, 1.0, 0, agents, 1, 1, 0);
|
||||||
|
|
||||||
if (::paintOn) {
|
if (::paintOn) {
|
||||||
drawtext(WIDTH-200,40, 0.10, 0, 1.0, 0, "Paint ON", 1, 1, 0);
|
|
||||||
|
char paintMessage[100];
|
||||||
|
sprintf(paintMessage,"Painting (%.3f,%.3f,%.3f/%.3f/%d,%d,%d)",
|
||||||
|
::paintingVoxel.x,::paintingVoxel.y,::paintingVoxel.z,::paintingVoxel.s,
|
||||||
|
(unsigned int)::paintingVoxel.red,(unsigned int)::paintingVoxel.green,(unsigned int)::paintingVoxel.blue);
|
||||||
|
drawtext(WIDTH-350,40, 0.10, 0, 1.0, 0, paintMessage, 1, 1, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
|
@ -749,6 +750,27 @@ void testPointToVoxel()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void shiftPaintingColor()
|
||||||
|
{
|
||||||
|
// About the color of the paintbrush... first determine the dominant color
|
||||||
|
::dominantColor = (::dominantColor+1)%3; // 0=red,1=green,2=blue
|
||||||
|
::paintingVoxel.red = (::dominantColor==0)?randIntInRange(200,255):randIntInRange(40,100);
|
||||||
|
::paintingVoxel.green = (::dominantColor==1)?randIntInRange(200,255):randIntInRange(40,100);
|
||||||
|
::paintingVoxel.blue = (::dominantColor==2)?randIntInRange(200,255):randIntInRange(40,100);
|
||||||
|
}
|
||||||
|
|
||||||
|
void setupPaintingVoxel()
|
||||||
|
{
|
||||||
|
glm::vec3 headPos = myHead.getPos();
|
||||||
|
|
||||||
|
::paintingVoxel.x = headPos.z/-10.0; // voxel space x is negative z head space
|
||||||
|
::paintingVoxel.y = headPos.y/-10.0; // voxel space y is negative y head space
|
||||||
|
::paintingVoxel.z = headPos.x/-10.0; // voxel space z is negative x head space
|
||||||
|
::paintingVoxel.s = 1.0/256;
|
||||||
|
|
||||||
|
shiftPaintingColor();
|
||||||
|
}
|
||||||
|
|
||||||
void addRandomSphere(bool wantColorRandomizer)
|
void addRandomSphere(bool wantColorRandomizer)
|
||||||
{
|
{
|
||||||
float r = randFloatInRange(0.05,0.1);
|
float r = randFloatInRange(0.05,0.1);
|
||||||
|
@ -835,7 +857,13 @@ void key(unsigned char k, int x, int y)
|
||||||
if (k == 'q') ::terminate();
|
if (k == 'q') ::terminate();
|
||||||
if (k == '/') stats_on = !stats_on; // toggle stats
|
if (k == '/') stats_on = !stats_on; // toggle stats
|
||||||
if (k == '*') ::starsOn = !::starsOn; // toggle stars
|
if (k == '*') ::starsOn = !::starsOn; // toggle stars
|
||||||
if (k == '&') ::paintOn = !::paintOn; // toggle paint
|
if (k == '&') {
|
||||||
|
::paintOn = !::paintOn; // toggle paint
|
||||||
|
setupPaintingVoxel(); // also randomizes colors
|
||||||
|
}
|
||||||
|
if (k == '^') {
|
||||||
|
shiftPaintingColor(); // shifts randomize color between R,G,B dominant
|
||||||
|
}
|
||||||
if (k == 'n')
|
if (k == 'n')
|
||||||
{
|
{
|
||||||
noise_on = !noise_on; // Toggle noise
|
noise_on = !noise_on; // Toggle noise
|
||||||
|
|
|
@ -37,25 +37,20 @@ void VoxelNode::addChildAtIndex(int childIndex) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// will average the child colors...
|
// will average the child colors...
|
||||||
void VoxelNode::setColorFromAverageOfChildren(int * colorArray) {
|
void VoxelNode::setColorFromAverageOfChildren() {
|
||||||
if (colorArray == NULL) {
|
int colorArray[4] = {0,0,0,0};
|
||||||
colorArray = new int[4];
|
for (int i = 0; i < 8; i++) {
|
||||||
memset(colorArray, 0, 4*sizeof(int));
|
if (children[i] != NULL && children[i]->color[3] == 1) {
|
||||||
|
for (int j = 0; j < 3; j++) {
|
||||||
for (int i = 0; i < 8; i++) {
|
colorArray[j] += children[i]->color[j];
|
||||||
if (children[i] != NULL && children[i]->color[3] == 1) {
|
}
|
||||||
for (int j = 0; j < 3; j++) {
|
colorArray[3]++;
|
||||||
colorArray[j] += children[i]->color[j];
|
}
|
||||||
}
|
}
|
||||||
colorArray[3]++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (colorArray[3] > 4) {
|
if (colorArray[3] > 4) {
|
||||||
// we need at least 4 colored children to have an average color value
|
// we need at least 4 colored children to have an average color value
|
||||||
// or if we have none we generate random values
|
// or if we have none we generate random values
|
||||||
|
|
||||||
for (int c = 0; c < 3; c++) {
|
for (int c = 0; c < 3; c++) {
|
||||||
// set the average color value
|
// set the average color value
|
||||||
color[c] = colorArray[c] / colorArray[3];
|
color[c] = colorArray[c] / colorArray[3];
|
||||||
|
|
|
@ -17,7 +17,7 @@ public:
|
||||||
~VoxelNode();
|
~VoxelNode();
|
||||||
|
|
||||||
void addChildAtIndex(int childIndex);
|
void addChildAtIndex(int childIndex);
|
||||||
void setColorFromAverageOfChildren(int * colorArray = NULL);
|
void setColorFromAverageOfChildren();
|
||||||
void setRandomColor(int minimumBrightness);
|
void setRandomColor(int minimumBrightness);
|
||||||
bool collapseIdenticalLeaves();
|
bool collapseIdenticalLeaves();
|
||||||
|
|
||||||
|
|
|
@ -100,8 +100,6 @@ int VoxelTree::readNodeData(VoxelNode *destinationNode,
|
||||||
|
|
||||||
// instantiate variable for bytes already read
|
// instantiate variable for bytes already read
|
||||||
int bytesRead = 1;
|
int bytesRead = 1;
|
||||||
int colorArray[4] = {};
|
|
||||||
|
|
||||||
for (int i = 0; i < 8; i++) {
|
for (int i = 0; i < 8; i++) {
|
||||||
// check the colors mask to see if we have a child to color in
|
// check the colors mask to see if we have a child to color in
|
||||||
if (oneAtBit(*nodeData, i)) {
|
if (oneAtBit(*nodeData, i)) {
|
||||||
|
@ -115,17 +113,12 @@ int VoxelTree::readNodeData(VoxelNode *destinationNode,
|
||||||
memcpy(destinationNode->children[i]->color, nodeData + bytesRead, 3);
|
memcpy(destinationNode->children[i]->color, nodeData + bytesRead, 3);
|
||||||
destinationNode->children[i]->color[3] = 1;
|
destinationNode->children[i]->color[3] = 1;
|
||||||
|
|
||||||
for (int j = 0; j < 3; j++) {
|
|
||||||
colorArray[j] += destinationNode->children[i]->color[j];
|
|
||||||
}
|
|
||||||
|
|
||||||
bytesRead += 3;
|
bytesRead += 3;
|
||||||
colorArray[3]++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// average node's color based on color of children
|
// average node's color based on color of children
|
||||||
destinationNode->setColorFromAverageOfChildren(colorArray);
|
destinationNode->setColorFromAverageOfChildren();
|
||||||
|
|
||||||
// give this destination node the child mask from the packet
|
// give this destination node the child mask from the packet
|
||||||
unsigned char childMask = *(nodeData + bytesRead);
|
unsigned char childMask = *(nodeData + bytesRead);
|
||||||
|
|
|
@ -85,8 +85,6 @@ void randomlyFillVoxelTree(int levelsToGo, VoxelNode *currentRootNode) {
|
||||||
if (levelsToGo > 0) {
|
if (levelsToGo > 0) {
|
||||||
|
|
||||||
bool createdChildren = false;
|
bool createdChildren = false;
|
||||||
int colorArray[4] = {};
|
|
||||||
|
|
||||||
createdChildren = false;
|
createdChildren = false;
|
||||||
|
|
||||||
for (int i = 0; i < 8; i++) {
|
for (int i = 0; i < 8; i++) {
|
||||||
|
@ -96,17 +94,8 @@ void randomlyFillVoxelTree(int levelsToGo, VoxelNode *currentRootNode) {
|
||||||
|
|
||||||
// give this child it's octal code
|
// give this child it's octal code
|
||||||
currentRootNode->children[i]->octalCode = childOctalCode(currentRootNode->octalCode, i);
|
currentRootNode->children[i]->octalCode = childOctalCode(currentRootNode->octalCode, i);
|
||||||
|
|
||||||
randomlyFillVoxelTree(levelsToGo - 1, currentRootNode->children[i]);
|
|
||||||
|
|
||||||
if (currentRootNode->children[i]->color[3] == 1) {
|
randomlyFillVoxelTree(levelsToGo - 1, currentRootNode->children[i]);
|
||||||
for (int c = 0; c < 3; c++) {
|
|
||||||
colorArray[c] += currentRootNode->children[i]->color[c];
|
|
||||||
}
|
|
||||||
|
|
||||||
colorArray[3]++;
|
|
||||||
}
|
|
||||||
|
|
||||||
createdChildren = true;
|
createdChildren = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -117,7 +106,7 @@ void randomlyFillVoxelTree(int levelsToGo, VoxelNode *currentRootNode) {
|
||||||
currentRootNode->setRandomColor(MIN_BRIGHTNESS);
|
currentRootNode->setRandomColor(MIN_BRIGHTNESS);
|
||||||
} else {
|
} else {
|
||||||
// set the color value for this node
|
// set the color value for this node
|
||||||
currentRootNode->setColorFromAverageOfChildren(colorArray);
|
currentRootNode->setColorFromAverageOfChildren();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// this is a leaf node, just give it a color
|
// this is a leaf node, just give it a color
|
||||||
|
@ -171,7 +160,12 @@ void *distributeVoxelsToListeners(void *args) {
|
||||||
packetCount++;
|
packetCount++;
|
||||||
totalBytesSent += voxelPacketEnd - voxelPacket;
|
totalBytesSent += voxelPacketEnd - voxelPacket;
|
||||||
|
|
||||||
if (agentData->rootMarkerNode->childrenVisitedMask == 255) {
|
// XXXBHG Hack Attack: This is temporary code to help debug an issue.
|
||||||
|
// Normally we use this break to prevent resending voxels that an agent has
|
||||||
|
// already visited. But since we might be modifying the voxel tree we might
|
||||||
|
// want to always send. This is a hack to test the behavior
|
||||||
|
bool alwaysSend = true;
|
||||||
|
if (!alwaysSend && agentData->rootMarkerNode->childrenVisitedMask == 255) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -311,6 +305,8 @@ int main(int argc, const char * argv[])
|
||||||
pVoxelData+=voxelDataSize;
|
pVoxelData+=voxelDataSize;
|
||||||
atByte+=voxelDataSize;
|
atByte+=voxelDataSize;
|
||||||
}
|
}
|
||||||
|
// after done inserting all these voxels, then reaverage colors
|
||||||
|
randomTree.reaverageVoxelColors(randomTree.rootNode);
|
||||||
}
|
}
|
||||||
if (packetData[0] == 'R') {
|
if (packetData[0] == 'R') {
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue