Instanciating & Rendering a Player w/o a server connection ?
by Orion Elenzil · in Torque Game Engine · 04/24/2008 (4:41 pm) · 9 replies
Howdy Folks -
i'd like to have a regular client instanciate, animate, & render a regular player object
without actually connecting to a server.
the player would be floating in space; it doesn't need navigation, physics, etc.
actually,
now that i think about it,
this seems like a bit of a tall order, just based on the fact that the player datablock needs to come from the server.
perhaps i should look getting the GuiObjectView to work with in combination with mesh-hiding and players.
anyhow,
i'll probably go back to the drawing board here,
but thought i'd check if anyone had some fabulous ideas.
thanks!
ooo
i'd like to have a regular client instanciate, animate, & render a regular player object
without actually connecting to a server.
the player would be floating in space; it doesn't need navigation, physics, etc.
actually,
now that i think about it,
this seems like a bit of a tall order, just based on the fact that the player datablock needs to come from the server.
perhaps i should look getting the GuiObjectView to work with in combination with mesh-hiding and players.
anyhow,
i'll probably go back to the drawing board here,
but thought i'd check if anyone had some fabulous ideas.
thanks!
ooo
About the author
#2
Header Stuff:
04/24/2008 (5:24 pm)
Found it, it's a blind drop, but here is what I use:Header Stuff:
void MeshHideAll(const char* name); void MeshShowAll(const char* name); void MeshOnOff(const char* name, const char* part, const char* part2); void MeshOff(const char* name, const char* part); void MeshOn(const char* name, const char* part); void MeshList(const char* name);
ConsoleMethod( GuiObjectView, MeshList, void, 3, 3, "List all meshes")
{
S32 i;
GuiObjectView* view = static_cast<GuiObjectView*>( object );
view->MeshList(argv[2]);
}
void GuiObjectView::MeshList(const char *name)
{
S32 index = mMeshObjects.findMeshByName(name);
if (index != -1)
{
int s = mMeshObjects.mMainObject->mMeshObjects.size();
for(int x = 0; x < s; x++) {
const char * skinName = "";
S32 nameIndex = mMeshObjects.mMainObject->getShape()->objects[x].nameIndex;
// find the name of the mesh
if (nameIndex>=0) {
skinName = mMeshObjects.mMainObject->getShape()->getName(nameIndex);
}
Con::printf("List: Mesh %s", skinName);
}
}
else
{
Con::printf("List: Could not find object %s", name);
}
}
ConsoleMethod( GuiObjectView, MeshHideAll, void, 3, 3, "Hide all meshes in a model"){
S32 i;
GuiObjectView* view = static_cast<GuiObjectView*>( object );
view->MeshHideAll(argv[2]);
}
void GuiObjectView::MeshHideAll(const char *name)
{
S32 index = mMeshObjects.findMeshByName(name);
if (index != -1)
{
int s = mMeshObjects.mMainObject->mMeshObjects.size();
for(int x = 0; x < s; x++) {
mMeshObjects.mMainObject->mMeshObjects[x].visible = 0.0;
mMeshObjects.mMainObject->mMeshObjects[x].forceHidden = 1.0;
}
}
else
{
Con::printf("Error: Could not find object %s", name);
}
}
ConsoleMethod( GuiObjectView, MeshOff, void, 4, 4, "(string meshname)")
{
GuiObjectView* view = static_cast<GuiObjectView*>( object );
view->MeshOff(argv[2],argv[3]);
}
void GuiObjectView::MeshOff(const char *name, const char *part)
{
//the first argument is the main mesh name, second argument is the mesh part
S32 index = mMeshObjects.findMeshByName(name);
if (index != -1)
{
int s = mMeshObjects.mMainObject->mMeshObjects.size();
for(int x = 0; x < s; x++) {
const char * skinName = "";
S32 nameIndex = mMeshObjects.mMainObject->getShape()->objects[x].nameIndex;
// find the name of the mesh
if (nameIndex>=0) {
skinName = mMeshObjects.mMainObject->getShape()->getName(nameIndex);
}
//Con::printf("Info: Looking at object %s", skinName);
// Look at second argument. if its a perfect match, turn it off
if (dStricmp(skinName, part) == 0)
{
mMeshObjects.mMainObject->mMeshObjects[x].visible = 0.0;
mMeshObjects.mMainObject->mMeshObjects[x].forceHidden = 1.0;
}
}
}
else
{
Con::printf("Error: Could not find object %s", name);
}
}
ConsoleMethod( GuiObjectView, MeshShowAll, void, 3, 3, "Show all meshes in a model"){
S32 i;
GuiObjectView* view = static_cast<GuiObjectView*>( object );
view->MeshShowAll(argv[2]);
}
void GuiObjectView::MeshShowAll(const char *name)
{
S32 index = mMeshObjects.findMeshByName(name);
if (index != -1)
{
int s = mMeshObjects.mMainObject->mMeshObjects.size();
for(int x = 0; x < s; x++) {
mMeshObjects.mMainObject->mMeshObjects[x].visible = 1.0;
mMeshObjects.mMainObject->mMeshObjects[x].forceHidden = 0.0;
}
}
else
{
Con::printf("Error: Could not find object %s", name);
}
}
ConsoleMethod( GuiObjectView, MeshOn, void, 4, 4, "(string meshname)"){
GuiObjectView* view = static_cast<GuiObjectView*>( object );
view->MeshOn(argv[2],argv[3]);
}
void GuiObjectView::MeshOn(const char *name, const char *part)
{
//the first argument is the main mesh name, second argument is the mesh part
S32 index = mMeshObjects.findMeshByName(name);
if (index != -1)
{
int s = mMeshObjects.mMainObject->mMeshObjects.size();
for(int x = 0; x < s; x++) {
const char * skinName = "";
S32 nameIndex = mMeshObjects.mMainObject->getShape()->objects[x].nameIndex;
// find the name of the mesh
if (nameIndex>=0) {
skinName = mMeshObjects.mMainObject->getShape()->getName(nameIndex);
}
//Con::printf("Info: Looking at object %s", skinName);
// Look at second argument. if its a perfect match, turn it off
if (dStricmp(skinName, part) == 0)
{
mMeshObjects.mMainObject->mMeshObjects[x].visible = 1.0;
mMeshObjects.mMainObject->mMeshObjects[x].forceHidden = 0.0;
}
}
}
else
{
Con::printf("Error: Could not find object %s", name);
}
}
// end meshon()
#3
I'll give that a gander.
.. and it can also load DSQs, huh.
those two together should work.
ideally we'd get texture swapping as well,
but i think we can either live without, or implement.
thanks again.
04/24/2008 (5:32 pm)
Hey Thanks Dave!I'll give that a gander.
.. and it can also load DSQs, huh.
those two together should work.
ideally we'd get texture swapping as well,
but i think we can either live without, or implement.
thanks again.
#4
04/24/2008 (6:38 pm)
Texture swapping eh?ConsoleMethod( GuiObjectView, setSkinName, void, 5, 5, "ObjectView.setSkinName(name, standardMaterial, newMaterial)" ) {
argc;
GuiObjectView* view = static_cast<GuiObjectView*>( object );
view->setSkinName(argv[2], argv[3], argv[4]);
}
void GuiObjectView::setSkinName(const char* name, const char* stdMaterial, const char* newMaterial)
{
//ObjectView.setSkinName("sphere", "base.sphere", SphereGlow);
S32 index = mMeshObjects.findMeshByName(name);
if (index != -1)
{
StringHandle stdHandle;
StringHandle newHandle;
if (stdMaterial[0] != '[[6287b4a71525c]]') {
if(stdMaterial[0] == StringTagPrefixByte) {
stdHandle = StringHandle(U32(dAtoi(stdMaterial + 1)));
}
else {
stdHandle = StringHandle(stdMaterial);
}
}
else {
stdHandle = StringHandle();
}
if (newMaterial[0] != '[[6287b4a71525c]]') {
// Use tags for better network performance
// Should be a tag, but we'll convert to one if it isn't.
if (newMaterial[0] == StringTagPrefixByte) {
newHandle = StringHandle(U32(dAtoi(newMaterial + 1)));
}
else {
newHandle = StringHandle(newMaterial);
}
}
else {
newHandle = StringHandle();
}
//Con::errorf("Handing off to tsmesh %s %s",stdHandle.getString(), newHandle.getString());
mMeshObjects.mMesh[index].mesh->reSkin(stdHandle, newHandle);
}
else
{
Con::printf("Error: Could not find object %s", name);
}
}
#5
04/25/2008 (7:40 am)
Dave Young, the drive-by helpful bandit strikes again!
#6
many thanks dave.
i'm also having trouble with animation,
but i think it's because of other ways i've "changed" (read: "broken") the stock code,
but hopefully i'll be pulling it all together over the weekend.
04/25/2008 (7:52 am)
G'urk! i've been helped! he got me right in the source code !many thanks dave.
i'm also having trouble with animation,
but i think it's because of other ways i've "changed" (read: "broken") the stock code,
but hopefully i'll be pulling it all together over the weekend.
#7
Lord knows I've cyberstalked your resources enough ;)
04/25/2008 (7:55 am)
If you would like the actual control .cc and .h, I'd be happy to email it, I know you like to work it out yourself, but it's yours for the asking, drop me a line on my profile email.Lord knows I've cyberstalked your resources enough ;)
#8
04/25/2008 (8:22 am)
Thanks Dave, i may do that. One of the problems i face is that we've futzed with just about everything, so stock mods sometimes no longer drop in place. So i'll poke at it a bit longer. cheers!
#9
04/25/2008 (2:08 pm)
Hey Dave - just fyi, i very much appreciate your help, but have decided not to show a 3D character at all in this particular situation, even though it's cooler than a 2D character. we eventually want to move this feature onto a non-3D webpage, so i'm going to try to do work that can be reused for that instead.
Torque 3D Owner Dave Young
Dave Young Games
In my experience GuiObjectView is the way to go for something like this without including server code. Mesh Hiding comes pretty easily from the shapebase style stuff. I'll see if I can find what I use